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: 

CO01/CO02 Badi (WORKORDER_UPDATE) brain teaser

Former Member
0 Kudos

Hi all

I would like to post a problem I'm having with this particoular BADI. There are 2 issues I am having.

Issue1: What I need is simple: open a popup with some data on the order I am saving (letting the user do some operation we don't care here)

The only thing I have to underline is that this popup must be shown only if user released the order.

So I used the AT_RELEASE method to set an attribute of the class implementing the BADI (the name of this attribute/flag is RELEASED)

At this point what I need was a method letting me to implement this logic :

IF released EQ 'X'.

     " operations

ENDIF.

The method I used tried were these:

AT_SAVE. this method is not good: if I am saving from CO01, order number is not yet present (and I need it). For CO02  is ok

NUMBER_SWITCH. this method is good for CO01 where the order number is given. But this method is not called from CO02.

So I mixed up these methods, but still having problems. The problems are given by the fact that the 'popup' mentioned above, has been realized with a function that read order data from database.. but data are not yet on database (subrc = 4 in the select).

I understood that commit is made after this method. So I tried the IN_UPDATE still without success, because it is not allowed in a UPDATE TASK like this to call dynpro (my popup). My solution is to call a function in SEPARATED TASK in AT_SAVE method; the function waits a second (let the DB to be updated) and go to read data. Have you a better solution to suggest ?


Issue 2: This issue regards the istance attribute I created. Actually, over the popup, I have to perform another task that I summarize as: "If order has been released, I need to put the order number in a Z table". So, I decide to put this statement in method IN_UPDATE, and it works on first test. Then I insert the logic:

IF released EQ 'X'.

     " insert into Z table

ENDIF.

Here I realized that RELEASED attribute was not set. It seems that in IN_UPDATE method, istance attribute have been reset. I cannot understand why and how is possible. While the method is running, the istance should be alive. The only clear that I make of this variable is in INTIALIZE method and putting break  point, I can see this method is not invoked (obviously) no more that once.

Any hint is welcome.

Thanks and regards

Gabriele

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hello,

solution one looks ok.

for issue number two you could check what is called after the AT_RELEASE, hopefully it should be AT_SAVE. Here you can update your Z table. If for some reason the save fails do not update the Z table or rollback.

best regards,

swanand

2 REPLIES 2

Former Member
0 Kudos

hello,

solution one looks ok.

for issue number two you could check what is called after the AT_RELEASE, hopefully it should be AT_SAVE. Here you can update your Z table. If for some reason the save fails do not update the Z table or rollback.

best regards,

swanand

0 Kudos

Hi and thanks for your reply. AT_SAVE is not good, because I don't have position data there, but BEFORE_UPDATE is perfect. I put there all I needed: popup and Z table update. And as you say, in case of problem (I think should be hard  problem because, if error are present in order, processing never reach BEFORE_UPDATE methods), data are rollback.

thanks and Regards


Gabriele