11-04-2010 7:06 PM
I am having difficulty finding the proper technique to open attachments stored in Unix via an Abap program. For files on a PC the class CL_GUI_FRONTEND_SERVICES is available for this purpose. What about files in Unix?
Thanks for any help.
11-04-2010 8:05 PM
Hi,
I think you need to use the below Statements
OPEN DATASET <UNIX Filepath> FOR INPUT IN BINARY MODE.
READ DATASET..
CLOSE DATASET <UNIX Filepath>.
I think this may help you.
Regards,
SRinivas
11-04-2010 8:05 PM
Hi,
I think you need to use the below Statements
OPEN DATASET <UNIX Filepath> FOR INPUT IN BINARY MODE.
READ DATASET..
CLOSE DATASET <UNIX Filepath>.
I think this may help you.
Regards,
SRinivas
11-17-2010 9:57 PM
Srinivas,
Thank you for your reply. It helped me get to a solution. In essence I needed to copy the Unix file to an internal table and then save it to the end user's PC file. Then I am able to open the document / attachment.
I created a new function to:
1) call method cl_gui_frontend_services=>directory_browse, to ask the end user to pick a PC directory to copy the Unix file attachment to.
2) Then using the following code, copy the Unix file (as determined by application or user) to an internal table. Note that the line is not limited by a certain length.
types: begin of t_tab,
line type string,
end of t_tab.
data: k_wa_itab type t_tab,
t_it_itab type standard table of t_tab.
open dataset v_unixfilename for input in binary mode.
if sy-subrc <> 0.
raise unix_filename_read_error.
endif.
do.
read dataset v_unixfilename into k_wa_itab-line.
if sy-subrc <> 0.
exit.
endif.
append k_wa_itab to t_it_itab.
enddo.
close dataset v_unixfilename.
3) Using call method cl_gui_frontend_services=>gui_download, save the contents of the internal table to the PC directory from step 1 above.
4) Open the Attachment from the end users PC via:
call method cl_gui_frontend_services=>execute
It seems like a long way to get this to work, but it is working. If there is a better way maybe someone else can fill in the blanks. Ideally a tool to read and open from a file from Unix without using the cl_gui_frontend_services would be ideal.