cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow SAP_WAPI_CREATE_EVENT

Former Member
0 Kudos

Hi,

I used the Function Module to trigger workflow SAP_WAPI_CREATE_EVENT.

the workflow triggers but I couldn't see the Custom conatiner values.The custom workflow requires the Customer container values.

Business Object: BUS2080.

Event : closed.

Conatiner Element: Notification Number (Standard)

Userstatus(Custom developed).

The Code is

swc_container i_event_cont.

swc_create_container i_event_cont.

userstatus = 'CUST'.

OBJKEY = EXTERNALNUMBER.

swc_set_element i_event_cont 'Notification' OBJKEY.

swc_set_element i_event_cont 'Userstatus' userstatus.

When I see the Workflow log the Workflow conatiner 'Userstatus' is blank.I could get the Notification Number.

Any Idea to how to Pass the custom fields to the Event Conatiner.

Thanks

Niranjan

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

It seems the Closed event is standard. I will request you to create a Custom Event and pass all the necessary parameters that you require in the Workflow in the Container Element of the Event.

Check the Code below it is with SWE_EVENT_CREATE.

<b>Reward Points if useful</b>

FUNCTION zwf_process_trip.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(I_EMP_NUMBER) TYPE PERNR_D

*" VALUE(I_EMP_TRIP) TYPE REINR

*"----


INCLUDE <cntn01> .

DATA:i_emp_details TYPE STANDARD TABLE OF p0001, "Employee Details

wa_request TYPE p0001, "Workarea for Employee details

v_country_grp TYPE molga, "Country SubGrouping

v_object_key TYPE sweinstcou-objkey. "Key for the buisness object ZWOBUSTRIP

CONSTANTS: c_bo_trip TYPE swo_objtyp VALUE 'ZWOBUSTRIP',

c_event_trip TYPE swo_event VALUE 'TripCreate',

c_infy_type_1 TYPE infty VALUE '0001'.

  • Event Container declaration

swc_container i_event_cont.

swc_create_container i_event_cont.

  • Reading the INFO TYPE 0001 to obtain the

  • Employee details

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = i_emp_number

infty = c_infy_type_1

begda = sy-datum

endda = sy-datum

TABLES

infty_tab = i_emp_details

EXCEPTIONS

infty_not_found = 1

OTHERS = 2.

  • SY-SUBRC check is not required as the error

  • handelling will be done by WorkFlow rule

  • resolution.

CLEAR wa_request.

READ TABLE i_emp_details INTO wa_request INDEX 1.

IF sy-subrc = 0.

  • Retrieving the Country SubGrouping for the employee

SELECT SINGLE molga

FROM t001p

INTO v_country_grp

WHERE werks = wa_request-werks

AND btrtl = wa_request-persk.

ENDIF.

  • Sending the relevant data to event container

swc_set_element i_event_cont 'EmpId' i_emp_number.

IF sy-subrc <> 0.

  • No Processing needed.

ENDIF.

swc_set_element i_event_cont 'PersonnelArea' wa_request-werks.

IF sy-subrc <> 0.

  • No Processing needed.

ENDIF.

swc_set_element i_event_cont 'CountryGrouping' v_country_grp.

IF sy-subrc <> 0.

  • No Processing needed.

ENDIF.

swc_set_element i_event_cont 'EmpSubGrp' wa_request-persk.

IF sy-subrc <> 0.

  • No Processing needed.

ENDIF.

swc_set_element i_event_cont 'EmpTripId' i_emp_trip.

IF sy-subrc <> 0.

  • No Processing needed.

ENDIF.

  • Raising the event to trigger the workflow

v_object_key = i_emp_number.

CALL FUNCTION 'SWE_EVENT_CREATE'

EXPORTING

objtype = c_bo_trip

objkey = v_object_key

event = c_event_trip

TABLES

event_container = i_event_cont

EXCEPTIONS

objtype_not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • No Processing needed.

ENDIF.

COMMIT WORK.

ENDFUNCTION.

Former Member
0 Kudos

Hi Niranjan,

When you are using the WAPI, you are actually using a simple container (type swr_cont) rather than a full container (swcont) structure.

This means your container itab has only the Element and Value fields. So using the WAPI you don't use the macros. Your logic will be:

data: gt_cont like swr_cont occurs 0 with header line.

gt_cont-element = 'Notification'.

gt_cont-value = objkey.

append gt_cont.

And so on...

You then pass this into the FM and trigger.

I am surprised your use of the full container didn't result in a short dump due to type conflict.

Regards

Gareth