Sunteți pe pagina 1din 5

1.

Basis Corner

Copy Transport Requests to local file system


Skip to end of metadata

Created by Matthias Arlt, last modified by Craig Cmehil on Dec 28, 2009

Go to start of metadata

Introduction
When you are doing development work or customizing in a SAP system your changes will be written to a transport request. Once the work is
finished, the request will be transported to another system (test or production system).
The source and target systems of such a transport route are defined in the SAP system customizing. In case you want to get direct access to a
transport file, e.g. to transport modifications to a third system that has not been included in the transport route yet, you need direct access to
the file system to copy the transport files manually.
This blog demonstrates a simple way to download released transport requests from an SAP system without accessing the file system directly.

Directions
This blog assumes that you have sufficient authorizations to perform the steps specified below.
Make sure the steps are compliant to your company's organizational and security guidelines!
You have to release the transport request before you are able to download it to your local machine.
1. Know your transport request
First you have to keep in mind the name of the transport request XXXKYYYYYY you want to store (e.g. A07K123456).
2. Find the transfer directory of the SAP system
Releasing a transport request forces the SAP system to store the request in two files on the server: one header (also known as "co-file") and
one body file (also known as "data-file"). To download these files you have to figure out the system specific settings in which directories the
files will be written.
Therefore, run transaction al11 in which the directory parameters can be accessed.
Search for the "Directory Parameter" DIR_TRANS and note the corresponding "Directory" (e.g. [file://myserver/saptrans/|
stage:\\myserver\saptrans]).
The header- and the body file are stored in different directories on the server. The next step will show how to figure out their names.
3. Find name and directory of the request header file
A double click on the entry DIR_TRANS in transaction al11 displays the corresponding content.
Beside other entries you will find two sub-directories called "cofiles" and "data".
First, double click on "cofiles" to enter this directory. Here you should find the header file of your transport request with the following
naming syntax: KYYYYYY.XXX (e.g. K123456.A07). You can use Crtl+F to search for it. If you have found your file note the entire
directory name (displayed above the table, e.g. file://myserver/saptrans/cofiles) and the file name (e.g. K123456.A07).
4. Find name and directory of the request body file
Return to the DIR_TRANS directory and open the "data" sub-folder. You should find the body file of your transport request in here with the
naming syntax: RYYYYYY.XXX (e.g. R123456.A07). Note directory and file name as well.
If you cannot find your files, either the release of the transport request failed or there are other sub-directories defined in your system!
5. Call function module to transfer the files
Now you are able to download the two files from the application server to your local file system. To download the files you can use the
standard function moduleARCHIVFILE_SERVER_TO_CLIENT. Use se37 to execute the function module.
The function module requires as importing parameters the full qualified paths a) from the source- and b) from the target system including the
filename.
To get the header file, the parameters might be:
[stage:Source] PATH: file://myserver/saptrans/cofiles/K123456.A07

TARGETPATH C:\Temp\K123456.A07
And to get the body file the parameters should something like:
[stage:Source] PATH: file://myserver/saptrans/data/R123456.A07
TARGETPATH: C:\Temp\R123456.A07
The downloaded files can be used to be imported into another SAP system.

Additional Steps
If you have to download transport requests this way very often, the procedure described above is very time-consuming.
So it might be an interesting option to further automate this process.
Below you find the basic idea to create your own program / transaction:.
Prompt for the transport request name and the local directory as input parameters.
Then you can use the statement
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_TRANS' ID 'VALUE' FIELD lv_dir.
to get the DIR_TRANS directory.
With knowledge about the (static) sub directories as well as the naming syntax of the transport request co- and data-files you can now
assemble both server source paths and (in combination with the prompted local directory) the target paths.
Finally call the function module ARCHIVE_SERVER_TO_CLIENT twice (with the assembled source and target paths) to copy the files to
the local system.

abap

transport

request

file

system

guidance

tutorial

al11

cofile

data

dir_trans

6 Comments
1.
Vinod Vemuru
Nice blog!!!

Feb 15, 2010

2.
Guest
Very useful, thanks!

Sep 01, 2010

3.

Guest
Thanks very much for posting this. The next question is ... How do we then import those transport files into another system? Do we simply
drop them in the same logical directory in the target system? What then? Will they automatically be in the buffer in STMS?

Nov 23, 2010

4.
Maximiliano Colman
*&---------------------------------------------------------------------*
*& Report ZMC_COFILES
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zmc_cofiles.
CONSTANTS:c_data_files_path TYPE string
VALUE 'data',
c_co_files_path
TYPE string
VALUE 'cofiles',
c_request_released TYPE c
VALUE 'R',
c_co_file_prefix
TYPE c
VALUE 'K',
c_data_file_prefix TYPE c
VALUE 'R',
c_execute_command TYPE sy-ucomm VALUE 'ONLI',
c_dot
TYPE c
VALUE '.',
c_slash_win
TYPE c
VALUE '\',
c_slash_lin
TYPE c
VALUE '/'.
DATA:gv_dir_trans TYPE char255.
PARAMETERS:p_ot TYPE e070-trkorr DEFAULT 'XXXKYYYYYY',
p_out TYPE string DEFAULT 'C:\temp' LOWER CASE.
INITIALIZATION.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_TRANS' ID 'VALUE' FIELD gv_dir_trans.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ot.
CALL FUNCTION 'TR_F4_REQUESTS'
EXPORTING
iv_trstatus
= c_request_released
IMPORTING
ev_selected_request = p_ot.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_out.
DATA:lv_selected_folder TYPE string.
CALL METHOD cl_gui_frontend_services=>directory_browse
CHANGING
selected_folder
= lv_selected_folder
EXCEPTIONS
cntl_error
= 1
error_no_gui
= 2
not_supported_by_gui = 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.
p_out = lv_selected_folder.
AT SELECTION-SCREEN.
IF sy-ucomm = c_execute_command.
PERFORM check_status.
PERFORM check_directory.

ENDIF.
START-OF-SELECTION.
PERFORM download USING c_co_file_prefix.
PERFORM download USING c_data_file_prefix.
PERFORM show_msg.
*&---------------------------------------------------------------------*
*&
Form check_directory
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM check_directory.
DATA: lv_result TYPE c,
lv_directory TYPE string.
lv_directory = p_out.
CALL METHOD cl_gui_frontend_services=>directory_exist
EXPORTING
directory
= lv_directory
RECEIVING
result
= lv_result
EXCEPTIONS
cntl_error
= 1
error_no_gui
= 2
wrong_parameter
= 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.
IF lv_result IS INITIAL.
MESSAGE e398(00) WITH text-001."The output directory does not exist!
ENDIF.
ENDFORM.
"check_directory
*&---------------------------------------------------------------------*
*&
Form check_status
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM check_status.
DATA:ls_e070 TYPE e070 .
SELECT SINGLE * INTO ls_e070 FROM e070 WHERE trkorr = p_ot.
IF sy-subrc = 0.
IF ls_e070-trstatus NE c_request_released.
MESSAGE e398(00) WITH text-002."The TR must be released!
ENDIF.
ELSE.
MESSAGE e398(00) WITH text-003."The TR does not exist!
ENDIF.
ENDFORM.
"check_status
*&---------------------------------------------------------------------*
*&
Form show_msg
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM show_msg.
MESSAGE s398(00) WITH text-004."Files downloaded successfully!
ENDFORM.
"show_msg
*&---------------------------------------------------------------------*
*&
Form download
*&---------------------------------------------------------------------*
*
text

*----------------------------------------------------------------------*
FORM download USING pv_type TYPE c.
DATA:lv_path LIKE sapb-sappfad,
lv_targetpath LIKE sapb-sappfad,
lv_ot_filename TYPE string.
CONCATENATE pv_type p_ot+4(6) c_dot p_ot(3) INTO lv_ot_filename.
CASE pv_type.
WHEN c_co_file_prefix.
CONCATENATE gv_dir_trans c_slash_lin c_co_files_path c_slash_lin INTO lv_path.
WHEN c_data_file_prefix.
CONCATENATE gv_dir_trans c_slash_lin c_data_files_path c_slash_lin INTO lv_path.
ENDCASE.
CONCATENATE lv_path lv_ot_filename INTO lv_path.
CONCATENATE p_out c_slash_win p_ot c_slash_win lv_ot_filename INTO lv_targetpath.
CALL FUNCTION 'ARCHIVFILE_SERVER_TO_CLIENT'
EXPORTING
path
= lv_path
targetpath = lv_targetpath
EXCEPTIONS
error_file = 1
OTHERS
= 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
"download
Jan 03, 2013

5.
Virendra Singh Somwanshi
Simply use CG3Y(to download) and CG3Z(to upload) tcode

Dec 06, 2013

o
Eric Brunelle
Virendra, CG3Y and CG3Z only exists on ECC systems.

Mathias, your trick worked like this for me:

To get the header file, the parameters might be:


[stage:Source] PATH: /usr/sap/trans/cofiles/K123456.SID
TARGETPATH C:\Temp\K123456.SID
And to get the body file the parameters should something like:
[stage:Source] PATH: /usr/sap/trans/data/R123456.SID
TARGETPATH: C:\Temp\R123456.SID

S-ar putea să vă placă și