2010 Mar 17 2:52 PM
Hi,
wondering if anyone can help, I'm using the following code to read from a file on app server, the file is of type .rtf
OPEN DATASET file_rtf FOR INPUT IN TEXT MODE
ENCODING DEFAULT
WITH SMART LINEFEED.
DO.
READ DATASET file_rtf INTO string.
IF SY-SUBRC = 0.
EXIT.
ENDIF.
ENDDO.
the open dataset part works sy-subrc = 0, but the read returns sy-subrc = 8 and no data is passed to string.
Any ideas as to what is causing this problem appreciated, <removed>
Thanks
Edited by: Thomas Zloch on Mar 17, 2010 3:57 PM - please don't offer p...
2010 Mar 18 4:17 PM
If you are reading an .RTF file, you should open it in binary mode. Not text mode.
What are you intending to use the file for?
You cannot open a true .RTF file and use it the way you use a regular text file. Either you should use a text file or open the rtf in binary mode and find a way to convert it to text. Try function SO_RTF_TO_RAW.
Hi,
wondering if anyone can help, I'm using the following code to read from a file on app server, the file is of type .rtf
OPEN DATASET file_rtf FOR INPUT IN TEXT MODE
ENCODING DEFAULT
WITH SMART LINEFEED.
DO.
READ DATASET file_rtf INTO string.
IF SY-SUBRC = 0.
EXIT.
ENDIF.
ENDDO.
the open dataset part works sy-subrc = 0, but the read returns sy-subrc = 8 and no data is passed to string.
Any ideas as to what is causing this problem appreciated, <removed>
Thanks
Edited by: Thomas Zloch on Mar 17, 2010 3:57 PM - please don't offer p...
2010 Mar 17 2:58 PM
Hi Adam,
The source code in the below link has details about how to read/write to application server.
[Application server file operartions|http://www.divulgesap.com/blog.php?p=NDk=]
Please let us know if you have any issues.
Regards,
Ravi
2010 Mar 17 3:02 PM
Hi,
I suspect that file has not been written to the server properly!
Can you try to download the file to presentation server using T-code CG3Y and see? If it is success here then just debug and see how SAP is handling. If it fails here also means that the file is not written properly.
Thanks,
Vinod.
2010 Mar 17 3:18 PM
Thanks for the swift response, unfortuantly I'm writing this program in BI so unable to use transaction cg3y, however, the file content looks as expected when previewed in al11
2010 Mar 17 7:13 PM
data: lv_line type string.
OPEN DATASET file_rtf FOR INPUT IN TEXT MODE
ENCODING DEFAULT
WITH SMART LINEFEED.
if sy-subrc eq 0. "was open actually successful?
DO.
READ DATASET file_rtf INTO lv_line." string.
IF SY-SUBRC NE 0. "exit when NOT EQUAL...
EXIT.
ENDIF.
ENDDO.
close dataset file_rtf.
endif.
Suggest you make these changes and retry...verify return code after open and after read.
2010 Mar 18 10:16 AM
Thanks breakpoint, I should have clarified, the open dataset statement is successful (sy-subrc = 0), bur the read dataset fails sy-subrc = 4.
F1 help states that this is because the end of file has been reached, so unsure why no data transferred to the string.
2010 Mar 18 10:31 AM
Hi Adam,
Looks like you are trying to transfer your data read from appl.server file into a variable of type string.Instead use a variable of type Character of length around 4000/8000 (which ever suits ur need) and re-run the code.
I think it should help.
Regards
Dedeepya
2010 Mar 18 11:16 AM
Thanks Dedeepya, have followed your advice, the read dataset still returns sy-subrc 4, but I now get a hexadecimal values off 200020002000.... at certain offset points.
2010 Mar 18 11:27 AM
Hi Adam,
Is there any specific reason that you are using WITH SMART LINEFEED ? Can you just comment that part and use OPEN DATASET FOR INPUT ENCODING DEFAULT and check.
2010 Mar 18 11:32 AM
Thanks Asmita, with smart linefeed was added following Breakpoint input, removed and no change to read dataset which is the problem, the file opens successfully.
2010 Mar 18 4:08 PM
I have to wonder what an RTF file looks like if it's sitting on the APPS server? Probably isn't true RTF format anymore, is it? Maybe just gobbledy-gook now.
If something gets saved to APPS server, I'd want to be sure it was in tab- or comma-delimited or space delimited (fixed length) format, so that I could actually read it and work with it in an SAP program.
Can you have the file put back out as tab-delimted(.txt), or comma-separated-values (csv) or fixed length text (.txt) and try to read it that way?
2010 Mar 18 4:17 PM
If you are reading an .RTF file, you should open it in binary mode. Not text mode.
What are you intending to use the file for?
You cannot open a true .RTF file and use it the way you use a regular text file. Either you should use a text file or open the rtf in binary mode and find a way to convert it to text. Try function SO_RTF_TO_RAW.
2010 Mar 19 8:59 AM
Thank for all your contributions, problem was to do with rtf format, so reverted to binary and rebuilt as text. Points awarded.
2010 Mar 19 3:47 PM
the question still shows unanswered. but that ok. can you just confirm if function SO_RTF_TO_RAW worked?
2010 Mar 19 4:08 PM
Getting errors when trying to close thread, will keep trying, thanks again. Oh and it worked!
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |