【Demo】创建固定资产Bapi
程序员文章站
2022-06-19 15:14:49
【样例代码】*&---------------------------------------------------------------------**& Report ZCREATE_ASSET*&*&---------------------------------------------------------------------**&*&*&-------------------------------------...
【样例代码】
*&---------------------------------------------------------------------*
*& Report ZCREATE_ASSET
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZCREATE_ASSET.
CONSTANTS : C_UPDATED TYPE C VALUE 'X'.
TYPES : BEGIN OF T_ASSET,
BUKRS TYPE ANLA-BUKRS,
ANLKL TYPE ANLA-ANLKL,"资产分类
TXT50 TYPE ANLA-TXT50,"资产描述
TXA50 TYPE ANLA-TXA50,"附加资产说明
KOSTL TYPE ANLZ-KOSTL,"成本中心
WERKS TYPE ANLZ-WERKS,"工厂
STORT TYPE ANLZ-STORT,"资产地点
ORD41 TYPE ANLA-ORD41,"评估组1
AKTIV TYPE ANLA-AKTIV,"资本化日期
SERNR TYPE ANLA-SERNR,"序列号
INVNR TYPE ANLA-INVNR,"存货号
GSBER TYPE ANLZ-GSBER,"业务范围
RAUMN TYPE ANLZ-RAUMN,"房间
MENGE TYPE ANLA-MENGE,"数量
MEINS TYPE ANLA-MEINS,"单位
END OF T_ASSET.
START-OF-SELECTION.
DATA : LW_ASSET TYPE T_ASSET.
DATA : LS_ASSET_CREATED TYPE BAPI1022_REFERENCE.
DATA : WS_ERROR TYPE STRING.
CLEAR LW_ASSET.
LW_ASSET-BUKRS = 'CN40'.
LW_ASSET-ANLKL = '00002205'.
LW_ASSET-TXT50 = '梅赛德斯奔驰S600 12缸'.
LW_ASSET-TXA50 = '梅赛德斯奔驰S600 12缸 2020 Version'.
LW_ASSET-KOSTL = '0000111102'.
LW_ASSET-WERKS = 'CN41'.
LW_ASSET-STORT = '0001'.
LW_ASSET-ORD41 = 'CN40'.
LW_ASSET-AKTIV = SY-DATUM.
LW_ASSET-SERNR = 'S600'.
LW_ASSET-INVNR = 'S600 12G'.
LW_ASSET-GSBER = 'CN41'.
LW_ASSET-RAUMN = 'ROOM'.
LW_ASSET-MENGE = 1.
LW_ASSET-MEINS = 'EA'.
IF LW_ASSET IS NOT INITIAL.
PERFORM ZF_BAPI_CALL USING LW_ASSET CHANGING LS_ASSET_CREATED WS_ERROR.
ENDIF.
*&---------------------------------------------------------------------*
*& Form zf_bapi_call
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PS_LS_ASSET text
* <--PS_LS_ASSET_CREATED text
* <--PS_WS_ERROR text
*----------------------------------------------------------------------*
FORM ZF_BAPI_CALL USING PS_LS_ASSET TYPE T_ASSET
CHANGING PS_LS_ASSET_CREATED TYPE BAPI1022_REFERENCE
PS_WS_ERROR TYPE STRING.
DATA:
LS_KEY TYPE BAPI1022_KEY,
LS_GENERAL_DATA TYPE BAPI1022_FEGLG001,
LS_GENERAL_DATA_X TYPE BAPI1022_FEGLG001X,
LS_INVENTORY TYPE BAPI1022_FEGLG011,
LS_INVENTORY_X TYPE BAPI1022_FEGLG011X,
LS_POSTING_INFORMATION TYPE BAPI1022_FEGLG002,
LS_POSTING_INFORMATION_X TYPE BAPI1022_FEGLG002X,
LS_TIME_DEPENDENT_DATA TYPE BAPI1022_FEGLG003,
LS_TIME_DEPENDENT_DATA_X TYPE BAPI1022_FEGLG003X,
LS_ALLOCATIONS TYPE BAPI1022_FEGLG004,
LS_ALLOCATIONS_X TYPE BAPI1022_FEGLG004X,
LS_ORIGIN TYPE BAPI1022_FEGLG009,
LS_ORIGIN_X TYPE BAPI1022_FEGLG009X,
LS_INVEST_ACCT_ASSIGNMNT TYPE BAPI1022_FEGLG010,
LS_INVEST_ACCT_ASSIGNMNT_X TYPE BAPI1022_FEGLG010X,
LS_REAL_ESTATE TYPE BAPI1022_FEGLG007,
LS_REAL_ESTATE_X TYPE BAPI1022_FEGLG007X,
LS_RETURN TYPE BAPIRET2.
***** Required fields - Create internal asset number *****
* COMPANY CODE
LS_KEY-COMPANYCODE = PS_LS_ASSET-BUKRS.
* Asset class
LS_GENERAL_DATA-ASSETCLASS = PS_LS_ASSET-ANLKL.
LS_GENERAL_DATA_X-ASSETCLASS = C_UPDATED.
***** Required fields - General Mills *****
* ASSET DESCRIPTION
LS_GENERAL_DATA-DESCRIPT = PS_LS_ASSET-TXT50.
LS_GENERAL_DATA_X-DESCRIPT = C_UPDATED.
LS_GENERAL_DATA-QUANTITY = PS_LS_ASSET-MENGE.
LS_GENERAL_DATA_X-QUANTITY = C_UPDATED.
LS_GENERAL_DATA-BASE_UOM = PS_LS_ASSET-MEINS.
LS_GENERAL_DATA_X-BASE_UOM = C_UPDATED.
* Cost center
LS_TIME_DEPENDENT_DATA-COSTCENTER = PS_LS_ASSET-KOSTL.
LS_TIME_DEPENDENT_DATA_X-COSTCENTER = C_UPDATED.
* Plant
LS_TIME_DEPENDENT_DATA-PLANT = PS_LS_ASSET-WERKS.
LS_TIME_DEPENDENT_DATA_X-PLANT = C_UPDATED.
* Asset location
LS_TIME_DEPENDENT_DATA-LOCATION = PS_LS_ASSET-STORT.
LS_TIME_DEPENDENT_DATA_X-LOCATION = C_UPDATED.
* Asset capitalization date
* LS_POSTING_INFORMATION-CAP_DATE = PS_LS_ASSET-AKTIV.
* LS_POSTING_INFORMATION_X-CAP_DATE = C_UPDATED.
***** Optional fields *****
* ASSET DESCRIPTION 2 附加资产描述
LS_GENERAL_DATA-DESCRIPT2 = PS_LS_ASSET-TXA50.
LS_GENERAL_DATA_X-DESCRIPT2 = C_UPDATED.
* Serial number
LS_GENERAL_DATA-SERIAL_NO = PS_LS_ASSET-SERNR.
LS_GENERAL_DATA_X-SERIAL_NO = C_UPDATED.
* Asset is managed historically 历史性管理
LS_GENERAL_DATA-HISTORY = C_UPDATED.
LS_GENERAL_DATA_X-HISTORY = C_UPDATED.
* Inventory number
LS_GENERAL_DATA-INVENT_NO = PS_LS_ASSET-INVNR.
LS_GENERAL_DATA_X-INVENT_NO = C_UPDATED.
* Last inventory date
* LS_INVENTORY-DATE = PS_LS_ASSET-IVDAT.
* LS_INVENTORY_X-DATE = C_UPDATED.
* Supplementary inventory specifications
* LS_INVENTORY-NOTE = PS_LS_ASSET-INVZU.
* LS_INVENTORY_X-NOTE = C_UPDATED.
* Inventory indicator
* LS_INVENTORY-INCLUDE_IN_LIST = C_UPDATED.
* LS_INVENTORY_X-INCLUDE_IN_LIST = C_UPDATED.
* Business Area
LS_TIME_DEPENDENT_DATA-BUS_AREA = PS_LS_ASSET-GSBER.
LS_TIME_DEPENDENT_DATA_X-BUS_AREA = C_UPDATED.
* Cost center responsible for asset
* LS_TIME_DEPENDENT_DATA-RESP_CCTR = PS_LS_ASSET-KOSTLV.
* LS_TIME_DEPENDENT_DATA_X-RESP_CCTR = C_UPDATED.
* Room
LS_TIME_DEPENDENT_DATA-ROOM = PS_LS_ASSET-RAUMN.
LS_TIME_DEPENDENT_DATA_X-ROOM = C_UPDATED.
* License plate no. of vehichle
* LS_TIME_DEPENDENT_DATA-PLATE_NO = PS_LS_ASSET-KFZKZ.
* LS_TIME_DEPENDENT_DATA_X-LICENSE_PLATE_NO = C_UPDATED.
* Platform
LS_ALLOCATIONS-EVALGROUP1 = PS_LS_ASSET-ORD41.
LS_ALLOCATIONS_X-EVALGROUP1 = C_UPDATED.
* LS_ALLOCATIONS-EVALGROUP1 = PS_LS_ASSET-ORD41.
* LS_ALLOCATIONS_X-EVALGROUP1 = C_UPDATED.
* GMI Class Code
* LS_ALLOCATIONS-EVALGROUP3 = PS_LS_ASSET-ORD43.
* LS_ALLOCATIONS_X-EVALGROUP3 = C_UPDATED.
* Location Type
* LS_ALLOCATIONS-EVALGROUP4 = PS_LS_ASSET-ORD44.
* LS_ALLOCATIONS_X-EVALGROUP4 = C_UPDATED.
* Reason for investment
* LS_ALLOCATIONS-INV_REASON = PS_LS_ASSET-IZWEK.
* LS_ALLOCATIONS_X-INV_REASON = C_UPDATED.
* Manufacturer of asset
* LS_ORIGIN-MANUFACTURER = PS_LS_ASSET-HERST.
* LS_ORIGIN_X-MANUFACTURER = C_UPDATED.
* Name of asset supplier
* LS_ORIGIN-VENDOR = PS_LS_ASSET-LIEFE.
* LS_ORIGIN_X-VENDOR = C_UPDATED.
* Asset type name
* LS_ORIGIN-TYPE_NAME = PS_LS_ASSET-TYPBZ.
* LS_ORIGIN_X-TYPE_NAME = C_UPDATED.
* WBS element investment project - external key
* LS_INVEST_ACCT_ASSIGNMNT-WBS_ELEMENT = PS_LS_ASSET-POSID.
* LS_INVEST_ACCT_ASSIGNMNT_X-WBS_ELEMENT = C_UPDATED.
* Local tax office
* LS_REAL_ESTATE-TAX_OFFICE = PS_LS_ASSET-FIAMT.
* LS_REAL_ESTATE_X-TAX_OFFICE = C_UPDATED.
CALL FUNCTION 'BAPI_FIXEDASSET_CREATE1'
EXPORTING
KEY = LS_KEY
* TESTRUN = 'X'
GENERALDATA = LS_GENERAL_DATA
GENERALDATAX = LS_GENERAL_DATA_X
INVENTORY = LS_INVENTORY
INVENTORYX = LS_INVENTORY_X
POSTINGINFORMATION = LS_POSTING_INFORMATION
POSTINGINFORMATIONX = LS_POSTING_INFORMATION_X
TIMEDEPENDENTDATA = LS_TIME_DEPENDENT_DATA
TIMEDEPENDENTDATAX = LS_TIME_DEPENDENT_DATA_X
ALLOCATIONS = LS_ALLOCATIONS
ALLOCATIONSX = LS_ALLOCATIONS_X
ORIGIN = LS_ORIGIN
ORIGINX = LS_ORIGIN_X
INVESTACCTASSIGNMNT = LS_INVEST_ACCT_ASSIGNMNT
INVESTACCTASSIGNMNTX = LS_INVEST_ACCT_ASSIGNMNT_X
REALESTATE = LS_REAL_ESTATE
REALESTATEX = LS_REAL_ESTATE_X
IMPORTING
ASSETCREATED = PS_LS_ASSET_CREATED
RETURN = LS_RETURN.
IF LS_RETURN-TYPE = 'S'.
COMMIT WORK.
WRITE : '资产创建成功:',PS_LS_ASSET_CREATED-COMPANYCODE,
PS_LS_ASSET_CREATED-ASSET,
PS_LS_ASSET_CREATED-SUBNUMBER.
ELSE.
CLEAR: PS_LS_ASSET_CREATED.
PS_WS_ERROR = LS_RETURN-MESSAGE.
WRITE : PS_WS_ERROR.
ENDIF.
ENDFORM. " zf_bapi_call
【效果展示】
本文地址:https://blog.csdn.net/zhongguomao/article/details/112686322
上一篇: python 合并多个excel中同名的sheet
下一篇: CDR怎么使用调和工具设计惊艳的图标?
推荐阅读