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

Selection-screen output with mandatory fields

Former Member
0 Likes
3,897

Hi all,

I have two radio buttons on my screen. Based on the selection I want to display only one of the two select-options.

select-option 1 should be displayed for radiobutton 1

select-option 2 should be displayed for radiobutton 2

As soon as I make those select-options mandatory I am not able to get the desired result.

Even if the radio button is changed from 1 to 2, the select-option 2 is not displayed.

I tried putting the validations the other way by throwing messages and not by making the fields obligatory. Still not successful. Kindly help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,891

hi

Try this

FORM selection_screen_modifications.

LOOP AT SCREEN.

IF screen-group1 = 'SG2' and p_aspt = 'X'..

screen-input = 1.

screen-reuiered = 1.

elseif IF screen-group1 = 'SG1' and p_ocfd = 'X'.

screen-input = 1.

screen-reuiered = 1.

else.

screen-input = 0.

screen-reuiered = 0.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

ENDFORM.

hi

Try this

FORM selection_screen_modifications.

LOOP AT SCREEN.

IF screen-group1 = 'SG2' and p_aspt = 'X'..

screen-input = 1.

screen-reuiered = 1.

elseif IF screen-group1 = 'SG1' and p_ocfd = 'X'.

screen-input = 1.

screen-reuiered = 1.

else.

screen-input = 0.

screen-reuiered = 0.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

ENDFORM.

9 REPLIES 9
Read only

Former Member
0 Likes
1,891

Hi,

use loop at screen... and validate the radio buttons

when u can post ur code and desired o/p clearly then we can help u out..

Regards

Syed

Read only

Former Member
0 Likes
1,891

Hi,

Possibly there's not a way to do this, using radiobuttons.

Try discussing your requirement, if it's necessary.

Try putting your requirement here, if possible. Then we can help any further.

Regards,

Brian Gonsales

Read only

Former Member
0 Likes
1,891

This is my code which is called in selection-screen output.

FORM selection_screen_modifications.

IF p_aspt = 'X'.

LOOP AT SCREEN.

IF screen-group1 = 'SG2'.

screen-active = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF p_ocfd = 'X'.

LOOP AT SCREEN.

IF screen-group1 = 'SG1'.

screen-active = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

call screen '1000'.

ENDIF.

ENDFORM.

The selection-screen is as follows.

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

SELECT-OPTIONS :

*plant

s_werks FOR i_orders-werks NO INTERVALS.

*Parameter

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-b02.

*OCFD

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 3(39) text-co1 FOR FIELD p_aspt.

PARAMETERS: p_aspt RADIOBUTTON GROUP rb1 DEFAULT 'X' USER-COMMAND hit.

SELECTION-SCREEN END OF LINE.

*ASPT

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 3(39) text-co2 FOR FIELD p_ocfd.

PARAMETERS: p_ocfd RADIOBUTTON GROUP rb1.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b2.

SELECT-OPTIONS :

*Order creation date - to be displayed for ASPT

s_crd FOR vbak-erdat MODIF ID sg1,

*Date scheduled for OCFD

s_schd FOR vbak-zzsoldate MODIF ID sg2,

*Order number range

s_order FOR vbak-vbeln.

*test mode

PARAMETER : p_test AS CHECKBOX DEFAULT 'X'.

SELECTION-SCREEN END OF BLOCK b1.

Read only

Former Member
0 Likes
1,891

Hi Brian,

The requirement is as follows.

I have two radiobuttons.

Rad 1

Rad 2

If Rad 1 is selected then I want to input Order Creation date (Field1) as mandatory, and Order scheduled date (Field 2) should not be displayed.

If Rad 2 is selected then I want to input Order Scheduled date (FIeld2) as mandatory, and order creation date(field1) should not be displayed.

If I can make the fields as obligatory at runtime, that may also solve my problem.

Read only

Former Member
0 Likes
1,891

Hi, Vipul.

To make the select-options obligatory during runtime, you can use this:


screen-required = 1.

screen-required = 1. (Field is mandatory)

screen-required = 0. (Field in NOT mandatory)

If there's any use for this, just let me know.

Regards,

Brian Gonsales

Read only

Former Member
0 Likes
1,891

Hi again, Vipul.

My suggestion is: let both field NOT mandatory, and check the displayed field. Example, if the field 1 is not locked, check it.

Like that:


AT SELECTION-SCREEN OUTPUT.

  LOOP AT SCREEN.
    IF p_aspt IS NOT INITIAL.

      IF screen-group1 = 'SG2'.
        screen-input    = 0.
      ENDIF.

    ELSEIF p_ocfd IS NOT INITIAL.

      IF screen-group1 = 'SG1'.
        screen-input    = 0.
      ENDIF.

    ENDIF.

    MODIFY SCREEN.
  ENDLOOP.

And right after, you can check if the displayed field is not empty:


IF p_aspt IS NOT INITIAL.

  IF s_crd-low  IS INITIAL AND
   s_crd-high IS INITIAL.
MESSAGE s000(zclass) WITH 'Fill in all required fields' 
DISPLAY LIKE 'E'.
  LEAVE LIST-PROCESSING AND RETURN TO SCREEN 0.
  ENDIF.

ELSEIF p_ocfd IS NOT INITIAL.

    IF s_schd-low  IS INITIAL AND
     s_schd-high IS INITIAL.
  MESSAGE s000(zclass) WITH 'Fill in all required fields'
  DISPLAY LIKE 'E'.
  LEAVE LIST-PROCESSING AND RETURN TO SCREEN 0.
  ENDIF.

ENDIF.

This will be like if the field which is displayed can't be empty, cause otherwise, the program will stop.

Hope it helps,

Brian Gonsales.

Read only

Former Member
0 Likes
1,892

hi

Try this

FORM selection_screen_modifications.

LOOP AT SCREEN.

IF screen-group1 = 'SG2' and p_aspt = 'X'..

screen-input = 1.

screen-reuiered = 1.

elseif IF screen-group1 = 'SG1' and p_ocfd = 'X'.

screen-input = 1.

screen-reuiered = 1.

else.

screen-input = 0.

screen-reuiered = 0.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

ENDFORM.

Read only

Former Member
0 Likes
1,891

Thank you all.

The answers were helpful to some extent but the only way I could solve the problem was by putting some default values in the mandatory fields. THose were date fields so I defaulted the current date.

Brian's answer was very helpful. It could have worked but since I am using SAP 4.6C. display like 'E' did not work.

Thank you very much.

Read only

Former Member
0 Likes
1,891

This problem was solved by putting a default value in the mandatory fields.