【ABAP】BAPI_OUTB_DELIVERY_CONFIRM_DEC过账数量出错

问题

BAPI_OUTB_DELIVERY_CONFIRM_DEC这个bapi修改过账数量报E类型错误

凭证 &1 项目 &2 中的错误 (数量一致性检查) 

解决办法

给这两个字段赋值,具体为啥我也不清楚

      ls_item_data-FACT_UNIT_NOM = 1.
      ls_item_data-FACT_UNIT_DENOM = 1. 

BAPI全部代码

DATA: ls_header           TYPE bapiobdlvhdrcon,
        ls_header_c         TYPE bapiobdlvhdrctrlcon,
        ls_delivery         TYPE bapiobdlvhdrcon-deliv_numb,
        lt_header_deadlines TYPE TABLE OF bapidlvdeadln,
        ls_header_deadlines TYPE bapidlvdeadln,
        lt_item_data_spl    TYPE TABLE OF /spe/bapiobdlvitemconf,
        ls_item_data_spl    TYPE /spe/bapiobdlvitemconf,
        lt_item_data  TYPE TABLE OF bapiobdlvitemcon,
        ls_item_data  TYPE  bapiobdlvitemcon,
        lt_item_control  TYPE TABLE OF bapiobdlvitemctrlcon,
        ls_item_control  TYPE  bapiobdlvitemctrlcon,
        lt_return           TYPE TABLE OF bapiret2,
        ls_return           TYPE bapiret2,
        ls_inputitem TYPE zsds002i_item,
        lt_lips             TYPE TABLE OF lips,
        ls_lips             TYPE lips,
        lv_time             TYPE t,
        lv_vdatu       TYPE dats,
         lv_msg       TYPE bapi_msg,
         e_msg       TYPE bapi_msg,
         lv_num   TYPE i,
          lv_error     TYPE c,
          p_dn TYPE vbeln,
          p_lfimg TYPE lfimg,
          p_lgort TYPE lgort.

  CLEAR: ls_header,ls_header_c,ls_delivery,lt_header_deadlines,ls_header_deadlines,lt_item_data_spl,ls_item_data_spl,lt_return,ls_return.
p_dn   =  '7000000371'.     "交货单
p_lfimg = '80'.                 "交货数量
p_lgort = '5001'.        "库存地点

  ls_header-deliv_numb    = p_dn.
  ls_header_c-deliv_numb  = p_dn.
  ls_header_c-post_gi_flg = 'X'.
  ls_header_c-volume_flg = 'X'.

  CLEAR: ls_header_deadlines,lt_header_deadlines[].
  ls_header_deadlines-deliv_numb  = p_dn.
  ls_header_deadlines-timetype    = 'WSHDRWADTI'.
  ls_header_deadlines-timezone    = sy-zonlo."sy-tzone lv_tzonrc.
  CONVERT DATE sy-datum TIME lv_time
          INTO TIME STAMP ls_header_deadlines-timestamp_utc
          TIME ZONE sy-zonlo.
  APPEND ls_header_deadlines TO lt_header_deadlines.

  REFRESH lt_lips .
  SELECT * FROM lips INTO CORRESPONDING FIELDS OF TABLE lt_lips
    WHERE vbeln = p_dn .

  REFRESH lt_item_data_spl .
  LOOP AT lt_lips INTO ls_lips .
        CLEAR: ls_item_data_spl,ls_item_data .

      ls_item_data-deliv_numb = ls_lips-vbeln.
      ls_item_data-deliv_item = ls_lips-posnr.
      ls_item_data-dlv_qty = p_lfimg.
      ls_item_data-dlv_qty_imunit = p_lfimg.
      ls_item_data-fact_unit_nom = 1.
      ls_item_data-fact_unit_denom = 1.
*     ls_item_data_spl-qty_post = ls_inputitem-lfimg.
      ls_item_control-deliv_numb = ls_lips-vbeln.
      ls_item_control-deliv_item = ls_lips-posnr.
      ls_item_control-chg_delqty = 'X'.
      ls_item_control-volume_flg = 'X'.

    ls_item_data_spl-deliv_numb = ls_lips-vbeln.
    ls_item_data_spl-deliv_item = ls_lips-posnr.
    ls_item_data_spl-stge_loc   = p_lgort.        "库存地点
    APPEND ls_item_data_spl TO lt_item_data_spl .
    APPEND ls_item_data TO lt_item_data.
    APPEND ls_item_control TO lT_ITEM_CONTROL.
    CLEAR: ls_lips,ls_item_data .
  ENDLOOP .

  CALL FUNCTION 'RV_DELIVERY_INIT'
    EXPORTING
      status_buff_init = space
      i_call_activity  = space
      if_no_deque      = 'X'.

  CALL FUNCTION 'BAPI_OUTB_DELIVERY_CONFIRM_DEC'  "对交货单过帐
    EXPORTING
      header_data      = ls_header
      header_control   = ls_header_c
      delivery         = p_dn
    TABLES
      header_deadlines = lt_header_deadlines
      item_data_spl    = lt_item_data_spl
      return           = lt_return
     item_data  = lt_item_data
    item_control = lt_item_control
.

  IF lt_return[]  IS  INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.
    COMMIT WORK.
    WRITE:'交货单过账成功'.
  ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

    LOOP AT lt_return INTO ls_return WHERE type CA 'AEX'.
      CLEAR: lv_msg.
      MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number
        INTO lv_msg
        WITH ls_return-message_v1 ls_return-message_v2 ls_return-message_v3 ls_return-message_v4.

      IF e_msg IS INITIAL.
        e_msg = lv_msg.
      ELSE.
        e_msg = |{ e_msg };{ lv_msg }|.
      ENDIF.
    ENDLOOP.
    WRITE:e_msg.
  ENDIF.

 

给TA买糖
共{{data.count}}人
人已赞赏
ABAPSAP

【ABAP】OA->SAP创建合同(ME31K)接口:BDC模式

2021-6-10 17:25:33

ABAPSAP

【ABAP】修改采购申请BAPI-BAPI_PR_CHANGE

2021-6-23 19:39:55

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索