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

Problem while hide a block on selection screen on button press

Former Member
0 Likes
2,514

Hi,

I have added two buttons on the application toolbar of the selection screen. I have input fields under two blocks on the selection-screen. Initially the second block is hidden. If I press the button 1 the second block should be made visible.

For this to happen, I captured the button 1 click event using the following statement.

IF sscrfields-ucomm = 'FC01'.

Inside the if ... endif, I looped at the screen and made the second block visible. It was working fine.


loop at screen.
  if screen-group4 = '013'.
     screen-invisible = 1.
     screen-active    = 0.
  endif.
endloop.

Later the second button was added. Now when i run the report for the first time, if button 2 is clicked the hidden block appears on the selection screen even though i have not added any code for it.

Just to check, i commented the logic to display the hidden block on button 1 click event. Even without any code the first time i press any of the two buttons added on the application toolbar the hidden block is displayed.

I saved a variant for the report.

During execution of the report, if i select any variant then the hidden block is displayed.

Can anyone please tell me how to fix this problem.

Regards,

T2.

12 REPLIES 12
Read only

Former Member
0 Likes
1,325

Put your logic un at selection-screen event..

loop at screen.

if screen-group4 = '013'.

screen-invisible = 1.

screen-active = 0.

endif.

endloop.

Read only

0 Likes
1,325

Hi Madhu,

Sorry. forgot to mention. The code is under <b>at selection-screen </b> event. I even tried it under <b>at selection-screen output</b> event.

Regards,

T2

Message was edited by: Titu Joseph

Read only

0 Likes
1,325

use this at selection screen output event

and use both radiobutton and use this stat while declaring the radio button:

USER-COMMAND ucom (where ucomm can have value like 'ONLI')...

and check if the first button is clicked make screen pertaining to modif id 1 visible and at the same time make the other screen invisible and say

modify screen...

reward point if it helps..

regds

gunjan

Read only

0 Likes
1,325

Hi Gunjan,

With radiobuttons on the selection screen it will work. But i want it to be triggered using buttons added on the application toolbar.

I can't change the scenario. Any inputs to solve the issue with same scenario.

Regards,

T2.

Read only

0 Likes
1,325

hi

modify screen is missing in ur code i guess...try with that....

Read only

Former Member
0 Likes
1,325

Use ur logic in At selection-screen output

Read only

Former Member
0 Likes
1,325

Hi Titu,

Add Modify Screen in your code.

loop at screen.

if screen-group4 = '013'.

screen-invisible = 1.

screen-active = 0.

endif.

<b>MODIFY SCREEN.</b>

endloop.

<b>Please reward points to all the helpful answers and close the thread.</b>

Regards,

Amit Mishra

Read only

0 Likes
1,325

Hi,

I guess you guys are getting confused. i am including the whole code here.

My requirement is when i press the first button on the

application server the second block should be visible.

which is happening now.

Now when i press the button again it should hide the

dynamic screen.


REPORT z_test_t2_1 .
INCLUDE <icon>.
TABLES: t001,
        lfa1,
        sscrfields.

DATA: gv_button_press   TYPE c.

DATA: gs_dyntxt TYPE smp_dyntxt.

SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN FUNCTION KEY 2.

SELECTION-SCREEN BEGIN OF BLOCK ccode 
WITH FRAME TITLE text-s03.
SELECT-OPTIONS: s_bukrs FOR t001-bukrs OBLIGATORY 
MEMORY ID buk.
SELECTION-SCREEN END OF BLOCK ccode.

SELECTION-SCREEN BEGIN OF BLOCK vend 
WITH FRAME TITLE text-s04.
SELECT-OPTIONS: s_konzs FOR lfa1-konzs.
SELECT-OPTIONS: s_txcd1 FOR lfa1-stcd1.
SELECT-OPTIONS: s_txcd2 FOR lfa1-stcd2.
SELECTION-SCREEN END OF BLOCK vend.

INITIALIZATION.
  PERFORM populate_app_toolbar_buttons.
  PERFORM hide_screenfields.

AT SELECTION-SCREEN.
  PERFORM adapt_screen.

*******************************************************

FORM populate_app_toolbar_buttons.

  CLEAR gs_dyntxt.
  WRITE icon_fencing     TO gs_dyntxt-icon_id AS ICON.
  MOVE  text-b01         TO gs_dyntxt-quickinfo.    
  MOVE gs_dyntxt         TO sscrfields-functxt_01.

  CLEAR gs_dyntxt.
  WRITE icon_information TO gs_dyntxt-icon_id AS ICON.
  MOVE  text-b02         TO gs_dyntxt-quickinfo.   
  MOVE gs_dyntxt         TO sscrfields-functxt_02.

ENDFORM.
                   
FORM hide_screenfields.

  LOOP AT SCREEN.
    IF   screen-group4 EQ '006' 
      OR screen-group4 EQ '007'
      OR screen-group4 EQ '008'.
      screen-invisible = 1.
      screen-active    = 0.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.

ENDFORM.  

FORM adapt_screen.

  CHECK sscrfields-ucomm NS '%'.
  IF sscrfields-ucomm = 'FC01'.
    IF gv_button_press IS INITIAL.
      LOOP AT SCREEN.
        IF   screen-group4 EQ '006' 
          OR screen-group4 EQ '007'
          OR screen-group4 EQ '008'.
          screen-invisible = 0.
          screen-active    = 1.
        ENDIF.
        MODIFY SCREEN.
      ENDLOOP.
      gv_button_press = 'X'.
    ELSEIF gv_button_press EQ 'X'.
      CLEAR gv_button_press.
      LOOP AT SCREEN.
        IF   screen-group4 EQ '006' 
          OR screen-group4 EQ '007'
          OR screen-group4 EQ '008'.
          screen-invisible = 1.
          screen-active    = 0.
        ENDIF.
        MODIFY SCREEN.
      ENDLOOP.
    ENDIF.
  ENDIF.
ENDFORM.

Read only

Former Member
0 Likes
1,325

hii Titu

in the hide perform

set a flag

ur problem will be solved

<b>The problem is when you press the variant button ucomm is gain stored as 'FC01' for both the buttons.</b>

<b>Where did you set the pf-status ?

if you can differentiate the pf-status of variant and the button you can achieve that.</b>

i guess this will solve the problem

Read only

rahulkavuri
Active Contributor
0 Likes
1,325

I have done a similar prob, this works absolutely fine even with ur case too even <b>though it has variants</b>, please check this and <b>award points if helpful</b>


*Selection Screen 1

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS : P_FILE(25) TYPE C,
             O_FILE(25) TYPE C.

SELECTION-SCREEN END OF BLOCK B1.

*Selection Screen 2

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.

PARAMETERS: CAL_TRA RADIOBUTTON GROUP G1 USER-COMMAND FLAG,
            SESSION RADIOBUTTON GROUP G1 DEFAULT 'X'.

SELECTION-SCREEN END OF BLOCK B2.

*Selection Screen 3

SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.

PARAMETERS: MODE DEFAULT 'X' MODIF ID BL1,
            UPDATE DEFAULT 'X' MODIF ID BL1.

SELECTION-SCREEN END OF BLOCK B3.

*Selection Screen 4

SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-003.


PARAMETERS: SES_NAM TYPE APQI-GROUPID MODIF ID BL2,
            KEP_TRAS TYPE C DEFAULT 'X' MODIF ID BL2,
            LOC_DATE TYPE SY-DATUM MODIF ID BL2,
            USER TYPE SY-UNAME DEFAULT SY-UNAME MODIF ID BL2.

SELECTION-SCREEN END OF BLOCK B4.

************************************************************************
*                     At  Selection-Screen Output                      *
************************************************************************

AT SELECTION-SCREEN OUTPUT.


  IF CAL_TRA = 'X'.
    LOOP AT SCREEN.

      IF SCREEN-GROUP1 = 'BL1'.
        SCREEN-ACTIVE = '1'.
      ENDIF.

      IF SCREEN-GROUP1 = 'BL2'.
        SCREEN-ACTIVE = '0'.
      ENDIF.
      MODIFY SCREEN.
    ENDLOOP.
  ENDIF.

  IF SESSION = 'X'.

    LOOP AT SCREEN.
      IF SCREEN-GROUP1 = 'BL1'.
        SCREEN-ACTIVE = '0'.
      ENDIF.

      IF SCREEN-GROUP1 = 'BL2'.
        SCREEN-ACTIVE = '1'.
      ENDIF.

      MODIFY SCREEN.

    ENDLOOP.
  ENDIF.

Read only

Former Member
0 Likes
1,325

Use at Selection-screen Output.

Read only

0 Likes
1,325

Hi All,

The problem is solved.

Everyone was confusing between the pushbutton on the selectio-screen and on apllication toolbar

(where you have the execute icon).

Please find the code below. Thanks for you time and help. I appreciate it.


REPORT ztest.


INCLUDE <icon>.

*----------------------------------------------------------------------*
*  TABLES                                                              *
*----------------------------------------------------------------------*
TABLES: t001,              " Company Codes
        lfa1,              " Vendor Master (General Section)
        sscrfields.        " Fields on selection screens

* To capture button press event.
DATA: gv_button_press       TYPE c.

* Menu Painter: Program interface for dynamic texts
DATA: gs_dyntxt             TYPE smp_dyntxt.

*----------------------------------------------------------------------*
*  SELECTION SCREEN                                                    *
*----------------------------------------------------------------------*
SELECTION-SCREEN FUNCTION KEY 1.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-s01.

* Company Code.
SELECTION-SCREEN BEGIN OF BLOCK ccode WITH FRAME TITLE text-s02.
SELECT-OPTIONS: s_bukrs FOR t001-bukrs OBLIGATORY MEMORY ID buk.
SELECTION-SCREEN END OF BLOCK ccode.
SELECTION-SCREEN END OF BLOCK blk1.

SELECTION-SCREEN BEGIN OF BLOCK dsel WITH FRAME TITLE text-s04.

* Vendor Master.
SELECTION-SCREEN BEGIN OF BLOCK vend WITH FRAME TITLE text-s07.
SELECT-OPTIONS: s_konzs FOR lfa1-konzs MODIF ID aw1.
SELECT-OPTIONS: s_txcd1 FOR lfa1-stcd1 MODIF ID aw1.
SELECT-OPTIONS: s_txcd2 FOR lfa1-stcd2 MODIF ID aw1.
SELECTION-SCREEN END OF BLOCK vend.
SELECTION-SCREEN END OF BLOCK dsel.


* ---------------------------------------------------------------------*
* INITIALIZATION                                                       *
* ---------------------------------------------------------------------*
INITIALIZATION.
* Populate the Application toolbar button attributes.
  PERFORM populate_app_toolbar_buttons.
* Hide the dynamic screen intially.
  PERFORM hide_screenfields.

* ---------------------------------------------------------------------*
* AT SELECTION SCREEN                                                  *
* ---------------------------------------------------------------------*
AT SELECTION-SCREEN.
* Capture the button press event.
  PERFORM capture_button_press.

*----------------------------------------------------------------------*
* AT SELECTION-SCREEN OUTPUT.                                          *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
* Show/Hide the dynamic selection screen based on button press.
  PERFORM adapt_screen.

*&---------------------------------------------------------------------*
*&  Form  populate_app_toolbar_buttons                                 *
*&---------------------------------------------------------------------*
*   Display Icon on the application toolbar buttons. Also set the      *
*   function codes for these buttons.                                  *
*----------------------------------------------------------------------*
FORM populate_app_toolbar_buttons.

  CLEAR gs_dyntxt.
  WRITE icon_fencing     TO gs_dyntxt-icon_id AS ICON.
  MOVE  text-b01         TO gs_dyntxt-quickinfo.   " Dynamic Selections
  MOVE gs_dyntxt         TO sscrfields-functxt_01.

ENDFORM.                    " populate_app_toolbar_buttons

*&---------------------------------------------------------------------*
*&  Form  hide_screenfields                                            *
*&---------------------------------------------------------------------*
*   Initially hide the Dynamic selection screen.                       *
*----------------------------------------------------------------------*

FORM hide_screenfields.

  LOOP AT SCREEN.
    IF screen-group1 = 'AW1'.
      screen-invisible = '1'.
      screen-active    = '0'.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.

ENDFORM.                    " hide_screenfields

*&---------------------------------------------------------------------*
*&  Form  capture_button_press                                         *
*&---------------------------------------------------------------------*
*   Set the flag based on button press event. Appication bar button    *
*   tcode is available only at 'At Selection-screen' event.            *
*   Use the captured data at 'At Selection-screen Output' event.       *
*   Screen adjustments is possible only under this event.              *
*----------------------------------------------------------------------*
FORM capture_button_press.

  IF sscrfields-ucomm = 'FC01'.
    IF gv_button_press IS INITIAL.
      gv_button_press = 'X'.
    ELSEIF gv_button_press EQ 'X'.
      CLEAR gv_button_press.
    ENDIF.
  ENDIF.

ENDFORM.                    " capture_button_press

*&---------------------------------------------------------------------*
*&  Form  adapt_screen                                                 *
*&---------------------------------------------------------------------*
*   Show/Hide the dynamic selection screen based on button press       *
*   captured at 'At selection-screen' event.                           *
*----------------------------------------------------------------------*
FORM adapt_screen.

* If button press flag is initial hide the dynamic selection screen.
  IF gv_button_press IS INITIAL.
    LOOP AT SCREEN.
      IF screen-group1 = 'AW1'.
        screen-invisible = '1'.
        screen-active    = '0'.
      ENDIF.
      MODIFY SCREEN.
    ENDLOOP.
* Elseif button press flag is 'X' show the dynamic selection screen.
  ELSEIF gv_button_press EQ 'X'.
    LOOP AT SCREEN.
      IF screen-group1 = 'AW1'.
        screen-invisible = '0'.
        screen-active    = '1'.
      ENDIF.
      MODIFY SCREEN.
    ENDLOOP.
  ENDIF.

ENDFORM.                    " adapt_screen

Regards,

T2

Message was edited by: Titu Joseph