cancel
Showing results for 
Search instead for 
Did you mean: 

To Disable a Button in Webdynpro abap

former_member219737
Participant
0 Kudos

Hi Experts,

I have an application where, when i click on SAVE button...Error Message is getting displayed and when i click it again...its allowing me to save the application....

scenario : 1

I need to grey out(disable) the SAVE button whenever , error msg getting displayed....

Scenario : 2

Else, whenever error message getting displayed...SAVE action shoukd not take place...

Can u suggest an idea to achieve the same ....

Regards,

Karthik S

Accepted Solutions (0)

Answers (3)

Answers (3)

denniss_
Explorer
0 Kudos

Hi Karthik,

create context attribute of type WDY_BOOLEAN and bind it to the ENABLED property of the save button. When error message is displayed, set the attribute to space.

But you haven't explained, when the button will be enabled again? You should also care about this. Otherwise it remains disabled after the first error message displayed.

Regards,

Dennis

former_member219737
Participant
0 Kudos

Hi Dennis,

Thanks for your reply ...

Whenever screen opens, SAVE button should be Enabled...

Once user clicks SAVE button, Error Message appears ...then i need to make SAVE button disabled...

Can u suggest idea on this ...

can u provide me sample code for it ...

Regards,

Karthik S

former_member219737
Participant
0 Kudos

Hi Denis ,

My code for SAVE button is available in the component controller Method...

But, SAVE button is available in a view designed ...

I have attached the screen shot for reference ...

Regards,

Karthik S

denniss_
Explorer
0 Kudos

Hi Karthik,

you can simply do this by using data binding.

Follow these steps:

- create attribute e.g. SAVE_BUTTON of type WDY_BOOLEAN in the component controller context

- map this attribute into your view controller

- go into layout, select your save button and bind the property ENABLED to your attribute SAVE_BUTTON

- whenever your error occurs set the context attribute to blank (button will be disabled)

- to activate the button set the attribute to X

Setting the context attribute can be done via wizzard.

Best regards,

Dennis

former_member219737
Participant
0 Kudos

Hi Dennis,

Thanks for yr' reply ...

I have used the below set of code..can u suugest me its the right one ..

  lv_enabled = space .

* set single attribute
  lo_el_timesheet->set_attribute(
    name =  `ENABLED`
    value = lv_enabled ).

Regards,

Karthik S

denniss_
Explorer
0 Kudos

Hi Karthik,

looks good. Now the flag should be available in the context. And after binding the button should change according to the flag.

Regards,

Dennis

former_member219737
Participant
0 Kudos

Hi Dennis,

When the Save button is pressed, Error message gets displayed ...then as per my code "Save button gets greyed out ."

Error Message is thrown from the BAPI in the application ...

when i delete that particular Line item...again i need to Enable that SAVE button ...

Can u suggest an idea on it ...

I have attached the screen shot for referenc ...

When

Regards,

KArthik S

denniss_
Explorer
0 Kudos

Hi,

that's what I meant in my first post: take care to enable the button again.

So, from your screenshot I assume you use the Webdynpro ALV and the delete button is standard ALV action.

My approach:

  1. define setting for ALV, now all changes (insert, delete, modify cell) will trigger an event: lr_table->if_salv_wd_table_settings~set_data_check( if_salv_wd_c_table_settings=>data_check_on_cell_event ).
  2. in your view register to the event ON_DATA_CHECK of the ALV
  3. this event is raised quite often and indicates some change in the ALV
  4. in the event handler set SAVE_BUTTON enabled again
      lo_el_timesheet->set_attribute(
        name =  `ENABLED`
        value = 'X' ).
  5. check if there are other changes possible and activate the SAVE_BUTTON also there


In our first applications we cared about enabled/disabled buttons, too.

But meanwhile we keep them enabled all the time and show some kind of message that there is nothing to save when they click on a button. It's much easier but your business has to accept it 😉


Kind regards,

Dennis

Former Member
0 Kudos

Hi,

Is your SAVE button is FPM Tool bar button or normal button?

If FPM button, which FPM framework are your using?

Thanks

KH

former_member219737
Participant
0 Kudos

Hi Katrice,

Thanks for yr' reply ...

Its a normal button .

S-1 :

When i click on SAVE button , error appears and then i need to make SAVE button disable ...as error message appears ...

Regards,

Karthik S

Former Member
0 Kudos

hi Karthik,

YOu can enable/disable by binding NULL to "enabled" attribute of the button.

its also possible to setting the attribute.

CL_WD_BUTTON->SET_ENABLED ( 'X' for Enable, '  ' for disable).

Thank you,

Kiran

former_member219737
Participant
0 Kudos

Hi Singh,

Thanks for your valuable reply ...

1. Code is available in the Method of Component Controller .

2. When i click on SAVE button , error throws ...then SAVE button should automatically get disabled .

Can u suggest an idea on it and snippet of code for it.

Regards,

KArthik S