*======================================================================*
* Initial idea and first release by Igor Yaskevitch (IBS), 2003 *
* Enhancements by Sergey Korolev, 2005 (Added F4 value *
* requests, authority checks, TMS function usage) *
*----------------------------------------------------------------------*
* Function : This is a utility tool for downloading binary *
* files of transport request to a Client PC *
*======================================================================*
REPORT yrs_download_transport_request.
PARAMETERS:
p_reqest TYPE trkorr OBLIGATORY,
p_folder(255) TYPE c LOWER CASE, p_sepr OBLIGATORY.
DATA:
folder TYPE string,
retval LIKE TABLE OF ddshretval WITH HEADER LINE,
fldvalue LIKE help_info-fldvalue,
transdir TYPE text255,
filename(255),
trfile(20) TYPE c,
datatab TYPE TABLE OF text8192 WITH HEADER LINE,
len TYPE i,
flen TYPE i.
TYPE-POOLS: sabc, stms, trwbo.
INITIALIZATION.
CONCATENATE sy-sysid 'K*' INTO p_reqest.
IF sy-opsys = 'Windows NT'.
p_sepr = '\'.
ELSE.
p_sepr = '/'.
ENDIF.
* CALL FUNCTION 'WSAF_BUILD_SEPARATOR'
* IMPORTING
* separator = p_sepr
* EXCEPTIONS
* separator_not_maintained = 1
* wrong_call = 2
* wsaf_config_not_maintained = 3
* OTHERS = 4.
*
* IF sy-subrc NE 0.
* MESSAGE s001(00)
* WITH
* 'Unable to find out the separator symbol for the system.'(011).
* ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_reqest.
DATA:
tt_system TYPE TABLE OF tmscsys WITH HEADER LINE,
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.
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_reqest = es_selected_request-trkorr.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.
DATA: title TYPE string.
title = 'Select target folder'(005).
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = title
CHANGING
selected_folder = folder
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
OTHERS = 3.
CALL FUNCTION 'CONTROL_FLUSH'
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3.
p_folder = folder.
AT SELECTION-SCREEN ON p_reqest.
DATA: request_info TYPE stms_wbo_request,
request_infos TYPE stms_wbo_requests.
REFRESH request_infos.
CALL FUNCTION 'TMS_MGR_READ_TRANSPORT_REQUEST'
EXPORTING
iv_request = p_reqest
iv_header_only = 'X'
IMPORTING
et_request_infos = request_infos
EXCEPTIONS
read_config_failed = 1
table_of_requests_is_empty = 2
system_not_available = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR request_info.
READ TABLE request_infos INTO request_info INDEX 1.
IF sy-subrc NE 0
OR request_info-e070-trkorr IS INITIAL.
MESSAGE e398(00) WITH 'Request'(006) p_reqest 'not found'(007).
ELSEIF request_info-e070-trstatus NE 'R'.
MESSAGE e398(00)
WITH 'You must release request'(008)
request_info-e070-trkorr
'before downloading'(009).
ENDIF.
START-OF-SELECTION.
folder = p_folder.
CONCATENATE p_reqest+3(7) '.' p_reqest(3) INTO trfile.
CALL FUNCTION 'RSPO_R_SAPGPARAM'
EXPORTING
name = 'DIR_TRANS'
IMPORTING
value = transdir
EXCEPTIONS
error = 0
OTHERS = 0.
PERFORM copy_file USING 'cofiles' trfile.
trfile(1) = 'R'.
PERFORM copy_file USING 'data' trfile.
trfile(1) = 'D'.
PERFORM copy_file USING 'data' trfile.
*---------------------------------------------------------------------*
* FORM copy_file *
*---------------------------------------------------------------------*
* --> SUBDIR * * --> FNAME *
*---------------------------------------------------------------------*
FORM copy_file USING subdir fname.
DATA:
auth_filename TYPE authb-filename,
gui_filename TYPE string.
CONCATENATE transdir subdir fname
INTO filename
SEPARATED BY p_sepr.
REFRESH datatab.
CLEAR flen.
auth_filename = filename.
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
EXPORTING
activity = sabc_act_read
filename = auth_filename
EXCEPTIONS
no_authority = 1
activity_unknown = 2
OTHERS = 3.
IF sy-subrc <> 0.
FORMAT COLOR COL_NEGATIVE.
WRITE: / 'Read access denied. File'(001),
filename.
FORMAT COLOR OFF. EXIT.
ENDIF.
OPEN DATASET filename FOR INPUT IN BINARY MODE.
IF sy-subrc NE 0.
FORMAT COLOR COL_TOTAL.
WRITE: / 'File open error'(010), filename.
FORMAT COLOR OFF. EXIT.
ENDIF.
DO.
CLEAR len.
READ DATASET filename INTO datatab LENGTH len.
flen = flen + len.
IF len > 0. APPEND datatab. ENDIF.
IF sy-subrc NE 0.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET filename.
CONCATENATE p_folder '\' fname INTO gui_filename.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = flen
filename = gui_filename
filetype = 'BIN'
CHANGING
data_tab = datatab[]
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 24.
IF sy-subrc = 0.
WRITE: / 'File'(002), filename, 'downloaded. Length'(003), flen.
ELSE.
FORMAT COLOR COL_NEGATIVE.
WRITE: / 'File download error. Filename:'(004), filename.
FORMAT COLOR OFF.
ENDIF.
ENDFORM. "copy_file
Friday, November 23, 2007
Report YRS_DOWNLOAD_TRANSPORT_REQUEST
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(952)
-
▼
November
(716)
- SAP Paper Documents
- SAP Repository
- SAP R/3 Implementation and Maintenance Tips
- ABAP/4 programming language overview
- The interactive eLearning system for ABAP™
- Helpful System Administration ABAPS
- free download abap programmin pdf book
- examples of real time objects in sap abap(1)
- examples of real time objects in sap abap
- work flow example2
- Workflow tips
- Miscellaneous sap abap faq
- BDC , LSMW, Conversions faq in abap
- Sap Scripts & Smart forms faqs in abap
- performance tuning in abap faqs
- Real Time BDC & LSMW faqs
- Real Time ABAP Internal Tables faqs
- Real Time ABAP Reports faqs
- Real Time questions ..in sap ABAP
- SAP ABAP FAQ (Technical)
- ABAP and Unicode
- ABAP and JavaScript
- ABAP Objects
- ABAP Database Access
- Running ABAP Programs
- ABAP User Dialogs
- The ABAP Programming Language
- Creating and Changing ABAP Programs
- Overview of the Components of Application Programs
- Introduction to ABAP
- ABAP Programming Documentation
- FREE DOWNLOAD ALE, EDI & IDOCS
- Conversion of IDOCs to XML.pdf
- FREE DOWNLOAD IDOC Interface Technology
- FREE DOWNLOAD EDI, IDOC Interface
- FREE DOWNLOAD IDOC BOOK
- FREE DOWNLOAD LSMW - Idoc Inbound Processing
- FREE DOWNLOAD SAP ABAP Idoc Interface
- FREE DOWNLOAD Java for SAP
- FREE DOWNLOAD Java for ABAP Programmers
- FREE DOWNLOAD Java and BAPI technology for EP
- free download Building Web Services with Java and ...
- free download Enable SAP with the power of Javascript
- FREE DOWNLOAD ABAP Training Simulator
- FREE DOWNLOAD SAP Accounting Training Simulators
- free download SAPScripts Made Easy
- CONDENSE
- CONSTANTS
- ABAP Quick Viewer
- sap abap XXL (EXtended Export of Lists)
- Some ABAP/4 Query header line variable
- Understanding SAP Query
- ABAP/4 Query
- ABAP/4 Query Hints and Tips
- SAP Website Links Exchange for ABAP, Basis or Cons...
- sap abap Program for Generate IDoc
- sap abap program for Reads an existing Idoc and di...
- List of ABAP Function modules
- sap abap FTP programming
- sap abap program for Issuing an Unix Command from ...
- sap abap program for RFC call to get Server List
- sap abap program for A SAP Pop-out Calculator
- sap ABAP program for Timers and Auto-refresh
- sap abap program for WS_EXECUTE to called External...
- sap abap programming Execute DOS Command from ABAP...
- To execute a dos command from ABAP
- sap abap program for Make your SAPGUI Disappear an...
- sap abap program for Using Function Modules F4_FIL...
- abp program for How to Restrict the Select Options
- sap abap program for Take Values from Selection-Sc...
- sap abap program for Change Text Into Password
- sap abap program for Function Module for Encryptio...
- sap abap program for FM VRM_SET_VALUE To List Box
- sap abap program for Value Request For Parameter
- sap abap program for Pop a Message to specific SAP...
- ABAP Pop-out box for user confirmation
- sap ABAP program for POP-UP Window
- sap abap program Sample XML Source Code For SAP
- sap abap XML file to word document through SAP
- sap abap program for How to Write Web Reports in SAP
- sap abap conversion Program to Test Line Selection...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for Convert SAP Spool List to HTML
- sap program for Convert Month to Word in ABAP
- ABAP function to convert Number to Words
- sap abap program for How to Create Tree Control
- sap abap A sample Tree Programming
-
▼
November
(716)
No comments:
Post a Comment