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 issue

Former Member
0 Likes
1,089

I have two blocks in my selection screen. now in the 2nd block I have material and substance id. for both the fields i have radio button option. now I want if user select Materail, substance id field should get become grayed out.

I have tried with loop at screen. it didn't work out

please find my code below and help me out

*Input for Date

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

PARAMETERS: p_date TYPE sy-datum OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

*Input for Material Number and Substance ID

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

*Radio Button for Material Number

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: rb_matnr RADIOBUTTON GROUP g1.

SELECTION-SCREEN COMMENT (15) text-003.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_matnr TYPE mara-matnr.

SELECTION-SCREEN END OF LINE.

*Radio Button for Substance ID

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: rb_subid RADIOBUTTON GROUP g1.

SELECTION-SCREEN COMMENT (15) text-004.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_subid TYPE estrh-subid.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b2.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,045

Hi,

To do this, you need to use the event AT SELECTION-SCREEN OUTPUT.

Here, you should check according to field group (assign one to each field using MODIF ID), and for both "checked and "unchecked" options. So there will be four scenarios to check as follows (don't forget to write MODIFY SCREEN!

Cheers,

Shailesh.

10 REPLIES 10
Read only

Former Member
0 Likes
1,045

Try something like following

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_date TYPE sy-datum OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.

*Input for Material Number and Substance ID
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
*Radio Button for Material Number
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rb_matnr RADIOBUTTON GROUP g1 USER-COMMAND g1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT (15) text-003.
SELECTION-SCREEN POSITION 33.
PARAMETERS: p_matnr TYPE mara-matnr.
SELECTION-SCREEN END OF LINE.
*Radio Button for Substance ID
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rb_subid RADIOBUTTON GROUP g1.
SELECTION-SCREEN COMMENT (15) text-004.
SELECTION-SCREEN POSITION 33.
PARAMETERS: p_subid TYPE estrh-subid.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b2.

INITIALIZATION.
   LOOP AT SCREEN.
       IF rb_matnr = 'X' AND SCREEN-NAME CS 'P_SUBID'.
          SCREEN-INPUT = '0'.
       ENDIF.
       IF rb_subid = 'X' AND SCREEN-NAME CS 'P_MATNR'.
          SCREEN-INPUT = '0'.
       ENDIF.
       MODIFY SCREEN.
   ENDLOOP.
AT SELECTION-SCREEN OUTPUT.
   LOOP AT SCREEN.
       IF rb_matnr = 'X' AND SCREEN-NAME CS 'P_SUBID'.
          SCREEN-INPUT = '0'.
       ENDIF.
       IF rb_subid = 'X' AND SCREEN-NAME CS 'P_MATNR'.
          SCREEN-INPUT = '0'.
       ENDIF.
       MODIFY SCREEN.
   ENDLOOP.

Read only

Former Member
0 Likes
1,046

Hi,

To do this, you need to use the event AT SELECTION-SCREEN OUTPUT.

Here, you should check according to field group (assign one to each field using MODIF ID), and for both "checked and "unchecked" options. So there will be four scenarios to check as follows (don't forget to write MODIFY SCREEN!

Cheers,

Shailesh.

Read only

Former Member
0 Likes
1,045

Hi,

You have to trigger an event when you check the radio button. So you gotto use the USER-COMMAND(fcode).

Use the AT SELECTION-SCREEN OUTPUT event. Check if the particular radio button is checked, if so, then disable the other radio button.



LOOP AT SCREEN.
      IF P_RAD EQ 'X' and screen-name eq 'p_field'.
          SCREEN-INPUT = '0'.
          MODIFY SCREEN.
      ENDIF.

Read only

Former Member
0 Likes
1,045

Hi GTREN,

thanks for your quick reply. I have verified that ur cod eis working fine. but the issue is in my scenario. actually there are multi ple blocks.

Now I am sending you the entire selection screen code.

&----


*& Include ZWEHSR_SPEC_DATA_SHEET_SCRN

&----


*Input for Date

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

PARAMETERS: p_date TYPE sy-datum OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

*Input for Material Number and Substance ID

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

*Radio Button for Material Number

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: rb_matnr RADIOBUTTON GROUP g1.

SELECTION-SCREEN COMMENT (15) text-003.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_matnr TYPE mara-matnr.

SELECTION-SCREEN END OF LINE.

*Radio Button for Substance ID

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: rb_subid RADIOBUTTON GROUP g1.

SELECTION-SCREEN COMMENT (15) text-004.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_subid TYPE estrh-subid.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b2.

*Input for Plant

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

PARAMETERS: p_plant TYPE marc-werks OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b3.

*Input for Customer and Vendor

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

*Radio Button for Customer

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: rb_cust RADIOBUTTON GROUP g2.

SELECTION-SCREEN COMMENT (15) text-007.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_cust TYPE kna1-kunnr.

SELECTION-SCREEN END OF LINE.

*Radio Button for Vendor

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: rb_vend RADIOBUTTON GROUP g2.

SELECTION-SCREEN COMMENT (15) text-008.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_vend TYPE lfa1-lifnr.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b4.

*External/Internal

SELECTION-SCREEN BEGIN OF BLOCK b5 WITH FRAME TITLE text-009.

*Radio Button for External

PARAMETERS: rb_extnl RADIOBUTTON GROUP g3.

*Radio Button for Internal

PARAMETERS: rb_intnl RADIOBUTTON GROUP g3.

SELECTION-SCREEN END OF BLOCK b5.

INITIALIZATION.

LOOP AT SCREEN.

IF rb_matnr = 'X' AND SCREEN-NAME CS 'P_SUBID'.

SCREEN-INPUT = '0'.

ENDIF.

IF rb_subid = 'X' AND SCREEN-NAME CS 'P_MATNR'.

SCREEN-INPUT = '0'.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF rb_matnr = 'X' AND SCREEN-NAME CS 'P_SUBID'.

SCREEN-INPUT = '0'.

ENDIF.

IF rb_subid = 'X' AND SCREEN-NAME CS 'P_MATNR'.

SCREEN-INPUT = '0'.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

NOW if I put the provided code ijust after block 2, it's throwing an error due to at selection-screen output. and if i put it at thelast its not working. pls help

Read only

0 Likes
1,045

Hi,

I have checked your code. Use GTREN's code in your's. You havent given the USER-COMMAND flag in the code that you have pasted above.


PARAMETERS: rb_matnr RADIOBUTTON GROUP g1  USER-COMMAND flag DEFAULT 'X'.

This should work. If you get an error like 'Fill in all madatory fields i.e your p_date is declared as mandatory, then you can say something like this in your AT SELECTION-SCREEN OUTPUT.



AT SELECTION-SCREEN OUTPUT.

 LOOP AT SCREEN.
   IF screen-name EQ 'P_DATE'.
      IF p_date IS  INITIAL.
        screen-required = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDIF.
  ENDLOOP.

Edited by: Nitwick on Jul 16, 2009 5:10 PM

Read only

Former Member
0 Likes
1,045

Hi,

In LOOP AT SCREEN statement.

use AT SELECTION SCREEN OUTPUT event and in this using IF...ENDIF statement MODIFY the screen as per requirement.

hope it helps.

Regards

Rajesh Kumar

Read only

Former Member
0 Likes
1,045

My Code:

*Input for Date

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

PARAMETERS: p_date TYPE sy-datum OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

*Input for Material Number and Substance ID

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

*Radio Button for Material Number

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: rb_matnr RADIOBUTTON GROUP g1.

SELECTION-SCREEN COMMENT (15) text-003.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_matnr TYPE mara-matnr.

SELECTION-SCREEN END OF LINE.

*Radio Button for Substance ID

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: rb_subid RADIOBUTTON GROUP g1.

SELECTION-SCREEN COMMENT (15) text-004.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_subid TYPE estrh-subid.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b2.

*Input for Plant

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

PARAMETERS: p_plant TYPE marc-werks OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b3.

*Input for Customer and Vendor

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

*Radio Button for Customer

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: rb_cust RADIOBUTTON GROUP g2.

SELECTION-SCREEN COMMENT (15) text-007.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_cust TYPE kna1-kunnr.

SELECTION-SCREEN END OF LINE.

*Radio Button for Vendor

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: rb_vend RADIOBUTTON GROUP g2.

SELECTION-SCREEN COMMENT (15) text-008.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_vend TYPE lfa1-lifnr.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b4.

*External/Internal

SELECTION-SCREEN BEGIN OF BLOCK b5 WITH FRAME TITLE text-009.

*Radio Button for External

PARAMETERS: rb_extnl RADIOBUTTON GROUP g3.

*Radio Button for Internal

PARAMETERS: rb_intnl RADIOBUTTON GROUP g3.

SELECTION-SCREEN END OF BLOCK b5.

Read only

0 Likes
1,045

Hi Nandi,

Check your changed code

REPORT ztest_notepad.
*Input for Date
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_date TYPE sy-datum OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.

*Input for Material Number and Substance ID
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
*Radio Button for Material Number
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rb_matnr RADIOBUTTON GROUP g1 USER-COMMAND rad1. "You need to add this one to get events triggered.
SELECTION-SCREEN COMMENT (15) text-003.
SELECTION-SCREEN POSITION 33.
PARAMETERS: p_matnr TYPE mara-matnr.
SELECTION-SCREEN END OF LINE.
*Radio Button for Substance ID
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rb_subid RADIOBUTTON GROUP g1.
SELECTION-SCREEN COMMENT (15) text-004.
SELECTION-SCREEN POSITION 33.
PARAMETERS: p_subid TYPE estrh-subid.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b2.

*Input for Plant
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-005.
PARAMETERS: p_plant TYPE marc-werks OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b3.

*Input for Customer and Vendor
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-006.
*Radio Button for Customer
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rb_cust RADIOBUTTON GROUP g2.
SELECTION-SCREEN COMMENT (15) text-007.
SELECTION-SCREEN POSITION 33.
PARAMETERS: p_cust TYPE kna1-kunnr.
SELECTION-SCREEN END OF LINE.
*Radio Button for Vendor
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rb_vend RADIOBUTTON GROUP g2.
SELECTION-SCREEN COMMENT (15) text-008.
SELECTION-SCREEN POSITION 33.
PARAMETERS: p_vend TYPE lfa1-lifnr.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b4.

*External/Internal
SELECTION-SCREEN BEGIN OF BLOCK b5 WITH FRAME TITLE text-009.
*Radio Button for External
PARAMETERS: rb_extnl RADIOBUTTON GROUP g3.
*Radio Button for Internal
PARAMETERS: rb_intnl RADIOBUTTON GROUP g3.
SELECTION-SCREEN END OF BLOCK b5.

"Add this code

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF rb_matnr = 'X'.
      IF screen-name = 'P_MATNR'.
        screen-input = '0'.
        MODIFY SCREEN.
        CLEAR  screen.
      ENDIF.
    ELSE.
      IF screen-name = 'P_SUBID'.
        screen-input = '0'.
        MODIFY SCREEN.
        CLEAR  screen.
      ENDIF.
    ENDIF.
  ENDLOOP.

<li> <font color=red>to see the effect on selection-screen, first fill the obligatory fields.</font>

Thanks

Venkat.O

Read only

Former Member
0 Likes
1,045

Use At selection-screen output event to change the layout of selection screen at run time.

Example.

PARAMETERS: p_mat RADIOBUTTON GROUP grp1 USER-COMMAND test

PARAMETERS: p_sub RADIOBUTTON GROUP grp1,

P_matnr like mara-matnr,

P_subid(20).

at selection-screen output.

loop at screen.

if p_mat = 'X'.

if screen-name = 'P_SUB'.

screen-input = 0.

modify screen.

endif

else.

if screen-name = 'P_MAT'.

screen-input = 0.

modify screen.

endif

endif.

endloop.

apply the above logic in ur code to change the layout at run time

Read only

Former Member
0 Likes
1,045

JUST CORRECT THIS LINE

PARAMETERS: rb_matnr RADIOBUTTON GROUP g1.

LIKE THIS

PARAMETERS: rb_matnr RADIOBUTTON GROUP g1 USER-COMMAND g1 DEFAULT 'X'.