Skip to Content
0
Former Member
Sep 14, 2007 at 09:00 AM

How to Output data in vertically from a horizontal format.

1546 Views

Hello

I have some difficulties how to display my data in my output table. I am greatful for

every tips provided. The data in my it_tab is in a horizontal format but I want to

display this data vertically in my output_tab.

My it_tab looks like this:

table: it_tab
id   date   amnt
011  2007   1200
011  2008   1400
011  2009   6700
011  2010   3500
012  2007   ---
013  2007   3000
013  2008   1300
014  2007   1200
014  2008   ---
014  2009   9000
015  2007   2500

I would like my output_tab should look like this:

table: t_output
id  name  date amnt  date1  amnt1 date2  amnt2 date3  amnt3
011 jx    2007 1200  2008   1400  2009   6700  2010   3500
012 tx    --
014 gx    2007 3000  2008   --    2009   9000   --    ---
015 hx    2007 2500

t_output already has some data init like id and name.

This is what I have done but I don't output all the data as I want.

clear w_output.
loop at t_output into w_output.
clear w_itab.
loop at it_tab into w_itab where id = w_output-id.
case sy-tabix.
WHEN '1'.
w_output-date = w_itab-date.
w_output-amnt = w_itab-amnt.
WHEN '2'.
w_output-date1 = w_itab-date.
w_output-amnt1 = w_itab-amnt.
WHEN '3'.
w_output-date2 = w_itab-date.
w_output-amnt2 = w_itab-amnt.
WHEN '4'.
w_output-date3 = w_itab-date.
w_output-amnt3 = w_itab-amnt.
endcase.
endloop.
modify t_output from w_output.
endloop.

Could some body please tell me how to do this? I think many people in here have come

across this type of problem before.

Thank you all for helping out.

Nadin