BAPI过账
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了BAPI过账相关的知识,希望对你有一定的参考价值。
REPORT ZWGX013.
* DATA LR_DOC TYPE REF TO CL_DOCUMENT.
* DATA LV_KEY TYPE BAPIACHE09-OBJ_KEY.
CLASS CL_DOCUMENT DEFINITION.
PUBLIC SECTION.
METHODS SET_HEAD
IMPORTING
HEADER_TXT TYPE BKTXT
COMP_CODE TYPE BUKRS
DOC_DATE TYPE DATS
PSTNG_DATE TYPE DATS
FISC_YEAR TYPE GJAHR
FIS_PERIOD TYPE MONAT.
METHODS ADD_ITEM
IMPORTING
ACCOUNT TYPE HKONT
TEXT TYPE SGTXT
CURRENCY TYPE WAERS
AMONT TYPE BAPIDOCCUR.
METHODS CHECK
RETURNING VALUE(FLAG) TYPE ABAP_BOOL.
METHODS POST
RETURNING VALUE(OBJKEY) TYPE BAPIACHE09-OBJ_KEY.
PRIVATE SECTION.
DATA HEADER TYPE BAPIACHE09."表头
DATA ITEMS TYPE TABLE OF BAPIACGL09.
DATA ITEM TYPE BAPIACGL09.
DATA CITEMS TYPE TABLE OF BAPIACCR09.
DATA CITEM TYPE BAPIACCR09.
DATA ITEMNO TYPE POSNR_ACC."会计凭证行项目编号
DATA RETURNS TYPE TABLE OF BAPIRET2."BAPIRET2返回参数
ENDCLASS.
CLASS CL_DOCUMENT IMPLEMENTATION.
METHOD SET_HEAD.
HEADER-USERNAME = SY-UNAME.
HEADER-COMP_CODE = COMP_CODE.
HEADER-HEADER_TXT = HEADER_TXT.
HEADER-DOC_DATE = DOC_DATE."DOC_DATE凭证中的凭证日期
HEADER-PSTNG_DATE = PSTNG_DATE."PSTNG_DATE凭证中的过帐日期
HEADER-DOC_TYPE = ‘SA‘."凭证类型
HEADER-FISC_YEAR = FISC_YEAR."财年
HEADER-FIS_PERIOD = FIS_PERIOD."会计期间
ITEMNO = 1.
ENDMETHOD.
METHOD ADD_ITEM.
DATA: ITEM TYPE BAPIACGL09."总账科项目
DATA: CITEM TYPE BAPIACCR09."货币项目
ITEM-ITEMNO_ACC = ITEMNO."ITEMNO_ACC会计凭证行项目编号
ITEM-GL_ACCOUNT = ACCOUNT."GL_ACCOUNT总账科目
ITEM-ITEM_TEXT = TEXT."ITEM_TEXT项目文本
APPEND ITEM TO ITEMS.
CLEAR ITEM.
CITEM-ITEMNO_ACC = ITEMNO.
CITEM-CURRENCY = CURRENCY.
CITEM-AMT_DOCCUR = AMONT.
APPEND CITEM TO CITEMS.
CLEAR CITEM.
ITEMNO = ITEMNO + 1.
ENDMETHOD.
METHOD CHECK.
CALL FUNCTION ‘BAPI_ACC_DOCUMENT_CHECK‘
EXPORTING
DOCUMENTHEADER = HEADER
* CUSTOMERCPD =
* CONTRACTHEADER =
TABLES
ACCOUNTGL = ITEMS
* ACCOUNTRECEIVABLE =
* ACCOUNTPAYABLE =
* ACCOUNTTAX =
CURRENCYAMOUNT = CITEMS
* CRITERIA =
* VALUEFIELD =
* EXTENSION1 =
RETURN = RETURNS
* PAYMENTCARD =
* CONTRACTITEM =
* EXTENSION2 =
* REALESTATE =
* ACCOUNTWT =
.
READ TABLE RETURNS WITH KEY TYPE = ‘E‘ TRANSPORTING NO FIELDS.
IF SY-SUBRC = 0.
FLAG = ABAP_FALSE.
ELSE.
FLAG = ABAP_TRUE.
ENDIF .
ENDMETHOD.
* DATA LV_KEY TYPE BAPIACHE09-OBJ_KEY.
METHOD POST.
CALL FUNCTION ‘BAPI_ACC_DOCUMENT_POST‘
EXPORTING
DOCUMENTHEADER = HEADER
* CUSTOMERCPD =
* CONTRACTHEADER =
IMPORTING ""没放开,DUMP
* OBJ_TYPE =
OBJ_KEY = OBJKEY" OBJ_KEY 字段参考关键
* OBJ_SYS =