Zcustomer Link Check Report
Zcustomer Link Check Report
Zcustomer Link Check Report
CLEAR: lv_msg,
lv_dbcnt,
ls_bp_customer_ids,
ls_entries_to_delete.
REFRESH lt_entries_to_delete.
DO.
CLEAR ls_bp_customer_ids.
REFRESH lt_bp_customer_ids.
REFRESH lt_but000.
REFRESH lt_kna1.
FETCH NEXT CURSOR db_customer INTO CORRESPONDING FIELDS OF TABLE
lt_bp_customer_ids
PACKAGE SIZE lc_pkg_size.
IF sy-subrc <> 0.
EXIT.
ELSE.
SELECT partner_guid FROM but000 INTO TABLE lt_but000 FOR ALL ENTRIES IN
lt_bp_customer_ids WHERE partner_guid = lt_bp_customer_ids-partner_guid.
SORT lt_but000 BY partner_guid.
SELECT kunnr FROM kna1 INTO TABLE lt_kna1 FOR ALL ENTRIES IN
lt_bp_customer_ids WHERE kunnr = lt_bp_customer_ids-customer.
SORT lt_kna1 BY kunnr.
IF sy-subrc <> 0.
ls_bp_customer_ids-del_flag = lc_x.
ELSE.
* clear lv_kunnr.
* select single kunnr FROM kna1
* INTO lv_kunnr
* WHERE kunnr = ls_bp_customer_ids-customer.
READ TABLE lt_kna1 WITH KEY kunnr = ls_bp_customer_ids-customer
TRANSPORTING NO FIELDS BINARY SEARCH.
IF sy-subrc <> 0.
ls_bp_customer_ids-del_flag = lc_x.
ENDIF.
ENDIF.
IF ls_bp_customer_ids-del_flag = lc_x.
CLEAR ls_entries_to_delete.
ls_entries_to_delete-partner_guid = ls_bp_customer_ids-partner_guid.
ls_entries_to_delete-customer = ls_bp_customer_ids-customer.
APPEND ls_entries_to_delete TO lt_entries_to_delete.
ENDIF.
ENDLOOP.
ENDIF.
ENDDO.
IF TESTMODE is INITIAL.
IF lt_entries_to_delete IS NOT INITIAL.
DELETE cvi_cust_link FROM TABLE lt_entries_to_delete.
WRITE : 'Non Test Run Mode'.
lv_dbcnt = sy-dbcnt.
lv_msg = text-002.
CONCATENATE lv_msg text-003 INTO lv_msg SEPARATED BY space.
CONCATENATE lv_msg lv_dbcnt INTO lv_msg SEPARATED BY space.
COMMIT WORK.
WRITE text-005.
NEW-LINE.
ULINE.
WRITE : 'Business partner GUID'.
WRITE :36 'Customer Number'.