‎2010 Feb 09 2:00 PM
hi everybody ,
i have an issue help me....
i want dynamic heading(size wise quandity)...
i am having internal table like this
*material1 unit 35 100(this is quandity)
material1 unit 40 200
material2 unit 35 500*
i want following out put in internal table is it possible?
material uom 35 40
-
material1 unit 100 200
material2 unit 500
prabhu
‎2010 Feb 09 3:56 PM
Hi Prabhu,
if i got your request right, you might try somthing like the below.
I assumed, that your variety of size is not unlimited. In my example i took 16 different values for size as maximum.
additionaly, you have to think of means to suppress empty fields or maybe distinguish them from actual zero.
Alternatively, you could apply deep structure (table in table) for sizes.
data: begin of itab occurs 0,
material(10),
unit(5),
size(2) type n,
quant type i,
end of itab,
begin of wa_out,
material(10),
unit(4),
size1(2) type n,
size2(2) type n,
size3(2) type n,
size4(2) type n,
size5(2) type n,
size6(2) type n,
size7(2) type n,
size8(2) type n,
size9(2) type n,
sizea(2) type n,
sizeb(2) type n,
sizec(2) type n,
sized(2) type n,
sizee(2) type n,
sizef(2) type n,
end of wa_out,
wa_head like wa_out,
tab_out like table of wa_out.
data: begin of ftab occurs 0,
s_val(2) type n,
s_idx type i,
end of ftab.
field-symbols: <col>.
wa_head-material = 'Material'.
wa_head-unit = 'uom'.
SORT itab by size.
ftab-s_idx = 2.
LOOP AT itab.
on change of itab-size.
add 1 to ftab-idx.
ftab-s_val = itab-size.
append ftab.
assign COMPONENT ftab-s_idx OF STRUCTURE wa_head to <col>.
<col> = itab-size.
endon.
ENDLOOP.
sort itab by material.
LOOP AT itab.
on CHANGE OF itab-material.
IF wa_out is not initial.
append wa_out to tab_out.
ENDIF.
clear wa_out.
wa_out-material = itab-material.
endon.
wa_out-unit = itab-unit.
READ TABLE ftab WITH KEY s_val = itab-size.
if sy-subrc ne 0.
* do something awfully impressive
endif.
ASSIGN COMPONENT ftab-s_idx OF STRUCTURE wa_out to <col>.
<col> = itab-quant.
ENDLOOP.