Demo银行主数据的修改
Posted SAP剑客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Demo银行主数据的修改相关的知识,希望对你有一定的参考价值。
测试源码:
REPORT ZTEST_BANK_MASTER.
PARAMETERS : P_BANKS TYPE BNKA-BANKS OBLIGATORY DEFAULT 'CN'.
PARAMETERS : P_BANKL TYPE BNKA-BANKL OBLIGATORY.
START-OF-SELECTION.
*** 判断银行代码是否存在
DATA : LW_BNKA TYPE BNKA.
SELECT SINGLE * FROM BNKA
INTO LW_BNKA
WHERE BANKS = P_BANKS
AND BANKL = P_BANKL.
IF SY-SUBRC = 0.
"已经存在银行代码,更新
PERFORM UPDATE_BNKA.
ELSE.
"还未存在银行代码,新建
PERFORM CREATE_BNKA.
ENDIF.
*&---------------------------------------------------------------------*
*& Form UPDATE_BNKA
*&---------------------------------------------------------------------*
* FI02 - 更改
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPDATE_BNKA .
DATA : BANKCOUNTRY LIKE BAPI1011_KEY-BANK_CTRY,
BANKKEY LIKE BAPI1011_KEY-BANK_KEY,
BANK_ADDRESS LIKE BAPI1011_ADDRESS,
BANK_ADDRESSX LIKE BAPI1011_ADDRESSX,
RETURN LIKE BAPIRET2,
LV_MESSG TYPE STRING.
BANKCOUNTRY = P_BANKS.
BANKKEY = '402857000100'."P_BANKL.
BANK_ADDRESS-BANK_NAME = '青海果洛农村商业银行股份有限公司玛沁支行'.
BANK_ADDRESSX-BANK_NAME = 'X'.
* BANK_ADDRESS-REGION = '190'.
* BANK_ADDRESSX-REGION = 'X'.
CALL FUNCTION 'BAPI_BANK_CHANGE'
EXPORTING
BANKCOUNTRY = BANKCOUNTRY
BANKKEY = BANKKEY
BANK_ADDRESS = BANK_ADDRESS
BANK_ADDRESSX = BANK_ADDRESSX
* BANK_DETAIL =
* BANK_DETAILX =
* BANK_ADDRESS1 =
* BANK_ADDRESS1X =
* I_CHECK_BEFORE_SAVE =
IMPORTING
RETURN = RETURN.
IF RETURN-TYPE = 'E' OR RETURN-TYPE = 'A' .
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
MSGID = RETURN-ID
MSGNR = RETURN-NUMBER
MSGV1 = RETURN-MESSAGE_V1
MSGV2 = RETURN-MESSAGE_V2
MSGV3 = RETURN-MESSAGE_V3
MSGV4 = RETURN-MESSAGE_V4
IMPORTING
MESSAGE_TEXT_OUTPUT = LV_MESSG.
WRITE : / LV_MESSG.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
WRITE : / '银行主数据修改成功:',BANKKEY.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CREATE_BNKA
*&---------------------------------------------------------------------*
* FI01 - 创建
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CREATE_BNKA .
DATA:BANK_CTRY TYPE BANKS,
BANK_ADDRESS TYPE BAPI1011_ADDRESS,
BANK_KEY TYPE BANKK,
RETURN TYPE BAPIRET2,
LV_MESSG TYPE STRING.
BANK_CTRY = P_BANKS."'CN'.
BANK_KEY = P_BANKL."'40285700010'.
BANK_ADDRESS-BANK_NAME = '青海果洛农村商业银行股份有限公司玛多花石峡支行'.
* BANK_ADDRESS-BANK_BRANCH = 'BANK_BRANCH'.
* BANK_ADDRESS-REGION = '190'.
CALL FUNCTION 'BAPI_BANK_CREATE'
EXPORTING
BANK_CTRY = BANK_CTRY
BANK_KEY = BANK_KEY
BANK_ADDRESS = BANK_ADDRESS
* BANK_METHOD =
* BANK_FORMATTING =
* BANK_ADDRESS1 =
* I_XUPDATE = 'X'
* I_CHECK_BEFORE_SAVE =
* BANK_IBAN_RULE =
* BANK_B2B_SUPPORTED =
* BANK_COR1_SUPPORTED =
* BANK_R_TRANSACTION_SUPPORTED =
IMPORTING
RETURN = RETURN
* BANKCOUNTRY =
BANKKEY = BANK_KEY.
IF BANK_KEY IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
WRITE : / '银行主数据创建成功:',BANK_KEY.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
IF RETURN-TYPE = 'E' OR RETURN-TYPE = 'A' .
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
MSGID = RETURN-ID
MSGNR = RETURN-NUMBER
MSGV1 = RETURN-MESSAGE_V1
MSGV2 = RETURN-MESSAGE_V2
MSGV3 = RETURN-MESSAGE_V3
MSGV4 = RETURN-MESSAGE_V4
IMPORTING
MESSAGE_TEXT_OUTPUT = LV_MESSG.
ENDIF.
WRITE : / LV_MESSG.
ENDIF.
ENDFORM.
以上是关于Demo银行主数据的修改的主要内容,如果未能解决你的问题,请参考以下文章