当前位置:   article > 正文

SAP 固定资产调拨BAPI:BAPI_FIXEDASSET_CHANGE

bapi_fixedasset_change

固定资产调拨
BAPI:BAPI_FIXEDASSET_CHANGE
以下代码供参考:

"BAPI导入参数
  DATA: LV_COMPANYCODE          LIKE  BAPI1022_1-COMP_CODE, "公司代码
        LV_ASSET                LIKE  BAPI1022_1-ASSETMAINO, "主资产号
        LV_SUBNUMBER            LIKE  BAPI1022_1-ASSETSUBNO, "资产次级编号
        LV_GROUPASSET           LIKE  BAPI1022_MISC-XANLGR, "标识:资产是集团公司资产
        LS_GENERALDATA          LIKE  BAPI1022_FEGLG001,    "逻辑字段组 001 - 通用数据
        LS_GENERALDATAX         LIKE  BAPI1022_FEGLG001X,
        LS_INVENTORY            LIKE  BAPI1022_FEGLG011,
        LS_INVENTORYX           LIKE  BAPI1022_FEGLG011X,
        LS_POSTINGINFORMATION   LIKE  BAPI1022_FEGLG002,
        LS_POSTINGINFORMATIONX  LIKE  BAPI1022_FEGLG002X,
        LS_TIMEDEPENDENTDATA    LIKE  BAPI1022_FEGLG003, "逻辑字段组003 - 时间相关的数据
        LS_TIMEDEPENDENTDATAX   LIKE  BAPI1022_FEGLG003X,
        LS_ALLOCATIONS          LIKE  BAPI1022_FEGLG004, "逻辑字段组004 - 分配
        LS_ALLOCATIONSX         LIKE  BAPI1022_FEGLG004X,
        LS_ORIGIN               LIKE  BAPI1022_FEGLG009, "逻辑字段组009 - 原件
        LS_ORIGINX              LIKE  BAPI1022_FEGLG009X,
        LS_INVESTACCTASSIGNMNT  LIKE  BAPI1022_FEGLG010,
        LS_INVESTACCTASSIGNMNTX LIKE  BAPI1022_FEGLG010X,
        LS_NETWORTHVALUATION    LIKE  BAPI1022_FEGLG006,
        LS_NETWORTHVALUATIONX   LIKE  BAPI1022_FEGLG006X,
        LS_REALESTATE           LIKE  BAPI1022_FEGLG007,
        LS_REALESTATEX          LIKE  BAPI1022_FEGLG007X,
        LS_INSURANCE            LIKE  BAPI1022_FEGLG008,
        LS_INSURANCEX           LIKE  BAPI1022_FEGLG008X,
        LS_LEASING              LIKE  BAPI1022_FEGLG005,
        LS_LEASINGX             LIKE  BAPI1022_FEGLG005X,
        LS_GLO_TIME_DEP         LIKE  BAPI1022_GLO_TIME_DEP. "Globalization fields: Date interval of time-dependent data
  "BAPI导出参数
  DATA: LS_RETURN       LIKE  BAPIRET2.             "返回参数
  "BAPI表参数
  DATA: LT_DEPRECIATIONAREAS  LIKE  STANDARD TABLE OF BAPI1022_DEP_AREAS,
        LT_DEPRECIATIONAREASX LIKE  STANDARD TABLE OF BAPI1022_DEP_AREASX,
        LT_INVESTMENT_SUPPORT LIKE  STANDARD TABLE OF BAPI1022_INV_SUPPORT,
        LT_EXTENSIONIN        LIKE  STANDARD TABLE OF BAPIPAREX.
  DATA: LS_DEPRECIATIONAREAS  LIKE  BAPI1022_DEP_AREAS,
        LS_DEPRECIATIONAREASX LIKE  BAPI1022_DEP_AREASX,
        LS_INVESTMENT_SUPPORT LIKE  BAPI1022_INV_SUPPORT,
        LS_EXTENSIONIN        LIKE  BAPIPAREX.

  DATA: LS_ANLU                TYPE BAPI_TE_ANLU.

  DATA: LT_DATA TYPE TABLE OF TY_ALV.
  DATA: LS_DATA TYPE TY_ALV.


  LT_DATA[] = GT_ALV[].
  DELETE LT_DATA WHERE SEL NE 'X'.
  DELETE LT_DATA WHERE ICON NE ''. "状态灯不为空说明校验不通过

  LOOP AT LT_DATA ASSIGNING FIELD-SYMBOL(<LW_DATA>).

    "清空BAPI参数
    CLEAR:LV_COMPANYCODE,LV_ASSET,LV_SUBNUMBER,LV_GROUPASSET,
    LS_GENERALDATA,LS_GENERALDATAX,LS_INVENTORY,LS_INVENTORYX,LS_POSTINGINFORMATION, LS_POSTINGINFORMATIONX,
    LS_TIMEDEPENDENTDATA,LS_TIMEDEPENDENTDATAX,LS_ALLOCATIONS,LS_ALLOCATIONSX,LS_ORIGIN,LS_ORIGINX,
    LS_INVESTACCTASSIGNMNT,LS_INVESTACCTASSIGNMNTX,LS_NETWORTHVALUATION,LS_NETWORTHVALUATIONX,LS_REALESTATE,LS_REALESTATEX,
    LS_INSURANCE,LS_INSURANCEX,LS_LEASING,LS_LEASINGX,LS_GLO_TIME_DEP.
    CLEAR:LS_RETURN.
    CLEAR:LS_DEPRECIATIONAREAS,LS_DEPRECIATIONAREASX,LS_INVESTMENT_SUPPORT,LS_EXTENSIONIN.
    FREE:LT_DEPRECIATIONAREAS,LT_DEPRECIATIONAREASX,LT_INVESTMENT_SUPPORT,LT_EXTENSIONIN.

    <LW_DATA>-ANLN1  = |{ <LW_DATA>-ANLN1  ALPHA = IN }|.
    <LW_DATA>-KOSTL  = |{ <LW_DATA>-KOSTL  ALPHA = IN }|.
    <LW_DATA>-KOSTLV = |{ <LW_DATA>-KOSTLV ALPHA = IN }|.

* Company code
    LV_COMPANYCODE = <LW_DATA>-BUKRS.
    LV_ASSET = <LW_DATA>-ANLN1.

    IF <LW_DATA>-ZCHG_ANLZ EQ 'X'.

* Cost center
      LS_TIMEDEPENDENTDATA-COSTCENTER = <LW_DATA>-KOSTL.
      LS_TIMEDEPENDENTDATAX-COSTCENTER = 'X'.

* Cost center responsible for asset
      LS_TIMEDEPENDENTDATA-RESP_CCTR = <LW_DATA>-KOSTLV.
      LS_TIMEDEPENDENTDATAX-RESP_CCTR = 'X'.

      "有效期起始日期
      LS_TIMEDEPENDENTDATA-FROM_DATE = <LW_DATA>-ADATU."有效期起始日期
      LS_TIMEDEPENDENTDATAX-FROM_DATE = 'X'.

      "资产停用
      LS_TIMEDEPENDENTDATA-SHUTDOWN = <LW_DATA>-XSTIL."资产停用
      LS_TIMEDEPENDENTDATAX-SHUTDOWN = 'X'.
    ENDIF.

    IF  <LW_DATA>-ZCHG_ANLU EQ 'X'.
      CLEAR LS_ANLU.
      LS_ANLU-COMP_CODE       = <LW_DATA>-BUKRS.
      LS_ANLU-ASSETMAINO       = <LW_DATA>-ANLN1.
      LS_ANLU-ZSTATUS         = <LW_DATA>-ZSTATUS. "资产状态
      LS_EXTENSIONIN-STRUCTURE = 'BAPI_TE_ANLU'.
      LS_EXTENSIONIN-VALUEPART1 = LS_ANLU.
      APPEND LS_EXTENSIONIN TO LT_EXTENSIONIN.
    ENDIF.

    IF <LW_DATA>-ZCHG_ANLH EQ 'X'.
      LS_GENERALDATA-MAIN_DESCRIPT = <LW_DATA>-ANLHTXT. "资产主号说明
      LS_GENERALDATAX-MAIN_DESCRIPT = 'X'.
    ENDIF.


    CALL FUNCTION 'BAPI_FIXEDASSET_CHANGE'
      EXPORTING
        COMPANYCODE          = LV_COMPANYCODE
        ASSET                = LV_ASSET
        SUBNUMBER            = LV_SUBNUMBER
        GROUPASSET           = LV_GROUPASSET
        GENERALDATA          = LS_GENERALDATA
        GENERALDATAX         = LS_GENERALDATAX
        INVENTORY            = LS_INVENTORY
        INVENTORYX           = LS_INVENTORYX
        POSTINGINFORMATION   = LS_POSTINGINFORMATION
        POSTINGINFORMATIONX  = LS_POSTINGINFORMATIONX
        TIMEDEPENDENTDATA    = LS_TIMEDEPENDENTDATA
        TIMEDEPENDENTDATAX   = LS_TIMEDEPENDENTDATAX
        ALLOCATIONS          = LS_ALLOCATIONS
        ALLOCATIONSX         = LS_ALLOCATIONSX
        ORIGIN               = LS_ORIGIN
        ORIGINX              = LS_ORIGINX
        INVESTACCTASSIGNMNT  = LS_INVESTACCTASSIGNMNT
        INVESTACCTASSIGNMNTX = LS_INVESTACCTASSIGNMNTX
        NETWORTHVALUATION    = LS_NETWORTHVALUATION
        NETWORTHVALUATIONX   = LS_NETWORTHVALUATIONX
        REALESTATE           = LS_REALESTATE
        REALESTATEX          = LS_REALESTATEX
        INSURANCE            = LS_INSURANCE
        INSURANCEX           = LS_INSURANCEX
        LEASING              = LS_LEASING
        LEASINGX             = LS_LEASINGX
        GLO_TIME_DEP         = LS_GLO_TIME_DEP
      IMPORTING
        RETURN               = LS_RETURN
      TABLES
        DEPRECIATIONAREAS    = LT_DEPRECIATIONAREAS
        DEPRECIATIONAREASX   = LT_DEPRECIATIONAREASX
        INVESTMENT_SUPPORT   = LT_INVESTMENT_SUPPORT
        EXTENSIONIN          = LT_EXTENSIONIN.
    IF SY-SUBRC EQ 0.
      IF LS_RETURN-TYPE EQ 'S'.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            WAIT = 'X'.

        CALL FUNCTION 'MESSAGE_TEXT_BUILD'
          EXPORTING
            MSGID               = LS_RETURN-ID
            MSGNR               = LS_RETURN-NUMBER
            MSGV1               = LS_RETURN-MESSAGE_V1
            MSGV2               = LS_RETURN-MESSAGE_V2
            MSGV3               = LS_RETURN-MESSAGE_V3
            MSGV4               = LS_RETURN-MESSAGE_V4
          IMPORTING
            MESSAGE_TEXT_OUTPUT = <LW_DATA>-MESSAGE.

        <LW_DATA>-ICON = ICON_GREEN_LIGHT.

      ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

        CALL FUNCTION 'MESSAGE_TEXT_BUILD'
          EXPORTING
            MSGID               = LS_RETURN-ID
            MSGNR               = LS_RETURN-NUMBER
            MSGV1               = LS_RETURN-MESSAGE_V1
            MSGV2               = LS_RETURN-MESSAGE_V2
            MSGV3               = LS_RETURN-MESSAGE_V3
            MSGV4               = LS_RETURN-MESSAGE_V4
          IMPORTING
            MESSAGE_TEXT_OUTPUT = <LW_DATA>-MESSAGE.

        <LW_DATA>-ICON = ICON_RED_LIGHT.

      ENDIF.

    ELSE.
      <LW_DATA>-ICON = ICON_RED_LIGHT.
      <LW_DATA>-MESSAGE = '调拨失败,未传入数据'.

    ENDIF.

  ENDLOOP.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185

OVER…

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/452036
推荐阅读
相关标签
  

闽ICP备14008679号