Monday, December 21, 2009

How to Remove Leading Zeros in Transformations

This can be done in many ways...
1) This can be very easily handled at the Info Object level by selecting 'ALPHA' conversion routine.

2) You can also tick the "Convesrion" option in Trasnfer Rules. This will perform same as ALPHA Converstion.

3) Some times you need to write an ABAP routine to remove leading zeros in transformations.

Here is the sample code to remove leading zeros for 0ALLOC_NMBR field

DATA: V_OUTPUT TYPE TRANSFER_STRUCTURE-ALLOC_NMBR.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = TRAN_STRUCTURE-ALLOC_NMBR
IMPORTING
OUTPUT = V_OUTPUT

RESULT = V_OUTPUT.


4) Another example ABAP Routine.

IF TRAN_STRUCTURE-ALLOC_NMBR+0(4) = '0000'.
RESULT = TRAN_STRUCTURE-ALLOC_NMBR+4(6).
ELSE.
RESULT = TRAN_STRUCTURE-ALLOC_NMBR.
ENDIF.

0 comments: