Skip to Content

How to disable button once click

Hi,

I have made a dialog program, in which, on the screen I have to push button, PB1 and PB2, my requirement is Once the user click on PB1 then that button I want to disable (inactive mode) or invisible till user click on PB2, I have written the code as below but it is not working,

module USER_COMMAND_0100 input.

OK_CODE = SY-UCOMM.

CASE OK_CODE.

WHEN 'PB2'.

CLEAR : VBELN,WA_VBAP,IT_VBAP[],WA_VBAP_RFC,IT_VBAP_RFC,MESSAGE.

WHEN 'PB1'.

PERFORM GET_SO_LINE.


ENDCASE.

endmodule. " USER_COMMAND_0100 INPUT

now when the OK_CODE is PB1 in that I have below code

**********

LOOP AT SCREEN.
IF SCREEN-NAME = 'PB1'.
SCREEN-ACTIVE = '0'.
SCREEN-INVISIBLE = '1'.
MODIFY SCREEN.
ENDIF.
IF SCREEN-NAME = 'VBELN'.
SCREEN-ACTIVE = '0'.
SCREEN-INPUT = '0'.
* SCREEN-INVISIBLE = '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.

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

but with this code it is not working.

regards,

zafar

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 31, 2012 at 02:12 AM

    Hi,

    Declare a global variable that will serve as your flag.

    * data declaration..

    data: g_flag type c.

    * PAI

    module USER_COMMAND_0100 input.
    OK_CODE = SY-UCOMM.
    CASE OK_CODE.
    WHEN 'PB1'.

    g_flag = 'X'. " set flag

    WHEN 'PB2'.

    g_flag = space. " reset flag

    ENDCASE.

    endmodule.

    * PBO

    LOOP AT SCREEN.
    IF SCREEN-NAME = 'PB1'.

    If g_flag = 'X'. " PB1 was clicked
    SCREEN-INPUT = '0'

    else.

    SCREEN-INPUT = '1'

    endif..
    MODIFY SCREEN.
    ENDIF.
    ENDLOOP.

    -Jake

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 30, 2012 at 11:22 AM

    You can modify SCREEN in your ABAP program during the PBO event of a screen.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member zafar karnalkar

      Hi Zafar,

      you must do the LOOP AT SCREEN in PBO, you can't do it in PAI.

      Declare a global vairiable, sey DATA: gv_bt1_pressed TYPE c LENTH 1.

      If the user press button1, set gv_bt1_pressed = 'X' within in PAI. If user press button2 and button1 should become aktiv again CLEAR gv_bt1_pressed in PAI.

      Within PBO you do the LOOP AT SCREEN, depending on gv_bt1_pressed you activate or deactivate Button1.

      Regards Hendrik

  • Posted on Jul 30, 2012 at 12:48 PM

    Hi.

    If you use an alv grid output, custom or standard, you can easily reach your need forcing your PBO after your PAI.

    Try this one:

    {

    call method cl_gui_cfw=>set_new_ok_code

    exporting

    new_code = 'ZREFRSH'. "Here you need a custom ok_code, that also do nothing

    "You need it only to refresh your dynpro

    }

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.