The previous two blogs of this series have covered vendor master table and screen enhancement (part1) and the vendor master update api class (part2) used to update vendor master. This final part will cover the steps required to enhance CREMAS idoc and generate idocs for changes to custom fields added to vendor master structure (LFA1 for this scenario).
STEP1: Create a new IDOC segment for the custom fields that need to be distributed as part of the vendor master idoc - transaction WE31. Release the new segment after saving. This step ensures the new segment is active and valid for use by the idoc extension.
STEP2: Create a new IDOC extension to include the new segment created in step1 - transaction WE30. Select CREMAS04 as the reference basic type and append the Z segment at the same /sub level of one of the header segments (E1LFA1M, E1LFA1H, E1FLA1A - other segments can be used for purchase org or company code depending on requirement ). Release the IDOC extension after saving
STEP3: Use transaction WE82 to assign extension created in previous step to combination of basic type (CREMAS04/05) and message type. Enter the Release version based on your current sap release.
STEP4: Update the message type defined in partner profile used in your scenario to define the extension created in step2, transaction - WE20.
STEP5: To enable change document creation for custom fields appended to vendor master table(s) follow the steps outlined below:
Activate change pointers for message type - transaction BD50
Assign table fields which are relevant for change pointer creation for message type. - transaction BD52
For more details regarding change pointers for IDOCS, check the sap help link.
STEP6: Implement badi VENDOR_ADD_DATA_BI which is called during execution of function module MASTER_IDOC_CREMAS_SMD. This function module creates the idocs for vendor master related change pointers.
The code below is implemented in BADi method FILL_ALE_SEGMENTS_OWN_DATA. It gets the vendor master header details from E1LFA1M segment and read the custom field values from LFA1 table. Finally a segment record ( with custom segment data) is appended to IDOC data.