Enable or disable a parameter on selection screen based on other parameter's value

By Jayshree Santosh Mahajan, Cognizant

Introduction:

Recently I got requirement to make visible a parameter based on the user input entered into another parameter.

Here are the details.

Scenario:

Depending on the user’s selection, the parameters should be visible/invisible.

In the below screen shot, suppose user selected the message type ‘EMAIL’ then, only the “Email Address” parameter will be visible and others would  be invisible. If message type ‘PRINT’ is selected then parameter ‘Printer Name’ will be visible. Similarly if user selected the message type ‘FAX’ then only the “FAX number” should be visible.

Here is the  code snippet:

REPORT  zdemo_prg.

PARAMETERS :p_kschl TYPE zmsg_type AS LISTBOX VISIBLE LENGTH 10
                                
USER-COMMAND us1,   " Message type
            p_email 
TYPE ad_smtpadr   MODIF ID md2, " Recipient email address
            p_print 
TYPE tsp03-padest MODIF ID md3, " Printer Name
             p_fax   
TYPE na_telfx     MODIF ID md4." Fax Number

TYPES BEGIN OF lty_kschl,
         kschl 
TYPE zmsg_type,
        
END OF lty_kschl.

DATA : lt_kschl TYPE STANDARD TABLE OF lty_kschl,
       ls_kschl 
TYPE lty_kschl.
CLEAR : lt_kschl[].

AT SELECTION-SCREEN OUTPUT.
  
LOOP AT SCREEN.
    
CASE p_kschl.
      
WHEN 'EMAIL'.
        
IF screen-group1 = 'MD3' OR screen-group1 = 'MD4'.
          screen-invisible = 
1.
          screen-input     = 
0.
        ENDIF.
      
WHEN 'PRINT'.
        
IF screen-group1 = 'MD2' OR screen-group1 = 'MD4'.
          screen-invisible = 
1.
          screen-input     = 
0.

        ENDIF.
      
WHEN 'FAX'.
        
IF screen-group1 = 'MD2' OR screen-group1 = 'MD3'.
          screen-invisible = 
1.
          screen-input     = 
0.
        ENDIF.
    ENDCASE.
    
MODIFY SCREEN.
  ENDLOOP.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_kschl.
  
IF lt_kschl[] IS INITIAL.
    ls_kschl-kschl = 
'EMAIL'.
    
APPEND ls_kschl TO lt_kschl.
    
CLEAR ls_kschl.

    ls_kschl-kschl = 
'PRINT'.
    
APPEND ls_kschl TO lt_kschl.
    
CLEAR ls_kschl.

    ls_kschl-kschl = 
'FAX'.
    
APPEND ls_kschl TO lt_kschl.
    
CLEAR ls_kschl.

    
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      
EXPORTING
        retfield    = 
'KSCHL'
        dynpprog    = sy-repid
        dynpnr      = sy-dynnr
        dynprofield = 
'P_KSCHL'
        value_org   = 
'S'
      
TABLES
        value_tab   = lt_kschl.
  ENDIF.

Output:

Selected: EMAIL

Selected: PRINT

Selected: FAX

In this way we can visible/invisible the parameters based on another parameter value.

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image