cancel
Showing results for 
Search instead for 
Did you mean: 

Different path to extraction file for each environment

former_member705809
Participant
0 Kudos

Hi,

Is it possible for each SAP environment (test, dev, prod) to have a different extraction path to the source file on the server? eg on the development server I have the path set: /cat_1/filename.csv on test server /cat_2/filename.csv? Can I replace 'cat_2, cat_1 with any variable ??

I would like to eliminate the possibility of accidentally loading data from the test environment into prod, but I don't want to manually change the directory every time after importing the transport.

Accepted Solutions (0)

Answers (6)

Answers (6)

MartinMaruskin
Active Contributor

You can leverage system variable sy-sysid to recognize what is the SAP server you are at. Based on this you add corresponding folder name into path. Some ABAP code can look like below:

CASE sy-sysid.
WHEN 'DEV'. lv_file_path = '/cat_1/filename.csv'.
WHEN 'QAS'. lv_file_path = '/cat_2/filename.csv'.
WHEN 'PRD'. lv_file_path = '/cat_3/filename.csv'.
WHEN OTHERS.
ENDCASE.
former_member231709
Active Contributor
MartinMaruskin
Active Contributor
0 Kudos

p_subrc - is return code of the routine, if the routine ended up corre3cntly it should be zero, if you want to raise an error set it to value different to zero.

Also you may change SIDs of your systems, not sure what is abbreviation of your Dev and Quality systems. I have given DEV and QAS just as an example.

former_member705809
Participant
0 Kudos

path.pngMartin Maruskin confirm please,

I have to click 'Create routine for filename' at the path to the file and enter the name of routine in the editor and enter case? How should the program look like (I don't know ABAP)

MartinMaruskin
Active Contributor
0 Kudos

yes I think you are on right spot.... variable p_filename needs to be populated with the value of the path to your file including folder

former_member705809
Participant
0 Kudos

Thank you Martin Maruskin,

So routine should look like this? What does the p_subrc parameter do? Should the value be 0?

FCI
Active Contributor
0 Kudos

Aren't logical files intended for this purpose ? There, you can use variable.

(transaction : FILE)

former_member705809
Participant
0 Kudos

Thank you Eugeniy,

but I never created a routine. Is there any easier way. For example, in the path, use a global variable, e.g. specifying the name of the environment ?? Will such a path entered in path work: / sap / <SYSID> / csv should it be defined differently?