Application Development 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: 

LOOP AT SCREEN and USER-COMMAND

Former Member
0 Kudos
4,151

Hi,experts.

I have a question when I want to modify the screen. My requirement is that: In the selection-screen there are two radio buttons, and four text fields. When I select the first radio button , the last two text fields will become gray; when I select the second radio button , the first two text fields will become gray.

At first , my code is below,but it doesn't work.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: <b>p_rb1 RADIOBUTTON GROUP radi DEFAULT 'X'</b>,

p_rb2 RADIOBUTTON GROUP radi.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.

PARAMETERS: p_txt1(10) MODIF ID sc1,

p_txt2(10) MODIF ID sc1,

p_txt3(10) MODIF ID sc2,

p_txt4(10) MODIF ID sc2.

SELECTION-SCREEN END OF BLOCK b2.

AT SELECTION-SCREEN OUTPUT.

IF p_rb1 = 'X'.

LOOP AT SCREEN.

IF screen-group1 = 'SC2'.

screen-input = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ELSE.

LOOP AT SCREEN.

IF screen-group1 = 'SC1'.

screen-input = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

But after I adding <b>USER-COMMAND UC1 </b> to <b>p_rb1 RADIOBUTTON GROUP radi DEFAULT 'X'</b> , it worked.

But I don't understand how the 'user-command uc1' works.Can you help me? And if you have a better idea , please tell me.

Regards,

feng.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
527

Hi Feng,

Actaully when you give selection field without user command, the code under the AT SELECTION-SCREEN OUTPUT will be triggered when the program is executed or else if there is any user action performed on the selection screen for eg: SAVE, EXECUTE(F8)., So when you change the value of the radio button which doesnt have any user command name so it wont trigger the PBO event. Whereas when you mention the user command name to the radio button. When there is a change in the radio button it will trigger PBO and after it will trigger PAI which SELECTION-SCREEN OUTPUT. Specifying the user-command name is the better option to use.

Reward if useful.

Thanks,

Muthu,

8 REPLIES 8

Former Member
0 Kudos
527

PARAMETERS: p_rb1 RADIOBUTTON GROUP radi DEFAULT 'X' <b>USER-COMMAND rb,</b>

I tried and its working well..

Regards,

sre

former_member188827
Active Contributor
0 Kudos
527

The addition USER-COMMAND can be used to assign a function code fcode to the first parameter in a radio button group. The function code fcode must be specified directly, and have a maximum length of 20 characters. To evaluate the function code, an interface work area of the structure SSCRFIELDS from the ABAP Dictionary must be declared using the statement TABLES. When the user selects any radio button of the radio button group on the selection screen, the runtime environment triggers the event AT SELECTION-SCREEN and transfers the function code fcode to the component ucomm of the interface work area sscrfields. If a function code used in the GUI status of the selection screen is specified for fcode, the selection screen processing is affected accordingly.

plz reward if dis helps

0 Kudos
527

Thanks very much, abapuser.

But in my code , I havn't used SSCRFIELDS. USER-COMMAND can trigger event AT SELECTION-SCREEN,can it trigger the event AT SELECTION-SCREEN OUTPUT?

Regards,

feng.

0 Kudos
527

at selection-screen output is trigirred even if hit enter on screen.

so u can also use it.

Former Member
0 Kudos
528

Hi Feng,

Actaully when you give selection field without user command, the code under the AT SELECTION-SCREEN OUTPUT will be triggered when the program is executed or else if there is any user action performed on the selection screen for eg: SAVE, EXECUTE(F8)., So when you change the value of the radio button which doesnt have any user command name so it wont trigger the PBO event. Whereas when you mention the user command name to the radio button. When there is a change in the radio button it will trigger PBO and after it will trigger PAI which SELECTION-SCREEN OUTPUT. Specifying the user-command name is the better option to use.

Reward if useful.

Thanks,

Muthu,

0 Kudos
527

Thanks , Muthu Prabakaran Selvam.

But I found this in the SAP Library:In the PBO of the selection screen, the

AT SELECTION-SCREEN OUTPUT event is triggered. So, AT SELECTION-SCREEN OUTPUT is a PBO event. Can it triggers a PBO event?

Regards,

feng.

0 Kudos
527

Hi feng,

After every PAI event, the screen program automatically calls the PBO event so there is no need to call it manually. When you give usercommand to any particular field and if you change the value at runtime it will trigger the PAI. When the PAI is completed then PBO is triggered automatically.

Thanks,

Muthu

0 Kudos
527

Hi Feng,

Yes it will trigger PBO event. But for your requirement you can also refer below thread

Regards,

Atish