Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Upload Application Server File...?

Former Member
0 Likes
437

Dear All,

I have to upload a file from Application server, the file name is "smsqry_20060902_102343.txt", so the file is generated by unix system i.e."smsqry_yyyymmdd_hhmmss.txt" so I don't know the file name, that at what time file was generated.

So plz. tell me how to solve this issue, plz with example.

regards.

2 REPLIES 2
Read only

Former Member
0 Likes
393

HI

You can use below code to first know the filename and

then you can use for open dataset statement.

DATA: IT_FILES LIKE EPSFILI OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
  EXPORTING
    DIR_NAME                     = '/dir/subdir'
   FILE_MASK                    = 'smsqry_*'
* IMPORTING
*   DIR_NAME                     =
*   FILE_COUNTER                 =
*   ERROR_COUNTER                =
  TABLES
    DIR_LIST                     = IT_FILES
 EXCEPTIONS
   INVALID_EPS_SUBDIR           = 1
   SAPGPARAM_FAILED             = 2
   BUILD_DIRECTORY_FAILED       = 3
   NO_AUTHORIZATION             = 4
   READ_DIRECTORY_FAILED        = 5
   TOO_MANY_READ_ERRORS         = 6
   EMPTY_DIRECTORY_LIST         = 7
   OTHERS                       = 8.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Now in it_files you will have the list of files for the

pattern, basing on your requirement you can filter the details and use the required filename.

Hope the above info helps you.

Kind Regards

Eswar

Read only

Former Member
0 Likes
393

as given by Eswar, you can use the function module,

'EPS_GET_DIRECTORY_LISTING' to get all the files starting with 'smsqry_' into itab IT_FILES.

first confirm how many files will be placed per day. if its 1 , then no problem,you can use the below logic.

smsqry_20060902_102343.txt

LOOP AT IT_FILES.

IF IT_FILES-FILENAME+7(8) = SY-DATUM.

V_FILENAME = IT_FILES-FILENAME.

EXIT.

" you got the file name here,so come out of loop.

ENDLOOP.

now V_FILENAME is the file you are seeking for.

here i am checking 8th position to 15th position values of the file to check the date is current date or not.

smsqry_<b>20060902</b>_102343.txt

this value i am comparing above in IF condition

actually i am not infront of SAP,so couldnot remember the field names in IT_FILES internal table. just i mentioned FILENAME (as a field of IT_FILES). you check it and replace it if required.

Regards

Srikanth