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

Internal table - output

Former Member
0 Likes
645

Hi friends,

I have an internal table with the following fields:

salesordernumber itemnumber etcetc

I want the output as below:

salesordernumber itemnumber1

itemnumber2

(if the salesordernumber has multiple items, the itemnumber2 should come exactly below itemnumber1)

or just

salesordernumber itemnumber (and go for the next sales order if it has single item)

Please suggest a code.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
619

Hi Nuren,

May be you can do a

DESCRIBE TABLE itab line sy-tfill.

And then if the line items are greater than 1 then you can call different subroutines. Each displaying the layout as u want.

Cheers

VJ

4 REPLIES 4
Read only

Former Member
0 Likes
619

WRITE : / 'Sales order', 50 'Item Number'.

sort <table> by vbeln posnr.

Loop at <table>.

at new vbeln.

write: <table>-VBELN, 50 <table>-POSNR.

endat.

write: 50 <table>-POSNR.

endloop.

Read only

Former Member
0 Likes
620

Hi Nuren,

May be you can do a

DESCRIBE TABLE itab line sy-tfill.

And then if the line items are greater than 1 then you can call different subroutines. Each displaying the layout as u want.

Cheers

VJ

Read only

Former Member
0 Likes
619

I am assuming that this is a simple list you are working with.

Here is the rough code I can think of.

loop at itab.
  at new vbeln.
    write: /5 itab-vbeln, 10 itab-posnr.
  endat.
    write: /10 itab-posnr.
endloop.

Hope this helps.

Thanks,

Read only

Former Member
0 Likes
619

Hi Nuren,

Please check this piece of code.

TYPES : BEGIN OF ty_itab,

f1,

f2(10),

END OF ty_itab.

DATA : itab TYPE TABLE OF ty_itab WITH HEADER LINE.

itab-f1 = 'A'.

itab-f2 = 'GANGA'.

APPEND itab.

itab-f1 = 'A'.

itab-f2 = 'GANGA'.

APPEND itab.

itab-f1 = 'B'.

itab-f2 = 'GANGA'.

APPEND itab.

itab-f1 = 'B'.

itab-f2 = 'GANGA'.

APPEND itab.

itab-f1 = 'C'.

itab-f2 = 'GANGA'.

APPEND itab.

LOOP AT itab.

AT NEW f1.

WRITE: /5 itab-f1, 10 itab-f2.

ENDAT.

WRITE: /10 itab-f2.

ENDLOOP.

Output will be :

A *************

GANGA

GANGA

B *************

GANGA

GANGA

C *************

GANGA

Hope this what u require. If found helpful, please do reward.