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

Internal table value comparison

Former Member
0 Likes
729

Hi ,

I have selected values from LIKPand LIPS by inner join and prepared one internal table ( which is suppose to be display in output also).

The table output comes as below :

VBELN POS LFART VKORG WADAT_IST WADAT MATNR VTWEG PRODH Total Line

80000093 10 ZLF 2000 0 20080609 GO1525 10 30

80000093 20 ZLF 2000 0 20080609 GO1525CTA 10 30

80000093 20 ZLF 2000 0 20080609 GO1525 10 90

Now we need to calculate Total line that a delivery which has similar product( prodh) it needs to add it

like in this case the output should be

VBELN POS LFART VKORG WADAT_IST WADAT MATNR VTWEG PRODH Total Line

80000093 10 ZLF 2000 0 20080609 GO1525 10 30 2

80000093 20 ZLF 2000 0 20080609 GO1525CTA 10 30 2

80000093 20 ZLF 2000 0 20080609 GO1525 10 90 1

Can you suggest how to calcuate the Total line value , how to do the comparison .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
691

Hi

Sort the table by product.

Now rows having same product no will be adjacent to each other.

Now use AT...ENDAT stmt and SUM. Store these values .

Now you can use these values n update that many rows with that val.

For eg:

after sorting your data

prod

30

30

90

sum[] = 2 1.

so for first two rows set total line as 2. Do this using a temp var n decrementing.

Hope this helps

Regards,

Jayanthi.K

5 REPLIES 5
Read only

Former Member
0 Likes
691

HI Anindita,

Instead of using append use collect statement while loding output table.

hope it help you.

regards,

LOkesh

Read only

0 Likes
691

This is not working.

Let me know some other way

Basically VBELN PRODH TOTAL LINES are important for total lines calculation

a 30 2

a 90 1

a 30 2

How do I compare the next row to the previous row in the internal table . Need some logic for that

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
691

Hello Anindita,

Plz change the structure of your internal table:

VBELN PRODH POS LFART VKORG WADAT_IST WADAT MATNR VTWEG Total Line

80000093 30 10 ZLF 2000 0 20080609 GO1525 10

80000093 30 20 ZLF 2000 0 20080609 GO1525CTA 10

80000093 90 20 ZLF 2000 0 20080609 GO1525 10

If this is possible then try the code below:


LOOP AT ITAB INTO WA.

V_CNT = V_CNT + 1.

AT END OF PRODH.
WA-TOTAL = V_CNT.
MODIFY ITAB FROM WA TRANSPORTING TOTAL 
WHERE VBELN  = WA-VBELN
AND       PRODH = WA-PRODH.
CLEAR V_CNT.
ENDAT.

ENDLOOP.

Hope this helps.

BR,

Suhas

Read only

Former Member
0 Likes
692

Hi

Sort the table by product.

Now rows having same product no will be adjacent to each other.

Now use AT...ENDAT stmt and SUM. Store these values .

Now you can use these values n update that many rows with that val.

For eg:

after sorting your data

prod

30

30

90

sum[] = 2 1.

so for first two rows set total line as 2. Do this using a temp var n decrementing.

Hope this helps

Regards,

Jayanthi.K

Read only

Former Member
0 Likes
691

Thank you all