SAPScript / SmartForms Custom Formatting

By | April 2, 2009 | Forms | 4,971 | 1

In the previous post, we have seen how we can apply Standard formatting options in the Smartform and SAPScripts. Today we will see, how we can create our own Formatting option which we can use in SAPScript or SmartForms.

There is lots of the similarity between Capital Oh “O” and the Zero “0” in the Output. So, business may wants to print the ZERO as the “Slashed Zero” like “Ø”. Let’s see how we can achieve to print the slashed Zero in our outputs.

For Smatforms, we can very well add the Program lines and convert all the Zeros to the slashed zero “Ø”. But, it would be difficult to implement the same in the SAPScript using the PERFORM.

We can use the Conversion Routine to achieve this easily.
1. Create a Conversion Routine Function Modules:
For Conversion Routines, we need two FM – One for the Input & One for Output. E.g. If we want to create a conversion routine like ZZERO, then our conversion FMs would be: CONVERSION_EXIT_ZZERO_INPUT & CONVERSION_EXIT_ZZERO_OUTPUT.

To replace the zeros with the Slashed Zero, we need to implement the logic in the OUTPUT Conversion FM CONVERSION_EXIT_ZZERO_OUTPUT.

FUNCTION conversion_exit_zzero_output.
*&---------------------------------------------------------------------*
*& Importing
*&   value(INPUT)
*& Exporting
*&   value(OUTPUT)
*&---------------------------------------------------------------------*
*
  output input.
  REPLACE ALL OCCURRENCES OF '0' IN output WITH 'Ø'.

ENDFUNCTION.

For the INPUT conversion FM CONVERSION_EXIT_ZZERO_INPUT, we really don’t need any logic. So, we are just going to move the INPUT to OUTPUT.

FUNCTION conversion_exit_zzero_input.
*&---------------------------------------------------------------------*
*& Importing
*&   value(INPUT) 
*& Exporting
*&   value(OUTPUT)
*&---------------------------------------------------------------------*
*
  INPUT OUTPUT.
  
ENDFUNCTION.

2. Create a New Domain & assign the Conversion Routine. Like: create the domain name
ZZ_ZERO for the amount


Data type CURR
No. characters 13
Decimal places 2

Output length 17
Convers. routine ZZERO

3. Use this domain and create a data element.

Now, you can refer to this data element in your Smartform / SAPScript and it will print the ‘1ØØØ.1Ø’ instead of the ‘1000.10’.

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{274 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 274 articles.

Load comments

1 Comment

  • That was awesome!!
    Conversion exit at its best, simple and effective.

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.