翻到之前写的测试代码,记录一下,用于创建DN的同时就进行批次拆分,不需要再调用变更的BAPI再去修改一次。
REPORT ZTEST_VL31N_BATCH_SPLIT.DATA:GS_VBSK_I TYPE VBSK, "構造:販売伝票ヘッダINGS_VBSK_E TYPE VBSK, "構造:販売伝票ヘッダOUTGS_BORGR_CT TYPE BORGR_CONTROL, "構造:GN_DELIVERY_CREATE の管理区分GT_XKOMDLGN TYPE STANDARD TABLE OF KOMDLGN, "T:明細GS_XKOMDLGN TYPE KOMDLGN, "構造:明細GT_PARTNER TYPE STANDARD TABLE OF PARTNER_GN,GS_PARTNER TYPE PARTNER_GN,GT_ADDRESS TYPE STANDARD TABLE OF BAPIADDR1,GS_ADDRESS TYPE BAPIADDR1,GT_XVBFS TYPE STANDARD TABLE OF VBFS, "T:一括処理用エラーログGS_XVBFS TYPE VBFS, "構造:一括処理用エラーログGT_XVBLS TYPE STANDARD TABLE OF VBLS, "T:一括処理用納品書GS_XVBLS TYPE VBLS, "構造:一括処理用納品書GS_ADDR_SEL TYPE ADDR1_SEL,GS_ADDR_VALUE TYPE ADDR1_VAL.* 抬头数据GS_BORGR_CT-SAVE_TEXTS = ABAP_TRUE. "グループタイプGS_VBSK_I-MANDT = SY-MANDT. "クライアントGS_VBSK_I-ERNAM = SY-UNAME. "オブジェクト登録者名GS_VBSK_I-ERDAT = SY-DATUM. "レコード登録日GS_VBSK_I-UZEIT = SY-UZEIT. "時刻
* GS_VBSK_I-VSTEL = '100B'. "装运点GS_VBSK_I-PROGRAMM = SY-REPID.GS_VBSK_I-SELSET = SY-SLSET.GS_VBSK_I-BATCH = SY-BATCH.GS_VBSK_I-SMART = 'L'. "グループタイプ* 内部番号割当の番号範囲取得SELECT SINGLE NUMKIINTO @DATA(GV_NUMKI) "変数:内部番号割当の番号範囲FROM TVSAWHERE SMART = @GS_VBSK_I-SMART. "グループタイプ* NUmber range: Assigns next free numberCALL FUNCTION 'NUMBER_GET_NEXT'EXPORTINGNR_RANGE_NR = GV_NUMKI "変数:内部番号割当の番号範囲OBJECT = 'RV_SAMMG' "番号範囲オブジェクト名
* QUANTITY = '1'
* SUBOBJECT = ' '
* TOYEAR = '0000'
* IGNORE_BUFFER = ' 'IMPORTINGNUMBER = GS_VBSK_I-SAMMG "グループタイプ
* QUANTITY =
* RETURNCODE =EXCEPTIONSINTERVAL_NOT_FOUND = 1NUMBER_RANGE_NOT_INTERN = 2OBJECT_NOT_FOUND = 3QUANTITY_IS_0 = 4QUANTITY_IS_NOT_1 = 5INTERVAL_OVERFLOW = 6BUFFER_OVERFLOW = 7OTHERS = 8.* 取得できなかた場合IF SY-SUBRC <> 0.ASSERT 0 = 0.ENDIF.* GS_XKOMDLGN-POSNR = '000010'.GS_XKOMDLGN-SPE_POSNR = '000010'.GS_XKOMDLGN-LIFNR = '5000000000'.GS_XKOMDLGN-LFIMG = '0'.GS_XKOMDLGN-KCMENG = '50'.GS_XKOMDLGN-MATNR = '000000010000000047'.GS_XKOMDLGN-EMATN = '000000010000000047'.GS_XKOMDLGN-PSTYV = 'ELN'.GS_XKOMDLGN-BLDAT = SY-DATUM.GS_XKOMDLGN-WERKS = '100B'.GS_XKOMDLGN-LGORT = 'JA06'.GS_XKOMDLGN-MTART = 'Z001'.GS_XKOMDLGN-VGBEL = '4100002508'. "参照伝票番号GS_XKOMDLGN-VGPOS = '000001'. "参照明細番号GS_XKOMDLGN-VGTYP = 'V'. "販売管理伝票カテゴリGS_XKOMDLGN-RFBEL = '4100002508'. "参照伝票番号GS_XKOMDLGN-RFPOS = '000001'. "参照明細番号GS_XKOMDLGN-LFART = 'EL'.GS_XKOMDLGN-AKMNG = 'A'.GS_XKOMDLGN-KZBEW = 'B'.GS_XKOMDLGN-LFDAT = SY-DATUM.GS_XKOMDLGN-VRKME = 'ST'.GS_XKOMDLGN-MEINS = 'ST'.GS_XKOMDLGN-KZAZU = 'X'. "受注結合区分GS_XKOMDLGN-XCHAR = 'X'. "GS_XKOMDLGN-XCHPF = 'X'. "APPEND GS_XKOMDLGN TO GT_XKOMDLGN.CLEAR GS_XKOMDLGN.* GS_XKOMDLGN-POSNR = '900001'.GS_XKOMDLGN-SPE_POSNR = '900001'.GS_XKOMDLGN-UECHA = '000010'.GS_XKOMDLGN-LIFNR = '5000000000'.GS_XKOMDLGN-LFIMG = '20'.GS_XKOMDLGN-LGMNG = '20'.GS_XKOMDLGN-CHARG = '90D128_80'.GS_XKOMDLGN-KCMENG = '0'.GS_XKOMDLGN-MATNR = '000000010000000047'.GS_XKOMDLGN-PSTYV = 'ELN'.GS_XKOMDLGN-BLDAT = SY-DATUM.GS_XKOMDLGN-WERKS = '100B'.GS_XKOMDLGN-LGORT = 'JA06'.GS_XKOMDLGN-MTART = 'Z001'.GS_XKOMDLGN-VGBEL = '4100002508'. "参照伝票番号GS_XKOMDLGN-VGPOS = '000001'. "参照明細番号GS_XKOMDLGN-VGTYP = 'V'. "販売管理伝票カテゴリGS_XKOMDLGN-RFBEL = '4100002508'. "参照伝票番号GS_XKOMDLGN-RFPOS = '000001'. "参照明細番号GS_XKOMDLGN-LFART = 'EL'.GS_XKOMDLGN-AKMNG = 'A'.GS_XKOMDLGN-KZBEW = 'B'.GS_XKOMDLGN-LFDAT = SY-DATUM.GS_XKOMDLGN-VRKME = 'ST'.GS_XKOMDLGN-MEINS = 'ST'.GS_XKOMDLGN-KZAZU = 'X'. "受注結合区分GS_XKOMDLGN-XCHAR = 'X'. "GS_XKOMDLGN-XCHPF = 'X'. "
* GS_XKOMDLGN-MFRGR = '02'. "便APPEND GS_XKOMDLGN TO GT_XKOMDLGN.GS_XKOMDLGN-SPE_POSNR = '900002'.GS_XKOMDLGN-UECHA = '000010'.GS_XKOMDLGN-LIFNR = '5000000000'.GS_XKOMDLGN-LFIMG = '30'.GS_XKOMDLGN-LGMNG = '30'.GS_XKOMDLGN-CHARG = '90D128_81'.GS_XKOMDLGN-KCMENG = '0'.GS_XKOMDLGN-MATNR = '000000010000000047'.GS_XKOMDLGN-PSTYV = 'ELN'.GS_XKOMDLGN-BLDAT = SY-DATUM.GS_XKOMDLGN-WERKS = '100B'.GS_XKOMDLGN-LGORT = 'JA06'.GS_XKOMDLGN-MTART = 'Z001'.GS_XKOMDLGN-VGBEL = '4100002508'. "参照伝票番号GS_XKOMDLGN-VGPOS = '000001'. "参照明細番号GS_XKOMDLGN-VGTYP = 'V'. "販売管理伝票カテゴリGS_XKOMDLGN-RFBEL = '4100002508'. "参照伝票番号GS_XKOMDLGN-RFPOS = '000001'. "参照明細番号GS_XKOMDLGN-LFART = 'EL'.GS_XKOMDLGN-AKMNG = 'A'.GS_XKOMDLGN-KZBEW = 'B'.GS_XKOMDLGN-LFDAT = SY-DATUM.GS_XKOMDLGN-VRKME = 'ST'.GS_XKOMDLGN-MEINS = 'ST'.GS_XKOMDLGN-KZAZU = 'X'. "受注結合区分GS_XKOMDLGN-XCHAR = 'X'. "GS_XKOMDLGN-XCHPF = 'X'. "
* GS_XKOMDLGN-MFRGR = '02'. "便APPEND GS_XKOMDLGN TO GT_XKOMDLGN.CALL FUNCTION 'GN_DELIVERY_CREATE'EXPORTINGVBSK_I = GS_VBSK_I
* NO_COMMIT = ' '
* IF_SYNCHRON = 'X'
* VBLS_POS_RUECK = ' '
* IF_CREATE_DEC = ' '
* IF_NO_DEQUE = ' '
* IT_HANDLING_UNITS =
* IF_QUAN_NO_CHECK =
* IF_MASS_READ_MAT_SW = ' '
* IS_DELIVERY_EXTEND =
* IS_CONTROL =IS_BORGR_CONTROL = GS_BORGR_CT
* IF_NO_INIT = ' '
* IF_NO_PARTNER_DIALOG = 'X'
* IF_CHECK_UOM = ' '
* IT_LECOMP =
* IF_CALL_ACTIVITY = ' 'IMPORTINGVBSK_E = GS_VBSK_E
* ET_SPLITPROT =
* ET_VBADR =
* ET_VBPA =TABLESXKOMDLGN = GT_XKOMDLGNXVBFS = GT_XVBFSXVBLS = GT_XVBLS
* XXLIPS =
* XVERKO =
* XVERPO =IT_GN_PARTNER = GT_PARTNER
* IT_GN_LIPSPO =
* IT_GN_LIPSRF =
* IT_GN_TEXTH =
* IT_GN_TEXTL =
* IT_GN_HUSERNR =
* IT_GN_SERNR =
* IT_TMSTMP =
* ET_SPE_VBFS =IT_BAPIADDR1 = GT_ADDRESS
* IT_GN_HU_HEADER_EPC =
* IT_GN_HU_ITEMS_EPC =
* IT_GN_HURES =.READ TABLE GT_XVBLS INTO GS_XVBLS INDEX 1.IF GS_XVBLS-VBELN_LIF IS NOT INITIAL.
* コミットCALL FUNCTION 'BAPI_TRANSACTION_COMMIT'EXPORTINGWAIT = ABAP_TRUE.WRITE GS_XVBLS-VBELN_LIF.ELSE.
* ロールバックCALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.DATA:LT_MESSAGE_TAB TYPE ESP1_MESSAGE_TAB_TYPE,LS_MESSAGE TYPE ESP1_MESSAGE_WA_TYPE.LOOP AT GT_XVBFS INTO GS_XVBFS.LS_MESSAGE-MSGID = GS_XVBFS-MSGID.LS_MESSAGE-MSGTY = GS_XVBFS-MSGTY.LS_MESSAGE-MSGNO = GS_XVBFS-MSGNO.LS_MESSAGE-MSGV1 = GS_XVBFS-MSGV1.LS_MESSAGE-MSGV2 = GS_XVBFS-MSGV2.LS_MESSAGE-MSGV3 = GS_XVBFS-MSGV3.LS_MESSAGE-MSGV4 = GS_XVBFS-MSGV4.LS_MESSAGE-LINENO = SY-TABIX.APPEND LS_MESSAGE TO LT_MESSAGE_TAB.ENDLOOP.CALL FUNCTION 'C14Z_MESSAGES_SHOW_AS_POPUP'TABLESI_MESSAGE_TAB = LT_MESSAGE_TAB.* CL_DEMO_OUTPUT=>DISPLAY( GT_XVBFS ).ENDIF.
以上。