Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Logic for end routine

Former Member
0 Kudos

Hello Gurus

I am trying to load the values into a field named Ysind which is present in a cube in BI 7 based on the following logic.

I have three tables with the following corresponding fields

Table1: /BIC/PYMAT

Fields: Ymat, Prdh5

Table2: /BIO/TPRD_HIER

Fields: Prd_hier, TXTMD

Table3: result_fields (refers to the ODS fields which feeds the Cube)

Fields: Ymat

Now,

Ysind should be equal to TXTMD from /BIO/TPRD_HIER if Prd_hier from /BIO/TPRD_HIER = Prdh5 from /BIC/PYMAT and Ymat from /BIC/PYMAT = Ymat from result_fields

Can you provide me with a sample code or the logic for the end routine to be implemented between the ODS and the cube for this. Furthermore, how can i use internal tables for this purpose.

Any help in this regards is appreciated and points will be assigned.

Thanks

Rishi

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi rishi,

End Routine

An end routine is a routine with a table in the target structure format as input and output parameters. You can use an end routine to postprocess data after transformation on a package-by-package basis. For example, you can delete records that are not to be updated, or perform data checks.

If the target of the transformation is a DataStore object, key figures are updated by default with the aggregation behavior Overwrite (MOVE). You have to use a dummy rule to override this.

Expert Routine

This type of routine is only intended for use in special cases. You can use the expert routine if there are not sufficient functions to perform a transformation. The expert routine should be used as an interim solution until the necessary functions are available in the standard routine.

You can use this to program the transformation yourself without using the available rule types. You must implement the message transfer to the monitor yourself.

If you have already created transformation rules, the system deletes them once you have created an expert 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:

<RESULT_FIELDS> TYPE tys_TG_1.

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

loop at RESULT_PACKAGE assigning <RESULT_FIELDS>

where vtype eq '010' or vtype eq '020'.

case <RESULT_FIELDS>-vtype.

when '010'.

<RESULT_FIELDS>-/bic/zplactual = 'A'. "Actual

when '020'.

<RESULT_FIELDS>-/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

regards

karthik

if the above information is usefull to you.pls reward me points

2 REPLIES 2

Former Member
0 Kudos

hi rishi,

End Routine

An end routine is a routine with a table in the target structure format as input and output parameters. You can use an end routine to postprocess data after transformation on a package-by-package basis. For example, you can delete records that are not to be updated, or perform data checks.

If the target of the transformation is a DataStore object, key figures are updated by default with the aggregation behavior Overwrite (MOVE). You have to use a dummy rule to override this.

Expert Routine

This type of routine is only intended for use in special cases. You can use the expert routine if there are not sufficient functions to perform a transformation. The expert routine should be used as an interim solution until the necessary functions are available in the standard routine.

You can use this to program the transformation yourself without using the available rule types. You must implement the message transfer to the monitor yourself.

If you have already created transformation rules, the system deletes them once you have created an expert 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:

<RESULT_FIELDS> TYPE tys_TG_1.

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

loop at RESULT_PACKAGE assigning <RESULT_FIELDS>

where vtype eq '010' or vtype eq '020'.

case <RESULT_FIELDS>-vtype.

when '010'.

<RESULT_FIELDS>-/bic/zplactual = 'A'. "Actual

when '020'.

<RESULT_FIELDS>-/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

regards

karthik

if the above information is usefull to you.pls reward me points

0 Kudos

Hi Kartikeya

Thanks for the Info but it would really help if you can provide some logic for my scenario. I wrote the following code, can this be optimized using internal tables.

data:

lv_prdh5 type /BI0/OIPRDH5.

data:

lv_txtsh type RSTXTSH.

loop at RESULT_PACKAGE assigning <result_fields>.

clear lv_prdh5.

if not <result_fields>-/BIC/YMAT is initial.

select single prdh5 into lv_prdh5

from /BIC/PYMAT

where /BIC/YMAT = <result_fields>-/BIC/YMAT.

select single TXTMD into lv_txtsh

from /BI0/TPRD_HIER

where PRD_HIER = lv_prdh5.

if sy-subrc = 0.

<result_fields>-/bic/ysind = lv_txtsh.

endif.

endif.

modify RESULT_PACKAGE from <result_fields>.

endloop.