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 user exit after save and database commit.

Former Member
0 Kudos

I have came across a requirement:

While saving production order (CO01) transaction, saved is performed after release.

Out of four operations from production order first two should get automatically confirmed.

Say i have four oprations:

The first two operation PRESS 2 & AGEING MACHINE should get confimed while saving prod order.

The problem is i am using Smod Enhancement PPCO0001.

FM->EXIT_SAPLCOBT_001

  INCLUDE ZXCO1U01.

here i am calling a BAPI ('BAPI_PRODORDCONF_CREATE_TT')

to automatic posting of confirmation of first two operations.

While passing production order no to this bapi(aufnr),

Error message are returned in return parameter of this bapi.

Order no ** is not found.

This is becoz, order no is generated by transaction but not has been

committed in database.

And also i cant use COMMIT WORK AND WAIT in USEr exit.

Suggest something which helps.

1 ACCEPTED SOLUTION

nabheetscn
Active Contributor
0 Kudos

Hi Abhishek

You can not do this here as order is not generated plus even if it is genearated it will be locked. Tell me one thing when you create production order check in SWEL does any event gets raised? (dont forget to switch on the trace in SWELS before creating the order). If some CREATED event is getting raised you can then attach you function module as receiving one in SWETYPV and create confirmations

Nabheet

43 REPLIES 43

nabheetscn
Active Contributor
0 Kudos

Hi Abhishek

You can not do this here as order is not generated plus even if it is genearated it will be locked. Tell me one thing when you create production order check in SWEL does any event gets raised? (dont forget to switch on the trace in SWELS before creating the order). If some CREATED event is getting raised you can then attach you function module as receiving one in SWETYPV and create confirmations

Nabheet

0 Kudos

hi nabheet,

actually i have not used this transaction SWEL till date.

but i have performed the trace as u said.

i dont know whether the events are fired or not.

i am attaching the screenshot of trace displayed

and please guide me if the events are fired then how to use these events to fulfil my requirement.

0 Kudos

What was the order number which was created is it the one under AFVC_PM check the key if it matches your order

0 Kudos

nabheet,

the key does not matches with the production order no.

but instead it matches the routing no.105512(check key in above screenshot)

This is the P.O which is created while the trace is ON.

0 Kudos

Hi Abhishek

does it have routing number and individual operation in concatenation..?If yes and you want to confirm opperations out of these?

Nabheet

0 Kudos

yes exactly nabheet,

It has routing no and individual operation no in concatenation.

i want to confirm first two operations.

Key

000010551200000001

000010551200000002

Please guide me how to proceed further.As i am still completely clueless about the use of these events.?

0 Kudos

cool.::) so go to tcode SWETYPV here you will need to add you custom function module FM1 (copy SWW_WI_CREATE_VIA_EVENT) as receiver function module. It will provide you with routing and operations in parameter OBJKEY.  You will need to activate this linkage by clicking on checkbox.

Seconldy you will have to create a wrapper FM2 which will be RFC enabled and contains the code to confirm the operations.

You will call this FM2 function module in FM1 as a background task so that you will able to commit also.

PS It will work only if it is released

0 Kudos

Nabheet,

to be very frank. i am going to try this concept as i dont have any option.

i'll let you know if i face some doubts or errors.

But this seems that these events are also fired on production order creation.

If yes, then which no is this in the KEY?(REd marked arrow).

Also, how come i have never heard of this concept till date.

I feel this is a breakthrough in sap user exits after badi's.

0 Kudos

bus2045 is for inspection lot. You can check in sWO1

0 Kudos

mindblowing

0 Kudos

h nabheet,

iam trying to copy FM -> SWW_WI_CREATE_VIA_EVENT into z Function module

but it is still showing error msg That

Function module name is reserved for SAP


0 Kudos

Hi Abhishek

Please create a Z function group and then copy dont use SAP function group

Nabheet

0 Kudos

nabheet,

i am using z Function group ZFG_TMP. (See screenshot posted above)

anyways, i have copied entire function module manually(along with import export parameters).

now i need some hint to proceed furthur,

Seconldy you will have to create a wrapper FM2 which will be RFC enabled and contains the code to confirm the operations.

You will call this FM2 function module in FM1 as a background task so that you will able to commit also.

now,i have created second FM -> Zfm2_afvc_pm.

in which parameter do i have to pass FM2 (Zfm2_afvc_pm)

in FM1 (ZSWW_WI_CREATE_VIA_EVENT_AFVC).

Also,Where do i have to call FM1??

And what are the import export paramters of FM2(wrapper FM)?

0 Kudos

oops i missed it. It is just a message by pass it .FM1 needs to be configured in SWETYPV. It will be called from there when event is raised. Fopr second FM you can pass the object key or you c an fetch data you need for second FM2 either in FM1 or in FM2 based on object key(Routing+operation)

0 Kudos

honestly, i am not getting.

what parameters to be defined in import and export parameters of FM2.?

and where i have to call FM2.

i have configured FM1(ZSWW_WI_CREATE_VIA_EVENT_AFVC) in SWETYPV.

and also i have placed a break-point in FM1 source code  but this break-point is not getting fired.??Any idea?

See Break-point.


0 Kudos

First of all it will not stop directly at the break point. Perform the following steps

When you press save switch on update debugging. Once inside update debugging put a breakpoint using the menu bar button at class CL_SWF_EVT_STRATEGY_BOR_FB method PROCESS. Once debugger stops at  change value of paramter  me->m_process_mode. to D. Then it will stop. Prior to this check if in SWEL your receiving function module is started if not check in test whether the Active check box is checked in SWETYPV.

Coming to your second point in FM1 you have got the Routine and operation. In FM2 which will be called in background task you need to find whatever data you need for confirmation based on it.

I guess its clear now

Nabheet

0 Kudos

now i am feeling like bagging my head on desk.

i have checked in SWEL. See screen-shot.

Receiver Function module is getting started but it also says

Feedback after error

Is thi some kind of error,Is it ok to have this??


0 Kudos

Remain calm that is how things are done. Double click on feedback after error to check the reason. You are not raising any exception i believe.

0 Kudos

nabheet,

after 2 years in abap i am now feeling that i am still a beginner.

anyways,

thankfully, i am able to see my FM1(ZSWW_WI_CREATE_VIA_EVENT_AFVC) in debugging.

But it is raising exception READ_FAILED.

I dont know why.

See Screenshot

Also,

i double click on Feedback error.

it says

   Task definition '' not found

0 Kudos

Is your code raising exceptions..? Share your sample code...Please make sure you do not change the importing/exporting/table name parmeters of the copied function module

Nabheet

0 Kudos

i haven't write anywhere code yet. moreover i dont understand the second FM zzfm_afvc_pm ,where i have to define this.

where in FM1(ZSWW_WI_CREATE_VIA_EVENT_AFVC)?

Coming to your second point in FM1 you have got the Routine and operation. 

Where can i capture these routing and operation from FM1?

if FM2(wrapper) is called in backgroud task, we have to define or declare FM2 somewhere...Where exactly???

what is mean by background task?

0 Kudos

Also when i test this copied function module in SE37.

The same feedback error comes and exception READ_FAILED is caught.

0 Kudos

Hi Abhishek

Here is the explanation for all

  1. In your Z copy remove all the existing code.
  2. OBJKEY has your routine and operation details.
  3. I am asking you create a new FM2 because this FM1 is called in update mode and you can not do a commit for your confirmation. So in order to confirm we call a wrapper FM2 which is RFC enabled in background task so it will start it own LUW and you can do a commit work.

Thanks

Nabheet

0 Kudos

now i am starting to understand your language.

U are saying:

i should write my entire code in a new FM say zfm_new (other than ZSWW_WI_CREATE_VIA_EVENT_AFVC) and i should call this zfm_new in the end of source code of ZSWW_WI_CREATE_VIA_EVENT_AFVC.

Am i right?

But the thing is i have placed a break-point in the end of ZSWW_WI_CREATE_VIA_EVENT_AFVC,

and this break-point is not getting fired becoz before that exception is caught.

See this screenshot;

what i am trying to code is the right way?

the program flow does not comes to break-point even in debugging mode

becoz it catches exception(try and end try block).

now where in this FM should i call my 2nd fm?

i hope u understand what i am trying to ask again and again.

0 Kudos

Hi Abhisek

I see you have some code in FM1 which came after copying from standard. Please remove everything( We dont need it we just want to copy the interface). Now just call your second FM in background task and pass to it routing and operation id.

I hope its clear now.

Nabheet

0 Kudos

Damm It.

oh man why didn't you said this in your very first reply.

0 Kudos

nabheet, a big thanks.

almost everything is clear now,

hopefully i'll be able to meet my requirement with the information u have provided.

However, there are some questions which are still revolving in my mind.

Some conceptual ques.

1. Is there any document available to study these workflow events in detail.(i have searched , but didn't found any).

2. What if i don't call my FM2(wrapper FM) in background task within FM1. What will happen if i call it normally. will it be fired? i want your views then i'll try myself.

3.why did you told me to Set FM2(for posting confirmations) as RFC Enabled. What if it is a normal FM.

0 Kudos

1-> search for worfklow events you will many.

2-> If you will call it normallly then you will get dump update terminated as you can not use commit in update task.

3-> In order to use it for background task we need to have it as RFC enabled only as it is executed via Trfc.

Nabheet

0 Kudos

1-> search for worfklow events you will many.

2-> If you will call it normallly then you will get dump update terminated as you can not use commit in update task.

3-> In order to use it for background task we need to have it as RFC enabled only as it is executed via Trfc.

Nabheet

0 Kudos

ok. seems satisfying.

0 Kudos

nabheet,

few more FAQ's.

as i am only able to capture routing no and its operation no.

Which has solved my requirement.

But my ques is:

We are able to capture both the key fields of buisness object.


Key fields

    PMorderoperation.RoutingNumber  Task list number of operations in the order

     PMorderoperation.Counter                   General counter for order

Buisness object AFVC_TMP has many other attributes also,

is there exists some way that we can capture values in these attributes while workflow event is triggered.

0 Kudos

Hi Abhishek

Good to know your issue is resolved:)

These values if you check for example put cursor on plant and then click Program in application toolbar..you will it is deriving this value from the key fields only.

Whenever a workflow event is raised you can pass additional parameter via EVENTS parameter.. Each events can have various parameters which will be passed to you in container. Check in debugging function module what does does container parameter has..

Nabheet

0 Kudos

nabheet madan wrote:

Whenever a workflow event is raised you can pass additional parameter via EVENTS parameter....

How??? Can u explain bit more clearly . Will be better with the help of a eg.

how can i pass paramters? Where t define parameters.

. Each events can have various parameters which will be passed to you in container.

Which container. moreover , where can i see the container. not getting this point also.


Check in debugging function module what does does container parameter has..

how??

0 Kudos

check this:

Event container parameter in FM.

This parameter EVENT_CONTAINER does not have a single information useful as far as i can see  other than routing no and operation no.

What do u suggest.?

0 Kudos

Hi Abhishek

In case of event if you want to pass additon information the event needs to have parameter associated with it. Sadly in your case event created does not have in case if it would have those would have visible in event container.  An example attached below  showing parameters for a custom event

Sadly i am not able to attach images:(

You can check for Business object BUS2105 event RELEASESTEPCREATED event. place cursor on it and click parameter. You will see release code. So when this event will be raised release code will be passed in event container

Nabheet

0 Kudos

nabheet,

Yes i can see the parameter release code.

But:

When i was checking on business object BUS2105 (For purchase req).

i have activated trace from SWELS. and created purchase Req and finally had trace off.

When i am checking in SWEL it is not showing any workflow event triggered.?? Why?

No entries between trace on and trace off.(no workflow event is fired ..why?).

One another question:

we can see Business object type in tcode SWO1 like BUS2105.

how we can business sub-object type??like QCYBUS2012

0 Kudos

PR release event gets triggered via release startegy. May be your PR does not have it activated.

Are you talking about sub type in second question

Nabheet

0 Kudos

i don't know about the release strategy of PR.

but i haven't released PR. i had just created PR.

May be this was the reason was the workflow event was not triggered.

Yes, nabheet. i was taking about Sub types.

How we can see sub type?

for e.g..

sub type QCYBUS2012 may have super business object type BUS2012.

where in sap we can see these(i mean t code). and how they are created.?

0 Kudos

In my system i can see FREBUS2012 as subtype created in my system in SWO1.

All subtypes which are created will be visible there only

Nabheet