10-07-2008 5:58 PM
Hi All,
Let me explain to you what I am doing and how I have not succeeded.
I am quiet a senior ABAP guy henceforth I am posting this and have also looked for previous posts to no avail.
Firstly, I use GUI_UPLOAD and OPEN dataset to store a PDF file on the Application Server. I have retrieved it with CG3Y without any problems. My requirement is that I have a list of these PDF files displayed on a report and a user selects ONE line and clicks VIEW PDF (custom ALV). This should then launch the PDF in acrobat from the Application server.
I have tried WS_EXECUTE but that does not work. I do not even mind if this PDF is displayed in HTML or an image. I just need some help??
ANy help will be greatly rewarded.
Thanks!!
10-07-2008 6:17 PM
ok ...
I did it about a month ago and I get any problem with this; can you open other kind of file?
for example, try to open a doc with word or wordpad or the openoffice writer...
now I am at home and I haven't an access on system. tomorrow I'll post you the piece of code I used.
If you want to post your cade, I could see if I see something wrong, else you have to wait until tomorrow.
10-07-2008 6:07 PM
hi
what's the error?
the pdf is displayed with WS_EXECUTE opening directly the adobe acrobat reader. often the error in this case is that the path to the exe for pdf is wrong
10-07-2008 6:09 PM
Hi, it just doesn't do anything. Say if the PDF location is /sap/usr/tmp/test.pdf, what should I do exactly?? Thanks in advance
10-07-2008 6:17 PM
ok ...
I did it about a month ago and I get any problem with this; can you open other kind of file?
for example, try to open a doc with word or wordpad or the openoffice writer...
now I am at home and I haven't an access on system. tomorrow I'll post you the piece of code I used.
If you want to post your cade, I could see if I see something wrong, else you have to wait until tomorrow.
10-07-2008 6:19 PM
That would be really, really handy and very appreciated.
I am also at home now, so please come back to me tomorrow.
I tried Excel File, but again, I just don't seem to get it right
10-07-2008 7:33 PM
Hi try OPEN statement FOR OUTPUT in Binary mode.
or else try to use FTP function to get the file.
Thanks.
Regards,
Jey
10-08-2008 8:18 AM
the working of this code is embedded in the comment:
" First I set some define for the program:
******************************************************************
define for the program *****************************************
******************************************************************
DATA exe_4_doc TYPE string VALUE '"C:\Program Files\OpenOffice.org 2.3\program\swriter.exe"'.
DATA exe_4_xls TYPE string VALUE '"C:\Program Files\OpenOffice.org 2.3\program\scalc.exe"'.
DATA exe_4_ods TYPE string VALUE '"C:\Program Files\OpenOffice.org 2.3\program\scalc.exe"'.
DATA exe_4_ppt TYPE string VALUE '"C:\Program Files\OpenOffice.org 2.3\program\simpress.exe"'.
DATA exe_4_pdf TYPE string VALUE '"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe"'.
*----
" local data
DATA file_path TYPE string.
" name of the executable
DATA program(128) TYPE c VALUE ''.
" I searched the file path for the extension for some type of file
" assigning the name of the program to use:
" pdf file
IF program IS INITIAL.
SEARCH file_path FOR '*pdf'.
IF sy-subrc = 0.
program = exe_4_pdf.
ELSE.
SEARCH file_path FOR '*PDF'.
IF sy-subrc = 0.
program = exe_4_pdf. " defined at the top
ENDIF.
ENDIF.
ENDIF.
....
.... " search for other extension
....
" then I assigned the value to
IF program IS NOT INITIAL.
" '"' are mandatory to avoid problems
" with white space in the path
CONCATENATE '"' file_path '"' INTO file_path.
CALL FUNCTION 'WS_EXECUTE'
EXPORTING
" file_path is the path to the file
commandline = file_path
" program is one of the define above
program = program
EXCEPTIONS
frontend_e
rror = 1
no_batch = 2
prog_not_found = 3
illegal_option = 4
OTHERS = 5.
IF sy-subrc = 0.
"error
ENDIF.
ENDIF.
-
With this code I can open every file I want with every program.
Hope this can help.
Cheers
Gabriele
10-08-2008 8:28 AM
Hi Gab,
We are so nearly there - it works for files that are on say my local drive example if I pass to the field commandline D:\test.pdf; however if I pass in say /usr/sap/tmp/00029498_30960208_delegation.pdf
which is on my application server it does not do anything apart from load acrobat.
Thanks for your help so far
10-08-2008 9:06 AM
ok
I don't know if I completley understand; in this way you are not putting information about network address. If you just set as path /usr/...
it cannot work: think if you have more hosts on the net. How can you find the correct path ? I suggest you this:
from windows "My Network Places" open a folder and then copy the path of the folder where the pdf is stored. Get from the explorer bar the address of the folder (it will be something like "
169.254.0.1\usr\.." or "
your_name_server\usr\...") and append the name of the file you want to open. Use this path in the WS_EXECUTE and retry, this should work .... (obviously you have to make sure that the folder is shared on the network)
Edited by: Gabriele Montori on Oct 8, 2008 10:07 AM
10-07-2008 8:04 PM
Can you post your GUI_UPLOAD, OPEN DATASET and WS_EXECUTE code? Did you specify BINARY for GUI_UPLOAD/OPEN Dataset?
WS_EXECUTE is marked as Obsolete in my system, what is your SAP? Do you have GUI_EXEC available?
10-08-2008 9:18 AM
Hi Dipesh ,
Please check the class CL_GUI_PDFVIEWER.
There is also a document which describes the method to display a PDF.
The link is beloe [PDF_VIEWER|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d8bb0975-0e01-0010-2192-bd1fffd80cae]
Regards,
Arun