Skip to Content

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

Need Help in Tuning this Code

DATA: BEGIN OF I_TEM_REVS OCCURS 1,

BUKRS LIKE BVOR-BUKRS,

BELNR LIKE BKPF-BELNR,

GJAHR LIKE BVOR-GJAHR,

STBLG LIKE BKPF-STBLG,

BVORG LIKE BKPF-BVORG,

BLART LIKE BKPF-BLART,

END OF I_TEM_REVS.

DATA: BEGIN OF I_BSEG OCCURS 1.

INCLUDE STRUCTURE BSEG.

DATA END OF I_BSEG.

DATA: BEGIN OF T_BSEG OCCURS 1.

INCLUDE STRUCTURE BSEG.

DATA END OF T_BSEG.

DATA: BEGIN OF I_BVOR OCCURS 10.

INCLUDE STRUCTURE BVOR.

DATA: BLART LIKE BKPF-BLART.

DATA: END OF I_BVOR.

DATA: BEGIN OF T_BSEG OCCURS 1.

INCLUDE STRUCTURE BSEG.

DATA END OF T_BSEG.

DATA: BEGIN OF T_DOCS OCCURS 0,

ZDATATYP LIKE ZSUINT10-ZDATATYP,

BSCHL LIKE BSEG-BSCHL,

BLART LIKE BKPF-BLART,

END OF T_DOCS.

*************************************************************************************

LOOP AT I_TEM_REVS.

CLEAR: I_BSEG .

REFRESH : I_BSEG.

SELECT SINGLE * FROM BKPF WHERE BUKRS EQ I_TEM_REVS-BUKRS

AND BELNR EQ I_TEM_REVS-STBLG

AND GJAHR EQ I_TEM_REVS-GJAHR.

IF SY-SUBRC EQ 0.

IF I_TEM_REVS-BUKRS <> BKPF-BVORG+10(4).

SELECT SINGLE * FROM BVOR INTO I_BVOR

WHERE BUKRS EQ I_TEM_REVS-BUKRS

AND GJAHR EQ I_TEM_REVS-GJAHR

AND BELNR EQ I_TEM_REVS-STBLG.

IF SY-SUBRC EQ 0.

SELECT SINGLE * FROM BKPF

WHERE BUKRS = I_BVOR-BVORG+10(4)

AND BELNR = I_BVOR-BVORG+0(10)

AND GJAHR = I_BVOR-GJAHR.

IF SY-SUBRC EQ 0.

V_AWKEY_BUKRS = BKPF-BUKRS.

V_AWKEY_STBLG = BKPF-STBLG.

V_AWKEY_GJAHR = BKPF-GJAHR.

ENDIF.

ENDIF.

SELECT * FROM BSEG INTO I_BSEG

WHERE BUKRS = I_TEM_REVS-BUKRS

AND BELNR = I_TEM_REVS-BELNR

AND GJAHR = I_TEM_REVS-GJAHR.

IF I_BSEG-HKONT IN RANGE_HKONT.

ELSE.

LOOP AT T_DOCS WHERE BSCHL = I_BSEG-BSCHL

AND BLART = I_TEM_REVS-BLART

AND ( BSCHL = '40' OR BSCHL = '50'

OR BSCHL = '81' OR BSCHL = '91' ).

APPEND I_BSEG.

ENDLOOP.

LOOP AT T_DOCS WHERE ZDATATYP = 'TAXRPT03'

AND BSCHL = I_BSEG-BSCHL

AND BLART = I_TEM_REVS-BLART

AND BSCHL = '50'.

MOVE-CORRESPONDING I_BSEG TO T_BSEG.

APPEND T_BSEG.

ENDLOOP.

ENDIF.

ENDSELECT.

ENDIF.

ENDIF.

LOOP AT T_BSEG.

LOOP AT GT_ALV_ITEM WHERE BUKRS = V_AWKEY_BUKRS

AND BELNR = V_AWKEY_STBLG

AND GJAHR = V_AWKEY_GJAHR.

LOOP AT I_BSEG WHERE GJAHR = GT_ALV_ITEM-GJAHR

AND TXGRP = GT_ALV_ITEM-TXGRP.

MOVE: I_BSEG-BUKRS TO GT_ALV_ITEM-BUKRS,

I_BSEG-EBELN TO GT_ALV_ITEM-EBELN,

I_BSEG-HKONT TO GT_ALV_ITEM-HKONT,

I_BSEG-BELNR TO GT_ALV_ITEM-BELNR,

I_BSEG-KOSTL TO GT_ALV_ITEM-KOSTL,

I_BSEG-PRCTR TO GT_ALV_ITEM-PRCTR,

I_BSEG-ZZINFO3 TO GT_ALV_ITEM-ZZINFO3.

ENDLOOP.

MODIFY GT_ALV_ITEM INDEX SY-TABIX.

ENDLOOP.

ENDLOOP.

CLEAR: I_BVOR. REFRESH : I_BVOR.

CLEAR: T_BSEG . REFRESH : T_BSEG.

CLEAR: I_BSEG . REFRESH : I_BSEG.

ENDLOOP.

Thanks and Regards

Siddhartha

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