‎2008 Aug 12 7:17 AM
hi iam sujay,
i ve an requirement to list out the quantity sold to customers.....but i need to list out the columns dynamically ie the column should contain customer only if sale done to him for the given period.for example - if sale is done for 15 customer for the given period then i need to have 15 +1(column for material) columns...if sale done for 30 customer then i need to have 30 + 1 columns in my report..
i ve tried this call method cl_alv_table_create=>create_dynamic_table and
created dynamic table but i cant move datas into the dynamic table as per my requirement..how is it possible? plz help me.............
regards,
sujay Pradeesh.
‎2008 Aug 12 11:51 AM
Hi,
Here's an example for the dynamically datau2013typed table <tab> and row <row> that has just code and description fields.
...
field-symbols:
<row_code>,
<row_desc>.
...
concatenate:
'<ROW>-' p_code into row_code_name,
'<ROW>-' p_desc into row_desc_name.
assign:
(row_code_name) to <row_code>,
(row_desc_name) to <row_desc>.
select * from (p_tabn) into table <tab>.
loop at raw_itab into raw_row.
<code> = raw_row-field1.
<desc> = raw_row-field2.
read table <tab> into <row> with key (p_code) = <code>.
if sy-subrc ne 0.
clear <row>.
<row_code> = <code>. "assigns to <row> 'code' field
<row_desc> = <desc>. "assigns to <row> 'desc' field
insert (p_tabn) from <row>. "creates a database-table row
if sy-subrc eq 0.
write: / 'Inserted :', <row_code>, <row_desc>.
endif.
endif.
endloop.
...
This should help.
John
‎2008 Aug 12 12:18 PM
1.create a field catelog based on the no: of columns.
2.use the following method to create a dynamic_table
field symbols
FIELD-SYMBOLS: <fs_any> TYPE ANY,
<fs_output> TYPE ANY,
<ft_output> TYPE table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat
IMPORTING
ep_table = ptr_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ASSIGN ptr_table->* TO <ft_output>.
CREATE DATA ptr_warea LIKE LINE OF <ft_output>.
ASSIGN ptr_warea->* TO <fs_output>.
3.use the following statement tot transfer the date to output
ASSIGN COMPONENT c_stext OF STRUCTURE <fs_output> TO <fs_any>.
IF sy-subrc = 0.
<fs_any> = <l_output>-stext.
ENDIF.
‎2008 Aug 12 12:27 PM
***field symbols
field-symbols: <l_table> type table,
<l_line> type any,
<l_field> type any.
**
data: is_lvc_cat type lvc_s_fcat,
it_lvc_cat type lvc_t_fcat.
data: new_table type ref to data,
new_line type ref to data.
***assigning filed names to field catalog
is_lvc_cat-fieldname = 'ESID'.
append is_lvc_cat to it_lvc_cat.
is_lvc_cat-fieldname = 'CALLOC'.
append is_lvc_cat to it_lvc_cat.
***creating table
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_lvc_cat
importing
ep_table = new_table.
assign new_table->* to <l_table>.
create data new_line like line of <l_table>.
assign new_line->* to <l_line>.
loop at t_grid into l_grid.
assign component 'ESID' of structure <l_line> to <l_field>.
<l_field> = l_esid.
assign component 'CALLOC' of structure <l_line> to <l_field>.
<l_field> = l_calloc.
endloop.