2011 May 06 3:11 PM
Hi all,
I need a help in read server file in batch input. ( The file address is correct and contains data.)
Follows my attempts:
- OPEN DATASET p_patch FOR INPUT IN TEXT MODE ENCODING DEFAULT.
The sy-subrc returns OK, but when I try read dataset the sy-subrc = 4.
- The Gui_upload function - Don't work to batch
What's wrong?
2011 May 06 3:19 PM
Also, it can be the case where the file exists on server but it's empty which might be the reason sy-subrc gives 4. Check transaction Al11 for the file and the contents. If not, then create a manual file, upload it through CG3y or CG3z and test your code.
Hi all,
I need a help in read server file in batch input. ( The file address is correct and contains data.)
Follows my attempts:
- OPEN DATASET p_patch FOR INPUT IN TEXT MODE ENCODING DEFAULT.
The sy-subrc returns OK, but when I try read dataset the sy-subrc = 4.
- The Gui_upload function - Don't work to batch
What's wrong?
2011 May 06 3:18 PM
You cannot use GUI_UPLOAD for application file server.
You need to use dataset commands. First Open, then Read into a string variable and then close the dataset. Later split the string variable into specific internal table format.
(Do an F1 on Dataset and you will find the exact syntax. or explore SDN as well).
2011 May 06 3:19 PM
Also, it can be the case where the file exists on server but it's empty which might be the reason sy-subrc gives 4. Check transaction Al11 for the file and the contents. If not, then create a manual file, upload it through CG3y or CG3z and test your code.
2011 May 06 3:32 PM
post your "read code" . Generally, it is done inside a do loop.
do.
read dataset <name> into <variable or structure of appropriate definition>.
if sy-subrc ne 0. "end of file reached
exit. "get out of DO
endif.
Do something with the variable or structure, to append an internal table
enddo.
2011 May 06 3:37 PM
Hi,
u could use FTP functions, such as:
FTP_CONNECT : use parameter rfc_destination = 'SAPFTPA' for background'
FTP_COMMAND
FTP_SERVER_TO_R3
Regards
2011 May 06 4:01 PM
Hi...
The Open, read and close dataset have already been declared and don't work. Sorry if I don't post all informations.
Follows the code:
open dataset p_path for input in text mode encoding default .
if sy-subrc = 0.
do.
read dataset p_path into t_arquivo.
if sy-subrc = 0.
append t_arquivo.
clear t_arquivo.
else.
exit.
endif.
enddo.
endif.
close dataset p_path.
2011 May 06 4:07 PM
Firstly, avoid using an internal table with header line.
Next SY-SUBRC = 4 when The end of the file has been reached. Can you check the file in Al11 and confirm if it has some data to read?
Regards,
Verma
2011 May 06 4:11 PM
Andrea,
The problem may be with the file. For your test purpose, try these two things:
1. Upload another test file, using C3GY/CG3X transactions and test your code.
2. See that your file has some splitter, and try moving the contents to string workarea first then split at the separator.
A sy-subrc can be 4 when the end of file reached. Either file is empty or some issue with the contents of the file.
Regards,
Verma
2011 May 06 7:53 PM
Hi...
The problem was solved.
The problem was a directory.. I was to AL11 transaction and don't found the server there... I used the CG3z transaction to upload the file a directory existent and change the parameters to ope, read and close file and well done!
Thanks you all for help.