cancel
Showing results for 
Search instead for 
Did you mean: 

How to disable button after error ?

Former Member
0 Kudos

Hello all
My program save data in table , when i have error. I upload excel file ,  then press Upload button ,it check the date in rows and if it incorrect print message. And if it found error, the save button must be disabled.How can i make this?


I create WDY_BOOLEAN in CONTEXT and bind it in button in enabled row. Pls help ,where i must write code, in WDINIT and how this code look like, maybe i need add something more in CONTEXT or write code with abap_true, abap_false ?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Follow the below steps which will help to resolve your issue.

1)As you are doing validation on click of Upload button and checking of the date in rows are valid or not.

2)

IF ( LV_DATE is not valid).

     "show the error message & set the attribute which you have binded to the visiblity property

      of button to ABAP_FALSE(here button will be disabled)

data : lo_element type ref to if_wd_context_element.

       lo_element = wd_context->get_element( ).

      CHECK lo_element is not initial.

     lo_element->set_attribute(
     exporting
     value    = 'ABAP_FALSE'
      name  = '<ATTRIBUTE_NAME>'.

        RETURN.

ELSE.

     lo_element->set_attribute(

     exporting

     value    = 'ABAP_TRUE'

      name  = '<ATTRIBUTE_NAME>'.

    "Proceed further as per your requirement.

ENDIF.

Below is the code for your reference only.

Hope this helps you.

Thanks

KH

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Pls close the thread if your issue is resolved.If not revert back .

Thanks

KH

Former Member
0 Kudos

Thx , it's very helpful information !

former_member197475
Active Contributor
0 Kudos

Hi,

Do the below logic.

1. Bind the visibility property of your Save button to a context of type WDUI_VISIBILITY and make the default value as '01'.

2. So when ever your application starts, user can't see the 'Save' button at any time.

3. Now when the data is uploaded and found that there is no error, make the 'Save' button to visible    by make the context value as '02'

    lref_context->set_attribute(

     name  `FIELDS_VISIBLE`

     value = '02' ).



Hope you got it:)



BR,

RAM.