‎2008 Mar 26 8:30 PM
Hi folks,
I am trying to upload a CSV file from the application server (SAP PRd server) The file is not opening
parameters: p_file like rlgrap-filename.
In p_file here is the path ' E:\sapprd\int_files\sap2008\import-export scripts\123.csv'
'sap2008' is the folder in SAP PRD server and 'import-export scripts' a sub folder and '123.csv' is the file...
OPEN DATASET p_file FOR INPUT IN TEXT MODE.
if sy-subrc = 8.
WRITE:/ 'FILE', P_FILE, 'cannot be opened'.
exit.
endif.
while sy-subrc = 4.
READ DATASET ld_file into wa_string.
if sy-subrc = 0.
MOVE-CORRESPONDING wa_string to itab.
append itab.
clear itab.
endif.
endwhile.
The result is sy-subrc = 8... file cannot open.
Am I missing something here?
Thanks in advance,
VG
‎2008 Mar 26 8:47 PM
Vinu.....
go to AL11 and take the exact path... i think path would be \sapprd\int_files\sap2008\import-export scripts\123.csv.
Check the path once again and not only that go to that path and double click on the file... and see whether u r able to open the file or not........
if you are not able to open the file then that means u don't have the authorization to do .....
Check that once if u have any further issues let me know.
‎2008 Mar 26 8:33 PM
Also,
How can I schedule to run this in batch mode as an automated process?
I need to run this process 2 to 3 times per week and each time I get the file with the date convention attached to it. I need to set this process automatic because running the file manually is cumbersome.
Thanks in advance in this regard,
VG
‎2008 Mar 26 8:44 PM
Try changing E:\sapprd\int_files\sap2008\import-export scripts\123.csv to \sapprd\int_files\sap2008\import-export scripts\123.csv
So, they leave the file with a date attached and that same day you pick the file?
Then, just add sy-datum to the name of the file and make it the default value, if someone is running a job it should pick the file of that day
‎2008 Mar 26 8:47 PM
Vinu.....
go to AL11 and take the exact path... i think path would be \sapprd\int_files\sap2008\import-export scripts\123.csv.
Check the path once again and not only that go to that path and double click on the file... and see whether u r able to open the file or not........
if you are not able to open the file then that means u don't have the authorization to do .....
Check that once if u have any further issues let me know.
‎2008 Mar 27 12:43 PM
Hi,
thanks for the response. I tried to locate the path using AL11. I did not find it. Does that mean I do not have the authorisation to read files from APP server? How should I go about from here?
Thanks in advance,
VG
‎2008 Mar 27 1:01 PM
Just to mention, the filepath that I had mentioned earlier, is the same physical path that I assign to the logical filenames to write a file on App server from various interfaces. Does it have to be different the other way?
Thanks,
VG
‎2008 Mar 27 1:04 PM
Vinu,
If I remember correctly, when using OPEN DATASET, the file name can not have spaces in the name. Try renaming your file removing spaces and retry.
For your code, you'll need to breakdown the CSV file by the delimiter.
This code makes an archive file while reading the main file.
OPEN DATASET filname IN TEXT MODE MESSAGE t_mesg.
IF sy-subrc NE 0.
MOVE 'X' TO t_error.
MESSAGE e100(z0) WITH 'Error reading file:' t_mesg.
EXIT.
ENDIF.
IF p_load = 'X'.
OPEN DATASET archfilname FOR OUTPUT IN TEXT MODE MESSAGE t_mesg.
IF sy-subrc NE 0.
MOVE 'X' TO t_error.
MESSAGE e100(z0) WITH 'Error opening achrive file:' t_mesg.
EXIT.
ENDIF.
ENDIF.
DO.
READ DATASET filname INTO my_rec.
IF sy-subrc NE 0.
EXIT.
ENDIF.
IF p_load = 'X'.
TRANSFER my_rec TO archfilname.
ENDIF.
SPLIT my_rec AT c_tab " Here my delimter was a tab change to ',' for comma
INTO in_rec-id
in_rec-fname
in_rec-lname
in_rec-addr
in_rec-apt
in_rec-city
in_rec-state
in_rec-zip
in_rec-branch
in_rec-phone1
in_rec-phone2
in_rec-phone3
in_rec-phone3_ext
in_rec-email
in_rec-hear
in_rec-prefcont
in_rec-ownland
in_rec-build
in_rec-ownhome
* in_rec-get_promo
in_rec-cmt1
in_rec-subdate.
APPEND in_rec TO it_input.
ENDDO.
CLOSE DATASET filname.
IF p_load = 'X'.
CLOSE DATASET archfilname.
DELETE DATASET filname.
ENDIF.
ENDIF.
‎2008 Mar 27 1:43 PM
Thanks for the response. It gives the message 'No such file or directory'. Coming to the use of Split command, I am using that piece of code in my subsequent lines. I am reading the data into a line string and then moving into the individual data elements of the itab.
Let me know if I am missing something here.
VG
‎2008 Mar 27 2:14 PM
try to get more info about the error
data: lv_messg type text50.
open dataset my_file for input... ... message lv_messg.
write: / sy-subrc, lv_messg.
that would help to know which is the error exactly
‎2008 Mar 27 7:09 PM
Hi folks,
Resolved the issue with the help of basis guy and it was related to file path and file type it is stored in the application server. Shall award the points and close the thread.
Thanks for the help,
VG