Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7203096
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类: 敏捷开发

2007-06-04 20:18:11

*&---------------------------------------------------------------------*
*& Report  Z_BARRY_UP_DOWN_REQUEST                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
*&  Ver 1.1 2007.06.04                                                 *
*&---------------------------------------------------------------------*
REPORT  z_barry_up_down_request                 .
TYPE-POOLS: trwbo, stms.
DATA:
    es_selected_request TYPE trwbo_request_header,
    es_selected_task TYPE trwbo_request_header,
    iv_organizer_type TYPE trwbo_calling_organizer,
    is_selection TYPE trwbo_selection.
DATA: folder TYPE string ,
      flag TYPE c        ,
      dir_trans TYPE text255  ,
      path2 TYPE text255 ,
      localfolder(128) TYPE c ,
      upfilename(11) TYPE c.
DATA:
  lt_request TYPE stms_tr_requests,
  lt_tp_maintain TYPE stms_tp_maintains.
DATA:
  et_request_infos TYPE stms_wbo_requests,
  request_info TYPE stms_wbo_request,
  request LIKE e070-trkorr.
DATA: BEGIN OF it_memo OCCURS 0 ,
        line(255) TYPE c,
      END OF it_memo.
DATA: error LIKE boole-boole ,
      err_txt(100) TYPE c .

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t1.
PARAMETERS: download RADIOBUTTON GROUP typ USER-COMMAND sele DEFAULT 'X'.
PARAMETERS: upload RADIOBUTTON GROUP typ.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE t2.
PARAMETERS:  p_file(255) TYPE c LOWER CASE MODIF ID m2,
             p_client LIKE tmsbuffer-tarcli DEFAULT sy-mandt
                           MATCHCODE OBJECT h_t000 MODIF ID m2.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE t3.
PARAMETERS:p_reqnum TYPE trkorr MODIF ID m3,
           p_folder LIKE rlgrap-filename DEFAULT 'C:\' LOWER CASE MODIF ID m3 ,
           p_memo(255) TYPE c MODIF ID m3.
SELECTION-SCREEN END OF BLOCK b3.
INITIALIZATION.
  t1 = '选择功能'.
  t2 = '上传参数'.
  t3 = '下载参数'.
  IF sy-opsys = 'Windows NT'.
    flag = '\'.
  ELSE.
    flag = '/'.
  ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_reqnum.
  iv_organizer_type = 'W'.
  is_selection-reqstatus = 'R'.
  CALL FUNCTION 'TR_PRESENT_REQUESTS_SEL_POPUP'
    EXPORTING
      iv_organizer_type   = iv_organizer_type
      is_selection        = is_selection
    IMPORTING
      es_selected_request = es_selected_request
      es_selected_task    = es_selected_task.
  p_reqnum = es_selected_request-trkorr.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.
  CALL METHOD cl_gui_frontend_services=>directory_browse
    CHANGING
      selected_folder = folder
    EXCEPTIONS
      cntl_error      = 1
      error_no_gui    = 2
      OTHERS          = 3.
  p_folder = folder.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  DATA:
    file TYPE file_table,
    rc TYPE i,
    file_table TYPE filetable,
    file_filter TYPE string VALUE '(K*.*)|K*.*||'.
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      file_filter             = file_filter
    CHANGING
      file_table              = file_table
      rc                      = rc
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      not_supported_by_gui    = 4
      OTHERS                  = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  READ TABLE file_table INTO file INDEX 1.
  p_file = file.
AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    CASE screen-group1.
      WHEN 'M2'.
        IF download = 'X'.
          screen-active = '0'.
        ELSE.
          screen-active = '1'.
        ENDIF.
      WHEN 'M3'.
        IF download = 'X'.
          screen-active = '1'.
        ELSE.
          screen-active = '0'.
        ENDIF.
    ENDCASE.
    MODIFY SCREEN.
  ENDLOOP.
START-OF-SELECTION.
  CALL FUNCTION 'RSPO_R_SAPGPARAM'
    EXPORTING
      name   = 'DIR_TRANS'
    IMPORTING
      value  = dir_trans
    EXCEPTIONS
      error  = 0
      OTHERS = 0.
  IF download = 'X'.
    IF p_reqnum = '' OR p_folder = ''.
      MESSAGE '必须输入请求号和地址' TYPE 'I'.
      EXIT.
    ENDIF.
    PERFORM downloadrequest.
  ELSE.
    IF p_client = '' OR p_file = '' .
      MESSAGE '必须输入文件名和Client' TYPE 'I'.
      EXIT.
    ENDIF.
    PERFORM uploadrequest.
    PERFORM addrequest.
  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  DOWNLOADREQUEST
*&---------------------------------------------------------------------*
FORM downloadrequest .
  CONCATENATE p_reqnum+3(7) '.' p_reqnum(3) INTO p_reqnum.
  CONCATENATE dir_trans 'cofiles' p_reqnum INTO path2 SEPARATED BY flag.
  CONCATENATE p_folder '\' p_reqnum INTO localfolder.
  PERFORM down_file USING path2
                          localfolder .
  p_reqnum(1) = 'R'.
  CONCATENATE dir_trans 'data' p_reqnum INTO path2 SEPARATED BY flag.
  CONCATENATE p_folder '\' p_reqnum INTO localfolder.
  PERFORM down_file USING path2
                          localfolder .
  IF p_memo <> ''.
    DATA str TYPE string.
    it_memo-line = p_memo.
    APPEND it_memo.
    p_reqnum(1) = 'K'.
    p_reqnum+8(3) = 'TXT'.
    CONCATENATE p_folder '\' p_reqnum INTO localfolder.
    str = localfolder .
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename = str
      TABLES
        data_tab = it_memo.
  ENDIF.
  MESSAGE '成功下载!' TYPE 'I'.
ENDFORM.                    " DOWNLOADREQUEST
*&--------------------------------------------------------------------*
*&      Form  DOWN_FILE
*&--------------------------------------------------------------------*
FORM down_file USING    p_path
                        file_name .
  DATA: path LIKE rcgfiletr-ftappl .
  DATA: localfile LIKE rcgfiletr-ftfront.
  path = p_path .
  localfile = file_name .
  CLEAR:error,err_txt.
  CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY'
    EXPORTING
      i_file_front_end    = localfile
      i_file_appl         = path
      i_file_overwrite    = 'X'
    IMPORTING
      e_flg_open_error    = error
      e_os_message        = err_txt
    EXCEPTIONS
      fe_file_open_error  = 1
      fe_file_exists      = 2
      fe_file_write_error = 3
      ap_no_authority     = 4
      ap_file_open_error  = 5
      ap_file_empty       = 6
      OTHERS              = 7.
  IF sy-subrc <> 0.
    IF sy-msgty = '' .
      sy-msgty = 'E' .
    ENDIF .
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  IF error = 'X'.
    MESSAGE err_txt TYPE 'I'.
    STOP.
  ENDIF.
ENDFORM.                               " DOWN_FILE
*&--------------------------------------------------------------------*
*&      Form  UP_FILE
*&--------------------------------------------------------------------*
FORM up_file USING      p_path
                        file_name .
  DATA: path LIKE rcgfiletr-ftappl .
  DATA: localfile LIKE rcgfiletr-ftfront.
  path = p_path .
  localfile = file_name .
  CLEAR:error,err_txt.

  sy-cprog = 'RC1TCG3Y'.
  CALL FUNCTION 'C13Z_FILE_UPLOAD_BINARY'
    EXPORTING
      i_file_front_end   = localfile
      i_file_appl        = path
      i_file_overwrite   = 'X'
    IMPORTING
      e_flg_open_error   = error
      e_os_message       = err_txt
    EXCEPTIONS
      fe_file_not_exists = 1
      fe_file_read_error = 2
      ap_no_authority    = 3
      ap_file_open_error = 4
      ap_file_exists     = 5
      OTHERS             = 6.
  IF sy-subrc <> 0.
    IF sy-msgty = '' .
      sy-msgty = 'E' .
    ENDIF .
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  IF error = 'X'.
    MESSAGE err_txt TYPE 'I'.
    STOP.
  ENDIF.
*  IF sy-subrc <> 0.
*    CASE sy-subrc  .
*      WHEN 1 .
*        MESSAGE '本地文件不存在!' TYPE 'I' .
*      WHEN 2 .
*        MESSAGE '读取本地文件出错!' TYPE 'I' .
*      WHEN 3 .
*        MESSAGE '服务器权限错误!' TYPE 'I' .
*      WHEN 4 .
*        MESSAGE '服务器文件打开错误!' TYPE 'I' .
*      WHEN 5 .
*        MESSAGE '服务器文件已经存在!' TYPE 'I' .
*      WHEN 6 .
*        MESSAGE '其他错误!' TYPE 'I' .
*    ENDCASE .
*  ENDIF.
ENDFORM.                    "UP_FILE
*&---------------------------------------------------------------------*
*&      Form  UPLOADREQUEST
*&---------------------------------------------------------------------*
FORM uploadrequest .
  DATA:
      filename LIKE sdbah-actid ,
      extension LIKE sdbad-funct,
      n TYPE i ,
      m TYPE i .
  CALL FUNCTION 'SPLIT_FILENAME'
    EXPORTING
      long_filename  = p_file
    IMPORTING
      pure_filename  = filename
      pure_extension = extension.
  CONCATENATE filename '.' extension INTO upfilename .
  CONCATENATE extension filename INTO request.
  CONCATENATE dir_trans 'cofiles' upfilename INTO path2 SEPARATED BY flag.
  PERFORM up_file USING path2
                        p_file .
  upfilename(1) = 'R'.
  CONCATENATE dir_trans 'data' upfilename INTO path2 SEPARATED BY flag.
  n = STRLEN( p_file ).
  m = n - 11 .
  p_file+m(1) = 'R'.
  PERFORM up_file USING path2
                        p_file .
ENDFORM.                    " UPLOADREQUEST
*&---------------------------------------------------------------------*
*&      Form  addrequest
*&---------------------------------------------------------------------*
FORM addrequest .
  DATA system LIKE tmscsys-sysnam .
  system = sy-sysid.
  CALL FUNCTION 'TR_AUTHORITY_CHECK_ADMIN'
    EXPORTING
      iv_adminfunction = 'TADD'
    EXCEPTIONS
      e_no_authority   = 1
      e_invalid_user   = 2
      OTHERS           = 3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.
  CALL FUNCTION 'TMS_UI_APPEND_TR_REQUEST'
    EXPORTING
      iv_system             = system
      iv_request            = request
      iv_expert_mode        = 'X'
      iv_ctc_active         = 'X'
    EXCEPTIONS
      cancelled_by_user     = 1
      append_request_failed = 2
      OTHERS                = 3.
  CHECK sy-subrc = 0.
  CALL FUNCTION 'TMS_MGR_READ_TRANSPORT_REQUEST'
    EXPORTING
      iv_request                 = request
      iv_target_system           = system
    IMPORTING
      et_request_infos           = et_request_infos
    EXCEPTIONS
      read_config_failed         = 1
      table_of_requests_is_empty = 2
      system_not_available       = 3
      OTHERS                     = 4.
  CLEAR request_info.
  READ TABLE et_request_infos INTO request_info INDEX 1.
  IF request_info-e070-korrdev = 'CUST' AND NOT p_client IS INITIAL.
    CALL FUNCTION 'TMS_MGR_MAINTAIN_TR_QUEUE'
      EXPORTING
        iv_command                 = 'FILLCLIENT'
        iv_system                  = system
        iv_request                 = request
        iv_tarcli                  = p_client
        iv_monitor                 = 'X'
        iv_verbose                 = 'X'
      IMPORTING
        et_tp_maintains            = lt_tp_maintain
      EXCEPTIONS
        read_config_failed         = 1
        table_of_requests_is_empty = 2
        OTHERS                     = 3.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      EXIT.
    ENDIF.
  ENDIF.
  CALL FUNCTION 'TR_AUTHORITY_CHECK_ADMIN'
    EXPORTING
      iv_adminfunction = 'IMPS'
    EXCEPTIONS
      e_no_authority   = 1
      e_invalid_user   = 2
      OTHERS           = 3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.
  CALL FUNCTION 'TMS_UI_IMPORT_TR_REQUEST'
    EXPORTING
      iv_system             = system
      iv_request            = request
      iv_tarcli             = p_client
      iv_some_active        = space
    EXCEPTIONS
      cancelled_by_user     = 1
      import_request_denied = 2
      import_request_failed = 3
      OTHERS                = 4.
ENDFORM.                    " addrequest
 
 
文件: R905285.rar
大小: 13KB
下载: 下载
阅读(8487) | 评论(11) | 转发(1) |
给主人留下些什么吧!~~

chinaunix网友2009-09-03 09:31:23

chinaunix网友2009-09-02 11:10:50

配置也能下载上传吗?

chinaunix网友2009-08-19 10:51:37

这个确实非常的强悍啦。非常的感谢老白

chinaunix网友2009-04-03 20:46:48

ECC可以用啊,很正常

chinaunix网友2009-04-03 15:53:50

老白,似乎这个程序在ECC6上不能运行。得不到当前用户的请求号列表。 应该怎么改下呢?