cancel
Showing results for 
Search instead for 
Did you mean: 

Call purchase requisition approval workflow in abap program

Former Member
0 Kudos

Hello,

I copied the standard workflow for the approvaI of a purchase requisition WS00000038 and i tested it. I create a purchase requisition in me51n. This is triggering the event releasestepcreated which starts my workflow. Everything goes ok.

Now, i want to call this workflow in ABAP. I do not know exactly how to do it. Here is the code I tried.

data: ls_objkey type SWR_STRUCT-OBJECT_KEY,

lt_mesage type table of SWR_MESSAG,

gt_container type table of swr_cont,

gs_container type swr_cont.

gs_container-element = 'ReleaseCode'.

gs_container-value = '01'.

append gs_container to gt_container.

gs_container-element = 'requisition'.

gs_container-value = '0010000362'.

append gs_container to gt_container.

gs_container-element = 'RequisitionHeader '.

gs_container-value = '0010000362'.

append gs_container to gt_container.

ls_objkey = '0010000362'.

CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'

EXPORTING

object_type = 'BUS2009'

object_key = ls_objkey

event = 'RELEASESTEPCREATED'

TABLES

input_container = gt_container

MESSAGE_LINES = lt_mesage.

As you can see i filled he RequisitionHeader, requisition and release code. I saw in the workflow that i copied, that these are import parameters. Requisition and release code are mandatory. 0010000362 is a purchase requisition that i created.

After i run the program i receive a work item in SBWP but it has the status error.

Can you help me?Perhaps anyone has done this. I think that i am not filling the correct data or something like that. Maybe you can look in the standard workflow WS00000038 and tell me what I should pass and how.

Thank you,

Efren

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Efren,

In the export parameter 'object_key' of function module SAP_WAPI_CREATE_EVENT, you should pass the Purchase requisition number.

As its a key field you should pass it to the workflow to instantiate the business object.

What error you got in the work flow? Workflow is triggered or not?

Thanks,

Viji.

Former Member
0 Kudos

Hello,

I am passing the purchase requisition number using ls_objkey = '0010000362', as you can see.

The workflow is triggered. I am receiving a work item in my inbox, but when i click on it, the status becomes red and indicates Error.

former_member185167
Active Contributor
0 Kudos

Hello,

Look in the workflow log (via eg SWI1) and find out what the error is.

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Hi Efren23,

The workflow is triggered, so there is no issue's with the event linkages and your program.

Can you check your workflow using transaction swi2_diag. It will give you the list of error's.

Try to fix that error or paste it here for thr better suggestions.

Thanks,

Viji.

Former Member
0 Kudos

Hi Efren,

The Problem is, for the purchase requisition there is two key fields.

So when you pass the keyfiled to workflow it should be the concatenation of Purchanse requisition number and the item number.

You have to pass the object key as below.

ls_objkey = '00100003620010'.

Then only your business object will getting insatanciated.

Thanks,

Viji.

Former Member
0 Kudos

Thanks Viji, that was the problem.

Efren

Answers (1)

Answers (1)

jitendra_it
Active Contributor
0 Kudos

Hi ,

Try using FM SWE_EVENT_CREATE. check below thread.