Showing posts with label Transfer Routines. Show all posts
Showing posts with label Transfer Routines. Show all posts

Monday, November 12, 2007

How to Remove Leading Zeros in Transformations

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 Transfer Rules or Update Rules.

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.

Tuesday, October 23, 2007

How To Calculate End Date of a Month

Scenario:

Based on Posting Date(0PSTNG_DATE) field we need to find the last date of the month. Posting Date can be any day of the month. But when loading into the cube it should be transformed into the last date of the month.

Here is the sample code used in the update rules.

data: ls_sdate like comm_structure-PSTNG_DATE,
ls_edate like sy-datum.

CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
DAY_IN = LS_SDATE
IMPORTING
LAST_DAY_OF_MONTH = LS_EDATE
* EXCEPTIONS
* DAY_IN_NOT_VALID = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.



RESULT = LS_EDATE.



Note:

- You can use the above sample code to find last date of the month from any date filed.
- You can use this code in transfer rules by replacing comm_structure with tran_structure.
- For BI 7 users replace comm_structure with SOURCE_FIELDS.