‎2008 Mar 08 10:57 AM
Hi Experts,
I have data in itab like :
Off. Prod. Qty. Value.
MUM A 13 1200
MUM C 14 1300
MUM B 9 990
DEL A 6 550
DEL E 21 1350
DEL B 125 9389
DEL C 35 7890
I am writting a classical reports and i want to print like
A B C D E F G
MUM 13 9 14
DEL 6 125 35 21
How to Loop the itab and how to write ? Pl. guide me....
Yusuf
‎2008 Mar 09 11:25 PM
Hi
Assumptions:
- you always have six letter A..F
- value in column 1 is always max. 3 chars
- value in column 2 is always max. 3 chars
- you want to show it in table like this:
A B C D E F
MUM 13 9 14
DEL 6 125 35 21
So, here we go:
CONSTANTS: lco_position_a TYPE i VALUE 4,
lco_position_b TYPE i VALUE 8,
lco_position_c TYPE i VALUE 12,
lco_position_d TYPE i VALUE 16,
lco_position_e TYPE i VALUE 20,
lco_position_f TYPE i VALUE 24.
DATA: ltp_value_position TYPE i,
lwa_data LIKE LINE OF itab.
WRITE AT lco_position_a 'A B C D E F'.
SORT itab BY col1, col2. "put proper col names here
LOOP AT itab INTO lwa_itab.
CASE lwa_itab-col2. "put proper col name here
WHEN 'A'.
ltp_value_position = lco_position_a.
WHEN 'B'.
ltp_value_position = lco_position_b.
WHEN 'C'.
ltp_value_position = lco_position_c.
WHEN 'D'.
ltp_value_position = lco_position_d.
WHEN 'E'.
ltp_value_position = lco_position_e.
WHEN 'F'.
ltp_value_position = lco_position_f.
ENDCASE.
AT NEW lwa_itab-col1. "put proper col name here
WRITE / lwa_itab-col1. "put proper col name here
ENDAT.
WRITE AT ltp_value_position lwa_itab-col2. "put proper col name here
ENDLOOP.
Haven't tested it though. Also if you have much more of the A..F letters or the number of these is not constant then additional logic for the auto-positioning would be required.
Rgds
Mat
‎2008 Mar 09 9:10 AM
Hello,
1ST : write the first line "A B C D E F G"
LOOP at itab.
if sy-tabix eq 1.
* Start New line
write / ...
else.
* Continue the Current line
write at ...
endif.
ENDLOOP.2D : write the 2d and 3d lines ("MUM 13 9 14" and "DEL 6 125 35 21")
SORT itab by "field1" (name of the 1st field of itab (with value 'MUM')
LOOP AT itab.
AT NEW field1.
* Start New line
write / field1.
ENDAT.
* Continue the Current line
write at 10 itab-field3 (3d field of itab with values 13 or 9 or 14 for MUM)
ENDLOOP.Cordialement,
Chaouki.
‎2008 Mar 09 11:25 PM
Hi
Assumptions:
- you always have six letter A..F
- value in column 1 is always max. 3 chars
- value in column 2 is always max. 3 chars
- you want to show it in table like this:
A B C D E F
MUM 13 9 14
DEL 6 125 35 21
So, here we go:
CONSTANTS: lco_position_a TYPE i VALUE 4,
lco_position_b TYPE i VALUE 8,
lco_position_c TYPE i VALUE 12,
lco_position_d TYPE i VALUE 16,
lco_position_e TYPE i VALUE 20,
lco_position_f TYPE i VALUE 24.
DATA: ltp_value_position TYPE i,
lwa_data LIKE LINE OF itab.
WRITE AT lco_position_a 'A B C D E F'.
SORT itab BY col1, col2. "put proper col names here
LOOP AT itab INTO lwa_itab.
CASE lwa_itab-col2. "put proper col name here
WHEN 'A'.
ltp_value_position = lco_position_a.
WHEN 'B'.
ltp_value_position = lco_position_b.
WHEN 'C'.
ltp_value_position = lco_position_c.
WHEN 'D'.
ltp_value_position = lco_position_d.
WHEN 'E'.
ltp_value_position = lco_position_e.
WHEN 'F'.
ltp_value_position = lco_position_f.
ENDCASE.
AT NEW lwa_itab-col1. "put proper col name here
WRITE / lwa_itab-col1. "put proper col name here
ENDAT.
WRITE AT ltp_value_position lwa_itab-col2. "put proper col name here
ENDLOOP.
Haven't tested it though. Also if you have much more of the A..F letters or the number of these is not constant then additional logic for the auto-positioning would be required.
Rgds
Mat
‎2008 Mar 14 5:37 AM
‎2008 Mar 14 7:45 AM