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: 

Enabling and Disabling pushbutton.

Former Member
0 Kudos

Hi Experts,

I have two pushbuttons declared push1 and push2 on my alv report selection screen.when i enter my selection screen, push2 should be disabled by default (it should be seen but disable it- with gray color). on click of my push1 it will check my validations if any error occurs push2 should not be enabled but if no error occurs push2 must be enabled.

7 REPLIES 7

Former Member
0 Kudos

hi

try this logic and modify according to your requirement

tables: rkwa,ekko,ekpo.

parameters : r1 radiobutton group g1 default 'X' user-command aa.

selection-screen: begin of block b1 with frame title text-001.

parameters: p_item like ekpo-pstyp modif id aa.

select-options: s_bukrs for rkwa-bukrs modif id aa,

s_lifnr for rkwa-lifnr modif id aa,

s_werks for rkwa-bukrs modif id aa,

s_matnr for rkwa-matnr modif id aa,

s_ekorg for ekko-ekorg modif id aa,

s_ekgrp for ekko-ekgrp modif id aa,

s_mblnr for rkwa-mblnr modif id aa,

s_bldat for rkwa-bldat modif id aa,

s_budat for rkwa-budat modif id aa.

selection-screen: end of block b1 .

selection-screen skip.

parameters : r2 radiobutton group g1.

selection-screen: begin of block b2 with frame title text-001.

parameters: p_item1 like ekpo-pstyp modif id cc.

select-options:s_lifnr1 for rkwa-lifnr modif id cc,

s_werks1 for rkwa-bukrs modif id cc,

s_matnr1 for rkwa-matnr modif id cc,

s_bldat1 for rkwa-bldat modif id cc,

s_ekorg1 for ekko-ekorg modif id cc.

selection-screen: end of block b2 .

at selection-screen output.

perform validations.

form validations .

if r1 = 'X'.

loop at screen.

if screen-group1 = 'AA'.

screen-input = '1'.

modify screen.

endif.

if screen-group1 = 'CC'.

screen-input = '0'.

screen-invisible = '1'.

modify screen.

endif.

endloop.

elseif r2 = 'X'.

loop at screen.

if screen-group1 = 'AA'.

screen-input = '0'.

screen-invisible = '1'.

modify screen.

endif.

if screen-group1 = 'CC'.

screen-input = '1'.

screen-invisible = '0'.

modify screen.

endif.

endloop.

endif.

endform. " Validations

anuraag_aggarwal
Active Participant
0 Kudos

Hi

I recommend to you to use module pool for this. It will be easier to handle enabling or disabling buttons.

Basic code give below, add conditions for buttons to handle the scenario.


LOOP AT SCREEN.

SCREEN-INPUT = '0' or '1'   "Depends you want to enable or disable

ENDLOOP.

Thanks

Anuraag

Former Member
0 Kudos

Hi

Create pushbuttons as follows:

SELECTION SCREEN PUSHBUTTON push1 MODIF ID PB1.

SELECTION SCREEN PUSHBUTTON push2 MODIF ID PB2.

Now to implement enable and disable:

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'PB1'.

" your validations

"if no error

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'PB2'.

SCREEN-ACTIVE = 1. "Make push2 enabled

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

ENDLOOP.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'PB2'.

SCREEN-ACTIVE = 0. "Make push2 disabled by default

MODIFY SCREEN.

ENDIF.

ENDLOOP.

Hope this helps

Regards,

Jayanthi.K

Former Member
0 Kudos

Hi

Was your query answered?

Regards,

Jayanthi.K

0 Kudos

Hi jayanthi,

Thanks for the answer but it did not solved yet, In the declaration you declared modif id pb1 and pb2 for two pushbuttons respectively, but i have a requirement where i can't declare two different modif id's, i have to use same modif id for both the pushbuttons...

Former Member
0 Kudos

Hi

check this code once....

TABLES : mara.

TABLES sscrfields.

DATA : v_matnr LIKE mara-matnr.

DATA : v_flag TYPE c.

PARAMETERS : p_matnr LIKE mara-matnr.

SELECTION-SCREEN:

PUSHBUTTON /2(10) but1 USER-COMMAND cli1,

PUSHBUTTON /20(30) but2 USER-COMMAND cli2

VISIBLE LENGTH 10.

INITIALIZATION.

but1 = 'BUtton1'.

but2 = 'BUtton2'.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF screen-name = 'BUT1'.

SELECT SINGLE matnr FROM mara INTO v_matnr WHERE matnr EQ p_matnr.

IF NOT sy-subrc IS INITIAL.

v_flag = 0.

MESSAGE 'Matnr doesnot exist' TYPE 'I'.

ELSEIF sy-subrc EQ 0.

v_flag = '1'.

ENDIF.

ENDIF.

IF screen-name = 'BUT2'.

IF v_flag EQ 1.

screen-input = 1.

ELSE.

screen-input = 0.

ENDIF.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

Former Member
0 Kudos

Hi

You can use screen-name.

for both pushbuttons give the same Modif-Id.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'PB1'.

IF SCREEN-NAME EQ 'pb1name'.

" your validations

"if no error

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'PB1'.

IF SCREEN-NAME EQ 'pb2name'.

SCREEN-ACTIVE = 1. "Make push2 enabled

MODIFY SCREEN.

ENDIF.

ENDIF.

ENDLOOP.

ENDIF.

IF SCREEN-NAME EQ 'pb2name'.

SCREEN-ACTIVE = 0. "Make push2 disabled by default

MODIFY SCREEN.

ENDIF.

ENDIF.

ENDLOOP.