Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

dynamic selection screen fetching the value from table fields

Former Member
0 Likes
489

hi gurus,

i have one table say ztable...and i should create a dynamic selection screen which should populate the selection screen by the table field names.

example..if i have 3 fields im my table..my selection screen should have three selection option fields..and in future if i add one more field in my table it should automatically create another slection-option in selection screen..

thanks

jaideep

3 REPLIES 3
Read only

Former Member
0 Likes
443

hi everyone

i have a similar problem it cud be of gr8 help if anyone can help me on this

Thanks

cnu

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
443

Hi,

This can solve your problem, but I dontthink its an IDEAL solution.

Use the statement

SELECTION-SCREEN BEGIN OF SCREEN 9001.

*Here give the list of SELECT-OPTIONS and

PARAMTERS as you wish for the table.

SELECTION-SCREEN END OF SCREEN.

Then once the FIELDS are selected to be displayed.

Use

CALL SELECTION-SCREEN 9001.

And then use

LOOP AT SCREEN.

Here hide the fields that you dont want

Or Activate the fields you want.

ENDLOOP.

Screen 9001 will not be shown till the point you use CALL SELECTION-SCREEN

Regards,

Sesh

Read only

Former Member
0 Likes
443

HI,

for this kind of requirement u need to create a dynamic program.for that u need to use the function module RSS_TEMPLATE_INSTANTIATE.see the doccumentation of the funtion module.

REPORT ZDYN_SELSCR.

DATA:T_ABAPSOURCE LIKE ABAPSOURCE OCCURS 0 WITH HEADER LINE.

"table which holds the sorce code for dynamic selection screen creation

CALL FUNCTION 'RSS_TEMPLATE_INSTANTIATE'"function module for creating the program dynamically to create dynamic sel screen

EXPORTING

I_TEMPLATE = '<b>ZDYN_TEMP</b>' "template(include program)

I_PROGRAM_NAME = 'ZDYN_PROG' "program that is to be created dynamicaly to create sel screen(this is just name)

I_PROGRAM_TYPE = '1' "type '1' indicates EXECUTABLE program

I_META_OBJECT = 'MARA' "meta object(give ur table name)

TABLES

E_T_PROGRAM_SOURCE = T_ABAPSOURCE. "this table holds the source code to create sel screen

INSERT REPORT 'ZDYN_PROG' FROM T_ABAPSOURCE."inserting source code into program from table

GENERATE REPORT 'ZDYN_PROG'. "generating the dynamically generated program

SUBMIT ZDYN_PROG VIA SELECTION-SCREEN AND RETURN.

<b>ZDYN_PROG</b>:

*@data: tabname like dfies-tabname.

*@DATA:H_NUM(3) TYPE N VALUE 1.

*@DATA:SEL_OPT(8).

*@DATA:FT_ZTMW_HEADER_COM TYPE DFIES OCCURS 0 WITH HEADER LINE.

*@tabname = i_meta_object.

REPORT z\i_meta_object\.

tables:\i_meta_object\.

*@call function 'GET_FIELDTAB'

*@ exporting

*@ only = 'X'

*@ tabname = tabname

*@ withtext = ' '

*@ tables

*@ fieldtab = FT_ZTMW_HEADER_COM

*@ exceptions

*@ internal_error = 1

*@ no_texts_found = 2

*@ table_has_no_fields = 3

*@ table_not_activ = 4

*@ others = 5.

*@LOOP AT FT_ZTMW_HEADER_COM.

*@CONCATENATE 'HEAD' H_NUM INTO SEL_OPT.

select-options \SEL_OPT\ for \tabname\-\FT_ZTMW_HEADER_COM-FIELDNAME\.

*@H_NUM = H_NUM + 1.

*@ENDLOOP.

at selection-screen output.

*@H_NUM = 1.

*@LOOP AT FT_ZTMW_HEADER_COM.

*@CONCATENATE 'HEAD' H_NUM INTO SEL_OPT.

%_\SEL_OPT\_%_APP_%-TEXT = '\FT_ZTMW_HEADER_COM-SCRTEXT_s\'.

*@H_NUM = H_NUM + 1.

*@endloop.

<b>reward if helpful.</b>

rgds,

bharat.

Message was edited by:

Bharat Kalagara