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

loop at screen

Former Member
0 Likes
836

Hi Friends:

I got a scenario.I've 2 radio buttons on selection screen. When I click on first, it should make one filed as mandatory. When I click on second, it should make the prior field non-mandatory & make other field mandatory.I tried doing that. When I made first field mandatory & tried to click on the second radio button, it gave the error"fill in all the required fields". Plz help.

8 REPLIES 8
Read only

former_member404244
Active Contributor
0 Likes
800

Hi,

U cannot do like that...u can default it as obligatory..

do like this..

parameters : p_case RADIOBUTTON GROUP grp USER-COMMAND app DEFAULT 'X',

p_test like mara-matnr.

parameters : p_case1 RADIOBUTTON GROUP grp

p_test1 like mara-werks.

IF p_case IS NOT INITIAL .

LOOP AT SCREEN.

CASE screen-name.

WHEN 'P_TEST' .

screen-input = 1.

MODIFY SCREEN.

WHEN 'P_TEST1'

screen-input = 0.

MODIFY SCREEN.

ENDCASE.

ENDLOOP.

ELSE.

LOOP AT SCREEN.

CASE screen-name.

WHEN 'P_TEST' .

screen-input = 0.

MODIFY SCREEN.

WHEN 'P_TEST1'

screen-input = 1.

MODIFY SCREEN.

ENDCASE.

ENDLOOP.

START-OF-SELECTION.

IF P_cASE IS NOT INITIAL.

IF P_TEST IS INITIAL..

THROW ERROR MESSAGE.

ENDIF.

ELSEIF P_CASE1 IS NOT INITIAL.

IF P_TEST1 IS INITIAL..

THROW ERROR MESSAGE.

ENDIF.

ENDIF.

Regards,

Nagaraj

Read only

Former Member
0 Likes
800

Hey hi!

Mandatory as in you want the fields under the selected radio button to be displayed and rest all should be disabled.. then if so.. this is the code..

firstly select all the fields under a radio button into a single group, and give a function code to the radio button and then write the loop at screen statement..

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'V1'. (The field is taken under a grp V1)

IF ZTAB2-VASTHU = 'X'. (The radio button name ZTAB2-VASTHU)

SCREEN-OUTPUT = 0.

SCREEN-INPUT = 1.

ELSE.

SCREEN-OUTPUT = 1.

SCREEN-INPUT = 0.

ENDIF.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

I used this in my requirement.. hope this will be helpful..

Regards,

Abhishek.

Read only

0 Likes
800

Abhishek..

The code which you have given, will not be able to make the field Mandatory.

It will only help us to either disable or enable giving input to the field, it will not make the input mandatory.

Regards.

Read only

VikasB
Active Participant
0 Likes
800

Hi Gaurav,

Write your code like this..

********************************

TABLES:

sscrfields.

PARAMETERS:

p_chk1 TYPE c RADIOBUTTON GROUP gr1 DEFAULT 'X',

p_mat TYPE matnr,

p_chk2 TYPE c RADIOBUTTON GROUP gr1,

p_wrk TYPE werks_d.

AT SELECTION-SCREEN.

IF sscrfields-ucomm EQ 'ONLI'.

IF p_chk1 EQ 'X' AND p_mat IS INITIAL.

MESSAGE 'Enter p_mat' TYPE 'E'.

ELSEIF p_chk2 EQ 'X' AND p_wrk IS INITIAL.

MESSAGE 'Enter p_wrk' TYPE 'E'.

ENDIF.

ENDIF.

*********************************

Regards,

Vikas.

Read only

Former Member
0 Likes
800

Hi,

Plz check these code...


PARAMETERS: rd1 RADIOBUTTON GROUP rg1 USER-COMMAND rd DEFAULT 'X',
            rd2 RADIOBUTTON GROUP rg1,
            a1 TYPE char10,
            a2 TYPE char10.

AT SELECTION-SCREEN ON a1.
  IF rd1 = 'X' AND a1 IS INITIAL AND sy-ucomm NE 'RD'.
    MESSAGE 'Please Fill a1' TYPE 'E'.
  ENDIF.

AT SELECTION-SCREEN ON a2.
  IF rd2 = 'X' AND a2 IS INITIAL AND sy-ucomm NE 'RD'.
    MESSAGE 'Please Fill a2' TYPE 'E'.
  ENDIF.

Read only

Former Member
0 Likes
800

hey try this...

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: rb_pz RADIOBUTTON GROUP r1 DEFAULT 'X' USER-COMMAND rb_pz,

rb_rz RADIOBUTTON GROUP r1.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-002.

PARAMETERS: s_pz LIKE p0001-werks,

s_pr LIKE p0001-werks.

SELECTION-SCREEN END OF BLOCK b4.

AT SELECTION-SCREEN

IF rb_pz = 'X' AND s_pz IS INITIAL AND ( sy-ucomm = ' ' OR sy-ucomm = 'ONLI' ).

MESSAGE 'Make an entry in all required fields' TYPE 'E'.

ELSEIF rb_rz = 'X' AND s_pr IS INITIAL AND ( sy-ucomm = ' ' OR sy-ucomm = 'ONLI' ).

MESSAGE 'Make an entry in all required fields' TYPE 'E'.

ENDIF.

Read only

Former Member
0 Likes
800

SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE text-004.

SELECT-OPTIONS: so_vbeln FOR v_vbeln MODIF ID md1,

so_matnr FOR v_matnr MODIF ID md2.

SELECTION-SCREEN: END OF BLOCK blk1.

SELECTION-SCREEN: BEGIN OF BLOCK blk2 WITH FRAME TITLE text-005.

PARAMETERS: p_vbeln RADIOBUTTON GROUP rd1

DEFAULT 'X'

user-command ucom,

p_matnr RADIOBUTTON GROUP rd1.

SELECTION-SCREEN: END OF BLOCK blk2.

  • Change the display behviour of screen elements

----


FORM change_display_behaviour .

LOOP AT SCREEN.

IF p_vbeln = 'X'.

IF screen-group1 = 'MD1'.

screen-input = 1.

MODIFY SCREEN.

ELSEIF screen-group1 = 'MD2'.

screen-input = 0.

MODIFY SCREEN.

ENDIF.

ELSEIF p_matnr = 'X'.

IF screen-group1 = 'MD1'.

screen-input = 0.

MODIFY SCREEN.

ELSEIF screen-group1 = 'MD2'.

screen-input = 1.

MODIFY SCREEN.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. " change_display_behaviour

Read only

Former Member
0 Likes
800

Hi,

You can use screen-required = 1. in the loop

to make a field mandatory.

TABLES sscrfields.

find the sample code.

<Code>

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME NO INTERVALS.

PARAMETERS: a(10) TYPE c MODIF ID sc3 ,

b(10) TYPE c MODIF ID sc2 .

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN SKIP.

PARAMETERS: rad1 RADIOBUTTON GROUP rad1 USER-COMMAND ucomm,

rad2 RADIOBUTTON GROUP rad1.

AT SELECTION-SCREEN OUTPUT.

IF rad2 = 'X'.

LOOP AT SCREEN.

IF screen-group1 = 'SC3'.

screen-intensified = 1.

screen-active = 1.

screen-display_3d = 1.

screen-required = 1.

MODIFY SCREEN.

ENDIF.

IF screen-group1 = 'SC2'.

screen-intensified = 0.

screen-active = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF rad1 = 'X'.

LOOP AT SCREEN.

IF screen-group1 = 'SC3'.

screen-intensified = 0.

screen-active = 1.

screen-display_3d = 1.

screen-required = 0.

MODIFY SCREEN.

ENDIF.

IF screen-group1 = 'SC2'.

screen-intensified = 1.

screen-active = 1.

screen-required = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

<code>

Regards.