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 variables: SELECTION-SCREEN PUSHBUTTON

Former Member
0 Likes
1,369

hi, how I can create 100 buttons on a cycle so dynamic?

example:

SELECTION-SCREEN BEGIN OF LINE.
   SELECTION-SCREEN PUSHBUTTON (4TEXT-001    USER-COMMAND but1.
   SELECTION-SCREEN PUSHBUTTON (4TEXT-002    USER-COMMAND but2.
   SELECTION-SCREEN PUSHBUTTON (4TEXT-003    USER-COMMAND but3.
   SELECTION-SCREEN PUSHBUTTON (4TEXT-004    USER-COMMAND but4.
SELECTION-SCREEN END OF LINE.


.....must be dynamic and they can be 100 and just 10


thanks in advance.

goudden.

6 REPLIES 6
Read only

LukaszPegiel
SAP Champion
SAP Champion
0 Likes
940

Define macro  for creation of selection-screen lines. Then you can do it dynamically.

Regards

Łukasz

Read only

0 Likes
940

Hi, thanks for replying, I do not work with macros as well the selection-screen tries to create the new variable and gives me error.


any other ideas?
Example:

DEFINE CREATEB.
   DATA a(2) TYPE C.
   a = 'a1'.
   SELECTION-SCREEN PUSHBUTTON (4a    USER-COMMAND but1.
END-OF-DEFINITION.


SELECTION-SCREEN BEGIN OF LINE.
   CREATEB.
SELECTION-SCREEN END OF LINE.


Read only

0 Likes
940

It gives you an error cause the macro is wrong. Try like this:

define create_line.

SELECTION-SCREEN BEGIN OF LINE.

   SELECTION-SCREEN PUSHBUTTON (4TEXT-&1    USER-COMMAND b&1.

   SELECTION-SCREEN PUSHBUTTON (4TEXT-&2    USER-COMMAND b&2.

   SELECTION-SCREEN PUSHBUTTON (4TEXT-&3    USER-COMMAND b&3.

   SELECTION-SCREEN PUSHBUTTON (4TEXT-&4    USER-COMMAND b&4.

SELECTION-SCREEN END OF LINE.

end-of-definition.

selection-screen begin of block b01.

     create_line: 001 002 003 004, 005 006 007 008.

selection-screen end of block b01.

Read only

Former Member
0 Likes
940

and what is the condition that drives the dynamism...

i can think of a couple of ways

you could have 100 buttons defined as in your question and then have a

at selection-screen processsing...

loop at screen

   ...apply an inactive status for the field after a certain number is reached so they are suppressed when dynpro is displayed

or use of if statements around each pushbutton but that would be long handed

the previous suggestion to also use a macro would keep coding tidy for whichever solution you go with as 100 buttons is a lot...

unusual requirement - why do you want this - whats the end goal?

Read only

0 Likes
940

thanks for replying, it is actually a banal case, I need to create multiple buttons with images that depend on a parameter if they are 10 or 30 or 100, an array of buttons as variables calculator buttons.

In the debugger I see the work screnn only see a structure.

Read only

matt
Active Contributor
0 Likes
940

As far as I am aware, you cannot dynamically create selection screens, except via dynamic generation of an ABAP program. Where I've had a similar requirement, I've created the maximum, and used LOOP AT SCREEN to hide the ones I didn't need.

Alternatively, develop it in Web Dynpro (which can run in SAPGui - see transaction SOAMANAGER to see how it can be done), and use the WDR_SELECT_OPTIONS component, which does allow fully dynamic select options.