Application Development 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: 

Combining rows into single row in dynamic internal table

Former Member
0 Kudos

Hello All,

i have created a dynamic internal table as below: (Here Prod. Orders are dynamic in the internal table), now i am passing this dynamic internal table to ALV for display.

Now i want to merge similar operations into 1 row like below.

Any ideas will be helpful.

Regards,

Sree.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

Before appending a row you should check if there's a record with the same operation and modify it

So I believe you should change your logic where you append the record in the dynamic internal table

Max

4 REPLIES 4

Former Member
0 Kudos

Hi

Before appending a row you should check if there's a record with the same operation and modify it

So I believe you should change your logic where you append the record in the dynamic internal table

Max

VenkatRamesh_V
Active Contributor

Hi,

Try,

Sort internal table by operations. Use  collect statement Instead of append.

Hope it helpful,

Regards,

Venkat.

0 Kudos

This. I signed up just to upvote this comment. Use collect instead of append to resolve the problem.

former_member184158
Active Contributor
0 Kudos

Hi,

Just use Collect ls_data into lt_data.


look to this example please,

this is the difference between collect ans append.


Append ls_data to lt_data.


After using collect statement

Collect ls_data into lt_data.


REPORT  zibo_pg_test2.


TYPES: BEGIN OF st_ty,
  operation
TYPE c LENGTH 2,
  prod1
TYPE i,
  prod2
TYPE i,
  prod3
TYPE i,
  prod4
TYPE i,
 
END OF st_ty.

 
data ls_data TYPE st_ty.
 
data lt_data TYPE TABLE OF st_ty.

  ls_data
-operation = 10.
  ls_data
-prod1 = 100.
 
APPEND ls_data to lt_data.
 
CLEAR ls_data.

  ls_data
-operation = 10.
 
APPEND ls_data to lt_data.
 
CLEAR ls_data.


  ls_data
-operation = 10.
  ls_data
-prod3 = 90.
 
APPEND ls_data to lt_data.
 
CLEAR ls_data.

  ls_data
-operation = 10.
  ls_data
-prod4 = 75.
 
APPEND ls_data to lt_data.
 
CLEAR ls_data.

 
BREAK-POINT.
 
CLEAR lt_data.

  ls_data
-operation = 10.
  ls_data
-prod1 = 100.
COLLECT  ls_data into lt_data.
 
CLEAR ls_data.

  ls_data
-operation = 10.
 
COLLECT  ls_data into lt_data.
 
CLEAR ls_data.


  ls_data
-operation = 10.
  ls_data
-prod3 = 90.
 
COLLECT  ls_data into lt_data.
 
CLEAR ls_data.

  ls_data
-operation = 10.
  ls_data
-prod4 = 75.
 
COLLECT  ls_data into lt_data.
 
CLEAR ls_data.

Regards

Ibrahim