Application Development 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: 

Disabling Fields in Selection-Screen Subscreen

Hi,

I am currently creating a module pool program that uses subscreens for selection-screens. Currently I have 3 subscreens: Subscreen 1 - radiobutton group
Subscreen 2 - manual input of data
Subscreen 3 - upload excel filepath

I want to disable the fields in subscreen 2 and 3 depending on the selection in subscreen 1. Is there any way to do this? I have tried inputting this into both PBO and PAI but nothing seems to be working.

IF p_manual = 'X'. "if user chooses to input manually
  LOOP AT SCREEN.
      IF screen-name = 'p_vers'.
        screen-input = '1'.
        MODIFY SCREEN.
      ENDIF.
      IF screen-name = 'p_file'.
        screen-input = '0'.
        MODIFY SCREEN.
      ENDIF.
      ENDLOOP.

    ELSEIF p_excel = 'X'. "if user wants to upload the file
    LOOP AT SCREEN.
      IF screen-name = 'p_vers'.
        screen-input = '0'.
        MODIFY SCREEN.
      ENDIF.
      IF screen-name = 'p_file'.
        screen-input = '1'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
    ENDIF.

My code for the selection screens are:

SELECTION-SCREEN BEGIN OF SCREEN 9210 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE TEXT-030. "upload option
PARAMETERS:
  p_manual RADIOBUTTON GROUP grp3, "manual upload
  p_excel  RADIOBUTTON GROUP grp3 DEFAULT 'X'. "excel/ flat file upload
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN END OF SCREEN 9210.

SELECTION-SCREEN BEGIN OF SCREEN 9230 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK b5 WITH FRAME TITLE TEXT-050. "manual select 
PARAMETERS:
  p_vers TYPE zbi_fin_consol-version MODIF ID upm, "company code
  p_year TYPE zbi_fin_consol-zyear MODIF ID upm. "customer
SELECT-OPTIONS:
  s_month FOR zbi_fin_consol-zmonth OBLIGATORY MODIF ID upm.
SELECTION-SCREEN END OF BLOCK b5.
SELECTION-SCREEN END OF SCREEN 9230.

SELECTION-SCREEN BEGIN OF SCREEN 9240 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK b6 WITH FRAME TITLE TEXT-060. "excel upload
PARAMETERS:
  p_file   TYPE rlgrap-filename MODIF ID upf, "filepath
  p_test   RADIOBUTTON GROUP grp5 MODIF ID upf,   "test file
  p_upload RADIOBUTTON GROUP grp5 MODIF ID upf. "upload data

SELECTION-SCREEN END OF BLOCK b6.
SELECTION-SCREEN END OF SCREEN 9240.

My code for PBO and PAI on the screen are:

PROCESS BEFORE OUTPUT.
 MODULE STATUS_9100.
call subscreen area_option including sy-repid '9210'.
call subscreen area_manual including sy-repid '9230'.
call subscreen area_excel  including sy-repid '9240'.
module modify_screen_9200_pbo.

PROCESS AFTER INPUT.
module cancel at EXIT-COMMAND.
 MODULE USER_COMMAND_9200.
call subscreen area_option.
call subscreen area_manual.
call subscreen area_excel.
module modify_screen_9200_pai.
1 ACCEPTED SOLUTION

GManousaridis
Participant

Hello Yi Lin Tan,

You are defining MODIF ID, but not using it.

You can do something like:

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
  PARAMETERS: rb1 RADIOBUTTON GROUP rbg DEFAULT 'X' USER-COMMAND uc,
              rb2 RADIOBUTTON GROUP rbg.
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-002.
  PARAMETERS p1 TYPE i MODIF ID 001.
  PARAMETERS p2 TYPE i MODIF ID 001.
SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE TEXT-003.
  PARAMETERS p3 TYPE i MODIF ID 002.
SELECTION-SCREEN END OF BLOCK b3.

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    CASE 'X'.
      WHEN rb1.
        CASE screen-group1.
          WHEN 001.
            screen-active = 1.
          WHEN 002.
            screen-active = 0.
        ENDCASE.
      WHEN rb2.
        CASE screen-group1.
          WHEN 001.
            screen-active = 0.
          WHEN 002.
            screen-active = 0.
        ENDCASE.
    ENDCASE.
    MODIFY SCREEN.
  ENDLOOP.

In this example we give the control of the parameter fields to the user. When he choses the radiobutton rb1, then we show only the p1,p2 fields and when he choses the radiobutton rb2, we show the p3 field. Mind that the component screen-group1, carries the MODIF ID of each field.

In the example we make use of the screen-active component to hide the fields. If you need some other action, rather than hiding the fields, you can experiment with the screen structure. You can use another component to suit your needs. Find all the options here.

Final note. Don't forget, the user command statement when declaring the radiobuttons. Bugged me for a while... 🙂

Hope it helps,

George


George Manousaridis -- Break on through to the ABAP side
8 REPLIES 8

former_member1716
Active Contributor

yi.lin.tan1,

While dealing with Module Pool Programming its very important you understand the events of the same as mentioned in the LINK.

In your case you are expecting a change in screen elements, any change to the screen elements must be handled in the PBO of that screen because the changes has to be reflected before the screen is displayed.

In simple Terms:

You make a Change in Screen 1.

The values of the changes should be available in the Global Variable.

Based on this Value you have to code in the PBO of the Sub-Screen 2 in which you intend to see the changes.

Regards!

0 Kudos

Hi Satish,

Thanks for your reply. The issue here is that the subscreen is defined as a selection dynpro and hence its PBO cannot be edited..

mateuszadamus
Active Contributor

Hello yi.lin.tan1

SELECTION-SCREEN PBO event is handled in the AT SELECTION-SCREEN OUTPUT event of the report in which the selection-screen was defined. You need to do the same.

AT SELECTION-SCREEN OUTPUT.
  IF p_manual = abap_true.
    " do some screen modification here
  ENDIF.

Also, you should have field names in uppercase in your LOOP AT screen logic.

IF p_manual = 'X'. "if user chooses to input manually
  LOOP AT SCREEN.
      IF screen-name = 'P_VERS'. " <-- uppercase
        screen-input = '1'.
        MODIFY SCREEN.
      ENDIF.
      IF screen-name = 'P_FILE'. " <-- uppercase
        screen-input = '0'.
        MODIFY SCREEN.
      ENDIF.
      ENDLOOP.
Kind regards,
Mateusz

Your comment helped me realize where I needed to put AT SELECTION-SCREEN OUTPUT event in my module pool program. I defined the selection screen in my TOP include. The only place I originally saw the output logic working was in the PBO of the dynamically-created screen. Now I see I can define the event at the end of my FRM include. Thank you!

Sandra_Rossi
Active Contributor

1) Indicate screen field names in UPPER CASE.

2) LOOP AT SCREEN should be used in the PBO of the screen in which the fields are. For fields of the selection screen, the PBO is defined in the event AT SELECTION-SCREEN OUTPUT.

AT SELECTION-SCREEN OUTPUT.
  CASE sy-dynnr.
    WHEN '9230'. " manual input
      LOOP AT SCREEN.
        ...
      ENDLOOP.
    WHEN '9240'. " excel upload
      LOOP AT SCREEN.
        ...
      ENDLOOP.
  ENDCASE.

GManousaridis
Participant

Hello Yi Lin Tan,

You are defining MODIF ID, but not using it.

You can do something like:

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
  PARAMETERS: rb1 RADIOBUTTON GROUP rbg DEFAULT 'X' USER-COMMAND uc,
              rb2 RADIOBUTTON GROUP rbg.
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-002.
  PARAMETERS p1 TYPE i MODIF ID 001.
  PARAMETERS p2 TYPE i MODIF ID 001.
SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE TEXT-003.
  PARAMETERS p3 TYPE i MODIF ID 002.
SELECTION-SCREEN END OF BLOCK b3.

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    CASE 'X'.
      WHEN rb1.
        CASE screen-group1.
          WHEN 001.
            screen-active = 1.
          WHEN 002.
            screen-active = 0.
        ENDCASE.
      WHEN rb2.
        CASE screen-group1.
          WHEN 001.
            screen-active = 0.
          WHEN 002.
            screen-active = 0.
        ENDCASE.
    ENDCASE.
    MODIFY SCREEN.
  ENDLOOP.

In this example we give the control of the parameter fields to the user. When he choses the radiobutton rb1, then we show only the p1,p2 fields and when he choses the radiobutton rb2, we show the p3 field. Mind that the component screen-group1, carries the MODIF ID of each field.

In the example we make use of the screen-active component to hide the fields. If you need some other action, rather than hiding the fields, you can experiment with the screen structure. You can use another component to suit your needs. Find all the options here.

Final note. Don't forget, the user command statement when declaring the radiobuttons. Bugged me for a while... 🙂

Hope it helps,

George


George Manousaridis -- Break on through to the ABAP side

0 Kudos

Hi George, thanks for your reply. I solved my problem by using your suggestions about USER COMMAND and MODIF ID. Cheers! 🙂

0 Kudos

Hey, I am glad I helped you!!


George Manousaridis -- Break on through to the ABAP side