Application Development and Automation 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: 
Read only

lock object does not work

Former Member
0 Likes
5,011

I created a lock object 'ezvso', and function 'ENQUEUE_EZVSO' and 'DEQUEUE_EZVSO' were generated.

and i used the two function to lock and release the object in my program, it is always successful,

except one circumstance, as follow:

1. call function to lock the object successfully,

CALL FUNCTION 'ENQUEUE_EZVSO'

   EXPORTING

        mode_ztso_head       = 'E'

        mandt                = sy-mandt

        zvvbeln              = pv_zvvbeln

*       X_VBELN              = ' '

        _SCOPE               = '3'                           " i tried 1,2,3 ,all the same

*       _WAIT                = ' '

*       _COLLECT             = ' '

      EXCEPTIONS

        foreign_lock         = 1

        system_failure       = 2

        OTHERS               = 3    .

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 DISPLAY LIKE 'W'.

     lv_7002 = '1'.

   ENDIF.


2. then, call function 'BAPI_SALESORDER_SIMULATE'

   the lock was released automatically,  how can i solve the problem?

  

BR!

   

1 ACCEPTED SOLUTION
Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
4,112

I believe this means database update (or rolback?) is happening somewhere. Check the documentation on The Lock Concept: https://help.sap.com/saphelp_nw70/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/content.htm

21 REPLIES 21
Read only

Former Member
0 Likes
4,112

hi,

  put breakpoint at bapi function module and check in sm12 tcode,whether lock is generated,if ur lock object exists then its working fine.

Read only

0 Likes
4,112

hi,

thanks at first.

yes, the lock is generated. i can see it in sm12.

and after call function 'BAPI_SALESORDER_SIMULATE', it disappeared.

Read only

Former Member
0 Likes
4,112

hi,

once bapi execution is complete,lock will be released automatically.but lock for database table or ztable.

Read only

0 Likes
4,112

Yes,

I create the lock object for a ztable, ZTSO_HEAD, lock mode = 'E'.

in my program,

1st, lock the ztable,

2nd, get data from ztable,

3rd, using data from ztable to create so directly, or after running 'BAPI_SALESORDER_SIMULATE', depends on users action

4th. release the lock.

if the user trigger to run 'BAPI_SALESORDER_SIMULATE', then the lock released immediately, do not need the 4th;

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
4,113

I believe this means database update (or rolback?) is happening somewhere. Check the documentation on The Lock Concept: https://help.sap.com/saphelp_nw70/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/content.htm

Read only

0 Likes
4,112

Thanks,

I get it after debugging the function 'BAPI_SALESORDER_SIMULATE'

there is a line of code: call function 'DEQUEUE_ALL'.

Read only

Former Member
0 Likes
4,112

I found why the lock released after running ’BAPI_SALESORDER_SIMULATE‘.

Because the bapi excute this code:

call function 'DEQUEUE_ALL'.


May i do sth, force the program dequeue all object expect my lock object EZVSO?

or i have to lock the object again after call function ’BAPI_SALESORDER_SIMULATE‘?

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
4,112

Not sure what you're trying to do exactly, but it doesn't seem to make a lot of sense in this case to combine the simulation and update into one transaction (and I mean "transaction" in update terms). Maybe run the simulation first, then lock / update / unlock your Z table? In case someone else "stole" the record while BAPI was running just show a message that oopsie daisy, too late.

If you lock the table beforehand and then BAPI releases the lock anyway then what's the point of blocking? Not sure a perfect solution is possible in this case, any way you chose will have some loopholes IMHO...

Read only

0 Likes
4,112

Thank you.

i will show you my detail requirements below;

I create two ztable, to sotr the information inputted by user, we call these information as 'virtual SO'.

and I create a transaction ZVA01N, that user can exucte to query the virtual so in alv form.

if user want to create a real SO(can be shown in va03) with the information in virtual so, they just double click the column 'virtual so' in alv list,

then the program do the following things:

1st, lock the virtual SO,

2nd,read the full information about the virtual SO from ztable

3rd, call screen to show the information from 2nd, and user can change, add, delete some data,

4th, click save to create a real SO, then, update ztable, release the lock, and return to the alv.

     but if the user want to see the detail condition of the SO before save, and sometimes they even want to change the conditions, so they will click one button to trigger the the  simulation, and the program get the conditions and pop to screen. but after the bapi of simulation, lock released.

I hope the lock can sustained until i call function to release it. but i do not find a perfect solution, as you said, there always some loopholes.

BR!

Read only

0 Likes
4,112

There already is "virtual SO" in SAP, it's called Quotation. Also if the users don't like what they see in SO when they start to enter it then just don't save it. I'm quite confused in what business context such process as you're describing could possibly be needed...

It looks like reinvention of bicycle, to be honest, and simply improper use of SAP. Might want to get a good SD consultant instead of using ABAP.

Read only

0 Likes
4,112

Yes, we know quotation, but we have some others problem, we can not use it.

because in our system one customer model have a few material no.

this is the currently situation, and we do not discuss whether it is reasonable now.

so when the user create the virtual SO, they only know the customer model, not exactly material no or batch no. so we can not use Quotation.

and before we change our system, set one customer model equal to one material no, we will use this 'Virtual SO', and the program will get corresponding material and batch to create SO.

Read only

0 Likes
4,112

How does "virtual SO" get into your system and how do users know which material corresponds to the customer's material? Also - how exactly does running order simulation BAPI help them in that process?

We frequently have a situation with EDI orders when customers send us a material ID that can't always be matched correctly with SAP ID (i.e. we can't just put it in the info record). Or we could get an order that requires adding VC, which can't be sent by the customers.

In these cases we use a user exit that puts EDI_UNKNOWN material number, moves the customer's information into the description field and adds a block to the order.

The sales reps then open those orders, enter the correct material and add VC, as needed, reject the EDI_UNKNOWN line and unblock the order. No "virtual orders" involved.

Read only

0 Likes
4,112

Jelena,

it  is so nice of you. what you said about EDI_UNKNOWN material, show me something different, maybe a different solution, thank you very much.

below is how we do in our system.

we add a field in mara to store the customer model, and always some different materials have the same customer model

When our sales department colleague receive a sales order from the customer;

if we have enough stock, they create sales order using a ztcode, because sales department just care about customer model, but the system case about material no, and just as what i said, some different material no have the same customer model, so it cost them a lot of time to find which material no they use in this sales order.So we developed this ztcode, they just input customer model, the program will find the material no to create sales order.

if we do not have stock, they will tell the factory to produce the product, and they will create a virtual sales order using customer model first. when we we get the product from factory, they use this transaction to create sales order from virtual SO.

simulation BAPI is to get the sales conditions, we have about 20 kinds of conditions, such as rebate, discount, some fee, not all of them are fixed, they may change it for every sales order. if they want to change it, the program should show the conditions. the gif image below is about the transaction create sales order from virtual SO.


Read only

0 Likes
4,112

But still you didn't answer - how do those "virtual orders" get into the system in the first place?

I did not see any value added by this Z transaction, to be honest. All the same activities can be done in VA01/VA02. If all the program does is determine the material number then why can't this be just added as a user exit in VA01/VA02? Or added in whatever process that creates those "virtual orders"?

Production is the whole another story. Is the "factory" owned by the company? Then why are you not using production orders and MTS process? Is it a third-party order? There is a process for that as well.

It just seems like a poorly designed process. I would really suggest to get a good functional consultant for this instead.

Read only

0 Likes
4,112

The virtual SO is input by sales department, all the info need to create a SO, one field by one field, using another ztcode.


the sales department receives a Customer po first, then create virtual SO and send requirement to the factory, then the factory create the material no and arrange production


when our sales department create the virtual SO, they do not get the material no. it is not possible to assign material no to SO according to customer model no when create the virtual SO.

the "factory" is not owned by the company, but they are both owned by the same Parent company

Read only

0 Likes
4,112

Plot thickens... Why does the factory create the material? Do you create new material for every order then? What sacred knowledge do factory workers have that the sales reps don't?

And what's the purpose of entering "virtual SO" into SAP if it doesn't drive any process, like sales forecast or ATP? You are essentially using SAP as a notepad and spending resources on all this custom development.

Again - I feel you just need a strong functional consultant here. If you're not taking advantage of best practice processes then what's even the point of paying for SAP?

Read only

0 Likes
4,112

Why does the factory create the material?

That is a long story. the factory get sap online years before the company, they create material for every production order, and when the company get sap online,  the factory said, you have to do as my way as usual, so the company get different material for the same customer model.


And what's the purpose of entering "virtual SO" into SAP if it doesn't drive any process

Just because the sales department said, we need this function, you have to do it.

Their may be many days between they receive the customer PO and create SO, they may forget it. this is their reason, and they always complain to the top leader group for this, and their words always weighed heavily.



Read only

0 Likes
4,112

This story sounds very familiar.

I somehow doubt factory actually creates a unique material number for each order, unless you are manufacturing airplanes. This would make all their processes rather difficult. Most likely either there is just some misunderstanding how this works or factory is actually using variant configuration (VC) and is not telling you material number, but only some characteristic. E.g. we also have lines of products and different models of each product. Models are entered in VC and material number is the whole line.

Obviously it's not my business, but still I feel the company is making a mistake by introducing these "virtual orders" into the mix. Not only you are spending resources on custom development but also you are not using any standard SAP tools / reports available for the sales documents. Also if, say, tomorrow a customer insists on using EDI to send you POs you are pretty much screwed. (And yes, there are customers who would only use EDI or will go to another vendor, no matter what problems it causes for you.)

I would strongly suggest to find a way just to enter a standard sales document for this. Either using a temporary "dummy" material or something else. You'd be much better off both short and long term. I actually don't understand why even the users insist on building this "parallel universe". Wouldn't it be actually more convenient to them to use the same reports to track all the orders? You could even build some interface with the factory or a workflow to update the orders. Lots of possibilities out there.

Read only

0 Likes
4,112

Jelena;

Of course this is not your business, but you still share so much solution with me, and give me some really valuable suggestion, thanks you, sincerely.

    

And for the factory, they really create a unique material number and BOM and routings and so on for each order,  i participated one of the brunch factory‘s project, i think that is werid too.

All the Zcode, about create virtual SO, transfer virtual SO to real SO, directly create real SO with customer model, this is a temporary solution. Finally, in the company's system, one customer one material no, all the Zcode is useless, and before the final solution get implemented, they will use these Zcode.

We are just started to build the EID system, and the interfaces between the company and the factory. All of your points, about Quotation, EDI_UNKNOWN material number, the integration of the company and the factory, taking advantage of SAP standard functions, all of your suggestion, I appreciate it.


Read only

RaymondGiuseppi
Active Contributor
0 Likes
4,112

A "pure technical" solution for your problem could be Asynchronous call (aRFC) of BAPI_SALESORDER_SIMULATE (STARTING NEW TASK with a CALLING meth/PERFORMING subr ON END OF TASK to RECEIVE results) so the DEQUEUE won't remove your lock.


Hint: Nevertheless on functional/maintainability/integration points of view you (your company/customer) should follow 's suggestions.


Regards,

Raymond

Read only

0 Likes
4,112

Hi, Raymond;

     Thanks for your suggestion, and both Jelena. How can i forget the aRFC. I think my problem about the lock object is solved, and i will review and share Jelena's suggestion with our team, that is great.