码迷,mamicode.com
首页 > Windows程序 > 详细

创建生产订单函数BAPI_PRODORD_CREATE

时间:2015-12-07 12:02:04      阅读:421      评论:0      收藏:0      [点我收藏+]

标签:

创建生产订单,创建订单长文本,订单下达

 

   LOOP AT gt_zstybcp INTO gw_zstybcp WHERE sel = X AND aufnr = ‘‘."ADD BY 20150716 LY FOR 批量创建
     CLEAR:gs_return,gw_return,gt_order_return[],gt_bapi_order_key[],gs_bapi_order_key.
     gs_bapi_pp_order_create-material = gw_zstybcp-matnr."订单物料号
     gs_bapi_pp_order_create-plant = gw_zstybcp-werks."订单工厂
     gs_bapi_pp_order_create-planning_plant = gw_zstybcp-werks."计划工厂
     gs_bapi_pp_order_create-basic_start_date = gw_zstybcp-gstrp."基础开始日期
     gs_bapi_pp_order_create-basic_end_date = gw_zstybcp-gstrp."基准解释日期
     gs_bapi_pp_order_create-quantity = gw_zstybcp-bdmng."订单数量
     CALL FUNCTION CONVERSION_EXIT_CUNIT_INPUT "单位
       EXPORTING
         input          = gw_zstybcp-meins
*        LANGUAGE       = SY-LANGU
       IMPORTING
         output         = gs_bapi_pp_order_create-quantity_uom
       EXCEPTIONS
         unit_not_found = 1
         OTHERS         = 2.
     IF sy-subrc <> 0.
     ENDIF.


*   GS_BAPI_PP_ORDER_CREATE-QUANTITY_UOM = GW_ZSTYBCP-MEINS."单位
     gs_bapi_pp_order_create-goods_recipient = gw_zstybcp-wempf."收货方
*   GS_BAPI_PP_ORDER_CREATE-GOODS_RECIPIENT = GW_ZSTYBCP-MEINS.
     gs_bapi_pp_order_create-order_type = DL02.
     "调用订单创建函数创建调油半成品生产订单
     CALL FUNCTION BAPI_PRODORD_CREATE
       EXPORTING
         orderdata    = gs_bapi_pp_order_create
       IMPORTING
         return       = gs_return
         order_number = gv_order_number.

     IF gs_return-type IS NOT INITIAL."消息填表
       gw_return-msgid = gs_return-id.
       gw_return-msgty = gs_return-type.
       gw_return-msgno = gs_return-number.
       gw_return-msgv1 = gs_return-message_v1.
       gw_return-msgv2 = gs_return-message_v2.
       gw_return-msgv3 = gs_return-message_v3.
       gw_return-msgv4 = gs_return-message_v4.
       APPEND gw_return TO gt_return.
     ENDIF.
*    APPEND GS_RETURN TO GT_RETURN."消息填表

     IF gs_return-type = E OR gs_return = A.
       CALL FUNCTION BAPI_TRANSACTION_ROLLBACK.
       gw_zstybcp-icon = @OA@.
       gw_zstybcp-message = gs_return-message.
     ELSE.
       CALL FUNCTION BAPI_TRANSACTION_COMMIT
         EXPORTING
           wait = X.
       gw_zstybcp-icon = @08@.
       gw_zstybcp-message = 成功创建调油半成品生产订单.
       gw_zstybcp-aufnr = gv_order_number.
       gw_zstybcp-psmng = gw_zstybcp-bdmng.
       gw_zstybcp-amein = gw_zstybcp-meins.

       CONCATENATE sy-mandt gv_order_number INTO g_fname.
       gw_tline-tdformat = 1.
       gw_tline-tdline = gw_zstybcp-ztiay.
       APPEND gw_tline TO gt_tline.

       CALL FUNCTION CREATE_TEXT
         EXPORTING
           fid       = KOPF
           flanguage = sy-langu
           fname     = g_fname
           fobject   = AUFK
         TABLES
           flines    = gt_tline
         EXCEPTIONS
           no_init   = 1
           no_save   = 2
           OTHERS    = 3.
       IF sy-subrc <> 0.
       ENDIF.
       IF sy-subrc = 0.
         CALL FUNCTION BAPI_TRANSACTION_COMMIT
           EXPORTING
             wait = X.
       ELSE.
         CALL FUNCTION BAPI_TRANSACTION_ROLLBACK.

       ENDIF.

       WAIT UP TO 1 SECONDS.
       UPDATE aufk SET ltext = 1 WHERE aufnr = gv_order_number.
       COMMIT WORK.

       gs_bapi_order_key-order_number = gv_order_number.
       APPEND gs_bapi_order_key TO gt_bapi_order_key.



       "ADD BY LY 20150610订单下达
       CALL FUNCTION BAPI_PRODORD_RELEASE
*         EXPORTING
*           RELEASE_CONTROL          = ‘1‘
*           WORK_PROCESS_GROUP       = ‘COWORK_BAPI‘
*           WORK_PROCESS_MAX         = 99
*         IMPORTING
*           RETURN                   =
         TABLES
           orders        = gt_bapi_order_key
           detail_return = gt_order_return.
       READ TABLE gt_order_return WITH KEY type = E.
       IF sy-subrc <> 0.
         CALL FUNCTION BAPI_TRANSACTION_COMMIT
           EXPORTING
             wait = X.
       ELSE.
         CALL FUNCTION BAPI_TRANSACTION_ROLLBACK.

         CONCATENATE 订单 gv_order_number 下达失败,请手动下达! INTO gw_return-msgv1.
         MESSAGE gw_return-msgv1  TYPE S DISPLAY LIKE E.
       ENDIF.

     ENDIF.
     MODIFY gt_zstybcp FROM gw_zstybcp.
   ENDLOOP.

 

创建生产订单函数BAPI_PRODORD_CREATE

标签:

原文地址:http://www.cnblogs.com/sapSB/p/5025371.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!