cancel
Showing results for 
Search instead for 
Did you mean: 

how to enable and disble to button at run time according to the condition s

Former Member
0 Kudos

hi,

how to enable and disable the buttons at run time according to the specified condition.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Please don't forget to close the post.

Srinivas

Former Member
0 Kudos

declare a variable flag type c.

Write this in PBO of your screen.

IF flag = ' '.

LOOP AT SCREEN.

IF SCREEN-NAME = Button1 "This button is which u want to hide from starting.

SCREEN-ACTIVE = 0.

screen-invisible = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF flag = 'x'.

LOOP AT SCREEN.

IF SCREEN-NAME = Button2 "This button is which u want to show on click of Button1.

SCREEN-ACTIVE = 1.

screen-invisible = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

In PAI write this coding

case sy-ucomm.

when 'SHOW'. " Fun code for Button.

flag = 'x'.

endcase.

Former Member
0 Kudos

If you are talking about selection screen push buttons, then you can do the following in the AT SELECTION-SCREEN OUTPUT event.


IF <condition>.
  LOOP AT SCREEN.
    IF SCREEN-NAME = <pushbuttonname>.
      SCREEN-ACTIVE = 0.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
ENDIF.

If they are push buttons in the application tool bar or menu, then you can build an internal table with the function codes of those pushbuttons and remove them from the menu as follows.


DATA: BEGIN OF i_fcodes OCCURS 0,
        fcode LIKE sy-fcode.
DATA: END OF i_fcodes.

MOVE: 'PUSH' TO i_fcodes-fcode.
APPEND i_fcodes.
clear i_fcodes.

IF <condition>.
  SET PF-STATUS <mymenuname> EXCLUDING i_fcodes.
*-- If there is only one button that you want to 
*   exclude, then you don't need an internal table. You 
*   can simply use as follows
*   SET PF-STATUS <mymenuname> EXCLUDING 'PUSH'.
ENDIF.

Former Member
0 Kudos

Amrendra,

In the PBO of your module pool program

use SET PF-STATUS ...EXCLUDING &

Then buttons which you are trying to exclude will become disabled. Here is some an example

TYPES: BEGIN OF TAB_TYPE,

FCODE LIKE RSMPE-FUNC,

END OF TAB_TYPE.

DATA: TAB TYPE STANDARD TABLE OF TAB_TYPE WITH

NON-UNIQUE DEFAULT KEY INITIAL SIZE 10,

WA_TAB TYPE TAB_TYPE.

CLEAR TAB.

MOVE 'DELE' TO WA_TAB-FCODE.

APPEND WA_TAB TO TAB.

MOVE 'AUSW' TO WA_TAB-FCODE.

APPEND WA_TAB TO TAB.

SET PF-STATUS 'STA3' EXCLUDING TAB.

Sets the status STA3 which renders the functions with the

function codes DELE and AUSW inactive.

Cheers

Raghava

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

When setting the gui status you can exclude the function code of the buttons.

set pf-status '0100' excluding 'SAVE'.

You can also exclude multiple fcodes, by using an ITAB.

Check the help for SET pf-status

REgards,

Rich Heilman