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 Parameter with field symbol

Former Member
0 Likes
3,180

Hello

I'm facing a problem in a report where I want to use a dynamic selection screen.

I got my internal table with e.g. 20 entries. In a LOOP I want to add with every entry a new parameter in my selection screen. So far so good, i already finished this, but its not that comfortable for me, because I wanted it some easier way if possible with field symbols.

I want in every LOOP entry that the content of one entry variable will be given to the parameters name or description. Is this possible? Any clever solution for this?

At the moment it looks pretty undynamical, because I had a limited amount of fields.


************************************************************************
INITIALIZATION.
************************************************************************

LOOP AT lt_lxe ASSIGNING <ls_lxe>.
     mac_para sy-tabix <ls_lxe>-language.
ENDLOOP.


DEFINE mac_para.
   case &1.
     when 1.
       selection-screen begin of block s03 with frame title text-z02.
       parameter: p_01 as checkbox.
       %_p_01_%_app_%-text = &2.
     when 2.
       parameter: p_02 as checkbox.
       %_p_02_%_app_%-text = &2.
     when 3.
       parameter: p_03 as checkbox.
       %_p_03_%_app_%-text = &2.
     when 4.
       parameter: p_04 as checkbox.
       %_p_04_%_app_%-text = &2.
     when 5.
       parameter: p_05 as checkbox.
       %_p_05_%_app_%-text = &2.
     when 6.
       parameter: p_06 as checkbox.
       %_p_06_%_app_%-text = &2.
     when 7.
       parameter: p_07 as checkbox.
       %_p_07_%_app_%-text = &2.
     when 8.
       parameter: p_08 as checkbox.
       %_p_08_%_app_%-text = &2.
     when 9.
       parameter: p_09 as checkbox.
       %_p_09_%_app_%-text = &2.
     when 10.
       parameter: p_10 as checkbox.
       %_p_10_%_app_%-text = &2.
     when 11.
       parameter: p_11 as checkbox.
       %_p_11_%_app_%-text = &2.
     when 12.
       parameter: p_12 as checkbox.
       %_p_12_%_app_%-text = &2.
       selection-screen end of block s03.
     when others.
   endcase.
END-OF-DEFINITION.

Regards

Michael

Hello

I'm facing a problem in a report where I want to use a dynamic selection screen.

I got my internal table with e.g. 20 entries. In a LOOP I want to add with every entry a new parameter in my selection screen. So far so good, i already finished this, but its not that comfortable for me, because I wanted it some easier way if possible with field symbols.

I want in every LOOP entry that the content of one entry variable will be given to the parameters name or description. Is this possible? Any clever solution for this?

At the moment it looks pretty undynamical, because I had a limited amount of fields.


************************************************************************
INITIALIZATION.
************************************************************************

LOOP AT lt_lxe ASSIGNING <ls_lxe>.
     mac_para sy-tabix <ls_lxe>-language.
ENDLOOP.


DEFINE mac_para.
   case &1.
     when 1.
       selection-screen begin of block s03 with frame title text-z02.
       parameter: p_01 as checkbox.
       %_p_01_%_app_%-text = &2.
     when 2.
       parameter: p_02 as checkbox.
       %_p_02_%_app_%-text = &2.
     when 3.
       parameter: p_03 as checkbox.
       %_p_03_%_app_%-text = &2.
     when 4.
       parameter: p_04 as checkbox.
       %_p_04_%_app_%-text = &2.
     when 5.
       parameter: p_05 as checkbox.
       %_p_05_%_app_%-text = &2.
     when 6.
       parameter: p_06 as checkbox.
       %_p_06_%_app_%-text = &2.
     when 7.
       parameter: p_07 as checkbox.
       %_p_07_%_app_%-text = &2.
     when 8.
       parameter: p_08 as checkbox.
       %_p_08_%_app_%-text = &2.
     when 9.
       parameter: p_09 as checkbox.
       %_p_09_%_app_%-text = &2.
     when 10.
       parameter: p_10 as checkbox.
       %_p_10_%_app_%-text = &2.
     when 11.
       parameter: p_11 as checkbox.
       %_p_11_%_app_%-text = &2.
     when 12.
       parameter: p_12 as checkbox.
       %_p_12_%_app_%-text = &2.
       selection-screen end of block s03.
     when others.
   endcase.
END-OF-DEFINITION.

Regards

Michael

8 REPLIES 8
Read only

matt
Active Contributor
0 Likes
2,389

Re-do your application as a web dynpro, using the WDR_SELECT_OPTIONS component. This makes it very easy to do a dynamic selection screen, and gives you the added advantage that you application is immediately web enabled.

Read only

Former Member
0 Likes
2,389

Matthew, are you sure that recommending another technology is the issue solver?

Michael - did you try to include the type of the parameter in lt_lxe and also it's description? If this would be sent to the macro, you would be able to implement logic like:


parameter: p_01 as checkbox type <ls_lxe>-type (of course, accessed via macro's parameters order).


You could also implement the solution in the way that every parameter would stand itself on a separated selection-screen line.


selection-screen begin of line.

  parameter: p_01 as checkbox type <ls_lxe>-type.

selection-screen end of line.


Then you can also use the position keyword along with comment to include the text, placed on some offset.

Read only

matt
Active Contributor
0 Likes
2,389

Pretty sure, yes. At some of my clients, the realisation that it makes sense for the majority of reports/applications/tools to be web enabled is begin to permeate. Since webdynpros can also be run in sapgui, there's no real reason for it not to be the UI of choice.

I also know that dynamic selection screens are vastly easier in web dynpro than in classic.

The only reason you have to use sapgui is if you're integrating with components that aren't web enabled. That can be a bit problematic.

Read only

Former Member
0 Likes
2,389

As I understand you right it would mean that every parameter got the same description/text, because it is the same type? I do not want it like that, I want the content of the fieldvalue displayed as parameter text. This works pretty fine with the macro above.

The only problem is, that I had to give a fix number of parameter, because I did not find a working solution for making dynamic parameter name. In the macro it did not work like:


parameter: p_&1 as checkbox.

because macro wants to transport the given fieldname ant not its content. With the macro it is ok like p_01, p_02 and so on but is there any way to make the macro that dynamic to build as much parameter as the table got entries? I do not want to build quite about 50 parameter just to be sure that every entry is caught in the macro.

Im looking for a solution to give the sy-tabix value dynamical to the parameters name, but it did not work. Even:


ASSIGN COMPONENT ....

did not work. Any ideas?

Read only

Former Member
0 Likes
2,389

did you try

parameter: p_01 as checkbox type <ls_lxe>-type


?

Read only

Former Member
0 Likes
2,389

Hi,

Can you elaborate a bit more?

What data you will have in your internal table? Will it contain any table structure? If the table type is a DDIC object, then perhaps you can try RTTI .


This link may come handy.

Sorry, as I did not understand fully, I have referred to SCN article. Maybe after understanding properly, I can suggest something.

Regards

Abhi

Read only

0 Likes
2,389

Its a table about system languages for translation (table lxe_t002). The field <ls_lxe>-language contains the language keys for translation, e.g. deDE, enUS, itIT, and so on....

For every language I want to create an own checkbox parameter with language key text..

p_01  -> deDE

p_02  -> enUS

p_03  -> itIT

....

With my coding above it works fine, the text is displayed correctly, but I just made an example with 12 checkboxes not considering the real number of rows (languages) in my internal table. I want to build exactly as much parameter as my internal table got rows. With sy-tabix I can find the number but I do not know how to make the parameters that dynamical that the number of row is just the sy-tabix value.

The easiest way would just be one parameter definition in the macro:


PARAMETER: p_&1 AS CHECKBOX.

with &1 as sy-tabix but this did not work, because when giving sy-tabix to the macro, it tries to create parameter named p_sy-tabix and not named p_1, p_2 and so on 😉

Read only

0 Likes
2,389

Hi,

Thanks for elaborating your objective.

I think you might not achieve your objective this way. When I cross-referenced SAP help I came across following statement.


When an ABAP program is activated, the components of the program selection screens, that is, screens with screen elements and screen flow logic, are automatically generated.

Thus I think, it will certainly expect some name there. However, I came across these three links, which throw (some) light on how it can be achieved.

http://stackoverflow.com/questions/15151714/dynamically-declaring-parameters-from-table-in-sap-abap:...

http://stackoverflow.com/questions/13348319/for-the-i-o-fields-in-a-normal-abap-screen-can-i-get-the...

http://help.sap.com/abapdocu_702/en/abenfree_selections.htm

Below link looks promisong but I am not sure. However it looks closest to meet your objective.

http://benxbrain.com/en/index.do?onInputProcessing(brai_object_thread)&001_threadid=0000261469&001_b...

I do not possess personal experience and hence can not give a concrete answer.

Regards

Abhi.