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: 

Unlock of Z table in Customer or Vendor BADIs

Former Member
0 Kudos

Hello gurus,

I have a question regarding Customer (or Vendor) transaction enhancement, using BAdi definitions 'CUSTOMER_ADD_DATA' and 'CUSTOMER_ADD_DATA_CS' (or 'VENDOR_ADD_DATA' and 'VENDOR_ADD_DATA_CS' respectively, it is the same example).

In the added tab of these enhancements, an ALV (or Table Control) has to be displayed.

That List is related to a 'Z' table of the dictionary. If an user is already working with the table, the List (or Table Control) has to appear grayed-out (in display-only mode). To do so I use a lock object of the table.

The problem is the following: How can I unlock my table, when necessary, with full confidence?

I do not find any method, in the related classes, that would be like an "on_exit" event-catcher. For instance, 'SAVE_DATA' method is triggered only if user wants to save changes.

I was based on SAP Notes '580266' and '577502'.

Thanks a lot in advance!,

Eloi

1 ACCEPTED SOLUTION

Ryan-Crosby
Active Contributor

Hi Eloi,

Here is a link to part of the help on lock SCOPE which may be helpful: Scope

The choice you have for the enqueue depends upon how you are executing the updates of that Z table in question. In the case where we have used 'CUSTOMER_ADD_DATA' and 'CUSTOMER_ADD_DATA_CS' we have implemented the BADI methods as required but we have wrapped the subscreen into a function group. The additional subscreen can then be tailored to include particular PBO/PAI events as required - so a PAI exit event for your case could be added in order to call a DEQUEUE function if you use scope 1. In the same respect for the PBO you can execute the ENQUEUE and check the results to see if the table control should show in display or change mode.

Regards,

Ryan Crosby

3 REPLIES 3

Ryan-Crosby
Active Contributor

Hi Eloi,

Here is a link to part of the help on lock SCOPE which may be helpful: Scope

The choice you have for the enqueue depends upon how you are executing the updates of that Z table in question. In the case where we have used 'CUSTOMER_ADD_DATA' and 'CUSTOMER_ADD_DATA_CS' we have implemented the BADI methods as required but we have wrapped the subscreen into a function group. The additional subscreen can then be tailored to include particular PBO/PAI events as required - so a PAI exit event for your case could be added in order to call a DEQUEUE function if you use scope 1. In the same respect for the PBO you can execute the ENQUEUE and check the results to see if the table control should show in display or change mode.

Regards,

Ryan Crosby

SimoneMilesi
Active Contributor

Hi Eloi

Did you tried with method CHECK_DATA_CHANGE?

It's triggered both when the user save the data or press the "back" button.

-edit-

or choose Ryan's solution which is even more better 🙂

0 Kudos

Thanks a lot guys!

@Ryan: I do have my subscreen in a function group too, but the PAI is triggered by the status of the main screen (outside of scope) and then I would have to hard-code the SY-UCOMM values (not that important, because they will unlikely be changed in the future). In addition, but this is really more important, the 'EXIT' and 'CANC' buttons (yellow and red, to quit) are set as system functions in the PF-Status of the standard screen; and they do not seem to trigger the PAI event.

@Simone: I actually used an approach like yours.

If it can help anyone else in the future, I did the following (simplifying the process):

1- In the 'CHECK_DATA_CHANGED' method, with a Function Module call to my Group, I check if changes were made to my data in my screen. If no changes were made, I unlock my table in this method.

2- If changes were made, I unlock my table in method 'SAVE_DATA' (which will be triggered afterwards).

There are two reasons I do the unlock of my table in different methods:

1- 'SAVE_DATA' method will not be triggered if not defined by 'CHECK_DATA_CHANGED' method (using variable 'E_CHANGED').

2- After 'CHECK_DATA_CHANGED' method is called and exporting variable 'E_CHANGED' is set, 'CHECK_ALL_DATA' method is called too (to validate your own data). If you display an error message using that method, 'SAVE_DATA' will also not be called.

Thank you for your help!

Eloi