cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Event Create

syed_ahmed
Discoverer
0 Kudos

Dear Experts,

I am new to workflow.

I am triggering BUS2017 Event through BADI and using function module "SAP_WAPI_CREATE_EVENT"

As you can see there are event parameters of MSEG and MKPF in BUS2017 object.

When i pass the MKPF parameter through SWUE its working fine and parameter is passed.

But when using "SAP_WAPI_CREATE_EVENT" , as input container is element - value pair , I am unable to pass

MSEG and MKPF values there.

Can any one guide please how to pass structured or tabled type values in sap_wapi_create_event as parameter of event,

View Entire Topic
StephaneBailleu
Active Contributor

Hi

Or use the more modern form with class

I made a quick and dirty test

REPORT z_bus2017_test.
CONSTANTS :
lc_typeid TYPE swrsibfti VALUE 'BUS2017',
lc_event TYPE sibfevent VALUE 'CREATED'.

DATA :
lo_event_parameters TYPE REF TO if_swf_ifs_parameter_container,
lv_param_name TYPE swfdname.
DATA : ls_mkpf TYPE mkpf,
ls_mseg TYPE mseg,
lt_mseg TYPE TABLE OF mseg,
ls_key TYPE sibfinstid.

SELECT SINGLE * FROM mkpf INTO ls_mkpf
WHERE mblnr EQ '4900000210'
AND mjahr EQ '2022'.
CONCATENATE ls_mkpf-mblnr ls_mkpf-mjahr INTO ls_key.

SELECT SINGLE * FROM mseg INTO ls_mseg
WHERE mblnr EQ '4900000210'
AND mjahr EQ '2022'
AND zeile = 1 .
APPEND ls_mseg TO lt_mseg.

"instanciate empty event container
CALL METHOD cl_swf_evt_event=>get_event_container
EXPORTING
im_objcateg = cl_swf_evt_event=>mc_objcateg_bor
im_objtype = lc_typeid
im_event = lc_event
RECEIVING
re_reference = lo_event_parameters.

"declaration of the container
TRY.
CALL METHOD lo_event_parameters->set
EXPORTING
name = 'MSEG'
value = lt_mseg
* UNIT =
* IMPORTING
* RETURNCODE =
.

CALL METHOD lo_event_parameters->set
EXPORTING
name = 'MKPF'
value = ls_mkpf
* UNIT =
* IMPORTING
* RETURNCODE =
.

CATCH cx_swf_cnt_cont_access_denied .
CATCH cx_swf_cnt_elem_access_denied .
CATCH cx_swf_cnt_elem_not_found .
CATCH cx_swf_cnt_elem_type_conflict .
CATCH cx_swf_cnt_unit_type_conflict .
CATCH cx_swf_cnt_elem_def_invalid .
CATCH cx_swf_cnt_container .
ENDTRY.


"Raise the event
TRY.
CALL METHOD cl_swf_evt_event=>raise
EXPORTING
im_objcateg = cl_swf_evt_event=>mc_objcateg_bor
im_objtype = lc_typeid
im_event = lc_event
im_objkey = ls_key
im_event_container = lo_event_parameters
.
CATCH cx_swf_evt_invalid_objtype .
CATCH cx_swf_evt_invalid_event .
ENDTRY.

COMMIT WORK. .

syed_ahmed
Discoverer
0 Kudos

Thanks Alot. It Solved my problem.

Regards