
Hi All,
This document help us to pass the serial number from CRM system to ECC system while the service order document replicated in ECC system.
The serial number value is not directly passed from CRM to ECC directly through the middleware.
We have to work on both CRM and ECC system.
First step we will proceed with changed required in CRM system.
We need to create a custom implementation for the BADI "CRM_DATAEXCHG_BADI" and change the method "IF_EX_CRM_DATAEXCHG_BADI~CRM_DATAEXCH_AFTER_BAPI_FILL".
Before passing the custom serial number value to ls_bapirex type bapiparex, the structure BAPE_VBAP should be enhanced with custom field.
After finishing the chnages in CRM side, then the serial number value will be passed to the middleware BAPI sturture.
Step 2: Changes to be carried out in ECC system.
To retrieve the value from BAPI structure to database table we need to enhance the structure "VBAPKOZ" with serial number value.
We will be saving the serial number value in vbap database table using a custom field enhancement to the VBAP table.
Till here the flow would be
CRM Middleware Exchange Badi -> BAPE_VBAP->VBAPKOZ->VBAP.
Now we need to update the technical object with serial number value within the replicated sales order in ECC system.
There is a include program which will be triggere every time before saving the document in database. This include program can be enhanced for our propose to update the serial number values.
The include name "MV45AFZZ" .. Within the custom enhancement place the below code
IF vbak-vbkla(3) = 'CRM'. " to trigger this only for documents received from CRM system
LOOP AT xvbap INTO ls_vbap.
IF ls_vbap-zzserialno IS NOT INITIAL.
REFRESH: lt_ser02, lt_riwol.
ls_riwol-sernr = ls_vbap-zzserialno.
ls_riwol-matnr = ls_vbap-matnr.
APPEND ls_riwol TO lt_riwol.
* FM used to assign serial Number
CALL FUNCTION 'IWOL_WV_ADD_OBJECTS'
EXPORTING
i_sdaufnr = ls_vbap-vbeln
i_sdposnr = ls_vbap-posnr
to_type = 'SD'
i_kunde = vbak-kunnr
i_vbtyp = vbak-vbtyp
i_sd_auart = vbak-auart
i_postyp = ls_vbap-pstyv
TABLES
t_riwol1 = lt_riwol
t_ser02 = lt_ser02
* T_RIWOL =
EXCEPTIONS
no_object_list = 1
entry_exists = 2
invalid_material = 3
invalid_serialnr = 4
invalid_equipment = 5
invalid_location = 6
invalid_assembly = 7
status_not_allowed = 8
equi_foreign_key = 9
equi_system_failure = 10
customer_exit_error = 11
OTHERS = 12.
IF sy-subrc EQ 0.
* Update Serial Number - POST
CALL FUNCTION 'IWOL_WV_POST_OBJECT_LIST'
EXPORTING
i_sdaufnr = ls_vbap-vbeln
i_sdposnr = ls_vbap-posnr
TABLES
i_ser02 = lt_ser02
EXCEPTIONS
no_object_list = 1
other_errors = 2
OTHERS = 3.
IF sy-subrc EQ 0.
COMMIT WORK AND WAIT.
* Taking the item
READ TABLE lt_ser02 INTO ls_ser02 WITH KEY posnr = ls_vbap-posnr.
IF sy-subrc EQ 0.
* Fetching SO item's object list number
SELECT SINGLE obknr
INTO lv_obknr
FROM ser02
WHERE sdaufnr = ls_vbap-vbeln
AND posnr = ls_vbap-posnr.
IF sy-subrc EQ 0.
* Fetching the object data
SELECT SINGLE *
FROM objk
INTO ls_objk
WHERE obknr = lv_obknr.
IF sy-subrc EQ 0.
ls_objk-objvw = 'S'.
* Update OBJK
CALL FUNCTION 'ISU_DB_OBJK_UPDATE' " by default the serial number objk field will store as K, but should be saved as 'S'.
EXPORTING
x_objk = ls_objk
x_upd_mode = 'M'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
CLEAR: ls_vbap.
ENDLOOP.
ENDIF.
Hope this would be helpful in solving issues related to this scenarios.
Best Regards,
Dharmakasi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.