使用SAP IDOC IDOC_INPUT_DEBITOR DEBMAS DEBMAS07创建客户主数据没返回消息解决方案

最近大家喜欢用IDOC来同步客户主数据到sap ecc系统。

没有什么太多特殊的。都是标准配置。消息类DEBMAS

基本类型DEBMAS07 。可是却死活都收不到状态消息。

经过DEBUG调试跟踪,也是头痛欲裂。确实没有抛出异常的地方。

于是想到会不会是官方问题?

然后搜索sap标准note。果不其然。

 

2678496 – Status message is no longer issued in batch input
2655937 – Status message is no longer displayed

事务代码SNOTE打上后,完美解决~【解决方案代码】

 

CONSTANTS:
*   XML data
*  lc_fk_stc2(20)        TYPE c  VALUE ‘FHK01_CCFCGD_STC2’,         “Sold-to Code
*  lc_fk_cn(8)           TYPE c  VALUE ‘FHK01_CCFCGD_CN’,            “Ship-to Code
*  lc_fk_cna(40)         TYPE c  VALUE ‘FHK01_CCFCGD_CNA’,           “Ship-to Name
*  lc_fk_a(40)           TYPE c  VALUE ‘FHK01_CCFCGD_A’,        “Address
*  lc_fk_a2(40)          TYPE c  VALUE ‘FHK01_CCFCGD_A2’,        “Address 2
*  lc_fk_a3(40)          TYPE c  VALUE ‘FHK01_CCFCGD_A3’,      “Address 3
*  lc_fk_ccn(30)         TYPE c  VALUE ‘FHK01_CCFCGD_CCN’,            “Customer Contact Name
*  lc_fk_ccp(8)          TYPE c  VALUE ‘FHK01_CCFCGD_CCP’,        “Customer Contact Phone
*  lc_fk_f(8)            TYPE c  VALUE ‘FHK01_CCFCGD_F’,        “Fax
*  lc_fk_cg3(3)          TYPE c  VALUE ‘FHK01_CUSTOMER_GROUP_3’, “Customer Group 1
*  lc_fk_cg4(3)          TYPE c  VALUE ‘FHK01_CUSTOMER_GROUP_4’,      “Customer Group 2
*  lc_fk_sgsg(30)        TYPE c  VALUE ‘FHK01_CCFCGD_SGSG’, “Ship-to-Group
*  lc_fk_cce(50)         TYPE c  VALUE ‘FHK01_CCFCGD_CCE’,                “Email Address
*  lc_fk_ag(4)           TYPE c  VALUE ‘FHK01_CCFCGD_AG’,             “Account Group
*  lc_fk_st(20)          TYPE c  VALUE ‘FHK01_CCFCGD_ST’,        “Search Term
*  lc_fk_so(4)           TYPE c  VALUE ‘FHK01_CCFCGD_SO’,             “Sales Organization
*  lc_fk_dc(2)           TYPE c  VALUE ‘FHK01_CCFCGD_DC’,         “Distribution Channel
*  lc_fk_d(2)            TYPE c  VALUE ‘FHK01_CCFCGD_D’,            “Division
*  lc_fk_ck(3)           TYPE c  VALUE ‘FHK01_CCFCGD_CK’,            “Country Key
*  lc_fk_sof(4)          TYPE c  VALUE ‘FHK01_CCFCGD_SOF’,            “Sales Office
*  lc_fk_ab(2)           TYPE c  VALUE ‘FHK01_CCFCGD_AB’,            “Areas Block
lc_fk_stc2            TYPE string  VALUE ‘FHK01_CCFCGD_STC2’,         “Sold-to Code
lc_fk_cn              TYPE string  VALUE ‘FHK01_CCFCGD_CN’,            “Ship-to Code
lc_fk_cna             TYPE string  VALUE ‘FHK01_CCFCGD_CNA’,           “Ship-to Name
lc_fk_a               TYPE string  VALUE ‘FHK01_CCFCGD_A’,        “Address
lc_fk_a2              TYPE string  VALUE ‘FHK01_CCFCGD_A2’,        “Address 2
lc_fk_a3              TYPE string  VALUE ‘FHK01_CCFCGD_A3’,      “Address 3
lc_fk_ccn             TYPE string  VALUE ‘FHK01_CCFCGD_CCN’,            “Customer Contact Name
lc_fk_ccp             TYPE string  VALUE ‘FHK01_CCFCGD_CCP’,        “Customer Contact Phone
lc_fk_f               TYPE string  VALUE ‘FHK01_CCFCGD_F’,        “Fax
lc_fk_cg3             TYPE string  VALUE ‘FHK01_CUSTOMER_GROUP_3’“Customer Group 1
lc_fk_cg4             TYPE string  VALUE ‘FHK01_CUSTOMER_GROUP_4’,      “Customer Group 2
lc_fk_sgsg            TYPE string  VALUE ‘FHK01_CCFCGD_SGSG’“Ship-to-Group
lc_fk_cce             TYPE string  VALUE ‘FHK01_CCFCGD_CCE’,                “Email Address
lc_fk_ag              TYPE string  VALUE ‘FHK01_CCFCGD_AG’,             “Account Group
lc_fk_st              TYPE string  VALUE ‘FHK01_CCFCGD_ST’,        “Search Term
lc_fk_so              TYPE string  VALUE ‘FHK01_CCFCGD_SO’,             “Sales Organization
lc_fk_dc              TYPE string  VALUE ‘FHK01_CCFCGD_DC’,         “Distribution Channel
lc_fk_d               TYPE string  VALUE ‘FHK01_CCFCGD_D’,            “Division
lc_fk_ck              TYPE string  VALUE ‘FHK01_CCFCGD_CK’,            “Country Key
lc_fk_sof             TYPE string  VALUE ‘FHK01_CCFCGD_SOF’,            “Sales Office
lc_fk_ab              TYPE string  VALUE ‘FHK01_CCFCGD_AB’,            “Areas Block
lc_fk_cc              TYPE string  VALUE ‘FHK01_CCFCGD_CC’,            “Areas Block
lc_rec_acct           TYPE string VALUE ‘10202200’” Reconciliation account in KNB1-AKONT
lc_tax_class          TYPE string VALUE ‘0’” Tax classification in KNVI-TAXKD
lc_tax_type           TYPE string VALUE ‘MWST’” Tax ‘category

*   Business Data
lc_fkhk_ship_to_group TYPE parvw VALUE ‘ZX’.

 

*———————————————————————-*
* Types
*———————————————————————-*
TYPESBEGIN OF ty_cust_in,
kunnr               TYPE kna1kunnr,
fk_sold_to_code     TYPE adrcsort2,
fk_ship_to_code     TYPE kna1sortl,
fk_ship_to_name     TYPE kna1name1,
fk_address          TYPE kna1stras,
fk_address2         TYPE adrcstr_suppl1,
fk_address3         TYPE adrcstr_suppl2,
fk_cust_contra_name TYPE kna1name2,
fk_cust_contact_tel TYPE kna1telf1,
fk_fax              TYPE kna1telfx,
fk_cust_grp1        TYPE knvvkvgr1,
fk_cust_grp2        TYPE knvvkvgr2,
fk_ship_to_grp      TYPE knvpparvw,
fk_search_term      TYPE adrcsort1,
*         fk_email_addr       TYPE kna1-zemail,
fk_account_grp      TYPE kna1ktokd,
fk_sales_org        TYPE knvvvkorg,
fk_distr_channel    TYPE knvvvtweg,
fk_division         TYPE knvvspart,
fk_country_key      TYPE kna1land1,
fk_sales_office     TYPE knvvvkbur,
fk_areas_block      TYPE knvvaufsd,
fk_company_code     TYPE knb1bukrs,
END OF ty_cust_in.

TYPESBEGIN OF ty_cust_out,
fk_ship_to_code     TYPE kna1sortl,
fk_ship_to_name     TYPE kna1name1,
fk_address          TYPE kna1stras,
fk_cust_contra_name TYPE kna1name2,
fk_cust_contact_tel TYPE kna1telf1,
fk_fax              TYPE kna1telfx,
fk_cust_grp1        TYPE knvvkvgr1,
fk_cust_grp2        TYPE knvvkvgr2,
fk_ship_to_grp      TYPE knvpparvw,
*         fk_email_addr       TYPE kna1-zemail,
fk_account_grp      TYPE kna1ktokd,
fk_sales_org        TYPE knvvvkorg,
fk_distr_channel    TYPE knvvvtweg,
fk_division         TYPE knvvspart,
fk_country_key      TYPE kna1land1,
fk_sales_office     TYPE knvvvkbur,
fk_areas_block      TYPE knvvaufsd,
fk_company_code     TYPE knb1bukrs,
status              TYPE c,
message             TYPE string,
END OF ty_cust_out.

 

 

*———————————————————————-*
* Data and define
*———————————————————————-*
DATA:
lt_cust_in    TYPE STANDARD TABLE OF ty_cust_in,
ls_cust_in    TYPE ty_cust_in,
lt_cust_out   TYPE STANDARD TABLE OF ty_cust_out,
ls_cust_out   TYPE ty_cust_out,
lr_parvw      TYPE RANGE OF parvw,
ls_e1kna1m    TYPE e1kna1m,
ls_e1knvvm    TYPE e1knvvm,
ls_e1knvim    TYPE e1knvim,
ls_e1knvpm    TYPE e1knvpm,
ls_e1knkkm    TYPE e1knkkm,
ls_e1knb1m    TYPE e1knb1m,
ls_e1bpad1vl  TYPE e1bpad1vl,
ls_e1bpadsmtp TYPE e1bpadsmtp.

DATA:
lt_idoc_contrl_cust        TYPE STANDARD TABLE OF edidc,
ls_idoc_contrl_cust        LIKE LINE OF lt_idoc_contrl_cust,
lt_idoc_data_cust          TYPE STANDARD TABLE OF edidd,
ls_idoc_data_cust          LIKE LINE OF lt_idoc_data_cust,
lt_idoc_status_cust        TYPE STANDARD TABLE OF bdidocstat,
ls_idoc_status_cust        LIKE LINE OF lt_idoc_status_cust,
lt_return_variables_cust   TYPE STANDARD TABLE OF bdwfretvar,
ls_return_variables_cust   LIKE LINE OF lt_return_variables_cust,
lt_serialization_info_cust TYPE STANDARD TABLE OF bdi_ser,
ls_serialization_info_cust LIKE LINE OF lt_serialization_info_cust.
DATA lv_index TYPE i.
CLEAR lv_index.

*  IF ls_xml-cname = c_index.
*    IF ls_xml-cvalue NE ‘1’ AND lv_flag = ‘X’.
*      APPEND ls_in TO lt_in.
*      CLEAR ls_in.
*    ELSE.
*      CLEAR ls_in.
*    ENDIF.
*  ENDIF.

ls_cust_infk_sold_to_code ‘ZZZ’” Not handled
ls_cust_infk_ship_to_code ‘ZZZ’” Not handled
ls_cust_infk_ship_to_name ‘asdf’” Not handled
ls_cust_infk_address ‘ADD’” Not handled
ls_cust_infk_address2 ‘ADDD2’” Not handled
ls_cust_infk_address3 ‘ADD3’” Not handled
ls_cust_infk_cust_contra_name ‘sdfafds’” Not handled
ls_cust_infk_cust_contact_tel ” Not handled
ls_cust_infk_fax ” Not handled
ls_cust_infk_cust_grp1 ’10’” Not handled
ls_cust_infk_cust_grp2 ” Not handled
ls_cust_infk_ship_to_grp ‘0003’” Not handled
ls_cust_infk_search_term ‘XXX’” Not handled
*  ls_cust_in-fk_email_addr = ”. ” Not handled
ls_cust_infk_account_grp ‘6000’” KTOKD
ls_cust_infk_sales_org ” Not handled
ls_cust_infk_distr_channel ” Not handled
ls_cust_infk_division ” Not handled
ls_cust_infk_country_key ‘CN’” Not handled
ls_cust_infk_sales_office ” Not handled
ls_cust_infk_areas_block ” Not handled
ls_cust_infk_company_code ” Not handled
lr_parvw VALUE #(   “( low = ‘SP’ )
low ‘BP’ )
low ‘PY’ )  low ‘SH’ )  ” ( low = lc_fkhk_ship_to_group )
).

APPEND ls_cust_in TO lt_cust_in.

LOOP AT lt_cust_in INTO ls_cust_in.
“SEND IDOC
CLEAR:
lt_idoc_contrl_cust,
lt_idoc_data_cust,
lt_idoc_status_cust,
lt_return_variables_cust,
lt_serialization_info_cust.

IF ls_cust_infk_sales_org IS NOT INITIAL AND
ls_cust_infk_distr_channel IS NOT INITIAL AND
ls_cust_infk_division IS NOT INITIAL AND
ls_cust_infk_ship_to_code IS NOT INITIAL.
SELECT SINGLE kunnr
FROM knvv
INTO ls_cust_inkunnr
WHERE vkorg ls_cust_infk_sales_org
AND vtweg ls_cust_infk_distr_channel
AND spart ls_cust_infk_division
AND eikto ls_cust_infk_ship_to_code.
ENDIF.

 

 

“CONTROL DATA  RBDMIDOC
ls_idoc_contrl_custmestyp ‘DEBMAS’.
ls_idoc_contrl_custidoctp ‘DEBMAS07’.
*  ls_idoc_contrl_cust-mestyp = ‘DEBMDM’.
*  ls_idoc_contrl_cust-idoctp = ‘DEBMDM06’.
ls_idoc_contrl_custsndprt ‘LS’.
CONCATENATE sysysid symandt INTO ls_idoc_contrl_custsndprn.
CONCATENATE sysysid symandt INTO ls_idoc_contrl_custrcvprn.
ls_idoc_contrl_custrcvprt ‘LS’.
APPEND ls_idoc_contrl_cust TO lt_idoc_contrl_cust.
CLEARls_idoc_contrl_cust.

“Master customer master basic data
ls_idoc_data_custsegnam ‘E1KNA1M’.
ls_idoc_data_custdtint2 0.
*  ls_e1kna1m-kunnr = ‘0000008998’.
ls_e1kna1msortl ‘sortl’.  “ls_cust_in-fk_ship_to_code.
ls_e1kna1mname1 ‘NAME1-WWW.HOT583.COM’“ls_cust_in-fk_ship_to_name.
ls_e1kna1mstras ls_cust_infk_address.
ls_e1kna1mname2 ‘name2’“ls_cust_in-fk_cust_contra_name.
ls_e1kna1mtelf1 ls_cust_infk_cust_contact_tel.
ls_e1kna1mtelfx ls_cust_infk_fax.
*  ls_e1kna1m-zemail = ls_cust_in-fk_email_addr.
ls_e1kna1mktokd ‘Z004’.  “ls_cust_in-fk_account_grp.
ls_e1kna1mland1 =  ‘CN’.” ls_cust_in-fk_country_key.
ls_e1kna1mspras ‘1’.
ls_idoc_data_custsdata ls_e1kna1m.
APPEND ls_idoc_data_cust TO lt_idoc_data_cust.
CLEARls_idoc_data_custls_e1kna1m.

“Master customer master sales data
ls_idoc_data_custsegnam ‘E1KNVVM’.
ls_idoc_data_custdtint2 0.
ls_e1knvvmkvgr1 ’10’.“ls_cust_in-fk_cust_grp1.
*  ls_e1knvvm-kvgr2 = ls_cust_in-fk_cust_grp2.

ls_e1knvvmvkorg ‘K001’   .“ls_cust_in-fk_sales_org.
ls_e1knvvmvtweg ’00’ .“ls_cust_in-fk_distr_channel.
ls_e1knvvmspart ’00’“ls_cust_in-fk_division.
ls_e1knvvmvkbur ‘2400’  .“ls_cust_in-fk_sales_office.
ls_e1knvvmaufsd .“ls_cust_in-fk_areas_block.
ls_e1knvvmkkber space“ls_cust_in-fk_sales_org.
ls_idoc_data_custsdata ls_e1knvvm.
*  APPEND ls_idoc_data_cust TO lt_idoc_data_cust.
CLEARls_idoc_data_custls_e1knvvm.

“Master customer master partner roles
*  BREAK-POINT.
*  LOOP AT lr_parvw ASSIGNING FIELD-SYMBOL(<fs>).
*    ls_idoc_data_cust-segnam = ‘E1KNVPM’.
*    ls_idoc_data_cust-dtint2 = 0.
*    ls_e1knvpm-parvw = <fs>-low.
*    ls_idoc_data_cust-sdata = ls_e1knvpm.
*    APPEND ls_idoc_data_cust TO lt_idoc_data_cust.
*    CLEAR: ls_idoc_data_cust, ls_e1knvpm.
*  ENDLOOP.

“Customer Master Company Code
ls_idoc_data_custsegnam ‘E1KNB1M’.
ls_idoc_data_custdtint2 0.
ls_e1knb1mbukrs ‘SH10’.“ls_cust_in-fk_company_code.
ls_e1knb1makont ‘0011220200’.“lc_rec_acct.
*    ls_e1knb1m-smtp_addr = ls_cust_in-fk_email_addr.
ls_idoc_data_custsdata ls_e1knb1m.
*  APPEND ls_idoc_data_cust TO lt_idoc_data_cust.
CLEARls_idoc_data_custls_e1knb1m.

“Customer Master accounting
ls_idoc_data_custsegnam ‘E1KNVIM’.
ls_idoc_data_custdtint2 0.
ls_e1knvimtaxkd ‘1’.“lc_tax_class.
ls_e1knvimaland ‘CN’ .“ls_cust_in-fk_country_key.
ls_e1knvimtatyp =  ‘MWST’.” lc_tax_type.
ls_idoc_data_custsdata ls_e1knvim.
*  APPEND ls_idoc_data_cust TO lt_idoc_data_cust.
CLEARls_idoc_data_custls_e1knvim.

“Customer Credit Control Area (  for testing as error message towards to KKBER )
ls_idoc_data_custsegnam ‘E1KNKKM’.
ls_idoc_data_custdtint2 0.
ls_e1knkkmkkber ls_cust_infk_sales_org.
ls_idoc_data_custsdata ls_e1knkkm.
*  APPEND ls_idoc_data_cust TO lt_idoc_data_cust.
CLEARls_idoc_data_custls_e1knkkm.

*  “Address
*  ls_idoc_data_cust-segnam = ‘E1BPAD1VL’.
*  ls_idoc_data_cust-dtint2 = 0.
*  ls_e1bpad1vl-sort1 = ls_cust_in-fk_search_term.
*  ls_e1bpad1vl-sort2 = ls_cust_in-fk_sold_to_code.
*  ls_e1bpad1vl-str_suppl1 = ls_cust_in-fk_address2.
*  ls_e1bpad1vl-str_suppl2 = ls_cust_in-fk_address3.
*  ls_idoc_data_cust-sdata = ls_e1bpad1vl.
*  APPEND ls_idoc_data_cust TO lt_idoc_data_cust.
*  CLEAR: ls_idoc_data_cust, ls_e1bpad1vl.
*
*  “E-Mail Addresses
*  ls_idoc_data_cust-segnam = ‘E1BPADSMTP’.
*  ls_idoc_data_cust-dtint2 = 0.
*  ls_e1bpadsmtp-e_mail = ls_cust_in-fk_email_addr.
*  ls_idoc_data_cust-sdata = ls_e1bpadsmtp.
*  APPEND ls_idoc_data_cust TO lt_idoc_data_cust.
*  CLEAR: ls_idoc_data_cust, ls_e1bpadsmtp.

BREAK-POINT.
CALL FUNCTION ‘IDOC_INPUT_DEBITOR’
*  CALL FUNCTION ‘IDOC_INPUT_DEBITOR_MDM’
EXPORTING
input_method          space
mass_processing       space
TABLES
idoc_contrl           lt_idoc_contrl_cust
idoc_data             lt_idoc_data_cust
idoc_status           lt_idoc_status_cust
return_variables      lt_return_variables_cust
serialization_info    lt_serialization_info_cust
EXCEPTIONS
wrong_function_called 1
OTHERS                2.

BREAK-POINT.
IF sysubrc <> 0.
*   Implement suitable error handling here
ENDIF.

*———————————————————————-*
* Prepare Result file
*———————————————————————-*
MOVE-CORRESPONDING ls_cust_in TO ls_cust_out.

LOOP AT lt_idoc_status_cust INTO ls_idoc_status_cust WHERE msgty ‘E’ OR msgty ‘A’.
ENDLOOP.

IF sysubrc 0.
ls_cust_outstatus ‘F’.
ls_cust_outmessage ‘Customer create fail’.
ELSE.
ls_cust_outstatus ‘S’.
ENDIF.

APPEND ls_cust_out TO lt_cust_out.
CLEAR ls_cust_out.

ENDLOOP.

本文链接:http://www.hot583.com/2022/03/16/debmas07-no-return-status-message/

本文为作者原创,如果这篇文章对您有用,欢迎转载,

转载请务必注明来源《今日热点在看》http://www.hot583.com/

我的微信公众号hot583或者在这个链接联系我

《全文完》