2006 Mar 01 12:35 PM
Hi All,
I need some help regarding dynamic internal table.
I am using BAPI_SALESORDER_SIMULATE for price simulation and the BAPI returns
the conditions for the customer, it will be identified in runtime only. Now i need to create a table in dynamic
and its displayed to ALV according to the BAPI return condition. Please help any one.
Thanks all.
Alex
2006 Mar 01 12:37 PM
HI
try this it will print it in ALV
REPORT Z_DYNAMIC_TABLE.
type-pools: slis.
field-symbols: <dyn_table> type standard table,
<dyn_wa>.
data: alv_fldcat type slis_t_fieldcat_alv,
it_fldcat type lvc_t_fcat.
selection-screen begin of block b1 with frame title text-001.
parameters: p_flds(5) type c.
selection-screen end of block b1.
start-of-selection.
build the dynamic internal table
perform build_dyn_itab.
write 5 records to the alv grid
do 5 times.
perform build_report.
enddo.
call the alv grid.
perform call_alv.
************************************************************************
Build_dyn_itab
************************************************************************
form build_dyn_itab.
data: new_table type ref to data,
new_line type ref to data,
wa_it_fldcat type lvc_s_fcat.
Create fields .
do p_flds times.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 5.
append wa_it_fldcat to it_fldcat .
enddo.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
endform.
*********************************************************************
Form build_report
*********************************************************************
form build_report.
data: fieldname(20) type c.
data: fieldvalue(5) type c.
data: index(3) type c.
field-symbols: <fs1>.
do p_flds times.
index = sy-index.
Set up fieldvalue
concatenate 'FLD' index into
fieldvalue.
condense fieldvalue no-gaps.
assign component index of structure <dyn_wa> to <fs1>.
<fs1> = fieldvalue.
enddo.
Append to the dynamic internal table
append <dyn_wa> to <dyn_table>.
endform.
************************************************************************
CALL_ALV
************************************************************************
form call_alv.
data: wa_cat like line of alv_fldcat.
do p_flds times.
clear wa_cat.
wa_cat-fieldname = sy-index.
wa_cat-seltext_s = sy-index.
wa_cat-outputlen = '5'.
append wa_cat to alv_fldcat.
enddo.
Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = alv_fldcat
tables
t_outtab = <dyn_table>.
endform.
<b>
plz close the thread if your problem is solved</b>
regards
kishore
Message was edited by: Harikishore Sreenivasulu
Hi All,
I need some help regarding dynamic internal table.
I am using BAPI_SALESORDER_SIMULATE for price simulation and the BAPI returns
the conditions for the customer, it will be identified in runtime only. Now i need to create a table in dynamic
and its displayed to ALV according to the BAPI return condition. Please help any one.
Thanks all.
Alex
2006 Mar 01 12:37 PM
HI
try this it will print it in ALV
REPORT Z_DYNAMIC_TABLE.
type-pools: slis.
field-symbols: <dyn_table> type standard table,
<dyn_wa>.
data: alv_fldcat type slis_t_fieldcat_alv,
it_fldcat type lvc_t_fcat.
selection-screen begin of block b1 with frame title text-001.
parameters: p_flds(5) type c.
selection-screen end of block b1.
start-of-selection.
build the dynamic internal table
perform build_dyn_itab.
write 5 records to the alv grid
do 5 times.
perform build_report.
enddo.
call the alv grid.
perform call_alv.
************************************************************************
Build_dyn_itab
************************************************************************
form build_dyn_itab.
data: new_table type ref to data,
new_line type ref to data,
wa_it_fldcat type lvc_s_fcat.
Create fields .
do p_flds times.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 5.
append wa_it_fldcat to it_fldcat .
enddo.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
endform.
*********************************************************************
Form build_report
*********************************************************************
form build_report.
data: fieldname(20) type c.
data: fieldvalue(5) type c.
data: index(3) type c.
field-symbols: <fs1>.
do p_flds times.
index = sy-index.
Set up fieldvalue
concatenate 'FLD' index into
fieldvalue.
condense fieldvalue no-gaps.
assign component index of structure <dyn_wa> to <fs1>.
<fs1> = fieldvalue.
enddo.
Append to the dynamic internal table
append <dyn_wa> to <dyn_table>.
endform.
************************************************************************
CALL_ALV
************************************************************************
form call_alv.
data: wa_cat like line of alv_fldcat.
do p_flds times.
clear wa_cat.
wa_cat-fieldname = sy-index.
wa_cat-seltext_s = sy-index.
wa_cat-outputlen = '5'.
append wa_cat to alv_fldcat.
enddo.
Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = alv_fldcat
tables
t_outtab = <dyn_table>.
endform.
<b>
plz close the thread if your problem is solved</b>
regards
kishore
Message was edited by: Harikishore Sreenivasulu
2006 Mar 02 6:16 AM
Hi,
Your answer really helpful for my problem, but still i am getting some error, can u please look it. This statement is giving dump ( <fs1> = t_order_condition1-COND_VALUE.)
*t_order_condition1 this table contain runtime condition type.
LOOP AT t_order_condition1.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = t_order_condition1-COND_TYPE.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 5.
append wa_it_fldcat to it_fldcat .
endloop.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
data: fieldname(20) type c.
data: fieldvalue(25) type c.
data: index(28) type c.
field-symbols: <fs1>.
LOOP AT t_order_condition1.
index = t_order_condition1-cond_value.
Set up fieldvalue
*concatenate t_order_condition1-COND_VALUE into
*fieldvalue.
*condense fieldvalue no-gaps.
assign component index of structure <dyn_wa> to <fs1>.
<fs1> = t_order_condition1-COND_VALUE.
ENDLOOP.
Append to the dynamic internal table
append <dyn_wa> to <dyn_table>.
data: wa_cat like line of alv_fldcat.
LOOP AT t_order_condition1.
clear wa_cat.
wa_cat-fieldname = t_order_condition1-COND_TYPE.
*wa_cat-seltext_s = sy-index.
wa_cat-outputlen = '5'.
append wa_cat to alv_fldcat.
ENDLOOP.
Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = alv_fldcat
tables
t_outtab = <dyn_table>.
2006 Mar 01 1:01 PM
2006 Mar 01 1:29 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |