04-21-2009 7:37 AM
Hi,
I have a Ztable created my program should create a dynamic selection screen depending on tht ztable
can you suggest me a solutin for this
Manohar.
04-21-2009 7:43 AM
Hi
Use this code
type-pools : abap.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat.
selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.
start-of-selection.
perform get_structure.
perform create_dynamic_itab. *********Creates a dyanamic internal table*********
form get_structure.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform.
form create_dynamic_itab.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = ifc
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
endform.
Kiran
04-21-2009 7:43 AM
Hi
Use this code
type-pools : abap.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat.
selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.
start-of-selection.
perform get_structure.
perform create_dynamic_itab. *********Creates a dyanamic internal table*********
form get_structure.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform.
form create_dynamic_itab.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = ifc
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
endform.
Kiran
04-21-2009 8:09 AM
kiran
u have given if we specify dyn_table it will pick all the fields from tht table
04-21-2009 8:18 AM
thanks for the code my requirement is it is picking all the fields from table but after picking it should generate selection screen for those fields.
04-21-2009 8:41 AM
code was gud tht is getting table can you please suggest how to build a dynamic selection screen for those fileds it is asking for table when we enter table it should create a slection screen for those fields
04-22-2009 8:25 AM
HI
I think (As per my knowledge) it is not possible to create a dynamic selection screen.
Kiran
Edited by: kiran vempati on Apr 22, 2009 9:25 AM
05-30-2009 7:09 PM
Hi Manohr,
I have similar requirements such as yours, where you able to create screen dynamically?
If so, then can you share the idea!!
Thanks in advance,
Reetesh
04-21-2009 7:45 AM
Hello,
can u please elaborate on your requirement.
Is it that the table structure changes and screen should work acordingly or its that some fields must be visible and some fileds invisble and must turn visible when a button is clciked etc.
If this is the case then you can use the following saple code:
loop at screen.
if screen-name = 'P_ABC'.
screen-invisble = '1'.
endif.
modify screen.
endloop.
Regards,
Mansi.
04-22-2009 9:34 AM
I don't think the PURE dynamic is possible...
some posibilities maybe:
create a number/variety of selection parameters refering to standard type
at initialization event,
- retrieve the field info/ text description
- determine which parameter fields to be used(by retrieved info)
- assign retrieved texts to selection texts
- disable/invisible unused parameters
This may work efficiently if you can forecast what kind of field to be used.
Regards,
05-22-2009 5:02 PM
You may not be able to create a selection screen dynamically, but you can create a program dynamically that has a selection screen, write the selection criteria to a table and then read it back into the main program.
See http://help.sap.com//saphelp_nw04/helpdata/EN/9f/db996135c111d1829f0000e829fbfe/frameset.htm or Special Techniques in the ABAP guide for help with creating dynamic programs.
Hope this helps,
Brian