Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Explain the Logic of ABAP Code in BW Transformations

Hi Gurus,

The Below Code(ABAP) is written Transformations

I shall be very very greatful if any of you step by step what it is performing

Thanks in Advance

Types :

Begin of ITABtype,

ORG TYPE /BIC/OIZORG,

CYEMPNO TYPE /BIC/OIZCYEMPNO,

HED_ID TYPE /BIC/OIZHED_ID,

RHED_ID TYPE /BIC/OIZRHED_ID,

CHNG_DTE TYPE /BIC/OIZCHNG_DTE,

HED_AMT TYPE /BIC/OIZHED_AMT,

HED_PAMT TYPE /BIC/OIZHED_PAMT,

End of ITABtype.

Data : ITAB type standard table of ITABtype

with key

ORG

CYEMPNO

HED_ID

RHED_ID

CHNG_DTE

HED_AMT

HED_PAMT,

wa_itab like line of itab.

Data : ITAB1 type standard table of ITABtype

with key

ORG

CYEMPNO

HED_ID

RHED_ID

CHNG_DTE

HED_AMT

HED_PAMT,

wa_itab1 like line of itab1.

*Create an internal table with all the field types with u want to have

*in the output */

Data : wa_SOURCE_PACKAGE type tys_SC_1.

Data : tmp(2) type n value 1.

\ The above loop is to get all the values into the internal table*/

Loop at SOURCE_PACKAGE into wa_SOURCE_PACKAGE.

Move wa_SOURCE_PACKAGE-/BIC/ZORG to wa_itab-ORG.

Move wa_SOURCE_PACKAGE-/BIC/ZCYEMPNO to wa_itab-CYEMPNO.

Move wa_SOURCE_PACKAGE-/BIC/ZHED_ID to wa_itab-HED_ID.

Move wa_SOURCE_PACKAGE-/BIC/ZHED_ID/BIC/ZRHED_ID to

wa_itab-RHED_ID.

Move wa_SOURCE_PACKAGE-/BIC/ZCHNG_DTE to wa_itab-CHNG_DTE.

Move wa_SOURCE_PACKAGE-/BIC/ZHED_AMT to wa_itab-HED_AMT.

*Move wa_SOURCE_PACKAGE-/BIC/ZHED_PAMT to wa_itab-HED_PAMT.

Append wa_itab to itab.

Endloop.

Sort itab by

ORG Ascending

CYEMPNO Ascending

HED_ID Ascending

RHED_ID Ascending

CHNG_DTE Descending.

Sort SOURCE_PACKAGE by

/BIC/ZORG Ascending

/BIC/ZCYEMPNO Ascending

/BIC/ZHED_ID Ascending

/BIC/ZHED_ID/BIC/ZRHED_ID Ascending

/BIC/ZCHNG_DTE Descending.

Loop at itab into wa_itab.

tmp = '1' .

Loop at SOURCE_PACKAGE into wa_SOURCE_PACKAGE from tmp.

If

wa_itab-CHNG_DTE GT wa_SOURCE_PACKAGE-/BIC/ZCHNG_DTE.

wa_itab-ORG = wa_SOURCE_PACKAGE-/BIC/ZORG.

wa_itab-CYEMPNO = wa_SOURCE_PACKAGE-/BIC/ZCYEMPNO.

wa_itab-HED_ID = wa_SOURCE_PACKAGE-/BIC/ZHED_ID.

wa_itab-RHED_ID = wa_SOURCE_PACKAGE-/BIC/ZHED_ID/BIC/ZRHED_ID

.

wa_itab-HED_PAMT = wa_SOURCE_PACKAGE-/BIC/ZHED_AMT.

tmp = tmp + 1.

Exit. Endif.

Endloop.

Modify itab from wa_itab.

Endloop.

itab1[] = itab[].

Sort itab1 by

ORG Ascending

CYEMPNO Ascending

HED_ID Ascending

RHED_ID Ascending

CHNG_DTE Descending.

Delete adjacent duplicates from itab1 comparing

ORG

CYEMPNO

HED_ID

RHED_ID

CHNG_DTE.

Loop at itab1 into wa_itab1.

wa_itab-HED_PAMT = '0'.

Modify itab1 from wa_itab1.

Endloop.

Loop at itab into wa_itab.

Loop at itab1 into wa_itab1.

If wa_itab1-ORG = wa_itab-ORG.

wa_itab1-CYEMPNO = wa_itab-CYEMPNO.

wa_itab1-HED_ID = wa_itab-HED_ID.

wa_itab1-RHED_ID = wa_itab-RHED_ID.

wa_itab1-CHNG_DTE = wa_itab-CHNG_DTE.

wa_itab1-HED_PAMT = wa_itab-HED_PAMT.

Exit.

Endif.

Endloop.

Modify itab from wa_itab.

Endloop.

Espically the below bit

Loop at itab into wa_itab.

tmp = '1' .

Loop at SOURCE_PACKAGE into wa_SOURCE_PACKAGE from tmp.

If

wa_itab-CHNG_DTE GT wa_SOURCE_PACKAGE-/BIC/ZCHNG_DTE.

wa_itab-ORG = wa_SOURCE_PACKAGE-/BIC/ZORG.

wa_itab-CYEMPNO = wa_SOURCE_PACKAGE-/BIC/ZCYEMPNO.

wa_itab-HED_ID = wa_SOURCE_PACKAGE-/BIC/ZHED_ID.

wa_itab-RHED_ID = wa_SOURCE_PACKAGE-/BIC/ZHED_ID/BIC/ZRHED_ID

.

wa_itab-HED_PAMT = wa_SOURCE_PACKAGE-/BIC/ZHED_AMT.

tmp = tmp + 1.

Exit.

Endif.

Endloop.

Modify itab from wa_itab.

Endloop.

Thanks in advance

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question