Outbound IDOC By Change Pointers And Customized Triggering Events
To illustrate the configuring steps required to trigger an customized outbound IDOC whenever there is change in particular
field through standard transaction code by setting change pointers for that particular field and triggering customized events/workflow task.
1. Introduction to Change Pointers:
Through Change Pointer’s mechanism if any master data field value is changed in SAP like Material master, Vendor master etc. through standard t-code like MM01,MM02, VA01,VA02, the corresponding records will be created in change pointers table(BDCP,BDCPS) and simultaneously events will get triggered to generated the required outbound IDOC’S.
In order to configure Change Pointer mechanism, we need to develop and do the settings as described in the following steps taking Vendor Master as an example.
2. IDOC Basic Type:
The basic element of any IDOC is Basic Type. There are standard BASIC TYPE available like CREMAS05,MATMAS05 which can be customized i.e. the structure can be extended to insert customized segments as per the requirement. We can create a new BASIC TYPE or extend the standard BASIC TYPE using the transaction WE30, WE31.
- Create IDOC segment ZMMPU_DOCK using WE31 having custom fields as per the requirement
- Create IDOC extension Z_CREMAS05 using WE30 for standard basic type CREMAS05
3. IDOC Message Type:
Create a new message type through the tcode WE81
Assign the message type created through WE81 to the desired BASIC TYPE using the transaction WE82
4. Activate Change Pointers Generally/Message Type:
Activate the change pointers generally using t-code BD61.
Activate the change pointer for above message type using t-code BD50
5. Assign Change Items to Message Type:
Assign the table LFA1 and the corresponding filed as per the requirement to above created message type using t-code:BD52
6. Business Object Repository:
The program that needs to be called when change pointers triggers an event is developed in BOR using t-code SWO1
Create one method RUNBD21 and two events CREATE and CHANGE as shown in the following figure.
In the program ZCHGPOINT.RUNBD21, call an method of class in which function module will be called to process and outbound IDOC passing the parameter ‘MESSAGE TYPE’
In ZCL_BD21=>ZCL_BD21_TEST put the below logic
select single idocfbname
from tbdme into lv_idocfbname
where mestyp = ‘MESSAGE_TYPE’ created above
call function lv_idocfbname
message_type = ‘MESSAGE_TYPE’ created above
7. Link Change Document object and BOR:
The BOR created in above step will be required to be linked Vendor change document object KRED using SWEC
8. Workflow Task:
Create an customized task in order to link it to BOR above created. Standard Task is created using t-code PFTC
9. Create Function Module
The processing logic required to generate outbound IDOC needs to be implemented in this FM.
a. Fetch change pointers record from table BDCP for the corresponding message type using the FM CHANGE_POINTERS_READ with parameters as
- MESSAGE_TYPE = Import parameter MESSAGE_TYPE
- CREATION_DATE_HIGH = Import parameter
- CREATION_TIME_HIGH = Import parameter
- READ_NOT_PROCESSED_POINTERS = ‘X’
b. For all the records fetched in step a ) check if BDCP-tabname = ‘LFA1’ THEN collect vendor number LIFNR = BDCP-tabkey+3(10)
c. Thus in above step we can get vendor number for which any field is being changed through XK01/XK02 and the correspoing change pointer is triggered.
d. Now populate segment ZCREMAS_05 as per the requirement and post the IDOC using MASTER_IDOC_DISTRIBUTE or STANDARD master idoc BAPI
e, Call the FM CHANGE_POINTERS_STATUS_WRITE to update all processed change pointer id
10. Configure Message type with Function Module:
The message type created ZMMVE_CREMAS01 needs to be linked with FM created ZFM_TRIGGER_IDOC
By completing the above configuration steps we will able to trigger outbound IDOC whenever there is change in particular field value through standard transaction.