Skip to Content
3
Former Member
Jul 19, 2007 at 09:51 AM

LOOP inside loop

20 Views

Hi ppl,

Am facing a problem wherin i need to process records inside an internal table which itself has huge number of records(say m).The details of each record is picked using loop on one more itab which also consists of huge number of records

(say n). hence the processing is for m*n records which is raising performance issue.

plz help.am pasting the code here.

FORM PROCESS_UNITS.

DATA : VL_TEXT(40) TYPE C.

SORT T_UNITS BY UNIT.

LOOP AT T_UNITS.

V_TABIX = SY-TABIX.

CONCATENATE TEXT-S01 T_UNITS-UNIT INTO VL_TEXT SEPARATED BY ' '.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

  • PERCENTAGE = 0

TEXT = VL_TEXT.

  • get GLPCA postings

SELECT AWTYP AWORG RACCT REFDOCNR SUM( HSL ) FROM GLPCA "1062

INTO TABLE T_GLPCA

WHERE RPRCTR = T_UNITS-UNIT

AND RACCT IN S_HKONT

AND KOKRS = V_KOKRS

AND RYEAR = P_GJAHR

AND POPER <= P_MONAT

GROUP BY AWTYP AWORG RACCT REFDOCNR. "GK_166118

SORT T_GLPCA BY AWTYP AWORG REFDOCNR. "1062

  • process GLPCA postings

LOOP AT T_GLPCA.

  • translate document number

IF T_GLPCA-AWTYP = 'BKPF' AND T_GLPCA-AWORG(4) = P_BUKRS."1062

ELSE. "1062

CALL FUNCTION 'Z_FIND_FIDOC' "1062

EXPORTING "1062

I_AWTYP = T_GLPCA-AWTYP "1062

I_AWORG = T_GLPCA-AWORG "1062

I_BUKRS = P_BUKRS "1062

I_GJAHR = P_GJAHR "1062

I_REFDOCNR = T_GLPCA-REFDOCNR "1062

IMPORTING "1062

E_FIDOCNR = T_GLPCA-REFDOCNR. "1062

ENDIF. "1062

  • at new refdocnr.

CLEAR BKPF-BLART.

SELECT SINGLE BLART BUDAT MONAT FROM BKPF

INTO (BKPF-BLART, BKPF-BUDAT, BKPF-MONAT)

WHERE BUKRS = P_BUKRS

AND BELNR = T_GLPCA-REFDOCNR

AND GJAHR = P_GJAHR.

  • endat.

  • IF ( BKPF-BLART = 'YF' AND T_GLPCA-RACCT IN R_HKONT1 "GK_166118

  • AND NOT R_HKONT1[] IS INITIAL ) "GK_166118

*OR ( BKPF-BLART = 'ZW' AND T_GLPCA-RACCT IN R_HKONT2 "GK_166118

  • AND NOT R_HKONT2[] IS INITIAL ). "GK_166118

IF BKPF-BLART IN R_BLART . "GK_151204

PERFORM ADD_TO_CORRECT_COLUMN USING T_GLPCA-HSL

BKPF-MONAT.

  • collect weekly data

CLEAR WEEKLY_ITAB.

WEEKLY_ITAB-MONAT = BKPF-MONAT.

WEEKLY_ITAB-BUDAT = BKPF-BUDAT.

WEEKLY_ITAB-PRCTR = T_UNITS-UNIT.

WEEKLY_ITAB-KTEXT = T_UNITS-UNIT_TEXT.

WEEKLY_ITAB-DMBTR = T_GLPCA-HSL.

COLLECT WEEKLY_ITAB.

ENDIF.

ENDLOOP.

  • get site

SELECT SINGLE KHINR FROM CEPC INTO T_UNITS-SITE_REF

WHERE PRCTR = T_UNITS-UNIT

AND KOKRS = V_KOKRS

AND DATBI = '99991231'.

MODIFY T_UNITS INDEX V_TABIX.

ENDLOOP.

ENDFORM. " PROCESS_UNITS

thanks in advance.

Archana