Skip to Content
0
Feb 12, 2008 at 01:16 PM

nested loops

10 Views

the problem is for every record its displaying the same GL ACC(saknr) no.. it should be differ for every record.. while debugging i am able to get the different values...but in the final result its not... please help me out....

and please write the code using read statement....

START-OF-SELECTION.

SELECT mblnr mjahr budat

FROM mkpf

INTO CORRESPONDING FIELDS OF

TABLE itab_mkpf

WHERE budat IN s_budat.

SELECT bukrs mblnr zeile

bwtar matnr gsber

werks menge meins dmbtr

FROM mseg

INTO CORRESPONDING FIELDS OF

TABLE itab_mseg

FOR ALL ENTRIES IN

itab_mkpf WHERE bukrs EQ p_bukrs

AND mblnr EQ itab_mkpf-mblnr

AND gsber IN p_gsber

AND bwtar IN s_bwtar

AND mjahr EQ itab_mkpf-mjahr.

SELECT bukrs saknr

FROM skb1

INTO corresponding fieldS of

table itab_skb1 WHERE bukrs EQ p_bukrs.

SELECT matnr maktx

FROM makt INTO

TABLE itab_makt

FOR ALL ENTRIES IN itab_mseg

WHERE matnr EQ itab_mseg-matnr.

LOOP AT itab_mkpf.

LOOP AT itab_mseg WHERE mblnr EQ itab_mkpf-mblnr.

MOVE-CORRESPONDING itab_mseg TO itab_final.

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

LOOP AT itab_skb1 WHERE bukrs EQ itab_mseg-bukrs.

MOVE-CORRESPONDING itab_skb1 TO itab_final.

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

LOOP AT itab_makt WHERE matnr EQ itab_mseg-matnr.

MOVE-CORRESPONDING itab_makt TO itab_final.

APPEND itab_final.

CLEAR itab_final.

ENDLOOP.

ENDLOOP.

ENDLOOP.

ENDLOOP.

all the table are with header line...

if i move the data to main table the value of gl account field SAKNR is same for all the records...

here i need to get different value for saknr for different records and also this is the performance issue please give me the solution for this ......

thanks

regards

babu

Edited by: Aeda N on Feb 12, 2008 2:22 PM

Edited by: Aeda N on Feb 12, 2008 2:26 PM