FI 创建资产接口AS01
FUNCTION ZREIP_CREATE_AS01TSET.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(BUKRS) TYPE BUKRS
*" VALUE(ANLKL) TYPE BF_ANLKL
*" VALUE(DESCRIPT1) TYPE BF_TXA50
*" VALUE(DESCRIPT2) TYPE BAPI1022_TXA50_MORE
*" VALUE(SERIAL_NO) TYPE BF_AM_SERNR
*" VALUE(INVENT_NO) TYPE BF_INVNR_ANLA
*" VALUE(COSTCENTER) TYPE KOSTL
*" VALUE(DEP_KEY) TYPE BF_AFASL
*" VALUE(ULIFE_YRS) TYPE BF_NDJAR
*" VALUE(ULIFE_PRDS) TYPE BF_NDPER
*" VALUE(ODEP_START_DATE) TYPE BF_AFABG
*" EXPORTING
*" VALUE(LS_ASSET) TYPE BAPI1022_1-ASSETMAINO
*" VALUE(LS_MESSAGE) TYPE STRING
*"----------------------------------------------------------------------
* TCODE:AS01 BAPI_FIXEDASSET_CREATE1
*"----------------------------------------------------------------------
DATA:
LS_KEY TYPE BAPI1022_KEY,
LS_GENERAL_DATA TYPE BAPI1022_FEGLG001,
LS_GENERAL_DATA_X TYPE BAPI1022_FEGLG001X,
LS_TIME_DEPENDENT_DATA TYPE BAPI1022_FEGLG003,
LS_TIME_DEPENDENT_DATA_X TYPE BAPI1022_FEGLG003X.
***折旧范围
DATA:LT_DEPRECIATIONAREAS LIKE TABLE OF BAPI1022_DEP_AREAS ,
LS_EPRECIATIONAREAS LIKE LINE OF LT_DEPRECIATIONAREAS ,
LT_DEPRECIATIONAREASX LIKE TABLE OF BAPI1022_DEP_AREASX,
LS_DEPRECIATIONAREASX LIKE LINE OF LT_DEPRECIATIONAREASX.
"输出
DATA: LS_RETURN TYPE BAPIRET2.
***公司代码
LS_KEY-COMPANYCODE = BUKRS." 必输
***资产分类
LS_GENERAL_DATA-ASSETCLASS = ANLKL. "必输RF1004
LS_GENERAL_DATA_X-ASSETCLASS = 'X'."相关用户数据字段的已更新信息
***类似资产的编号 不能为空 大于1
*** 描述 描述2 序列号 存货号
LS_GENERAL_DATA-DESCRIPT = DESCRIPT1. "必输
LS_GENERAL_DATA_X-DESCRIPT = 'X'.
LS_GENERAL_DATA-DESCRIPT2 = DESCRIPT2."可选
LS_GENERAL_DATA_X-DESCRIPT2 = 'X'.
LS_GENERAL_DATA-SERIAL_NO = SERIAL_NO ."序列号
LS_GENERAL_DATA_X-SERIAL_NO = 'X'.
LS_GENERAL_DATA-INVENT_NO = INVENT_NO ."存货号
LS_GENERAL_DATA_X-INVENT_NO = 'X'.
* ** 成本中心
LS_TIME_DEPENDENT_DATA-COSTCENTER = COSTCENTER . "必输
LS_TIME_DEPENDENT_DATA_X-COSTCENTER = 'X' .
***折旧范围
LS_EPRECIATIONAREAS-AREA = '01'.
"LS_EPRECIATIONAREAS-DESCRIPT = '帐面折旧'.
LS_EPRECIATIONAREAS-DEP_KEY = DEP_KEY .
LS_EPRECIATIONAREAS-ULIFE_YRS = ULIFE_YRS.
LS_EPRECIATIONAREAS-ULIFE_PRDS = ULIFE_PRDS.
LS_EPRECIATIONAREAS-ODEP_START_DATE = ODEP_START_DATE.
APPEND LS_EPRECIATIONAREAS TO LT_DEPRECIATIONAREAS.
LS_DEPRECIATIONAREASX-AREA = '01'.
" ls_DEPRECIATIONAREASX-DESCRIPT = 'X'.
LS_DEPRECIATIONAREASX-DEP_KEY = 'X'.
LS_DEPRECIATIONAREASX-ULIFE_YRS = 'X'.
LS_DEPRECIATIONAREASX-ULIFE_PRDS = 'X'.
LS_DEPRECIATIONAREASX-ODEP_START_DATE = 'X'.
APPEND LS_DEPRECIATIONAREASX TO LT_DEPRECIATIONAREASX.
CALL FUNCTION 'BAPI_FIXEDASSET_CREATE1'
EXPORTING
KEY = LS_KEY
GENERALDATA = LS_GENERAL_DATA
GENERALDATAX = LS_GENERAL_DATA_X
TIMEDEPENDENTDATA = LS_TIME_DEPENDENT_DATA
TIMEDEPENDENTDATAX = LS_TIME_DEPENDENT_DATA_X
IMPORTING
ASSET = LS_ASSET
RETURN = LS_RETURN
TABLES
DEPRECIATIONAREAS = LT_DEPRECIATIONAREAS
DEPRECIATIONAREASX = LT_DEPRECIATIONAREASX.
IF LS_ASSET IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
IF LS_RETURN IS NOT INITIAL.
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 LS_MESSAGE.
ENDIF.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
IF LS_RETURN IS NOT INITIAL.
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 LS_MESSAGE.
ENDIF.
ENDIF.
ENDFUNCTION