Monday, November 9, 2009

End Routine

Example: End Routine

In the SAP ERP system, you are loading data using the General Ledger: Transaction Figures DataSource (0FI_GL_1) into the DataStore object FIGL: Transaction Figures (0FIGL_O06).

You want to create an end routine to fill the additional InfoObject Plan/Actual Indicator (ZPLACTUAL). You also want the routine to read field Value Type. If the value is 10 (actual), value A is written to the Plan/Actual Indicator InfoObject; if the value is 20 (plan), value P is written to the Plan/Actual Indicator InfoObject.

...

1. You are in transformation maintenance. Choose Create End Routine. The routine editor opens.

2. You enter the following lines of code:



*----------------------------------------------------------------------*
METHOD end_routine.
*=== Segments ===

FIELD-SYMBOLS:
TYPE _ty_s_TG_1.

*$*$ begin of routine - insert your code only below this line *-*

loop at RESULT_PACKAGE assigning
where vtype eq '010' or vtype eq '020'.
case -vtype.
when '010'.
-/bic/zplactual = 'A'. "Actual
when '020'.
-/bic/zplactual = 'P'. "Plan
endcase.
endloop.
*$*$ end of routine - insert your code only before this line *-*
ENDMETHOD. "end_routine
*----------------------------------------------------------------------*


The code loops through result_package searching for values that have the value type 10 or 20. For these values, the appropriate value is passed on to InfoObject Plan/Actual Indicator (ZPLACTUAL).

3. You exit the routine editor.

4. You save the transformation. An edit icon next to the End Routine indicates that an end routine is available.

No comments: