SAP ABAP 更新BP银行数据

FUNCTION GROUP:BUBA_3
BAPI_BUPA_BANKDETAIL_CHANGE
BAPI_BUPA_BANKDETAIL_ADD

FORM frm_save_data_new .

FIELD-SYMBOLS: TYPE ty_data.
DATA:
ls_but0bk TYPE but0bk,
lv_bkvid TYPE but0bk-bkvid,
lv_type TYPE char1.

DATA: ls_bankdetail TYPE bapibus1006_bankdetail.
DATA: ls_bankdetail_x TYPE BAPIBUS1006_BANKDETAIL_X.
DATA: lt_return TYPE TABLE OF bapiret2.
DATA: ls_return TYPE bapiret2.

LOOP AT gt_data ASSIGNING WHERE led IS INITIAL.
CLEAR: lv_type,lt_return[],ls_bankdetail_x,ls_return.

  • 判断< 银行账号 + 参考明细 > 是否一样 --》 一样:
  • 判断账户收款人是否一样(如果一样,提示“已存在”,如果不一样,执行处理的时候修改账户收款人)
    READ TABLE gt_but0bk INTO ls_but0bk WITH KEY partner = -lifnr
    bankl = -bankl
    bankn = -bankn
    bkref = -bkref BINARY SEARCH.
    IF sy-subrc = 0.
    lv_type = ‘U’.
    ELSE.
    lv_type = ‘I’.
    ENDIF.
ls_bankdetail-bank_ctry = -banks.
ls_bankdetail-bank_key  = -bankl.
ls_bankdetail-bank_acct = -bankn.
ls_bankdetail-ctrl_key  = -bkont.
ls_bankdetail-bank_ref  = -bkref.
ls_bankdetail-accountholder = -koinh.
IF lv_type = 'I'.
  CALL FUNCTION 'BAPI_BUPA_BANKDETAIL_ADD'
      EXPORTING
        businesspartner       = -lifnr
        bankdetaildata        = ls_bankdetail
     TABLES
       return                = lt_return
              .
ELSE.
  ls_bankdetail_x-ctrl_key = abap_true.
  ls_bankdetail_x-accountholder = abap_true.
  CALL FUNCTION 'BAPI_BUPA_BANKDETAIL_CHANGE'
    EXPORTING
      businesspartner        = -lifnr
      bankdetailid           = ls_but0bk-bkvid
      bankdetaildata         = ls_bankdetail
      bankdetaildata_x         = ls_bankdetail_x
   TABLES
     return                 = lt_return
            .

ENDIF.

READ TABLE lt_return INTO ls_return INDEX 1.
IF sy-subrc = 0.

  MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number
   WITH ls_return-message_v1  ls_return-message_v2 ls_return-message_v3 ls_return-message_v4
   INTO -message.
  -led = 1.

  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

ELSE.
  -message = '修改成功'.
  -led = 3.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
   EXPORTING
     wait          = abap_true.

ENDIF.

ENDLOOP.

ENDFORM.

你可能感兴趣的:(SAP-ABAP,sap,sap,abap)