Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
Showing results for 
Search instead for 
Did you mean: 
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 globally - transaction BD61
      • 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.
METHOD if_ex_vendor_add_data_bi~fill_ale_segments_own_data.

  CONSTANTS: c_newseg_name TYPE edilsegtyp VALUE 'ZE1LFA1A'.

  DATA: idoc_data   TYPE LINE OF edidd_tt,

        wa_e1lfa1m  TYPE e1lfa1m,

        wa_ze1lfa1a TYPE ze1lfa1a.

  DATA: wa_lfa1     TYPE lfa1.

  DATA: lr_vendor   TYPE REF TO zcl_vendor_base.

  FIELD-SYMBOLS: <fs_idoc_data> TYPE LINE OF edidd_tt.

  "Only for message type ZESCREMAS and segment name = E1LFA1M

  IF i_message_type = 'ZESCREMAS' AND i_segment_name = 'E1LFA1M'.

    LOOP AT t_idoc_data ASSIGNING <fs_idoc_data> WHERE segnam = 'E1LFA1M'.

      MOVE <fs_idoc_data>-sdata TO wa_e1lfa1m.



*** get Vendor compliance safe score information for this vendor.

*** assign value to idoc_data-SDATA and append to changing T_IDOC_DATA

    CREATE OBJECT lr_vendor


        iv_vendor = wa_e1lfa1m-lifnr.

    wa_lfa1 = lr_vendor->get_vendor_master( ).

*** ASSIGN the values from LFA1 (wa_lfa1) to structure of segment ZE1LFA1A ( wa_lfa1fa1a ) ****

    wa_ze1lfa1a-CUSTOM_FIELDS     = wa_lfa1-zzvscs_CUSTOM_FIELDS.

*** set the idoc extention name in control record.

    e_cimtype = 'ZCREMAS04'.

*** populate segment name in the data record, copy data contents into

*** it, and append the data record to existing data records

    idoc_data-mandt    = sy-mandt.

    idoc_data-hlevel   = '01'.

    MOVE c_newseg_name TO idoc_data-segnam.

    MOVE wa_ze1lfa1a   TO idoc_data-sdata.

    APPEND idoc_data   TO t_idoc_data.


Testing IDOC generation for custom fields.

IDOC generation can be tested by one of the methods noted below

  • Using transaction BD14. - Provide vendor number and IDOC message type
  • Using transaction BD21 - Provide the message type for IDOC generation.

Status of generated IDOC can be checked using transaction WE02 - provide the basic type CREMAS04/05.


Below are some pointers to try if IDOCS are not generated/generated without custom segment during testing.

  1. Ensure change pointers are being generated. this can be verified by checking entries of table BDCP2. following tips could help if change pointer generation is the problem
    • Ensure the fields for which change pointers need to be generated have data elements with "change document" field selected ( as noted in part 1).
    • Ensure fields for which change pointers are needed are specified  in transaction BD52.
    • In case BADI- BDCP_BEFORE_WRITE is implemented, ensure logic is not preventing change pointer creation.
  2. IDOC is generated but no custom segment. Following tips might come in handy.
    • Ensure IDOC reduction is not active ( most unlikely, since this is a new segment ) using transaction SALE.
    • Check if some sort of segment filter is  active ,using transaction SALE.
    • Check transaction BD64 to validate if any filters are setup for your segment.