PDF stored on Application Server - Need to retrieve and display
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!!
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
Similar Messages
-
Spool to PDF stored in application server
Hi Experts,
Please, please.....I need help.......
I have a problem with converting spool to PDF. If I download the spool to presentation, the output is fine, BUT when I download it to application server and try to view it in al11, a set of characters comes out and if I try to save it on my local drive from the application server, an error message pops out stating that it could not read the file because it is either not a supported file type or because the file has been damaged. Please help me. I've tried doing everything I can already. I cannot run the convertion of spool file to presentation because it always ends up as run time error, that's why I have no choice but to run it in background. These files will only be viewed by different offices. This files will NOT be sent via email. Please, please.......help......I'm really, really desperate......Here's what I did with the program....Please tell me where I went wrong.....Help......I've been on it for days and this is really causing a major headache........
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
PARAMETERS: p_file TYPE LOCALFILE DEFAULT TEXT-F02 OBLIGATORY.
DATA: gd_buffer TYPE STRING OCCURS 0 WITH HEADER LINE.
lt_conv LIKE gd_buffer OCCURS 0 WITH HEADER LINE.
DATA lv_string TYPE string.
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING '~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~'.
APPEND gd_buffer.
DO.
counter = strlen( gd_buffer ).
IF counter GE 255.
lt_conv = gd_buffer(255).
APPEND lt_conv.
SHIFT gd_buffer LEFT BY 255 PLACES.
ELSE.
lt_conv = gd_buffer(counter).
APPEND lt_conv.
EXIT.
ENDIF.
ENDDO.
IF lt_conv[] IS NOT INITIAL.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
IF sy-subrc 0.
MESSAGE e398(00) WITH 'Error creating file' p_file.
ENDIF.
LOOP AT lt_conv INTO lv_string.
TRANSFER lv_string TO p_file.
ENDLOOP.
CLOSE DATASET p_file.
IF sy-subrc EQ 0.
ELSE.
MESSAGE e398(00) WITH 'Error closing file' p_file.
ENDIF.
ELSE.
MESSAGE e398(00) WITH 'Error creating file' p_file.
ENDIF.
ENDIF.Hi,
maybe a look at Function Module 'CONVERT_ABAPSPOOLJOB_2_PDF' could solve your problem.
Regards
Mark-André -
Read PDF Formatted Spool and write PDF File to Application Server
Hi Experts,
After ECC 6.0, HR-W2 and W2C Form Spools are getting generated in PDF format.
We have a requirement wherein we want to read the PDF Spool Programatically and write the PDF file to Application server (Using OPEN DATASET and CLOSE DATASET)
PARAMETERS : p_spono LIKE tsp01-rqident.
DATA: pdf_data type FPCONTENT.
types: lt_pdf_table(1000) type x.
data: l_pdf_data type standard table of lt_pdf_table,
l_pdf_line type lt_pdf_table,
l_offset type i,
l_len type i,
p_file(100) VALUE '\sapout\DVH\pdf2.pdf'.
*Read the spool content
CALL FUNCTION 'FPCOMP_CREATE_PDF_FROM_SPOOL'
EXPORTING
i_spoolid = p_spono
i_partnum = '1'
IMPORTING
e_pdf = pdf_data
* e_pdf_file = file
EXCEPTIONS
ads_error = 1
usage_error = 2
system_error = 3
internal_error = 4
OTHERS = 5.
* Modify the spool contents to prepare internal table
l_len = xstrlen( pdf_data ).
while l_len >= 1000.
l_pdf_line = pdf_data+l_offset(1000).
append l_pdf_line to l_pdf_data.
add 1000 to l_offset.
subtract 1000 from l_len.
endwhile.
if l_len > 0.
l_pdf_line = pdf_data+l_offset(l_len).
append l_pdf_line to l_pdf_data.
endif.
* GUI DOWNLOAD Works Fine
* Now pdf contents is ready , lets store in local PC
*CALL FUNCTION 'GUI_DOWNLOAD'
* EXPORTING
* filename = 'C:\Documents and Settings\Desktop\shital.pdf'
* filetype = 'BIN'
* TABLES
* data_tab = l_pdf_data.
OPEN DATASET p_file FOR OUTPUT IN BINARY MODE.
IF sy-subrc <> 0.
MESSAGE ID '00' TYPE 'E' NUMBER '398' WITH 'sy-subrc:' sy-subrc
' Error opening file:'(Z03) p_file.
ENDIF.
LOOP AT l_pdf_data INTO l_pdf_line.
TRANSFER l_pdf_line TO p_file.
ENDLOOP.
CLOSE DATASET p_file.
IF sy-subrc <> 0.
MESSAGE ID '00' TYPE 'E' NUMBER '398' WITH 'sy-subrc:' sy-subrc
' Error closing file:'(Z04) p_file.
ENDIF.
Currently as you can see I have commented out GUI_DOWNLOAD Function Module, But it works perfect when I try to Download file to Local Desktop.
But when I try to pass the same Contents to Application server file and then try to open it by downloading file then it opens BLANK pdf file.
As per requirements I should be able to write the file correctly on Application server and If I dowload it from there it should open PDF file correctly.
Let me know if you require further details about the issue.
Regards
Shital
Edited by: shital phadake on Apr 8, 2009 9:39 PMThanks Selçuk for your reply and taking time for understanding the Issue,
I went thru Functionality of the program you suggested but dont think it matches my requirement.
Regards
Shital -
Retrieving PDF form from Application server
hi all,
i am saving a pdf form in application server and when the user wants the same file then i want to retrive that file from application and show the user and it should not be saved to presentation server only he should see it.
iam able to save it to presentation layer using gui_download but my requirement is not to save it show only display the form.
Thanks in advance,
Sree
helpful answers will be surely rewarded pointsHi,
1st solution - use DOI (desktop office integration). This way you can open Adobe, Microsoft, and others application documents directly in the SAP windows. See SAP document how to do it. It's not a little work, but it should fulfill your requirements.
2nd solution - share the folder with the PDF documents and then with shell command (start
server\folder\xxxxxx.pdf) at the front end access it and start the associated application at the frontend. I don't recommend this one, sharing folders at the appl.server is a security threat...
You know about the points and useful answers... -
Download PDF file from Application Server in BSP
Hello,
We have a requirement on which we want to download a PDF file stored in Application server using BSP application. I have used function module ARCHIVFILE_SERVER_TO_CLIENT but this FM will help only if i want to download file from GUI it won't work in BSP application.
Further i have used class CL_BSP_UTILITY and download method to download file from application server but it is not working in desired manner.
I am attaching my code for your reference:
DATA: BUTTON_EVENT TYPE REF TO CL_HTMLB_EVENT_BUTTON ,
EVENT TYPE REF TO IF_HTMLB_DATA.
DATA: LS_HOURS LIKE LINE OF GT_HOURS.
DATA STR TYPE STRING.
DATA: OUTPUT TYPE STRING ,
L_XSTRING TYPE XSTRING ,
APP_TYPE TYPE STRING.
EVENT = CL_HTMLB_MANAGER=>GET_EVENT( REQUEST ).
DATA PHY_NAME_OUT TYPE SAPB-SAPPFAD.
IF EVENT IS NOT INITIAL AND EVENT->EVENT_NAME = HTMLB_EVENTS=>BUTTON .
BUTTON_EVENT ?= EVENT .
CASE EVENT->EVENT_SERVER_NAME.
WHEN 'test' .
IF GT_HOURS IS NOT INITIAL.
PHY_NAME_OUT = '/usr/sap/put/form16//01000200_2007.PDF'.
OPEN DATASET PHY_NAME_OUT FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC IS INITIAL.
DO.
READ DATASET PHY_NAME_OUT INTO STR.
IF SY-SUBRC IS INITIAL.
CONCATENATE
OUTPUT
str
cl_abap_char_utilities=>cr_lf
INTO output SEPARATED BY space. "cl_abap_char_utilities=>horizontal_tab
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
*LOOP AT gt_hours INTO ls_hours.
*CONCATENATE
*OUTPUT
*ls_hours-hour
*cl_abap_char_utilities=>cr_lf
*INTO output SEPARATED BY space. "cl_abap_char_utilities=>horizontal_tab
*ENDLOOP.
APP_TYPE = 'APPLICATION/PDF;charset=utf-16le'.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = OUTPUT
MIMETYPE = 'APPLICATION/PDF;charset=utf-16le'
IMPORTING
BUFFER = L_XSTRING.
CONCATENATE CL_ABAP_CHAR_UTILITIES=>BYTE_ORDER_MARK_LITTLE
L_XSTRING
INTO L_XSTRING IN BYTE MODE.
CALL METHOD CL_BSP_UTILITY=>DOWNLOAD
EXPORTING
OBJECT_S = L_XSTRING
CONTENT_TYPE = APP_TYPE
CONTENT_DISPOSITION = 'attachment;filename=webforms.pdf'
RESPONSE = _M_RESPONSE
NAVIGATION = NAVIGATION.
ENDIF.
ENDCASE.
ENDIF.
From this code i am able to download PDF file but it is not opening in local machine.
If any other way to download file then please suggest.
waiting for ur reply.
Regards,
GaganHi,
you do the file reading wrong:
have a look at:
Local declarations.
data:
components type stringtab,
component type string,
path type text255,
file type text255,
line_length type i,
filecontent_binary type sdokcntbin,
rows type sytabix,
content type sdokcntbin,
exception type ref to cx_sy_file_access_error,
exception_tmf type ref to cx_sy_too_many_files ,
block_size type i value 1022,
length type i.
field-symbols:
<hex_container> type x.
constants:
c_dms_blk_size type i value 2550.
clear file_size.
try.
open dataset file_name for input in binary mode message message.
catch cx_sy_file_open into exception.
case exception->textid.
when '4182174D03030063000000000A1551B1'. raise access_error.
when '41825AD355C3005E000000000A1551B1'. raise open_error.
when '47E8B03AECE5BA07E10000000A114829'. raise already_open.
when others.
endcase.
catch cx_sy_file_authority into exception.
case exception->textid.
when '4182174D03030063000000000A1551B1'. raise access_error.
when 'A70BB8396F051547E10000000A11447B'. raise authority_error.
when others.
endcase.
catch cx_sy_too_many_files into exception_tmf.
case exception_tmf->textid.
when '8708B73915F6B645E10000000A11447B'. raise too_many_files.
when others.
endcase.
endtry.
do.
try.
read dataset file_name into filecontent_binary-line.
if sy-subrc <> 0.
add line_length to file_size.
append filecontent_binary to file_content_binary.
exit.
else.
add line_length to file_size.
append filecontent_binary to file_content_binary.
endif.
catch cx_sy_file_open_mode into exception.
case exception->textid.
when '9207B73915F6B645E10000000A11447B'. raise cx_sy_file_open_mode.
when '9807B73915F6B645E10000000A11447B'. raise read_only.
when '9E07B73915F6B645E10000000A11447B'. raise not_open.
when '409D273A2D824360E10000000A11447B'. raise incompatible_mode.
when others.
endcase.
endtry.
enddo.
try.
close dataset file_name.
catch cx_sy_file_close into exception.
case exception->textid.
when '4182174D03030063000000000A1551B1'. raise access_error.
when 'C10BB8396F051547E10000000A11447B'. raise close_error.
when others.
endcase.
catch cx_sy_file_access_error into exception.
case exception->textid.
when '4182174D03030063000000000A1551B1'. raise access_error.
when others.
endcase.
endtry.
Get file size.
split file_name at '/' into table components.
describe table components lines sy-tfill.
read table components into component index sy-tfill.
path = file_name.
replace component in path with ''.
file = component.
call function '/EUH/MMS_GET_FILE_SIZE'
exporting
dir_name = path
file_name = file
importing
file_size = file_size.
and function /euh/mms_get_file_size.
""Local Interface:
*" IMPORTING
*" VALUE(DIR_NAME) TYPE TEXT255
*" VALUE(FILE_NAME) TYPE TEXT255
*" EXPORTING
*" VALUE(FILE_SIZE) TYPE SDOK_FSIZE
*" EXCEPTIONS
*" NO_AUTHORITY
*" ACTIVITY_UNKNOWN
*" NOT_A_DIRECTORY
*" NO_MEDIA_IN_DRIVE
*" TOO_MANY_ERRORS
*" TOO_MANY_FILES
*" BRACKET_ERROR_IN_FILENAME
*" NO_SUCH_PARAMETER
types: begin of files,
line like ocs_file,
end of files.
data: file type files,
f_subrc like sy-subrc value 0,
errno(3) type c,
errmsg(40) type c,
pos type i,
len type i,
parameter(120) type c,
help1(120) type c,
help2(120) type c,
error_counter type i.
data:
dir_list like ocs_file occurs 0 with header line.
CASE sy-subrc.
WHEN 1. f_subrc = 64.
WHEN 2. f_subrc = 65.
WHEN 0.
search dir_name for 'SY-HOST'. "Is SY-HOST used in directory name?
if sy-subrc = 0.
pos = sy-fdpos + 7.
move dir_name(sy-fdpos) to help1.
move dir_name+pos to help2.
concatenate help1 sy-host help2 into dir_name.
endif.
do 12 times. " To avoid endless loop
if dir_name cs '$('. " Replace parameter by their value
pos = sy-fdpos + 2.
if dir_name cs ')'.
len = sy-fdpos - pos.
if len le 0.
f_subrc = 4. exit.
else.
parameter = dir_name+pos(len).
call 'C_SAPGPARAM' id 'NAME' field parameter
id 'VALUE' field parameter.
if sy-subrc = 0.
len = pos + len + 1.
pos = pos - 2.
if pos > 0.
move dir_name(pos) to help1.
else.
help1 = ''.
endif.
pos = strlen( dir_name ).
if pos > len.
move dir_name+len to help2.
else.
help2 = ''.
endif.
concatenate help1 parameter help2 into dir_name.
else.
f_subrc = 8. exit.
endif.
endif.
else.
exit.
endif.
else.
exit.
endif.
enddo.
shift dir_name right deleting trailing '/\ '.
shift dir_name left deleting leading space.
call 'C_DIR_READ_FINISH' " this is from RSWATCH0
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
call 'C_DIR_READ_START'
id 'DIR' field dir_name
id 'FILE' field file_name
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
case sy-subrc.
when 1.
case errno.
when 2 or 20. f_subrc = f_subrc + 66.
when ' '. f_subrc = f_subrc + 67.
endcase.
when 0.
clear error_counter.
do.
clear file.
clear dir_list.
call 'C_DIR_READ_NEXT'
id 'TYPE' field file-line-type
id 'NAME' field file-line-name
id 'LEN' field file-line-len
id 'OWNER' field file-line-owner
id 'MTIME' field file-line-mtime
id 'MODE' field file-line-acc_mode
id 'ERRNO' field errno
id 'ERRMSG' field errmsg. "sy-subrc = 3 is e.g. if return
if sy-subrc = 0 or sy-subrc = 3."data do not fit into variables
perform p6_to_date_time_tz(rstr0400) using
file-line-mtime
file-line-mod_time
file-line-mod_date.
file_size = file-line-len.
dir_list = file-line.
append dir_list.
elseif sy-subrc = 1. " nothing (more) found
exit.
else.
if error_counter > 50.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
pos = f_subrc mod 2.
if pos = 0. f_subrc = f_subrc + 1. endif.
exit.
endif.
add 1 to error_counter.
endif.
if sy-index > 1000.
pos = f_subrc mod 4.
if pos = 0. f_subrc = f_subrc + 2. endif.
exit.
endif.
enddo.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
if sy-opsys(3) = 'Win' and not ( file_name cs '*' ).
describe table dir_list lines len.
if len = 0.
help1 = file_name.
translate help1 to upper case.
translate help1 using
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
call 'C_DIR_READ_START'
id 'DIR' field dir_name
id 'FILE' field help1.
if sy-subrc = 0.
clear error_counter.
do.
clear file.
clear dir_list.
call 'C_DIR_READ_NEXT'
id 'TYPE' field file-line-type
id 'NAME' field file-line-name
id 'LEN' field file-line-len
id 'OWNER' field file-line-owner
id 'MTIME' field file-line-mtime
id 'MODE' field file-line-acc_mode
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
if sy-subrc = 0 or sy-subrc = 3.
help2 = file_name.
translate help2 to upper case.
help1 = file-line-name.
translate help1 to upper case.
if help1 = help2.
perform p6_to_date_time_tz(rstr0400) using
file-line-mtime
file-line-mod_time
file-line-mod_date.
dir_list = file-line.
append dir_list.
endif.
elseif sy-subrc = 1.
exit.
else.
if error_counter > 50.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
pos = f_subrc mod 2.
if pos = 0. f_subrc = f_subrc + 1. endif.
exit.
endif.
add 1 to error_counter.
endif.
if sy-index > 1000.
pos = f_subrc mod 4.
if pos = 0. f_subrc = f_subrc + 2. endif.
exit.
endif.
enddo.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
endif.
endif.
endif.
endcase.
ENDCASE.
CASE f_subrc.
WHEN 1 OR 3. RAISE too_many_errors.
WHEN 2. RAISE too_many_files.
WHEN 4 OR 5 OR 6 OR 7 OR 70 OR 71.
RAISE bracket_error_in_filename.
WHEN 8 OR 9 OR 10 OR 11 OR 74 OR 75.
RAISE no_such_parameter.
WHEN 64. RAISE no_authority.
WHEN 65. RAISE activity_unknown.
WHEN 66. RAISE not_a_directory.
WHEN 67. RAISE no_media_in_drive.
ENDCASE.
endfunction.
Now you will be able to get the filesize and the file in SDOK format sdokbin.
Okay.
You have to build an request and push the content to the user like:
call method server->response->set_header_field( name = 'Content-Type' value = value ).
describe field file_content_binary-line length line_length in byte mode.
bytes_rest = file-size.
loop at file_content_binaries assigning <file_content_binary>.
move <file_content_binary>-line to data.
if bytes_rest <= 0. "mismatch between line values and size
exit.
endif.
if bytes_rest >= line_length.
call method server->response->append_data( data = data
length = line_length ).
else.
call method server->response->append_data( data = data
length = bytes_rest ).
endif.
bytes_rest = bytes_rest - line_length.
endloop.
This will work.
You can set the header fields like you want. Have also a look at sicf node contentserver
and its handler: CL_HTTP_EXT_CSIF -
Create a Document with an original file stored on application server
Hello,
I start with document managment system : i am able to create new document (CV01N) manually, add a local file and check-in this file.
Now we need to store file which are stored on the SAP Application Server.
Firstly, in the GUI of transaction CV01N, i don't know how to browse file on application server. All files i can't attach as original, are files i can access from my computer.
Is it possible to access also on application server files ?
Moreover, i have to define function module which have to
- Create a document (DMS)
- Attach an orginial file which is stored on application server
- Check-in the file
This function module will be called from a web application
I define this kind of function and run it correctly with a local file (stored on my computer) : i call BAPI "BAPI_DOCUMENT_CREATE2" and "BAPI_DOCUMENT_CHECKIN2"
But i don't how to do with a file stored on application server. I see also note 504692 and try a program like ZZUZTEST_TEST_CHECKIN which use FM CVAPI_DOC_CHECKIN but it return an error Error uploading E:\usr\sap\TD1\DVEBMGS00\data\FACTURE.txt" (this path and file exist on application server and is really the file i want to checkin)
Please could you confirm what i search, is possible or not.
If possible, could help me with some explanations and guidelines and perhaps a sample ?
Thank you very much.
Regards,
Eric
The function used
FUNCTION Z_TEST_CHECKIN.
Checkin the first original of a document info record *
from the application server and/or in the background *
data : w_host like BAPI_DOC_AUX-HOSTNAME.
data: lf_line(255).
data: ls_draw like DRAW,
ls_message_cvapi like messages,
lt_files_cvapi type standard table of CVAPI_DOC_FILE,
lt_files_cvapi_header like CVAPI_DOC_FILE.
data: lt_originals LIKE cvapi_doc_file OCCURS 0 WITH HEADER LINE,
vo_originals LIKE cvapi_doc_file OCCURS 0 WITH HEADER LINE.
ls_draw-dokar = 'ZFT'.
ls_Draw-doknr = '0000000000000004500000032'.
ls_Draw-dokvr = '00'.
ls_Draw-doktl = '000'.
Read Originals contained in the document info record
CALL FUNCTION 'CVAPI_DOC_GETDETAIL'
EXPORTING
pf_batchmode = 'X'
pf_hostname = ' '
pf_dokar = ls_draw-dokar
pf_doknr = ls_draw-doknr
pf_dokvr = ls_draw-dokvr
pf_doktl = ls_draw-doktl
pf_active_files = 'X'
IMPORTING
psx_draw = ls_draw
TABLES
pt_files = vo_originals
EXCEPTIONS
not_found = 1
no_auth = 2
error = 3
OTHERS = 4.
IF sy-subrc <> 0.
WRITE 'Error returned by CVAPI_DOC_GETDETAIL'. "#EC NOTEXT
EXIT.
ENDIF.
Check if we can really access the file from the application server
read table vo_originals index 1.
open dataset vo_originals-filename for input in text mode ENCODING DEFAULT.
if not sy-subrc is initial.
message e500(26) with vo_originals-filename 'not found'.
endif.
read dataset vo_originals-filename into lf_line.
if not sy-subrc is initial.
message e500(26) with vo_originals-filename 'read error'.
endif.
lt_originals = vo_originals.
lt_originals-STORAGE_CAT = 'SAP-SYSTEM'.
append lt_originals.
w_host = sy-host.
CALL FUNCTION 'CVAPI_DOC_CHECKIN'
EXPORTING
PF_DOKAR = ls_draw-dokar
PF_DOKNR = ls_draw-doknr
PF_DOKVR = ls_draw-dokvr
PF_DOKTL = ls_draw-doktl
PS_DOC_STATUS =
PF_FTP_DEST = 'SAPFTPA'
PF_HTTP_DEST = 'SAPHTTPA'
*PF_HOSTNAME = w_host
PS_API_CONTROL =
PF_REPLACE = ' '
PF_CONTENT_PROVIDE = 'SRV'
IMPORTING
PSX_MESSAGE = ls_message_cvapi
TABLES
PT_FILES_X = lt_originals
PT_COMP_X =
PT_CONTENT =
IF ls_message_cvapi-msg_type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_message_cvapi-msg_txt.
ELSE.
COMMIT WORK and wait.
ENDIF.
ENDFUNCTION.This is a bit tricky. I spent lots of hours about this .
You have to set PF_HOSTNAME with your name of your AS and gives the path to the file on the server.
You wrote
*PF_HOSTNAME = w_host
But beware: if you have more thän one AS you have to fix one AS for upload or you have to find the servers name of the file. A better way can be to share one folder by each AS.
You also have to decide between HTTP or FTP.
You wrote:
PF_FTP_DEST = 'SAPFTPA'
PF_HTTP_DEST = 'SAPHTTPA'
You must define only one ! Then you have to check your settings in SM59 about working right.
Pls rate, if this was helpful.
Regards,
Markus -
How i access file which stored at application server .? Is there any fm ?
Hi,
How i access file which stored at application server . Is there any function module which provide same funtinality.
Regards,
Gurprit BhatiaHi ,
U need to use datasets for reading data from application server.Do a f1 on dataset,u will get to know rest of the things.
TRY.
OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING UTF-8.
ENDTRY.
IF sy-subrc = 0.
READ DATASET file INTO <wa_data> MAXIMUM LENGTH 200.
move the data in to internal table
close dataset
Edited by: A kumar on Aug 21, 2008 1:37 PM -
Saving PDF file into application server
Dear all,
My requirement is retrieving a PDF file from application server and modifying the document and saving it back to the application server through BSP application.
I've retrieved the data from the application server and displayed it in the frame of BSP layout and modified the same (adding signature). We got stuck in saving back the signed document into the application server.
Can anyone guide me in saving back the modified document or how to get the modified file content through BSP.
Regards
SriniHi Friend,
Hope these links will help you ,
File Upload in BSP Applications and store in Application server
Re: How to Upload .TXT, BITMAP, .PDF files into a Data base Table.
Re: sapscript - pdf
With Regards,
SHARMILA BRINDHA.M -
Issue with Uploading OTF converted PDF file on application server...
Hello Gurus,
I want to download otf converted pdf data on application server. I am using following but it does not work ?
data: i_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
wa_pdf_tab like tline,
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
max_linewidth = 132
IMPORTING
BIN_FILESIZE = w_bin_filesize
TABLES
OTF = I_OTFDATA
LINES = i_pdf_tab
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
concatenate './' 'ARCH_' SY-DATUM '_' SY-UZEIT INTO FILENAME.
OPEN DATASET FILENAME FOR output in text mode encoding default.
loop at i_pdf_tab INTO wa_pdf_tab.
TRANSFER wa_pdf_tab TO FILENAME .
ENDLOOP.
CLOSE DATASET FILENAME.
After this I am using CG3Y to downlaod the file created on application server to front end with "Transfer format data" as BIN.
But it dos not work.
Please hlep.
Regards,
Rajesh.Instead of CG3Y use this code.
DATA : p_sour TYPE string VALUE '\\usr\sap\trans\tmp\test.pdf',
p_dest TYPE string VALUE 'c:\test.pdf'.
CALL METHOD cl_gui_frontend_services=>file_copy
EXPORTING
SOURCE = p_sour
destination = p_dest
overwrite = SPACE -
PDF write to application server
Hi All,
I want to write PDF string to application server its writing but in this manner
%PDF-1.6#%####
108 0 obj#<</First 17/Length 108/Filter/FlateDecode/N 3/Type/ObjStm>>stream
xڲT0P04Q07W05#2,#ll##K#J*#R#C####Sbq#[^##GjNYjIfr##SN##kr~Jf#~xf#c^q&##Ҧ##agG#a####X###T##XR### ##b#
Please let me know where i am doing wrong.
Please see below my code .
(the scenario is when i download the pdf file i want to write the same file in to app server, there user changes the data and he will do upload )
call function fm_name
exporting
/1bcdwb/docparams = fp_docparams "
ls_header = ls_waste
lt_item = gt_rkpf
aufnr = lv_aufnr
importing
/1bcdwb/formoutput = fp_formoutput
exceptions
usage_error = 1
system_error = 2
internal_error = 3
others = 4.
concatenate 'D:\temp\PROCESSORDER_' ls_waste-rsnum '.PDF' into lv_file.
pr_file = lv_file.
open dataset pr_file for output in binary mode."text mode encoding NON-UNICODE.
if sy-subrc <> 0.
exit.
endif.
transfer fp_formoutput-pdf to pr_file.
close dataset pr_file.
clear :fp_formoutput-pdf,lv_file.
Please any one help me thanks,
Thanks,
KumarYou can't tranfer the whole PDF data with just one transfer statement, instead you have to loop that table and transfer the data to the file until you reach the last row.
open dataset pr_file for output in binary mode."text mode encoding NON-UNICODE.
if sy-subrc 0.
exit.
endif.
loop at fp_formoutput-pdf *****************
transfer fp_formoutput-pdf to pr_file.
endloop.
close dataset pr_file.
clear :fp_formoutput-pdf,lv_file. -
How to store PDF spool in Application server.
Hi,
I have a requirement to send Print form spool in Application server.
For converting OTF format we have CONVERT_OTFSPOOLJOB_2_PDF.
How to convert and store Interactive print forms spool number(PDF type) in application server.
Thanks in advance.Hi,
I have a requirement to send Print form spool in Application server.
For converting OTF format we have CONVERT_OTFSPOOLJOB_2_PDF.
How to convert and store Interactive print forms spool number(PDF type) in application server.
Thanks in advance. -
Files are stored in application server,
Files are stored in application server, I am using Open dataset to write to a file in unix box.would like to convert my itab into tab delimted and download. Please let know
is there any function?You should do a search to get the right ascii value (you can get an
ascii chart, you can google a bit, you can visit the group's page and
search for tab delimited... ) and replace 09 by the right value. And
that's it.. The technique (which is what it matters) is right.
Another tip:: you could download in two steps: first you use
gui_download or ws_download to create a tab delimited file in your pc or
in a network. Then you upload this file (using gui_upload or ws_upload
into an internal table and the final step is to use open dataset -
transfer - close dataset to write down this last itab to your app
server. -
Move pdf file into application server
Hi ABAP Gurus,
i want your valuable help in solving my problem.
i tried to create PDF file in application server and its creating as
PDF file in Application server..but i am unable to see the content in text ,
instead it is displaying in binary content...but when i tried to create
in presentation server i am able to see it as text in PDF file....
Can u please let me know whats wrong in my work and how to create a PDF file
in Application server with text content
with regards,
Gowri.Hi Gowri,
Check this example....
report ztest.
data: begin of itab occurs 0,
field(256),
end of itab.
data: dsn(100) value '/usr/sap/xfr/FIS/testpdf',
length like sy-tabix,
lengthn like sy-tabix.
call function 'GUI_UPLOAD'
exporting
filename = 'c:\temp\test.pdf'
filetype = 'BIN'
importing
filelength = length
tables
data_tab = itab.
open dataset dsn for output in binary mode.
loop at itab.
transfer itab-field to dsn.
endloop.
close dataset dsn.
clear itab.
refresh itab.
*- To crosscheck if it went well
open dataset dsn for input in binary mode.
do.
read dataset dsn into itab-field.
if sy-subrc = 0.
append itab.
else.
exit.
endif.
enddo.
call function 'GUI_DOWNLOAD'
exporting
filename = 'c:\temp\testn.pdf'
filetype = 'BIN'
bin_filesize = length
importing
filelength = lengthn
tables
data_tab = itab.
Or
Use the TCode
CG3Z or CG3Y
for downloading to Application Server.
Thanks,
Reward If helpful. -
Write PDF file into application server.
Hi Gurus,
I have created a smartform and converted into PDF using function module as given below. Now I want to write this generated PDF file into application server. I am not generating any spool request too. How can I proceed from here? Pls advice..
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = lv_bin_filesize
TABLES
otf = ls_job_output_info-otfdata
doctab_archive = lt_docs
lines = lt_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
Thanks..
Sajtransfer all the data from ur itabs to one final itab declared as follow
DATA: BEGIN OF final_itab OCCURS 0,
document TYPE string,
END OF final_itab.
then finally,
OPEN DATASET 'yourfile.pdf' FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
len = strlen( final_itab-DOCUMENT ).
TRANSFER final_itab-DOCUMENT TO 'yourfile.pdf' LENGTH len.
CLOSE DATASET 'yourfile.pdf'.
This ends the coding mate.
Enjoy it n have a good day.
Cheers -
Which application server supports EJB 3 and Java EE 5?
Hi all,
I want to develop an application using EJB 3.
I was planning on using JBOSS 4.0.4 as application server, but I am not sure whether EJB 3 is fully supported.
Which application server supports EJB 3 and Java EE 5?
ThanksJust install it using the EJB3 profile in the installer. Don't use the "All" profile
and think EJB3 is included in it :)
Maybe you are looking for
-
So, what are the best settings to record in using Canon HD Vixia HG20 for easy migration into iMovee'11 v.9.0.9? It would be most helpful to list what the best possible settings are. frame rate? format? FXP?
-
Do I need to pay anything to Adobe if I inject java script using some open source library?
Hello, I want to restrict PDF reader to achieve Digital Rights Management (DRM). Do I need to pay anything to Adobe if I inject java script to achieve so using some open source library? Basically I want my PDF documents to be restricted such that I c
-
hi can u say in which failed user login attempts will be stored.
-
Adjustment brush sliders missing in LR4 when trying to manipulate masks originally created in LR3
I am trying to re-edit some of my birding photos (CR2 raw images). I have difficult masks that were created in LR3 and took alot of time due to feathers on a complicated background. I do not want to have to re-mask everything in LR4. When I have i
-
Why do i get ORA-03113 when doing a spatial query against union all view?
Hi, i created the following view CREATE OR REPLACE FORCE VIEW cola_markets_v AS (SELECT mkt_id, NAME, shape shape_a, NULL shape_b, NULL shape_c, NULL shape_d FROM COLA_MARKETS WHERE NAME = 'cola_a') UNION ALL (SELECT mkt_id,