LI11N input inventory count L_INV_COUNT_EXT

data i_check_only type rl04i-xfeld.

  data i_commit     type rl03b-comit.

  data alle_lgnum   type linv-lgnum.

  data alle_ivnum   type linv-ivnum.

  data alle_nvers   type linv-nvers.

  data s_linv       type standard table of e1linvx with header line.

  loop at gt_detail where zpdno = l_zpdno and werks = l_werks and zykmg > 0

    and ivnum is not initial and li11n is initial.

    lv_value = gt_detail-lgort && gt_detail-grtxt.

    s_linv-lgnum = gt_detail-lgnum. "Warehouse number

    s_linv-lgort = gt_detail-lgort. "Inventory location

    s_linv-ivnum = gt_detail-ivnum. "System inventory record number

    s_linv-idatu = sy-datum. "The actual inventory date

    s_linv-wdatu = sy-datum. "Receipt date

    s_linv-lgpla = lv_value. "Position

    s_linv-lgtyp = '919'. "Storage type (inventory order)

    s_linv-matnr = gt_detail-matnr. "Item number (18 characters)

    s_linv-werks = gt_detail-werks.

    s_linv-charg = gt_detail-charg.

    s_linv-lsonr = gt_detail-lenum. "Special stock number

    s_linv-menga = gt_detail-zykmg. "数量

    s_linv-altme = gt_detail-meins. "单位

    append s_linv.

  endloop.

  if s_linv[] is not initial.

    data(lv_li11n) = 'X'.

    call function 'L_INV_COUNT_EXT'

      exporting

        i_check_only                 = i_check_only

        i_commit                     = 'X'

      importing

        alle_lgnum = alle_lgnum

        alle_ivnum = alle_ivnum

        alle_nvers = alle_nvers

      tables

        s_linv                       = s_linv

      exceptions

        either_quantity_or_empty_bin = 1

        ivnum_not_found              = 2

        check_problem                = 3

        no_count_allowed             = 4

        l_inv_read                   = 5

        bin_not_in_ivnum             = 6

        counts_not_updated           = 7

        lock_error                   = 8.

    if sy-subrc ne 0.

      message id sy-msgid type 'S' number sy-msgno

        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

        into  lv_rtmsg.

      lv_rtmsg =  'LI11N失败:' && lv_rtmsg.

      lv_rtype = 'E'.

      call function 'BAPI_TRANSACTION_ROLLBACK'.

    else.

      call function 'BAPI_TRANSACTION_COMMIT'

        exporting

          wait = 'X'.

      lv_rtype = 'S'.

      lv_rtmsg ='LI11N succeeded'.

    endif.

*Write back inventory post message

    if lv_li11n = 'X'.

      loop at gt_detail where zpdno = l_zpdno and werks = l_werks and zykmg > 0 and ivnum is not initial

        and li11n is initial.

        if lv_rtype = 'S'.

          gt_detail-li11n = 'X'.

        endif.

        gt_detail-rtype = lv_rtype.

*        gt_detail-rtmsg =  gt_detail-rtmsg && ',' && lv_rtmsg.

        gt_detail-rtmsg = lv_rtmsg.

        modify gt_detail.

      endloop.

    endif.

  endif.

 

Guess you like

Origin blog.csdn.net/cylcylcylcylwo/article/details/113986219