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: 

Internal table data from one columns data into two columns

Former Member
0 Kudos

hi friends,

how to split one column data to two columns.

here in one column i have docment numbers i.e material doc and invoice document nos. so i want to split as material doc into material doc columns and invoice document no into invoice columns. here transaction type event for material doc is '1' and transaction type event for invoice doc is '2' .

So here material doc's are greater than or less than the invoice doc's numbers .I what basis i can split the records from one columns to two columns from an internal table.

internal table data:

po item transaction_event document

100000 1 1 560000001

100000 1 1 560000002

100000 1 2 620000004

100000 1 2 620000006

100000 1 2 620000007

so i want these into final table : itab as

po item mat_doc inv_doc

100000 1 560000001 620000004

100000 1 560000002 620000006

100000 1 620000007

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Prasad,

Declare one more internal table it_final_temp with all the fields fields.

sort it_final on material doc number.

Loop at it_final into wa_final.

v_tabix = sy_tabix + 1.

Read table it_final into wa_final1 index tabix.

if wa_final-mat_doc = wa_final1-mat_doc.

move: < required fields of wa_final and wa_final1 into wa_final_temp>.

Append wa_final_temp to it_final_temp.

else.

move only fields of wa_final to wa_final_temp.

Append wa_final_temp to It_final_temp.

endif.

Endloop.

Regards,

Avi

4 REPLIES 4

Former Member
0 Kudos

Hello,

Can you explain it cleary because the example which you give is not understanding.

Tell me at which condition we have move to other colum

Former Member
0 Kudos

Hi,

I got your requirement but i have a doubt that the invoice document is corresponding to some material document.

I mean how you will come to know which invoice doc is to be written in front of which material doc as in the example given by you.

Please revert back.

Regards

Natasha Garg

rainer_hbenthal
Active Contributor
0 Kudos

>

>

> po item mat_doc inv_doc

>

> 100000 1 560000001 620000004

> 100000 1 560000002 620000006

> 100000 1 620000007

You cannot have tables with variable amount of columns.

Former Member
0 Kudos

Hi Prasad,

Declare one more internal table it_final_temp with all the fields fields.

sort it_final on material doc number.

Loop at it_final into wa_final.

v_tabix = sy_tabix + 1.

Read table it_final into wa_final1 index tabix.

if wa_final-mat_doc = wa_final1-mat_doc.

move: < required fields of wa_final and wa_final1 into wa_final_temp>.

Append wa_final_temp to it_final_temp.

else.

move only fields of wa_final to wa_final_temp.

Append wa_final_temp to It_final_temp.

endif.

Endloop.

Regards,

Avi