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: 

How to lock PO document and change it from outside of SAP?

Former Member
0 Kudos
357

Requirement: After user save the PO. The PO will be locked from sap users. PO can be only updated by BAPI_PO_RELEASE/BAPI_PO_CHANGE outside of the SAP.

This is what we do for now.

We save the PO info in a add-on table to keep locking records (also publish data to a outter system). Then we activate user exist MM06E005 to check the add-on table and keep normal users out doing any updates. The updates can only be done by a outter system using JavaConnector(calling BAPI_PO_RELEASE).

Now here's my problem. BAPI_PO_RELEASE seem to be bumped into the user exist and locked like every other sap user as well. Is there any better way to do this other what I do now? Please advise...

Thanks biggy.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
76

Jim,

All the user exits that will be called from a transaction, will be called from the BAPI as well.

In fact its a good thing that the BAPI is calling a user exit other wise some one can write Z Program and call the BAPI to release the PO from the SAP GUI.

In your case, You can check the transaction using SY-TCODE to find out the entry point of the user. So, if he has through the Release T-Code of PO then block him from doing anything. As you are saying the user will login from an external system, I belive that the Sy-TCODE will not be set. So, you can go ahead release the PO.

Let me know if this solves your issue.

Regards,

Ravi

Note : Please mark the helpful answers

3 REPLIES 3

Former Member
0 Kudos
77

Jim,

All the user exits that will be called from a transaction, will be called from the BAPI as well.

In fact its a good thing that the BAPI is calling a user exit other wise some one can write Z Program and call the BAPI to release the PO from the SAP GUI.

In your case, You can check the transaction using SY-TCODE to find out the entry point of the user. So, if he has through the Release T-Code of PO then block him from doing anything. As you are saying the user will login from an external system, I belive that the Sy-TCODE will not be set. So, you can go ahead release the PO.

Let me know if this solves your issue.

Regards,

Ravi

Note : Please mark the helpful answers

0 Kudos
76

the release seems to be fine. however since the PO change screen uses me22n and the bapi use the same bnc also. It act the same no matter I try to access the PO from outside or inside. a thought of using username to Case this situation. but other issues might occur. Anyways, how do I reward your reply? I remember there's some radio button I can click on but I can only see "solve this on my own". hmm, strange. Am I missing something?

0 Kudos
76

Jim,

As I said, its the same user exit that fires for both Transaction ME22n as well as the BAPI.

Looking at it from a long term perspect, if some one changes the username in JCo destination, then your code will fail.

That is why I suggested using the transaction code as this will NOT change. I am sure that SY-TCODE will be empty when the BAPI is called from outside and it will have a value when called from any of the GUI transactions or even from SE38(Custom ABAP Program). So, in my point of view its safe to check the value of SY-TCODE and proceed for releasing the PO. If SY-TCODE has a value, then error out so that release does not happen.

Regarding the reward, looks like there is a problem with SDN since morning. Don't worry about that.

Regards,

Ravi