02-22-2005 10:30 AM
Hello,
I would need your councils.
I can read a logical file on my server(logical example of name: NAMEFILE) with function FILE_GET_NAME.
But I would like to be able to read a file with a counter i.e.
the first time: to read NAMEFILE001;
the second time read NAMEFILE002;
the third time read NAMEFILER003...
How made you that?
With function FILENAME_EXIT _?
But, where do I put the variable = counter? In a table...?
Thank you in advance of your answer
Servane
02-22-2005 11:29 AM
Hello Servane,
What I understood from your description is that you want to call the Function FILE_GET_NAME multiple number of times. Is that correct? If yes, then look at the following code :
DATA : W_LOGICAL_FILENAME TYPE FILEINTERN,
W_FILENUMBER(3) TYPE N.
DO 10 TIMES.
MOVE SY-INDEX TO W_FILENUMBER.
CONCATENATE 'TESTFILE'
W_FILENUMBER
INTO W_LOGICAL_FILENAME.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = W_LOGICAL_FILENAME
IMPORTING
FILE_NAME = FILE
FILE_FORMAT = FORMAT.
ENDDO.
Does that answer your question ? If yes, then please close the thread. Otherwise, get back with the problem.
02-22-2005 2:27 PM
Hi Servane,
You could also do the following:
in transaction FILE you set up the physical path name as follows:
/<i>path</i>/.../<FILENAME><PARAM_1>
then you call the function FILE_GET_NAME:
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = W_LOGICAL_FILENAME
PARAMETER_1 = W_FILENUMBER
IMPORTING
FILE_NAME = THEFILE
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
This will equally construct the name/counter as you wish.
AND, if I am not wrong, since the system does it, you will not have to worry about putting the last counter value away in the DB.
cheers,
Phil
Message was edited by: Phillip Morgan