Application Development and Automation 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: 
Read only

help with loop

Former Member
0 Likes
885

how i can write:

loop at gt_test1 into <ls_test1>.

loop at gt_test into <test> where material = <ls_test1>.?????

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
864

loop at gt_test into <test> where material = <ls_test1>-material.???

8 REPLIES 8
Read only

Former Member
0 Likes
865

loop at gt_test into <test> where material = <ls_test1>-material.???

Read only

0 Likes
864

Hi Liat,

1. <ls_test1>-MATNR

Using field-symbol of type any

won't do.

Because the system won't know -MATNR.

2. Try with this :

FIELD-SYMBOLS : <f> TYPE MARA.

3.

REPORT abc.

DATA : itab LIKE TABLE OF mara WITH HEADER LINE.

DATA : wa LIKE mara.

FIELD-SYMBOLS : <f> TYPE MARA.

SELECT * FROM mara INTO TABLE itab.

*----


ASSIGN wa TO <f>.

LOOP AT itab INTO <f> WHERE matnr = <f>-matnr.

WRITE 😕 <f>-matnr .

ENDLOOP.

Regards,

Amit M.

Message was edited by: Amit Mittal

Read only

0 Likes
864

Hi,

your coding should work if you defined your <ls_test1> as

field-symbols: <ls_test1> type 'name of structure'.

if it is defined as

field-symbols: <ls_test1> type any.

you need to define another field symbol and do a assign component after the first loop.

assign component 'MATERIAL' of structure <ls_test1> to <new field-symbol>.

loop at gt_test into <test> where material = <new field-symbol>.

regards

Siggi

Read only

0 Likes
864

amit i need loop in loop.

Read only

0 Likes
864
report ztest.
types: begin of tab ,
      matnr like mara-matnr,
      end of tab.
data: begin of itab occurs 0,
      matnr like mara-matnr,
      end of itab.
      data: begin of itab2 occurs 0,
      matnr like mara-matnr,
      meins like mara-meins,
      end of itab2.
field-symbols : <fs> type tab.
loop at itab into <fs>.
loop at itab2 where matnr = <fs>-matnr.

endloop.

endloop.

try this...

Vijay

Read only

0 Likes
864

i get error becuase of that i'm asking

Read only

0 Likes
864

hi liat,

try to see my code...

thanks

vijay

Read only

Former Member
0 Likes
864

Hi again,

REVISED CODE :

1. try this code (just copy paste)

LOOP IN LOOP

REPORT abc.

DATA : itab LIKE TABLE OF mara WITH HEADER LINE.

DATA : itab1 LIKE TABLE OF mara WITH HEADER LINE.

FIELD-SYMBOLS : <f> TYPE mara.

FIELD-SYMBOLS : <f1> TYPE mara.

DATA : wa LIKE mara.

DATA : wa1 LIKE mara.

*----


ASSIGN wa TO <f>.

ASSIGN wa1 TO <f1>.

*----


SELECT * FROM mara INTO TABLE itab WHERE matnr = '000000000000000001'.

SELECT * FROM mara INTO TABLE itab1.

*----


LOOP AT itab INTO <f> .

LOOP AT itab1 INTO <f1> WHERE matnr = <f>-matnr.

WRITE 😕 <f1>-matnr .

ENDLOOP.

ENDLOOP.

I hope it helps.

regards,

amit m.

Message was edited by: Amit Mittal

Message was edited by: Amit Mittal