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

Compare lines

Former Member
0 Likes
1,037

Hello,

my requirement is to check multiple plants on saving the purchase order but I dont know how to compare several lines.

In Include ZXM06U43

Position 1 Plant XXX

Position 2 Plant XXY

Now I have to loop the internal table like wa_ekpo but how can I write the if-check for several lines comparing the first line?

Thanks & best regards,

Nino

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
852

Hi Vuckovic,

You can use this:

loop at it_ekpo into wa_ekpo.
    If wa_ekpo-att1 = 'Position' and wa_ekpo-att2 = '01' or wa_ekpo-att4 = 'XXYX' .
Endif.
endloop.

You can use sy-index inside the loop to determine which line has the same attributes (Position 01 XXYX) with the first one. You can change conditions according to your choice.

4 REPLIES 4
Read only

Former Member
0 Likes
852

Do you want to check all other plants with the first line or subsequent lines such as 1 & 2, 2 & 3, 3 & 4 etc.??

you could loop at TEKPO and use a read table again on TEKPO to read at index with which u may want to compare

Read only

Former Member
0 Likes
853

Hi Vuckovic,

You can use this:

loop at it_ekpo into wa_ekpo.
    If wa_ekpo-att1 = 'Position' and wa_ekpo-att2 = '01' or wa_ekpo-att4 = 'XXYX' .
Endif.
endloop.

You can use sy-index inside the loop to determine which line has the same attributes (Position 01 XXYX) with the first one. You can change conditions according to your choice.

Read only

0 Likes
852

> You can use sy-index inside the loop to determine which line has the same attributes (Position 01 XXYX) with the first one. You can change conditions according to your choice.

Just to correct you its sy-tabix and not sy-index

Read only

former_member214857
Contributor
0 Likes
852

Hello Nino

You can use 2 variables. First one to store and keep value from first collumn and then you can start the loop comparing with varibalbes

Best Regards