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

internaltable modification

Former Member
0 Likes
877

Hi,

my internaltable contains data like

company cost assignment period amount

code center

cs01 1000 100000 1 1000

cs01 1001 100000 1 1200

cs01 1000 100000 2 1400

cs01 1000 100000 3 1600

I need to modify above internaltable lik below

company cost assignment period1 period2 period3

code center amount amount amount

cs01 1000 100000 1000 1400 1600

cs01 1001 100000 1200 - -

how can i modify?

Regards,

Suresh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
850

cs01 1000 100000 1 1000

cs01 1000 100000 2 1400

cs01 1000 100000 3 1600

cs01 1001 100000 1 1200

first sort the table on first 3 fields. the above is the sorted data. now place the control break on second field.

use appropriate types and fieldnames.

data: begin of it_final occurs 0,
          first,
          second,
          third,
          id1,
          id2,
          id3,
          ...
          idn,
        end of it_final.
data: val(20).
field-symbols: <fs> type any.
loop at it_data.
 it_final-first = it_data-first.
 it_final-secnd = it_data-second.
 it_final-third  = it_Data-third.
  concatenate 'IT_FINAL-ID' it_data-four to val.
  assign (val) to <fs>.
  <fs> = it_data-five.  
at end of field2.
  append it_final.
endat.

endloop.

6 REPLIES 6
Read only

Former Member
0 Likes
851

cs01 1000 100000 1 1000

cs01 1000 100000 2 1400

cs01 1000 100000 3 1600

cs01 1001 100000 1 1200

first sort the table on first 3 fields. the above is the sorted data. now place the control break on second field.

use appropriate types and fieldnames.

data: begin of it_final occurs 0,
          first,
          second,
          third,
          id1,
          id2,
          id3,
          ...
          idn,
        end of it_final.
data: val(20).
field-symbols: <fs> type any.
loop at it_data.
 it_final-first = it_data-first.
 it_final-secnd = it_data-second.
 it_final-third  = it_Data-third.
  concatenate 'IT_FINAL-ID' it_data-four to val.
  assign (val) to <fs>.
  <fs> = it_data-five.  
at end of field2.
  append it_final.
endat.

endloop.

Read only

0 Likes
850

Hi Vijay,

Thanks for reply. one more question.

in my final internal table like first,second and third columns are static and other columns are id1, id2 ,id3 ...idn are dynamic columns.

How can i bulid the internal table.please help me..

Regards,

Suresh.

Read only

0 Likes
850

you can populate the fieldcatalog with the fieldnames and lengths . and using the class cl_alv_table_create , method CREATE_DYNAMIC_TABLE

and create the dynamic table, using that you can proceed. for sample code search here with the class cl_alv_table_create

Read only

Former Member
0 Likes
850

hi,

will the period1 period2........ column will be dynamic.

Read only

0 Likes
850

Hi,

yes column1 column2 are dynamic.

Regards,

Suresh.

Read only

Former Member
0 Likes
850

Hi vijay,

Thanks you.

Regards,

Suresh