Skip to Content
author's profile photo Former Member
Former Member

Read a file with a variable=counter : NAMEFILE001,NAMEFILE002..

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Feb 22, 2005 at 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.

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.