2008 Nov 17 10:24 AM
Hello Guru's
I am having dificulties with OPEN DATASET OUTPUT. When I run my report I am not getting any output.
I have the following piece of code:
OPEN DATASET filename FOR OUTPUT IN TEXT MODE MESSAGE D_MSG_TEXT ENCODING DEFAULT.
IF sy-subrc <> 0.
write: 'file could not be opened, reason:' D_MSG_TEXT.
exit.
endif.
Loop at itab.
transfer itab-field to filename.
endloop.
Close dataset filename.
Sy-subrc = 0 so the file could be opened/created but there is no data being transfered and the itab contains data. Does anybody know why it doen't work?
Best regards,
Guido
2008 Nov 17 10:45 AM
Hi Gowri
I have tried it, but it doesn't make any difference wheter I use a workarea or not.
Thnx though.
Anyone else any idea's?
Hello Guru's
I am having dificulties with OPEN DATASET OUTPUT. When I run my report I am not getting any output.
I have the following piece of code:
OPEN DATASET filename FOR OUTPUT IN TEXT MODE MESSAGE D_MSG_TEXT ENCODING DEFAULT.
IF sy-subrc <> 0.
write: 'file could not be opened, reason:' D_MSG_TEXT.
exit.
endif.
Loop at itab.
transfer itab-field to filename.
endloop.
Close dataset filename.
Sy-subrc = 0 so the file could be opened/created but there is no data being transfered and the itab contains data. Does anybody know why it doen't work?
Best regards,
Guido
2008 Nov 17 10:35 AM
Hi
If you're sure the table is filled are u sure the file was created?
Max
2008 Nov 17 10:38 AM
Hi,
I checked sy-subrc = 0 and this was the case, so the file is created then, right?
Guido
2008 Nov 17 10:39 AM
Hi
Use like this....
OPEN DATASET filename FOR OUTPUT IN TEXT MODE MESSAGE D_MSG_TEXT ENCODING DEFAULT.
IF sy-subrc ne 0.
write: 'file could not be opened, reason:' D_MSG_TEXT.
exit.
endif.
Loop at itab into <workarea>.
transfer <workarea>-field to filename.
endloop.
Close dataset filename.
Hope it will helps
2008 Nov 17 10:42 AM
2008 Nov 17 10:45 AM
Hi Gowri
I have tried it, but it doesn't make any difference wheter I use a workarea or not.
Thnx though.
Anyone else any idea's?
2008 Nov 17 10:50 AM
2008 Nov 17 11:40 AM
Hi
Try to check the sap server in order to know if the file was created: if SY-SUBRC is equal to 0 the file should be created so it's very strange u can't see any data there.
If you had authorization problem the OPEN DATASET would fail.
Max
2008 Nov 17 6:24 PM
Hi guido,
We use the following and it works fine. The one thing we did have an issue with initially was the permissions on the directory we were trying to write to, since the file goes to the application server. Talk to your network guys if you are still having problems.
DATA: dsn(40) VALUE '/usr/filename.txt'.
DATA: wa_itab like line of itab.
OPEN DATASET dsn FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
LOOP AT ITAB INTO wa_itab.
TRANSFER wa_itab TO dsn.
ENDLOOP.
ENDIF.
CLOSE DATASET dsn.
Good Luck
-SL
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |