Additional Blogs by Members
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
  *Introduction * bq. Michal Krawczyk on his blog (Distribution of full master data objects from change pointers) provided a great solution for full master data distribution. However, described change pointer "trick" with Implicit Enhancement in ABAP source code is valid for materials only. My need was to distribute complete IDocs for vendor master data generated from change pointers. Proposition stays the same: we still need to modify function module CHANGE_POINTERS_READ like Michal mentioned, but with a different part of a code.   *Scenario* bq. It can be used for both vendor and customer master data. The only action you need is to make sure, that configuration is performed correctly. When you use change pointers for master data distribution, a suitable function module is called. To check it, use a transaction BD60 and select your message type. In this case, I use YCREMAS as a copy of the standard vendor message type.       bq. It is assigned to the standard function module MASTERIDOC_CREATE_SMD_CREMAS. This function calls CHANGE_POINTERS_READ where we insert customized enhancement. Enhancement should be created at the end of the function. Place of the CHANGE_POINTERS_READ function module modification: |    ENDIF  CLEAR change_pointers. <-- here --> ENDFUNCTION. |   Insert below source code: *--------------------- ( CHANGE IT )------------------- CONSTANTS: lc_msgtype(7) TYPE c VALUE 'YCREMAS', lc_object(4) TYPE c VALUE 'KRED'. *------------------------------------------------------ * general condition IF message_type EQ lc_msgtype AND change_document_object_class EQ lc_object AND change_pointers[] IS NOT INITIAL. DATA: lt_tabnames TYPE TABLE OF tbd62, lt_tbd62 TYPE TABLE OF tbd62, ls_tabnames LIKE LINE OF lt_tabnames, lt_bdcp TYPE TABLE OF bdcp, ls_bdcp TYPE bdcp, ls_cpinit TYPE bdcp, lt_dd03l TYPE TABLE OF dd03l, ls_dd03l LIKE LINE OF lt_dd03l, dref TYPE REF TO data, itab_type TYPE REF TO cl_abap_tabledescr, struct_type TYPE REF TO cl_abap_structdescr, comp_tab TYPE cl_abap_structdescr=>component_table, lv_length TYPE i, lv_offset TYPE i, lv_from TYPE i, lv_lines TYPE i, lv_index TYPE i. FIELD-SYMBOLS: TYPE ANY. lt_bdcp[] = change_pointers[]. * get all tables and corresponding fields from object class SELECT * INTO TABLE lt_tabnames FROM tbd62 WHERE mestyp EQ lc_msgtype AND cdobjcl EQ lc_object. lt_tbd62[] = lt_tabnames[]. * reduce records only to table names SORT lt_tabnames BY tabname. DELETE ADJACENT DUPLICATES FROM lt_tabnames COMPARING tabname. * to not ommit any vendor SORT lt_bdcp BY cdobjid cdchgno. DELETE ADJACENT DUPLICATES FROM lt_bdcp COMPARING cdobjid. DESCRIBE TABLE lt_bdcp LINES lv_lines. lv_index = 1. * lv_lines now contains all vendors to be processed DO lv_lines TIMES. READ TABLE lt_bdcp INTO ls_cpinit INDEX lv_index. * get next record index if more than one vendor IF lv_lines GT 1 AND lv_lines NE lv_index. lv_index = lv_index + 1. ENDIF. SELECT COUNT(*) FROM lfb1 WHERE lifnr EQ ls_cpinit-cdobjid. IF sy-dbcnt EQ 0. DELETE lt_bdcp WHERE cdobjid EQ ls_cpinit-cdobjid. DELETE change_pointers WHERE cdobjid EQ ls_cpinit-cdobjid. CHECK lv_index NE 1. lv_index = lv_index - 1. EXIT. ENDIF. * get all entries from database for each tabname LOOP AT lt_tabnames INTO ls_tabnames. * creation of structures struct_type ?= cl_abap_typedescr=>describe_by_name( ls_tabnames-tabname ). comp_tab = struct_type->get_components( ). struct_type = cl_abap_structdescr=>create( comp_tab ). itab_type = cl_abap_tabledescr=>create( struct_type ). CREATE DATA dref TYPE HANDLE itab_type. ASSIGN dref->* TO . * get all data from tables related to our object class IF change_document_object_class EQ 'KRED'. SELECT * INTO TABLE FROM (ls_tabnames-tabname) WHERE kunnr EQ ls_cpinit-cdobjid. ELSE. MESSAGE a024(b1) WITH change_document_object_class message_type. ENDIF. * then we need key fieldnames for each table SELECT * INTO TABLE lt_dd03l FROM dd03l WHERE tabname EQ ls_tabnames-tabname AND keyflag EQ 'X'. SORT lt_dd03l BY position ASCENDING. * fill every field of the table with data LOOP AT lt_tbd62 ASSIGNING . CLEAR ls_bdcp. ls_bdcp-mandt = ls_cpinit-mandt. ls_bdcp-cpident = ls_cpinit-cpident. * here is the tabkey creation (BDCP-TABKEY) LOOP AT lt_dd03l INTO ls_dd03l. ASSIGN COMPONENT ls_dd03l-fieldname OF STRUCTURE . ls_bdcp-cretime = ls_cpinit-cretime. ls_bdcp-acttime = ls_cpinit-acttime. ls_bdcp-usrname = ls_cpinit-usrname. ls_bdcp-cdobjid = ls_cpinit-cdobjid. ls_bdcp-cdchgno = ls_cpinit-cdchgno. ls_bdcp-cdchgid = ls_cpinit-cdchgid. APPEND ls_bdcp TO change_pointers. * many loops... but it works 😉 ENDLOOP. "tabkeys ENDLOOP. "fields for table ENDLOOP. "tables from BD52 for our object class ENDDO. "every vendor processing ENDIF.   bq. After setting values for two constants at the beginning of the source code, you can now maintain table with document items used by change pointers (transaction BD52). Put there all the fields you find useful in the final IDOC message, but remember that only those items related to the object class will be taken into account.