• AS01/KO02/KO88 新建创建资产卡片函数/内部订单结算维护/内部订单转固接口


    导入
    IV_BUKRS TYPE BUKRS 公司代码
    IV_ANLKL TYPE ANLKL 资产分类
    IV_TXT50 TYPE TXA50_ANLT 资产描述
    IV_TXA50 TYPE TXA50_MORE 附加资产描述
    IV_ANLHTXT TYPE ANLHTXT 资产主号说明
    IV_MEINS TYPE MEINS 基本计量单位
    IV_MENGE TYPE MENGE_D 数量
    IV_KOSTL TYPE KOSTL 成本中心
    IV_KOSTLV TYPE KOSTLV 成本中心对资产负责
    IV_SERNR TYPE AM_SERNR 序列号
    IV_INVNR TYPE INVNR_ANLA 存货号
    IV_INVZU TYPE INVZU_ANLA 补充库存说明
    IV_AUFNR TYPE AUFNR 订单号
    IV_ASSET TYPE BF_ANLN1 主资产号

    导出
    EV_ASSET TYPE BF_ANLN1 主资产号
    EV_STATUS TYPE CHAR1 状态
    EV_MESSAGE TYPE CHAR100 描述

    FUNCTION zfm_create_zg.
    *“----------------------------------------------------------------------
    "“本地接口:
    *” IMPORTING
    *” VALUE(IV_BUKRS) TYPE BUKRS OPTIONAL
    *" VALUE(IV_ANLKL) TYPE ANLKL OPTIONAL
    *" VALUE(IV_TXT50) TYPE TXA50_ANLT OPTIONAL
    *" VALUE(IV_TXA50) TYPE TXA50_MORE OPTIONAL
    *" VALUE(IV_ANLHTXT) TYPE ANLHTXT OPTIONAL
    *" VALUE(IV_MEINS) TYPE MEINS OPTIONAL
    *" VALUE(IV_MENGE) TYPE MENGE_D OPTIONAL
    *" VALUE(IV_KOSTL) TYPE KOSTL OPTIONAL
    *" VALUE(IV_KOSTLV) TYPE KOSTLV OPTIONAL
    *" VALUE(IV_SERNR) TYPE AM_SERNR OPTIONAL
    *" VALUE(IV_INVNR) TYPE INVNR_ANLA OPTIONAL
    *" VALUE(IV_INVZU) TYPE INVZU_ANLA OPTIONAL
    *" VALUE(IV_AUFNR) TYPE AUFNR OPTIONAL
    *" VALUE(IV_ASSET) TYPE BF_ANLN1 OPTIONAL
    *" EXPORTING
    *" VALUE(EV_ASSET) TYPE BF_ANLN1
    *" VALUE(EV_STATUS) TYPE CHAR1
    *" VALUE(EV_MESSAGE) TYPE CHAR100
    *"----------------------------------------------------------------------
    *(修改日志)--------------------------------------------------------
    *

    • 日志号 修改人 修改时间 修改说明 传输号码


    IF iv_asset IS INITIAL.
    "创建资产卡片
    PERFORM frm_create_anln1 USING iv_bukrs "公司代码
    iv_anlkl "资产分类
    iv_txt50 "资产描述
    iv_txa50 "附加资产描述
    iv_anlhtxt "资产主号说明
    iv_meins "基本计量单位
    iv_menge "数量
    iv_kostl "成本中心
    iv_kostlv "成本中心对资产负责
    iv_sernr "序列号
    iv_invnr "存货号
    iv_invzu "补充库存说明
    ev_asset "资产编号
    ev_status"状态
    ev_message"描述
    .
    ELSE.
    ev_asset = iv_asset.
    ENDIF.

    IF ev_status <> ‘E’
    AND iv_aufnr IS NOT INITIAL
    AND ev_asset IS NOT INITIAL.

    "新增内部订单结算规则
    PERFORM frm_ko02_bdc USING iv_aufnr
                               ev_asset
                               ev_status"状态
                               ev_message"描述
                                   .
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    ENDIF.

    IF ev_status <> ‘E’
    AND iv_aufnr IS NOT INITIAL.

    "内部工单完全结算
    PERFORM frm_ko88_bdc USING iv_aufnr
                               ev_status"状态
                               ev_message"描述
          .
    
    • 1
    • 2
    • 3
    • 4
    • 5

    ENDIF.

    ENDFUNCTION.

    ----------------------------------------------------------------------
    ***INCLUDE LZFG_ECC_JDF05.
    ----------------------------------------------------------------------
    &---------------------------------------------------------------------
    *& Form FRM_CREATE_ANLN1
    &---------------------------------------------------------------------

    •   创建资产卡片
      
      • 1

    ----------------------------------------------------------------------
    FORM frm_create_anln1 USING pv_bukrs TYPE bukrs "公司代码
    pv_anlkl TYPE anlkl "资产分类
    pv_txt50 TYPE txa50_anlt "资产描述
    pv_txa50 TYPE txa50_more "附加资产描述
    pv_anlhtxt TYPE anlhtxt "资产主号说明
    pv_meins TYPE meins "基本计量单位
    pv_menge TYPE menge_d "数量
    pv_kostl TYPE kostl "成本中心
    pv_kostlv TYPE kostlv "成本中心对资产负责
    pv_sernr TYPE am_sernr "序列号
    pv_invnr TYPE invnr_anla "存货号
    pv_invzu TYPE invzu_anla "补充库存说明
    pv_asset TYPE bf_anln1 "资产编号
    pv_status TYPE char1 "状态
    pv_message TYPE char100 "描述
    .

    DATA:ls_key LIKE bapi1022_key,
    ls_gen LIKE bapi1022_feglg001,
    ls_genx LIKE bapi1022_feglg001x,
    ls_tim LIKE bapi1022_feglg003,
    ls_timx LIKE bapi1022_feglg003x.
    DATA:ls_inventory LIKE bapi1022_feglg011.
    DATA:ls_inventoryx LIKE bapi1022_feglg011x.
    DATA:ls_return LIKE bapiret2.

    ls_key-companycode = pv_bukrs. "公司代码

    ls_gen-assetclass = pv_anlkl. "资产分类
    ls_gen-descript = pv_txt50. "资产描述
    ls_gen-descript2 = pv_txa50. "附加资产描述

    • ls_gen-acct_detrm = pv_anlkl. "科目定位码
      ls_gen-serial_no = pv_sernr. "序列号
      ls_gen-invent_no = pv_invnr. "库存号
      ls_gen-quantity = pv_menge. "数量
      ls_gen-base_uom = pv_meins. "基本计量单位
    • ls_gen-base_uom_iso = pv_meins. "计量基本单位
    • ls_gen-HISTORY = "资产被历史性管理
      ls_gen-main_descript = pv_anlhtxt. "资产主号说明

    ls_genx-assetclass = ‘X’.
    ls_genx-descript = ‘X’.
    ls_genx-descript2 = ‘X’.
    ls_genx-serial_no = ‘X’.
    ls_genx-invent_no = ‘X’.
    ls_genx-quantity = ‘X’.
    ls_genx-base_uom = ‘X’.
    ls_genx-main_descript = ‘X’.

    ls_inventory-note = pv_invzu."库存注记
    ls_inventoryx-note = ‘X’.

    ls_tim-costcenter = pv_kostl.
    ls_tim-resp_cctr = pv_kostlv.

    ls_timx-costcenter = ‘X’.
    ls_timx-resp_cctr = ‘X’.

    CALL FUNCTION ‘BAPI_FIXEDASSET_CREATE1’
    EXPORTING
    key = ls_key
    generaldata = ls_gen
    generaldatax = ls_genx
    inventory = ls_inventory
    inventoryx = ls_inventoryx
    timedependentdata = ls_tim
    timedependentdatax = ls_timx
    IMPORTING
    asset = pv_asset
    return = ls_return.
    IF pv_asset IS NOT INITIAL .
    CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’.
    pv_status = ‘S’.
    pv_message = ‘资产编号创建成功’.

    ELSE.
    CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK’.
    pv_status = ls_return-type.
    pv_message = ls_return-message.
    ENDIF.

    ENDFORM.

    ----------------------------------------------------------------------
    ***INCLUDE LZFG_ECC_JDF06.
    ----------------------------------------------------------------------
    &---------------------------------------------------------------------
    *& Form FRM_KO02_BDC
    &---------------------------------------------------------------------

    •   新增内部订单结算规则
      
      • 1

    ----------------------------------------------------------------------

    •  -->P_IV_AUFNR  text
      
      • 1
    •  -->P_EV_ASSET  text
      
      • 1
    •  -->P_EV_STATUS  text
      
      • 1
    •  -->P_EV_MESSAGE  text
      
      • 1
    •  -->P_ENDFUNCTION  text
      
      • 1

    ----------------------------------------------------------------------
    FORM frm_ko02_bdc USING pv_aufnr TYPE aufnr
    pv_asset TYPE bf_anln1 "资产编号
    pv_status TYPE char1 "状态
    pv_message TYPE char100 "描述
    .
    DATA:lv_message TYPE string.
    DATA:lv_objnr TYPE j_objnr.

    REFRESH:bdcdata,
    messtab.

    CLEAR:bdcdata,
    messtab.

    "结算规则重复检查
    lv_objnr = ‘OR’ && pv_aufnr.

    SELECT SINGLE *
    INTO @DATA(ls_cobrb)
    FROM cobrb
    WHERE objnr = @lv_objnr
    AND bureg = ‘0’.
    IF sy-subrc = 0.
    pv_status = ‘E’.

    IF pv_message IS INITIAL.
      pv_message = lv_message.
    ELSE.
      pv_message = pv_message && '/'&& '该内部订单已分配过转固结算规则'.
    ENDIF.
    
    • 1
    • 2
    • 3
    • 4
    • 5

    ELSE.

    PERFORM bdc_dynpro      USING 'SAPMKAUF' '0110'.
    PERFORM bdc_field       USING 'BDC_CURSOR'
          'COAS-AUFNR'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
          '/00'.
    PERFORM bdc_field       USING 'COAS-AUFNR'
          pv_aufnr.
    
    PERFORM bdc_dynpro      USING 'SAPMKAUF' '0600'.
    PERFORM bdc_field       USING 'BDC_CURSOR'
          'COAS-KTEXT'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
          '=ABVO'.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • PERFORM bdc_field USING ‘COAS-KTEXT’

    •    record-ktext_002.
      
      • 1

      PERFORM bdc_dynpro USING ‘SAPLKOBS’ ‘0130’.
      PERFORM bdc_field USING ‘BDC_CURSOR’
      ‘COBRB-KONTY(01)’.
      PERFORM bdc_field USING ‘BDC_OKCODE’
      ‘=NEUR’.

      PERFORM bdc_dynpro USING ‘SAPLKOBS’ ‘0100’.
      PERFORM bdc_field USING ‘BDC_CURSOR’
      ‘COBRB-GABJA’.
      PERFORM bdc_field USING ‘BDC_OKCODE’
      ‘=SICH’.
      PERFORM bdc_field USING ‘COBRB-GABPE’
      sy-datum+4(2).
      PERFORM bdc_field USING ‘COBRB-GABJA’
      sy-datum+0(4).
      PERFORM bdc_field USING ‘COBRB-PERBZ’
      ‘FUL’.
      PERFORM bdc_field USING ‘COBRB-PROZS’
      ‘100’.
      PERFORM bdc_field USING ‘COBL-ANLN1’
      pv_asset.

      IF bdcdata[] IS NOT INITIAL.

      CALL TRANSACTION 'KO02' USING bdcdata
            MODE bdcmode
            UPDATE bdcupdate
            MESSAGES INTO messtab.
      
      READ TABLE messtab INTO DATA(ls_message) WITH KEY msgid	= 'KO'
                                                        msgnr	= '109'.
      IF sy-subrc = 0.
        COMMIT WORK AND WAIT.
      
        IF pv_message IS INITIAL.
          pv_message = lv_message.
        ELSE.
          pv_message = pv_message && '/'&& '内部订单' && pv_aufnr && '结算规则维护成功'.
        ENDIF.
      
      ELSE.
        ROLLBACK WORK.
      
        pv_status = 'E'.
      
        LOOP AT messtab INTO ls_message.
          CLEAR : lv_message.
          CALL FUNCTION 'MESSAGE_TEXT_BUILD' " 显示出具体的错误讯息
            EXPORTING
              msgid               = ls_message-msgid
              msgnr               = ls_message-msgnr
              msgv1               = ls_message-msgv1
              msgv2               = ls_message-msgv2
              msgv3               = ls_message-msgv3
              msgv4               = ls_message-msgv4
            IMPORTING
              message_text_output = lv_message.
      
          CONDENSE lv_message NO-GAPS.
      
          IF pv_message IS INITIAL.
            pv_message = lv_message.
          ELSE.
            pv_message = pv_message && '/'&& lv_message.
          ENDIF.
        ENDLOOP.
      ENDIF.
      
      • 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

      ENDIF.
      ENDIF.

    ENDFORM.

    ----------------------------------------------------------------------

    •    Start new screen                                              *
      
      • 1

    ----------------------------------------------------------------------
    FORM bdc_dynpro USING program dynpro.
    CLEAR bdcdata.
    bdcdata-program = program.
    bdcdata-dynpro = dynpro.
    bdcdata-dynbegin = ‘X’.
    APPEND bdcdata.
    ENDFORM.

    ----------------------------------------------------------------------

    •    Insert field                                                  *
      
      • 1

    ----------------------------------------------------------------------
    FORM bdc_field USING fnam fval.
    CLEAR bdcdata.
    bdcdata-fnam = fnam.
    bdcdata-fval = fval.
    APPEND bdcdata.
    ENDFORM.

    ----------------------------------------------------------------------
    ***INCLUDE LZFG_ECC_JDF07.
    ----------------------------------------------------------------------
    &---------------------------------------------------------------------
    *& Form FRM_KO88_BDC
    &---------------------------------------------------------------------

    •   内部工单完全结算
      
      • 1

    ----------------------------------------------------------------------

    •  -->P_IV_AUFNR  text
      
      • 1
    •  -->P_EV_STATUS  text
      
      • 1
    •  -->P_EV_MESSAGE  text
      
      • 1

    ----------------------------------------------------------------------
    FORM frm_ko88_bdc USING pv_aufnr TYPE aufnr
    pv_status TYPE char1 "状态
    pv_message TYPE char100 "描述
    .

    DATA:lv_message TYPE string.

    REFRESH:bdcdata,
    messtab.

    CLEAR:bdcdata,
    messtab.

    PERFORM bdc_dynpro USING ‘SAPLKO71’ ‘1000’.
    PERFORM bdc_field USING ‘BDC_CURSOR’
    ‘LKO74-TESTLAUF’.
    PERFORM bdc_field USING ‘BDC_OKCODE’
    ‘=AUSF’.
    PERFORM bdc_field USING ‘LKO74-PERIO’
    sy-datum+4(2)."期间月
    PERFORM bdc_field USING ‘LKO74-GJAHR’
    sy-datum+0(4)."年
    PERFORM bdc_field USING ‘LKO74-VAART’
    ‘8’."固定值 8 完全结算
    PERFORM bdc_field USING ‘LKO74-TESTLAUF’
    ‘’."固定值 空 测试运行
    PERFORM bdc_field USING ‘LKO74-TDCHECK’
    ‘’."固定值 空 检查业务数据
    PERFORM bdc_field USING ‘CODIA-AUFNR’
    pv_aufnr."订单

    IF bdcdata[] IS NOT INITIAL.

    CALL TRANSACTION 'KO88' USING bdcdata
          MODE bdcmode
          UPDATE bdcupdate
          MESSAGES INTO messtab.
    
    READ TABLE messtab INTO DATA(ls_message) WITH KEY msgtyp = 'E'.
    IF sy-subrc <> 0.
      COMMIT WORK AND WAIT.
      IF pv_message IS INITIAL.
        pv_message = '结算成功'.
      ELSE.
        pv_message = pv_message && '/'&& '结算成功'.
      ENDIF.
    ELSE.
      ROLLBACK WORK.
      pv_status = 'E'.
    
      LOOP AT messtab INTO ls_message.
        CLEAR : lv_message.
        CALL FUNCTION 'MESSAGE_TEXT_BUILD' " 显示出具体的错误讯息
          EXPORTING
            msgid               = ls_message-msgid
            msgnr               = ls_message-msgnr
            msgv1               = ls_message-msgv1
            msgv2               = ls_message-msgv2
            msgv3               = ls_message-msgv3
            msgv4               = ls_message-msgv4
          IMPORTING
            message_text_output = lv_message.
    
        CONDENSE lv_message NO-GAPS.
    
        IF pv_message IS INITIAL.
          pv_message = lv_message.
        ELSE.
          pv_message = pv_message && '/'&& lv_message.
        ENDIF.
      ENDLOOP.
    
    ENDIF.
    
    • 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

    ENDIF.

    ENDFORM.

  • 相关阅读:
    spring boot配置ssl证书,支持https访问
    基于微信小程序的在线商城设计(后台PHP)
    Linux命令入门教程(五):系统管理篇
    [Linux]shell文本处理记录 - 查找、增删特定行及附近行
    安装SSL证书对于APP的重要意义
    一文教你如何快速备考云计算HCIE 3.0 !
    疫情可视化part2
    节点导纳矩阵
    IntelliJ IDEA 2023.2 主要更新了什么?(图文版)
    【Linux】---进程控制(创建、终止、等待、替换)
  • 原文地址:https://blog.csdn.net/FQHX_116/article/details/126273425