PP生产订单创建组件

*&---------------------------------------------------------------------*
*&      Form  FRM_UPDATAMARA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_updatamara .
  DATA:l_matnr TYPE mara-matnr.
  DATA:lv_posnr TYPE afpo-posnr.
  CLEAR:lv_posnr.
  IF it_upload IS NOT INITIAL.
    SELECT
          werks
          aufnr
          matnr
          lgort
          vornr
          bdmng
          meins
          postp
      FROM zpp038
      INTO TABLE gt_zpp038_back
      FOR ALL ENTRIES IN it_upload
      WHERE aufnr = it_upload-aufnr AND werks = p_werks.

    IF gt_zpp038_back IS NOT INITIAL.
      SELECT
            resb~aufnr
            resb~matnr
            resb~xloek
            resb~rsnum"
            resb~rspos "
            marc~xchpf"批次标识
        INTO TABLE gt_resbcheck
        FROM resb INNER JOIN marc ON resb~matnr = marc~matnr
        FOR ALL ENTRIES IN gt_zpp038_back
        WHERE aufnr = gt_zpp038_back-aufnr AND resb~matnr = gt_zpp038_back-matnr.
    ENDIF.
    CLEAR:gt_aufnr.
    LOOP AT gt_zpp038_back INTO gw_zpp038_back WHERE aufnr NE space.
      gw_aufnr-aufnr = gw_zpp038_back-aufnr.
      APPEND gw_aufnr TO gt_aufnr.
      CLEAR:gw_resb,gw_aufnr.
    ENDLOOP.
    DELETE ADJACENT DUPLICATES FROM gt_aufnr.

    LOOP AT gt_aufnr INTO gw_aufnr.
      CLEAR:lt_components_detail.
*      CALL FUNCTION 'BAPI_NETWORK_GETDETAIL'
*        EXPORTING
*          number              = gw_aufnr-aufnr
*        TABLES
*          e_components_detail = lt_components_detail.
      CLEAR:it_activity.
      CALL FUNCTION 'BAPI_NETWORK_GETDETAIL'
        EXPORTING
          number     = gw_zpp038_back-aufnr
        TABLES
          e_activity = it_activity.

      " IF gt_zpp038_back IS NOT INITIAL.
      LOOP AT gt_zpp038_back INTO gw_zpp038_back WHERE aufnr = gw_aufnr-aufnr.
        CLEAR:lt_components_detail.
        IF it_activity IS NOT INITIAL.
          READ TABLE it_activity INTO lw_activity INDEX 1.
        ENDIF.
        lv_posnr = lw_activity-activity.

        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gw_zpp038_back-matnr
          IMPORTING
            output = l_matnr.


        lw_comp_add-activity        = lv_posnr.
        lw_comp_add-material       = l_matnr.
        lw_comp_add-plant          = p_werks."组件的需求数量
        lw_comp_add-entry_quantity = gw_zpp038_back-bdmng."组件的需求数量
        lw_comp_add-item_cat       = gw_zpp038_back-postp."项目类别(物料单)
        lw_comp_add-stge_loc       = gw_zpp038_back-lgort."存储位置
        lw_comp_add-base_uom       = gw_zpp038_back-meins."基本计量单位
        lw_comp_add-activity       = gw_zpp038_back-vornr."活动编号
*        lw_comp_add-type_of_pur_resv = ''."采购类型
*        lw_comp_add-price_unit = '1'."价格单位
*        *        lw_comp_add-req_date = '1'."组件的需求日期
        APPEND lw_comp_add TO it_comp_add.

        CALL FUNCTION 'BAPI_PS_INITIALIZATION' .

        CALL FUNCTION 'BAPI_NETWORK_COMP_ADD'
          EXPORTING
            number           = gw_zpp038_back-aufnr
          IMPORTING
            return           = lv_return
          TABLES
            i_components_add = it_comp_add
            e_message_table  = lt_message_table.

        COMMIT WORK AND WAIT.

        CLEAR:lv_posnr,lw_comp_add,gw_zpp038_back.
      ENDLOOP.
    ENDLOOP.
    " ENDIF.

  ENDIF.
ENDFORM.

上一篇:Linux添加永久路由


下一篇:配置Linux实现静态路由