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

loop

Former Member
0 Likes
657

Hi

I want to check one condition

ex : select field1 field2 from table

into i_table..where..

select from table1

select from table2 for all entries of table1.

now ..

if i_table-field1 = something

perform update table1 table2.(in this perform iam passing to bapi fm from tabl1 and table2)

which tables to loop..and read here..i tried..but not working...dont know where doing mistake..

Please help me on this.

thanks in advance

1 ACCEPTED SOLUTION
Read only

former_member632991
Active Contributor
0 Likes
631

Hi,

loop at table1.

if table1-field = 'required value'.

read table table2 with key k1 = table1-key1.

if sy-subrc = 0.

perform f_ff.

endif.

endif.

endloop.

Regards,

Sonika

6 REPLIES 6
Read only

former_member632991
Active Contributor
0 Likes
631

Hi,

loop at table1 and read table2 based on some field

and write ur code in loop.

Regards,

Sonika

Read only

0 Likes
631

Hi

Thanks for that..

How do we check condition

thanks

Read only

Former Member
0 Likes
631

Hi,

Consider the example of EKKO and EKPO.

select the data from EKKO and use the data in itab1 to fetch the data fromEKPO.this is itab2.

Now use second itab since it as an item level

loop at itab2 into wa2.

read table itab1.

call BAPI.

endloop.

Regards

Kannaiah

Read only

Former Member
0 Likes
631

Hi

I know those how to loop and fetch..

My req is I want to check condition first then proceed further.

to check the condition iam using select at beginning...

after i had written some code...

now i want to check condition again for this..

assume i have 10 performs ...for every perform iam checking condition

..now i want to check that condition

select system abc from zdabc..

if i_zdpd-system = 'abc'

perform ...

Read only

former_member632991
Active Contributor
0 Likes
632

Hi,

loop at table1.

if table1-field = 'required value'.

read table table2 with key k1 = table1-key1.

if sy-subrc = 0.

perform f_ff.

endif.

endif.

endloop.

Regards,

Sonika

Read only

Former Member
0 Likes
631

try like this

data : index1 like sy-tabix,

index2 like sy-tabix.

loop at itab1.

index1 = sy-tabix.

if itab1-field1 = something.

read table itab2 with key f1 = itab-f1<ince u are using for all entries means common field may be there>

if sy-subrc = 0.

index2 = sy-tabix.

perform update .

endif.

endif.

form update.

read table itab1 index index1.

itab1-field = changevalue.

modify itab1 index index1.

read table itab2 index index2.

itab2-field = changevalue.

modify itab2 index index2.

endform.

regards

shiba dutta