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

Logic

Former Member
0 Likes
756

Hi,

I have a data in my Itab like this: -

ebeln ebelp Quantity

1000005 10 100

1000005 10 20

1000005 10 80

1000005 20 10

1000005 20 15

1000006 10 240

1000006 20 60

1000006 20 60

I need my output in my Itab like this: -

How could I do it?

ebeln ebelp Quantity

1000005 10 200

1000005 20 25

1000006 10 240

1000006 20 120

Let me know how can this be achieved?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
734

make a second table with keys ebeln and ebelp.

Loop at the first table and use collect statement to add all the entries to the second table and you'll get what you want

6 REPLIES 6
Read only

Former Member
0 Likes
735

make a second table with keys ebeln and ebelp.

Loop at the first table and use collect statement to add all the entries to the second table and you'll get what you want

Read only

Former Member
0 Likes
734

Hi

U can use a new internal table for output structurated just as ITAB, where u collect the record of ITAB to T_OUTPUT.

LOOP AT ITAB INTO T_OUTPUT.
  COLLECT T_OUTPUT.
ENDLOOP.

Max

Read only

0 Likes
734

Hi Max,

Could you please tell How it works using SUM key word?

I m doing something like this: -

LOOP AT i_ekbe.

ON CHANGE OF EBELN OR

EBELP.

SUM ( MENGE ).

ENDON.

ENDLOOP.

Read only

Former Member
0 Likes
734

Hi,

Use control break statement,

AT NEW
 SUM,
END AT.

Regards

Adil

Edited by: Syed Abdul Adil on Jul 4, 2008 7:04 PM

Edited by: Syed Abdul Adil on Jul 4, 2008 7:12 PM

Read only

Former Member
0 Likes
734

Hi,

I think the COLLECT statement is the best, very performing too.

Regards

AP

Read only

Former Member
0 Likes
734

Hi,

Hope this will help you.

DATA: 
  BEGIN OF w_test,
    ebeln    TYPE ekpo-ebeln,
    ebelp    TYPE ekpo-ebelp,
    quantity TYPE ekpo-MENGE,
  END OF w_test,
  
  t_test LIKE TABLE OF w_test.

w_test-ebeln = '1000005'.
w_test-ebelp = '10'.
w_test-quantity = '100'.
APPEND w_test TO t_test.

w_test-ebeln = '1000005'.
w_test-ebelp = '10'.
w_test-quantity = '20'.
APPEND w_test TO t_test.

w_test-ebeln = '1000005'.
w_test-ebelp = '10'.
w_test-quantity = '80'.
APPEND w_test TO t_test.

w_test-ebeln = '1000005'.
w_test-ebelp = '20'.
w_test-quantity = '10'.
APPEND w_test TO t_test.

w_test-ebeln = '1000005'.
w_test-ebelp = '20'.
w_test-quantity = '15'.
APPEND w_test TO t_test.

w_test-ebeln = '1000006'.
w_test-ebelp = '10'.
w_test-quantity = '240'.
APPEND w_test TO t_test.

w_test-ebeln = '1000006'.
w_test-ebelp = '20'.
w_test-quantity = '60'.
APPEND w_test TO t_test.

w_test-ebeln = '1000006'.
w_test-ebelp = '20'.
w_test-quantity = '60'.
APPEND w_test TO t_test.

LOOP AT t_test INTO w_test.
  AT NEW ebelp.
    SUM.
  WRITE:/
  w_test-ebeln,
  w_test-ebelp,
  w_test-quantity.
  ENDAT.
ENDLOOP.

Regards

Adil