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.
New Z segment.png
Zsegment release.png
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
ZCREMAS_extension_creation.png
ZCREMAS extension.png
Release ZCREMAS04.png
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.
Assign extension to message type.png
STEP4: Update the message type defined in partner profile used in your scenario to define the extension created in step2, transaction – WE20.
Change partner profile for ZESCREMAS.png
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.
Activate change pointer globally.png
Activate change pointers for ZESCREMAS04.png
BD52 change pointers.png
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.

      EXIT.

    ENDLOOP.

*** 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

      EXPORTING

        iv_vendor = wa_e1lfa1mlifnr.

    wa_lfa1 = lr_vendor->get_vendor_master( ).

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

    wa_ze1lfa1aCUSTOM_FIELDS     = wa_lfa1zzvscs_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_datamandt    = symandt.

    idoc_datahlevel   = ’01’.

    MOVE c_newseg_name TO idoc_datasegnam.

    MOVE wa_ze1lfa1a   TO idoc_datasdata.

    APPEND idoc_data   TO t_idoc_data.

  ENDIF.

ENDMETHOD.

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.

BD14.png

BD21.png

Troubleshooting

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.

SALE.png

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

    1. Vivek Priyadarshi Post author

      Hi Jixin,

      ZCL_VENODR_BASE is a model custom class.  You could use function module

      ‘WY_LFA1_SINGLE_READ’ to read LFA1 for the above piece of code.

      Regards,

      Vivek

      (0) 

Leave a Reply