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: 

Dynamically hiding parameters AND selection texts

RomyA
Explorer
0 Kudos
287

Good afternoon!

I'm trying to hide a parameter based on the tcode the program is used in. The selection screen has several tabs with input parameters. When I tried the following code on the first tab, everything worked fine: Neither the input or the selection text of the parameter is shown.
However, on the next tab, for some reason it does hide the input fields, but it still shows the selection texts. 
With the shown code, the first case is what does work correctly. The second case (with screen2) doesnt work. I first tried only using the 'active' part and setting it to 0, which is how I had it in the first place for the parameters that do correctly get hidden. Then I tried setting 'screen-invisible' to 1, and to 0, and putting either 'invisible' first or 'active' first, but nothing works. 

Does anyone have any idea what might be going wrong here?

Thank you so much in advance!

 

AT SELECTION-SCREEN OUTPUT.
   IF sy-tcode = 'TCODE'. 
    LOOP AT SCREEN INTO DATA(ls_screen).
      CASE ls_screen-name.
        WHEN 'P_NAME'. 
        ls_screen-active = '0'. 
        MODIFY SCREEN FROM ls_screen.
      ENDCASE.
    ENDLOOP.
    ELSEIF sy-tcode <> 'TCODE'. 
    LOOP AT SCREEN INTO DATA(ls_screen2).
      CASE ls_screen2-name.
        WHEN 'P_NAME'. 
        ls_screen2-invisible = '1'.
        ls_screen2-active = '0'. 
        MODIFY SCREEN FROM ls_screen2.
      ENDCASE.
    ENDLOOP.
  ENDIF. 

 

5 REPLIES 5

RomyA
Explorer
0 Kudos
283

I just realized I should have changed the parameter names, so for clarity, the two parameters are supposed to be two totally different parameters. 

RaymondGiuseppi
Active Contributor
269

The reason I prefer to use MODIF ID modid in PARAMETERS or SELECT-OPTIONS syntax and then not checking actual field name, especially for other screen elements such as COMMENT.

  • Else try to debug to find actual values of SCREEN-NAME
  • Setting ACTIVE to '0' will always set INPUT and OUTPUT to '0' and INVISIBLE to '1'

0 Kudos
206

Ah thanks, I hadn't heard of that before!
I'm trying it now, but for some reason the ID isn't being added to the screen table. Do you have any idea what could be the cause of that? Is there anything else that needs to be done, besides changing the parameter and setting the screen to invisible when the group1 has the value of the ID?

I do see that there are four groups in the SCREEN table, could it have to do anything with that?



PARAMETERS: p_host   TYPE char70 LOWER CASE MODIF ID sc1.

IF sy-tcode = 'TCODE'.
    LOOP AT SCREEN INTO DATA(ls_screen2).
      CASE ls_screen2-group1.
        WHEN 'SC1'.
          screen-invisible = '1'.
        MODIFY SCREEN FROM ls_screen2.
      ENDCASE.
    ENDLOOP.
  ENDIF. "END CHANGE RA16012025

 

202

I tried your code, and it worked with few changes:

PARAMETERS: p_host TYPE char70 LOWER CASE MODIF ID sc1.

AT SELECTION-SCREEN OUTPUT.
  IF sy-tcode = 'SE38'.
    LOOP AT SCREEN INTO DATA(ls_screen2).
      CASE ls_screen2-group1.
        WHEN 'SC1'.
          ls_screen2-active = '0'.
          MODIFY SCREEN FROM ls_screen2.
      ENDCASE.
    ENDLOOP.
  ENDIF. 

 

0 Kudos
160

Aaah you are amazing, it works now! Thank you so much for all the help!😄