co11n 报工 货物移动bapi

 DATA: lt_tt     TYPE TABLE OF bapi_pp_timeticket,
        ls_tt     TYPE bapi_pp_timeticket,
        lt_dr     TYPE TABLE OF bapi_coru_return,
        ls_dr     TYPE bapi_coru_return,
        ls_return TYPE bapiret1,
        ls_gm     TYPE  bapi2017_gm_item_create,
        lt_gm     TYPE TABLE OF bapi2017_gm_item_create,
        lt_link   TYPE TABLE OF bapi_link_conf_goodsmov,
        ls_link   TYPE bapi_link_conf_goodsmov,
        propose   LIKE bapi_pp_conf_prop.
  DATA: lv_aufnr TYPE afko-aufnr,
        lv_aplzl TYPE afvc-aplzl,
        lv_aufpl TYPE afvc-aufpl,
        ls_afvv  TYPE afvv.
  DATA: lv_exit   TYPE c.
  DATA: ev_rueck TYPE afru-rueck,
        ev_rmzhl TYPE afru-rmzhl.
  DATA :lv_in TYPE init.
  DATA :lv_line TYPE i.
  BREAK pwc-ljf.
  CONSTANTS:
      cn_flagx TYPE c VALUE X.
  LOOP AT gt_out ASSIGNING FIELD-SYMBOL(<fs_out>) WHERE che = X
                                                   GROUP BY  ( aufnr = <fs_out>-aufnr  bc = <fs_out>-bc ) .
    CLEAR :lv_aplzl,lv_aufpl,ls_tt,ls_afvv,lv_aufnr,ev_rueck,ev_rmzhl,lt_tt[],lt_gm[],lv_in,lt_link[],lv_line.

*    SELECT SINGLE afvc~aplzl afvc~aufpl vornr
*              INTO (lv_aplzl, lv_aufpl,ls_tt-operation )
*              FROM afvc INNER JOIN afko
*              ON    afvc~aufpl = afko~aufpl
*              WHERE afko~aufnr = ls_tt-orderid .
*
*    SELECT SINGLE * FROM afvv INTO ls_afvv
*                    WHERE aufpl = lv_aufpl
*                    AND   aplzl = lv_aplzl.
    "   LOOP AT lt_tt ASSIGNING FIELD-SYMBOL(<ls_time>).

    CALL FUNCTION CONVERSION_EXIT_ALPHA_INPUT
      EXPORTING
        input  = <fs_out>-aufnr
      IMPORTING
        output = lv_aufnr.
    ls_tt-operation  = <fs_out>-vornr ."‘0010‘.
    ls_tt-orderid    = lv_aufnr.
    ls_tt-yield      = <fs_out>-menge. "待确认的产量
    ls_tt-scrap      = <fs_out>-xmnga. "当前要确认废品
    ls_tt-postg_date = <fs_out>-budat.
    ls_tt-dev_reason = <fs_out>-bc.
    ls_tt-conf_activity1  = <fs_out>-jgzq.
    ls_tt-conf_activity2  = <fs_out>-jqzj.
    ls_tt-conf_activity3  = <fs_out>-mjzj.
    ls_tt-conf_activity4  = <fs_out>-dzq.
    ls_tt-conf_activity5  = <fs_out>-zbsj.
    ls_tt-conf_activity6  = <fs_out>-qt.
    APPEND ls_tt TO lt_tt.
    CLEAR ls_tt.

    LOOP AT GROUP <fs_out> ASSIGNING FIELD-SYMBOL(<fs_gm>).

      ls_gm-material = <fs_gm>-matnr.
      CALL FUNCTION CONVERSION_EXIT_MATN1_INPUT
        EXPORTING
          input  = ls_gm-material
        IMPORTING
          output = ls_gm-material.
      ls_gm-orderid    = lv_aufnr.  "生产订单号
      ls_gm-plant      = s_werks-low.
      ls_gm-stge_loc   = <fs_gm>-lgort .
      ls_gm-entry_qnt  = <fs_gm>-erfmg .
      SELECT SINGLE meins FROM mara  INTO ls_gm-entry_uom WHERE matnr = ls_gm-material.
      ls_gm-stge_bin   = <fs_gm>-lgort.
      ls_gm-move_type  = <fs_out>-bwart."‘261‘.
      ls_gm-activity   = <fs_out>-vornr."‘0010‘.
      SELECT SINGLE rsnum rspos FROM resb
            INTO ( ls_gm-reserv_no , ls_gm-res_item )
            WHERE aufnr  =  <fs_gm>-aufnr AND matnr  = ls_gm-material.
      APPEND ls_gm TO lt_gm.
      CLEAR ls_gm.

      lv_in = lv_in + 1.
      ls_link-index_confirm = 1.
      ls_link-index_goodsmov = lv_in.
      APPEND ls_link TO lt_link.
      CLEAR ls_link.
    ENDLOOP.
    CLEAR :lt_dr[],ls_return .
    CALL FUNCTION BAPI_PRODORDCONF_CREATE_TT
      IMPORTING
        return             = ls_return
      TABLES
        timetickets        = lt_tt
        goodsmovements     = lt_gm
        link_conf_goodsmov = lt_link
        detail_return      = lt_dr.

    CLEAR lv_exit.
    LOOP AT  lt_dr  INTO ls_dr WHERE type CA EA.
      lv_exit = X.
      EXIT.
    ENDLOOP.

    IF lv_exit = X.
      CALL FUNCTION BAPI_TRANSACTION_ROLLBACK.
      <fs_out>-led = icon_red_light.
      <fs_out>-message =  ls_dr-message.
    ELSE.
      LOOP AT  lt_dr  INTO ls_dr WHERE type CA IS.
        ev_rueck = ls_dr-conf_no.
        ev_rmzhl = ls_dr-conf_cnt.
        EXIT.
      ENDLOOP.
*
*      DO 5 TIMES.
*        SELECT SINGLE *
*        FROM afwi INTO @DATA(afwi)
*        WHERE rueck = @ev_rueck
*          AND rmzhl = @ev_rmzhl.
*
*        IF afwi-mjahr IS NOT INITIAL.
*          EXIT.
*        ELSE.
*          WAIT UP TO 1 SECONDS.
*        ENDIF.
*      ENDDO.
*
*      IF afwi-mjahr+0(2) <> ‘49‘.
*        CLEAR afwi.
*      ENDIF.
*      IF afwi IS INITIAL.
*        CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK‘.
*        <fs_out>-led = icon_red_light.
*        <fs_out>-message =  ‘生产完工入库物料凭证未生成成功,请检查处理!‘.
      "   ELSE.
      CALL FUNCTION BAPI_TRANSACTION_COMMIT
        EXPORTING
          wait = X.
      <fs_out>-led = icon_green_light.
      CONCATENATE <fs_out>-message 确认序号: ev_rmzhl INTO <fs_out>-message.
      "ENDIF.
    ENDIF.
  ENDLOOP.

  LOOP AT gt_out ASSIGNING  <fs_out>  WHERE che = X AND led = ‘‘.
    LOOP AT gt_out INTO DATA(ls_out)  WHERE che = X AND led <> ‘‘ AND bc = <fs_out>-bc AND aufnr = <fs_out>-aufnr  .
      <fs_out>-led = ls_out-led.
      <fs_out>-message = ls_out-message.
    ENDLOOP.
  ENDLOOP.

 

co11n 报工 货物移动bapi

上一篇:RESTful API后台系统架构设计(Java)


下一篇:asp.net 点击切换验证码