初步判断原因, bp同步是 以修改的模式发送到crm后,crm不存在该bp 所以报 guid不存在的错误。
解决方法: 609766提供的方案太麻烦,最简单的方法:在CRM建一个相同号码的bp,然后将but000里的partner_guid改成和ECC的一样,再去ECC抽下数据就行了。
解决方法: 参考 note 步骤1, crm端新建一个相同编号的bp
2, crm开发一个报表 , ECC开发一个rfc函数Z_REPAIR_CRMKUNNR
3, 执行报表 Z_REPAIR_CRMKUNNR
4, R3AR4 把这个bp信息传到crm
*&---------------------------------------------------------------------*
*& Report Z_CHECK_BP_GUID *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT z_check_bp_guid .
TABLES: crmm_but_custno, but000.
TYPES: BEGIN OF ty_but000 ,
partner LIKE but000-partner,
partner_guid LIKE but000-partner_guid,
END OF ty_but000 .
TYPES: BEGIN OF ty_crmkunnr ,
client TYPE mandt,
custome_no TYPE kunnr,
partn_guid TYPE sychar32,
END OF ty_crmkunnr .
DATA: lv_partner LIKE but000-partner,
lv_partner_guid LIKE but000-partner_guid,
BEGIN OF lt_korr OCCURS 1,
partner LIKE but000-partner,
guid1 LIKE but000-partner_guid,
guid2 LIKE but000-partner_guid,
END OF lt_korr,
lt_crmm_but_custno TYPE TABLE OF crmm_but_custno,
ls_crmm_but_custno TYPE crmm_but_custno.
DATA: lt_smoferpsh LIKE smof_erpsh OCCURS 1 WITH HEADER LINE,
ls_smoferpsh TYPE smof_erpsh,
lt_but000 TYPE TABLE OF ty_but000,
ls_but000 TYPE ty_but000,
lt_crmkunnr TYPE TABLE OF ty_crmkunnr,
ls_crmkunnr TYPE ty_crmkunnr.
***********************************************************************
SELECT-OPTIONS: s_kunnr FOR crmm_but_custno-customer_no.
PARAMETERS: p_test LIKE boole-boole DEFAULT 'X'.
START-OF-SELECTION .
REFRESH: lt_but000,lt_korr,lt_crmm_but_custno .
SELECT partner partner_guid
INTO CORRESPONDING FIELDS OF TABLE lt_but000
FROM but000
WHERE partner IN s_kunnr.
SELECT * INTO TABLE lt_crmm_but_custno
FROM crmm_but_custno
WHERE customer_no IN s_kunnr.
SORT lt_but000 BY partner .
SORT lt_crmm_but_custno BY customer_no .
CLEAR: ls_but000 .
LOOP AT lt_but000 INTO ls_but000 .
CLEAR: ls_crmm_but_custno .
READ TABLE lt_crmm_but_custno INTO ls_crmm_but_custno
WITH KEY customer_no = ls_but000-partner .
IF ls_but000-partner_guid <> ls_crmm_but_custno-partner_guid. "取出guid不相同的bp
lt_korr-partner = ls_but000-partner.
lt_korr-guid1 = ls_but000-partner_guid.
lt_korr-guid2 = ls_crmm_but_custno-partner_guid.
APPEND lt_korr. CLEAR lt_korr .
ENDIF.
ls_crmkunnr-custome_no = ls_but000-partner.
ls_crmkunnr-partn_guid = ls_but000-partner_guid.
APPEND ls_crmkunnr TO lt_crmkunnr . CLEAR ls_crmkunnr .
ENDLOOP.
SORT lt_korr BY partner .
CLEAR: ls_crmm_but_custno .
LOOP AT lt_crmm_but_custno INTO ls_crmm_but_custno.
READ TABLE lt_korr WITH KEY partner = ls_crmm_but_custno-customer_no .
IF sy-subrc <> 0. " 取出正确的bp
DELETE lt_crmm_but_custno .
ENDIF.
ENDLOOP.
IF p_test IS INITIAL .
IF lt_crmm_but_custno[] IS NOT INITIAL .
DELETE crmm_but_custno FROM TABLE lt_crmm_but_custno .
COMMIT WORK AND WAIT .
ENDIF.
REFRESH lt_crmm_but_custno .
LOOP AT lt_korr.
ls_crmm_but_custno-customer_no = lt_korr-partner.
ls_crmm_but_custno-partner_guid = lt_korr-guid1.
APPEND ls_crmm_but_custno TO lt_crmm_but_custno.
ENDLOOP.
IF lt_crmm_but_custno[] IS NOT INITIAL .
MODIFY crmm_but_custno FROM TABLE lt_crmm_but_custno .
COMMIT WORK AND WAIT .
ENDIF.
ENDIF.
IF lt_crmkunnr[] IS NOT INITIAL .
* repair crmkunnr in R/3
REFRESH lt_smoferpsh . CLEAR ls_smoferpsh .
CALL FUNCTION 'SMOF_READ_SMOFERPSH'
EXPORTING
i_sitetypeid = 'SMOF_ERPSITE'
TABLES
t_erpsites = lt_smoferpsh.
READ TABLE lt_smoferpsh INTO ls_smoferpsh INDEX 1.
IF ls_smoferpsh-rfcdest = space.
WRITE /01 'ECC连接不通'.
EXIT.
ENDIF.
CALL FUNCTION 'Z_REPAIR_CRMKUNNR'
DESTINATION ls_smoferpsh-rfcdest
EXPORTING
iv_test_mode = p_test
TABLES
t_crmm_but_custno = lt_crmkunnr
EXCEPTIONS
system_failure = 1
communication_failure = 2
OTHERS = 3.
ENDIF.
WRITE: /01 'CRM端'.
LOOP AT lt_korr.
WRITE: /01 'BP编号', lt_korr-partner, '正确GUID', lt_korr-guid1,
'错误GUID', lt_korr-guid2.
ENDLOOP.
SKIP .
WRITE: /01 'ECC端'.
LOOP AT lt_crmkunnr INTO ls_crmkunnr.
WRITE: /01 'BP编号', ls_crmkunnr-custome_no, '正确GUID', ls_crmkunnr-partn_guid.
ENDLOOP.
FUNCTION z_repair_crmkunnr.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(IV_TEST_MODE) LIKE BOOLE-BOOLE OPTIONAL
*" TABLES
*" T_CRMM_BUT_CUSTNO STRUCTURE CRMKUNNR
*"----------------------------------------------------------------------
TABLES: crmkunnr.
DATA: lt_crmkunnr TYPE TABLE OF crmkunnr,
ls_crmkunnr TYPE crmkunnr,
lt_crmkunnr_u TYPE TABLE OF crmkunnr.
**********************************************************************
CHECK t_crmm_but_custno[] IS NOT INITIAL .
REFRESH: lt_crmkunnr,lt_crmkunnr_u .
SELECT * INTO TABLE lt_crmkunnr
FROM crmkunnr
FOR ALL ENTRIES IN t_crmm_but_custno
WHERE custome_no EQ t_crmm_but_custno-custome_no .
SORT lt_crmkunnr BY custome_no .
LOOP AT t_crmm_but_custno.
CLEAR ls_crmkunnr .
READ TABLE lt_crmkunnr INTO ls_crmkunnr
WITH KEY custome_no = t_crmm_but_custno-custome_no .
IF sy-subrc = 0.
IF ls_crmkunnr-partn_guid = t_crmm_but_custno-partn_guid.
* nothing to repair
DELETE t_crmm_but_custno.
CONTINUE .
ELSE.
* if guid does already exist with other customer number, delete
IF iv_test_mode IS INITIAL.
DELETE FROM crmkunnr
WHERE custome_no = t_crmm_but_custno-custome_no.
ENDIF.
ls_crmkunnr-client = sy-mandt.
ls_crmkunnr-custome_no = t_crmm_but_custno-custome_no.
ls_crmkunnr-partn_guid = t_crmm_but_custno-partn_guid.
APPEND ls_crmkunnr TO lt_crmkunnr_u .
ENDIF.
ELSE.
* This means CUSTOMER NUMBER doesnot exist in CRMKUNNR.
ls_crmkunnr-client = sy-mandt.
ls_crmkunnr-custome_no = t_crmm_but_custno-custome_no.
ls_crmkunnr-partn_guid = t_crmm_but_custno-partn_guid.
APPEND ls_crmkunnr TO lt_crmkunnr_u .
ENDIF.
ENDLOOP.
CHECK lt_crmkunnr_u[] IS NOT INITIAL AND iv_test_mode IS INITIAL .
MODIFY crmkunnr FROM TABLE lt_crmkunnr_u .
COMMIT WORK AND WAIT .
ENDFUNCTION.
阅读(1450) | 评论(0) | 转发(0) |