SAP BAPI For LU01/LU04 记账更改

场景:采购收货质检放行的时候,发现存在有些做QA11的时候,进入到TR-ZONE中,没有进入到指定的仓位

解决方案:前端通过LU04进入,可以查看到一些未清的记账更改通知单,点击工具栏上的创建转储单,这个时候就会创建转储单进行过账处理掉了,从TR-ZONE中释放出来,进入到指定的仓位

程序处理的话,需要使用BAPI: L_TO_CREATE_POSTING_CHANGE

代码示例:

*&---------------------------------------------------------------------*
*& Report  ZWMR315
*&
*&---------------------------------------------------------------------*
*&
*&WMS-LU01确认未清过帐更改凭证
*&---------------------------------------------------------------------*

REPORT zwmr315.
TABLES: lubu.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_lgnum FOR lubu-lgnum NO INTERVALS OBLIGATORY, "仓库
                s_bdatu FOR lubu-bdatu OBLIGATORY, "过帐日期
                s_bwart FOR lubu-bwart, "移动类型
                s_ubnum FOR lubu-ubnum. "过帐凭证
SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN.

START-OF-SELECTION.
  PERFORM frm_get_data.
*&---------------------------------------------------------------------*
*&      Form  FRM_GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_get_data .
  DATA: lt_lubu    TYPE TABLE OF lubu,
        ls_lubu    TYPE lubu,
        i_lgnum    TYPE ltak-lgnum,
        i_ubnum    TYPE ltak-ubnum,
        e_tanum    TYPE ltak-tanum,
        t_lubqu    TYPE TABLE OF lubqu,
        ls_lubqu   TYPE lubqu,
        t_ltap_vb  TYPE TABLE OF ltap_vb,
        ls_ltap_vb TYPE ltap_vb,
        t_ltak     TYPE TABLE OF ltak_vb,
        ls_ltak    TYPE ltak_vb.

  SELECT * INTO TABLE lt_lubu
    FROM lubu
    WHERE lgnum IN s_lgnum
      AND bdatu IN s_bdatu
      AND bwart IN s_bwart
      AND ubnum IN s_ubnum
      AND statu = ''.

  LOOP AT lt_lubu INTO ls_lubu.
    CLEAR: i_lgnum,
           i_ubnum,
           e_tanum,
           t_lubqu,
           ls_lubqu,
           t_ltap_vb,
           ls_ltap_vb,
           t_ltak,
           ls_ltak.

    i_lgnum = ls_lubu-lgnum.
    i_ubnum = ls_lubu-ubnum.

    CALL FUNCTION 'L_TO_CREATE_POSTING_CHANGE'
      EXPORTING
        i_lgnum                      = i_lgnum
        i_ubnum                      = i_ubnum
*       I_LUBUI                      = ' '
*        i_squit                      = 'X'
*       I_NIDRU                      = ' '
*       I_DRUKZ                      = ' '
*       I_LDEST                      = ' '
*       I_UPDATE_TASK                = ' '
        i_commit_work                = 'X'
        i_bname                      = sy-uname
*       I_SOLEX                      = 0
*       I_PERNR                      = 0
      IMPORTING
        e_tanum                      = e_tanum
      TABLES
        t_lubqu                      = t_lubqu
        t_ltap_vb                    = t_ltap_vb
        t_ltak                       = t_ltak
      EXCEPTIONS
        foreign_lock                 = 1
        tp_completed                 = 2
        xfeld_wrong                  = 3
        ldest_wrong                  = 4
        drukz_wrong                  = 5
        tp_wrong                     = 6
        squit_forbidden              = 7
        no_to_created                = 8
        update_without_commit        = 9
        no_authority                 = 10
        i_ubnum_or_i_lubu            = 11
        bwlvs_wrong                  = 12
        material_not_found           = 13
        manual_to_forbidden          = 14
        bestq_wrong                  = 15
        sobkz_missing                = 16
        sobkz_wrong                  = 17
        meins_wrong                  = 18
        conversion_not_found         = 19
        no_quants                    = 20
        t_lubqu_required             = 21
        le_bulk_quant_not_selectable = 22
        quant_not_selectable         = 23
        quantnumber_initial          = 24
        kzuap_or_bin_location        = 25
        date_wrong                   = 26
        nltyp_missing                = 27
        nlpla_missing                = 28
        lgber_wrong                  = 29
        lenum_wrong                  = 30
        menge_wrong                  = 31
        menge_to_big                 = 32
        open_tr_kzuap                = 33
        lock_exists                  = 34
        double_quant                 = 35
        quantity_wrong               = 36
        OTHERS                       = 37.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.

    WRITE: / i_lgnum, i_ubnum, e_tanum.

  ENDLOOP.

ENDFORM.                    " FRM_GET_DATA

你可能感兴趣的:(sap)