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

Split data into header and line items....

Former Member
0 Likes
1,527

Gurus,

I have to split data in an internal table based on a condition.

record type

H

L

L

L

H

L

L

L

I have to split this data and group as HLLL and HLLL.

H,L denotes header and line items..

Any ideas on how can we do it....

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
864

Mayank,

If I understood it correctly do you want to arrange the rows in the internal table like this?

Header record 1st row

Item record 2nd row

Item record 3rd row

Item record 4th row

Header record 5th row

Item record 6th row

Item record 7th row

Item record 8th row

................................

or do you want to merge each header and its items in to one row?

Let me know.

5 REPLIES 5
Read only

Former Member
0 Likes
865

Mayank,

If I understood it correctly do you want to arrange the rows in the internal table like this?

Header record 1st row

Item record 2nd row

Item record 3rd row

Item record 4th row

Header record 5th row

Item record 6th row

Item record 7th row

Item record 8th row

................................

or do you want to merge each header and its items in to one row?

Let me know.

Read only

0 Likes
864

Thats correct....

Thats the way i want it.....separate rows...

Thanks.

Edited by: Mayank Sharma on Jul 17, 2008 9:56 PM

Read only

0 Likes
864

Mayank,

In your program where from are you pulling those header and item records? And how and where are they stored?

Paste the definition of the header and item structures here.

Thanks,

Naren

Read only

0 Likes
864

If you are reading this data from a file on the application server,

then you need to use the open dataset, read dataset and close dataset statements.

If you are reading the file from presentation server, you need to use the function module 'GUI_UPLOAD'.

This FM will load the data into an internal table. It will create exactly the same number of rows in the internal table as those present in the file.

Loop at the internal table, check the first character, if its 'H' it means header, else line item.

cheers,

Sushil Joshi

Read only

Former Member
0 Likes
864

U can achieve it by using nested internal table means table with table..like:

types: ty_item type standard table of itemdata.

types: begin of ty_data,

header type headerdata,

item type ty_item, << it is an internal table

end of ty_data.

data: i_data type standard table of ty_data. << Nested table

data: w_data type ty_data.

data: w_item type itemdata.

say i_file contains header and line item data.

loop at i_final into w_final.

if w_final-rectyp = 'H'.

if sy-tabix <> 1.

append w_data to i_data.

endif.

l_rectyp = w_final-rectyp.

w_data-header = w_final-headerdata.

else.

w_item = w_final-itemdata.

append w_item to w_data-item.

endif.

endloop.

append w_data to i_data.

Regards,

Joy.