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

Two Loop for the position

Former Member
0 Likes
354

Hi people i explain my situation.

I have a table with some component.

Every component have a type. For example:

Pos Name Netprice Type Uepos

10 xxxx xxxx TAP

20 yyyy yyyy TAN 10

30 zzzz zzzz TAN 10

Now i must do it.

Loop at this table, if TYPE = TAN i read the UEPOS value and get it into a Zvariable.

Now i must reloop in the table because i must SUM the Netprice of every element Type TAN that have the same UEPOS, and this UEPOS must be the same of the POSNR of the element that have the Type TAP.

Understand? I Know it's difficolt to explain. I try more in another type.

I have this situation:

POS NAME NETPR

10 A 0

20 A.1 xx

30 A.2 yy

40 B 0

50 B.1 xx

In this actual situation the A.1 are dependento of A and i wanto to sum in the NETPR of A the netpr xx , yy of the A.1 and A.2. then the same for B position.

Thanks for the attention.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
318

hey i think you can do like this.

SORT ITAB by TYPE UEPOS.

clear: w_type, w_uepos, w_netpr.

loop at itab.

if w_type ne itab-type

or w_uepos ne itab-uepos.

    • here you can capture previous type and uepos.. so write logic to use netprice before clearing that.

clear w_netpr.

w_type = itab-type.

w_uepos = itab-uepos.

endif.

w_netpr = w_netpr + itab-netprice.

endloop.

Pos Name Netprice Type Uepos

10 xxxx xxxx TAP

20 yyyy yyyy TAN 10

30 zzzz zzzz TAN 10

1 REPLY 1
Read only

Former Member
0 Likes
319

hey i think you can do like this.

SORT ITAB by TYPE UEPOS.

clear: w_type, w_uepos, w_netpr.

loop at itab.

if w_type ne itab-type

or w_uepos ne itab-uepos.

    • here you can capture previous type and uepos.. so write logic to use netprice before clearing that.

clear w_netpr.

w_type = itab-type.

w_uepos = itab-uepos.

endif.

w_netpr = w_netpr + itab-netprice.

endloop.

Pos Name Netprice Type Uepos

10 xxxx xxxx TAP

20 yyyy yyyy TAN 10

30 zzzz zzzz TAN 10