ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 计划订单批导

计划订单批导

原创 Linux操作系统 作者:hzq2010 时间:2011-04-11 20:56:14 0 删除 编辑

TYPE-POOLS truxs.
DATA: xlstab TYPE truxs_t_text_data,
      f_size TYPE i .
PARAMETERS: filename LIKE rlgrap-filename .
DATA header TYPE bapiplaf_i1.
DATA error TYPE bapireturn1.
DATA:BEGIN OF itb_input OCCURS 0,
       plannedorder_num LIKE bapiplaf_i1-plannedorder_num,
       pldord_profile LIKE bapiplaf_i1-pldord_profile,
       material LIKE bapiplaf_i1-material,
       total_plord_qty LIKE bapiplaf_i1-total_plord_qty,
       plan_plant LIKE bapiplaf_i1-plan_plant,
       prod_plant LIKE bapiplaf_i1-prod_plant,
       order_start_date LIKE bapiplaf_i1-order_start_date,
       version LIKE bapiplaf_i1-version,
END OF itb_input.
DATA:BEGIN OF itb_err OCCURS 0.
        INCLUDE STRUCTURE bapireturn1.
DATA:END OF itb_err.
DATA flag TYPE i.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
  PERFORM. get_pc_filename.


START-OF-SELECTION.
  PERFORM. upload_file TABLES itb_input.
  LOOP AT itb_input.
    CALL FUNCTION 'AIPC_CONVERT_TO_UPPERCASE'
      EXPORTING
        i_input        = itb_input-plannedorder_num
*     I_LANGU        = SY-LANGU
     IMPORTING
       e_output       = itb_input-plannedorder_num
              .
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = itb_input-material
      IMPORTING
        utput = itb_input-material.
    MOVE-CORRESPONDING itb_input TO header.
    header-firming_ind = 'X'.
    CALL FUNCTION 'BAPI_PLANNEDORDER_CREATE'
    EXPORTING
      headerdata                  = header
   IMPORTING
     return                      = error
*   PLANNEDORDER                =
*   CREATEDHEADERDATA           =
*   CAPACITYHEADERDATA1         =
*   CAPACITYHEADERDATA2         =
*   CAPACITYHEADERDATA3         =
* TABLES
*   COMPONENTSDATA              =
*   CREATEDCOMPONENTSDATA       =
*   CAPACITYDATA1               =
*   CAPACITYDATA2               =
*   CAPACITYDATA3               =
            .
    MOVE-CORRESPONDING error TO itb_err.
    APPEND itb_err.
  ENDLOOP.
  flag = 0.
  LOOP AT itb_err.
    IF itb_err-number NE '010'.
      flag = 1.
    ENDIF.
  ENDLOOP.
  LOOP AT itb_err.
    WRITE: / itb_err-message.
  ENDLOOP.

END-OF-SELECTION.
  IF flag = 0.
    SET PF-STATUS 'COMMAND'.
  ENDIF.

AT USER-COMMAND.
  CASE sy-ucomm.
    WHEN '&RUN'.
      IF flag = 0.
        COMMIT WORK.
        MESSAGE  '计划批导成功!' TYPE 'I'.
        SET PF-STATUS 'DEFAULT' IMMEDIATELY .


      ELSE.
        MESSAGE  '批导失败!请核查错误!' TYPE 'E'.


      ENDIF.
    WHEN '&CAN'.
      EXIT.
  ENDCASE.

*&---------------------------------------------------------------------*
*&      Form  upload_file
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->FTAB       text
*----------------------------------------------------------------------*
FORM. upload_file TABLES ftab.


  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    EXPORTING
      percentage = 0
      text       = '转换Ing。。'.

  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
      i_tab_raw_data       = xlstab
      i_filename           = filename
    TABLES
      i_tab_converted_data = ftab
    EXCEPTIONS
      conversion_failed    = 1
      OTHERS               = 2.
  IF sy-subrc <> 0.
    MESSAGE '转换Excel表有错误发生!' TYPE 'E' .
  ENDIF.
ENDFORM.                    " UPLOAD_FILE
*&--------------------------------------------------------------------*
*&      Form  get_pc_filename
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM. get_pc_filename.
  CALL FUNCTION 'WS_FILENAME_GET'
      EXPORTING
*         def_filename     = PAY_FILE
*         DEF_PATH         = ' '
*          mask             = ',*.XLS ,*.XLS.'
          mode             = '0'
          title            = 'Get the import file name'
     IMPORTING
          filename         = filename
*         RC               =
     EXCEPTIONS
          inv_winsys       = 1
          no_batch         = 2
          selection_cancel = 3
          selection_error  = 4
          OTHERS           = 5.
  IF sy-subrc <> 0.
*    MESSAGE 'ERROR' TYPE 'E' .
  ENDIF.
ENDFORM.                    " GET_PC_FILENAME 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23495244/viewspace-692257/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 低值货币的转换
下一篇: 跳过SAP Access Key
请登录后发表评论 登录
全部评论

注册时间:2010-03-11

  • 博文量
    196
  • 访问量
    168717