types: begin of type_item,
f1(3),
f2(3),
f3(3),
f4(3),
end of type_item.
types: begin of type_data,
data(800),
end of type_data.
data: lineitems type table of type_item with header line,
t_output type table of type_data with header line,
fieldlist type table of rstrucinfo with header line,
fieldsym type table of rfieldlist with header line.
data: syrepid type sy-repid.
data: fieldname like fieldlist-compname,
data_line type type_data.
field-symbols :
lineitems-f1 = 'a1'.
lineitems-f2 = 'a2'.
lineitems-f3 = 'a3'.
lineitems-f4 = 'a4'.
append lineitems.
lineitems-f1 = 'b1'.
lineitems-f2 = 'b2'.
lineitems-f3 = 'b3'.
lineitems-f4 = 'b4'.
append lineitems.
lineitems-f1 = 'c1'.
lineitems-f2 = 'c2'.
lineitems-f3 = 'c3'.
lineitems-f4 = 'c4'.
append lineitems.
lineitems-f1 = 'd1'.
lineitems-f2 = 'd2'.
lineitems-f3 = 'd3'.
lineitems-f4 = 'd4'.
append lineitems.
syrepid = sy-repid.
* Gets all of the global data types.
call function 'GET_GLOBAL_SYMBOLS'
exporting
program = syrepid
tables
fieldlist = fieldsym.
* gets all of the components of a structure
call function 'GET_COMPONENT_LIST'
exporting
program = syrepid
fieldname = 'lineitems'
tables
components = fieldlist.
loop at lineitems assigning
loop at fieldlist.
fieldname = fieldlist-compname .
assign component fieldname of structure
concatenate data_line
endloop.
append data_line to t_output.
clear data_line.
endloop.
loop at t_output.
write:/ t_output.
endloop.
No comments:
Post a Comment