Spool to PDF output in application server
Hi Experts,
I have a problem with converting spool to PDF. If I download the spool to presentation, the outputs 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, 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 needs to be distributed to all branch offices. Please, please.......help......I'm desperate......
Hi Nikhil,
I'm sorry....but I'm still stucked. If I try to view the pdf output in AL11 this characters are still displayed "═䑆ⴱ⸳ഊ◢팍ਲ扪ഊ⽗楮䅮獩䕮捯摩湧ഊ敮摯扪ഊ㌠〠潢樍਼㰍ਥ䑥癴祰攠偏協㈠⁆潮琠䍏啒䥅删潲浡氠䱡湧⁅不ਯ呹灥 䙯湴ഊ⽓畢瑹灥 呹灥ㄍਯ䉡獥䙯湴 䍯畲楥爍ਯ乡浥 䘰", and when the basis transferred it to the local folder the same error came out that the file could not be read either it is corrupted or file type is not supported. Please.....I've been on it for hours and can't seem to get the problem. Here's what I did with the program....Please tell me where I went wrong.....Help......
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.
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é -
Download spool to PDF document on application server
Hi,
I am using function CONVERT_OTFSPOOLJOB_2_PDF to convert a sapscript spool and then downloading the internal table provided to a pdf file on the application server. The sapscript form contains company logos.
After transferring the file from the application server to PC and then opening the pdf document I get the following message:
"There was an error while trying to parse an image."
The PDF doc contains everything except the company logo.
I noticed that this works (i.e. company logo is present in the downloaded file) when I transfer the internal table that contains the PDF contents onto my PC using GUI_DOWNLOAD using mode 'BIN'. However, when I transfer the contents of the same internal
table to a file on the application server using abap statement:
'Open Dataset <filename> FOR OUTPUT IN BINARY MODE'
I get the problem described above.
I noticed that SAP has provided standard program RSTXPDFT4 to convert a spool and download it into a PC file. However is there a similar program that downloads a spool onto the application server? Perhaps there is a 'special' way in downloading PDF documents onto the application server?
I don't this problem with sapscripts that do not have a company logo.
Is there a certain restriction on 'Open Dataset'with transfering logos in PDF documents?
Any help would be greatly appreciated in the form of reward points.
Thanks
LiamHi,
We convert some of our spools to pdf and store them on the app server using following high level process.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = p_spool
no_dialog = 'X'
dst_device = 'LOCL'
TABLES
pdf = lt_pdf
EXCEPTIONS
OTHERS = 0.
Write PDF file
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_32 = l_guid.
CONCATENATE '/your_path_goes_here/'
l_guid
INTO l_filename.
CONCATENATE l_filename '.pdf' INTO l_filename.
Store
OPEN DATASET l_filename IN TEXT MODE.
IF NOT sy-subrc IS INITIAL. " only write pdf if new
LOOP AT lt_pdf.
TRANSFER lt_pdf TO l_filename.
ENDLOOP.
ENDIF.
CLOSE DATASET l_filename.
If it doesn't work, I would 1st try and play with image type. I'm wondering if it's tripping on image conversion. Perhaps revert to 1st principles and try monochrome bitmap and a few variations thereof. I stand by my code above. Definitely works. HTH, Dave -
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 -
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 -
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. -
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. -
Display logo In PDF output ( Spool to PDF output )
Hi Experts,
In my requirement i am using 'REUSE_ALV_GRID' to display logo.
In our functionality we are executing report in background and we are converting spool into PDF output. Now our requirement is to display LOGO in PDF output.
Any pointers on this are appreciated.
Regards,
Bhanu.RHello,
Use the top-of-page parameter of the FM 'REUSE_ALV_GRID_DISPLAY' and use the FM REUSE_ALV_COMMENTARY_WRITE to add the logo to the I_LOGO export parameter to get the logo in the ALV output. Now convert this to spool and to pdf and you can get the logo in the pdf as well
Vikranth -
Output to application server.
Hello All,
I have ouput in HIERARCHIAL LIST. Im displaying Header table G_T_VBAK and Item table G_T_VBAP.
I want to save this output in application server. Can any one help?
My code is as follows.
OPEN DATASET g_f_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
MESSAGE e899(mm) WITH 'not possible' space space space.
EXIT.
ELSE.
LOOP AT g_t_vbak.
TRANSFER g_t_vbak TO g_f_file.
LOOP AT g_t_vbap.
TRANSFER g_t_vbap TO g_f_file.
ENDLOOP.
ENDLOOP.
ENDIF.
It is giving dump at the line TRANSFER g_t_vbap TO g_f_file. (second loop statement).
Good answers will be appriciated with points.
Thanks in advance.
Best Regards,
Sasidhar Reddy Matli.Hello Kris,
The dump message is as follows:
What happened?
Error in ABAP application program.
The current ABAP program "ZSSR_ORDER_DETAILS_HIER1" had to be terminated
because one of the
statements could not be executed.
This is probably due to an error in the ABAP program.
Error analysis
Only character-type data objects are supported at the argument
position "f" for the statement
"TRANSFER f TO ...".
In this case, the operand "f" has the non-character-type "u". The
current program is flagged as a Unicode program. In the Unicode context,
type X fields are seen as non-character-type, as are structures that
contain non-character-type components.
Source code extract
002370 FORM download_to_application_server .
002380
002390 OPEN DATASET g_f_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
002400
002410 IF sy-subrc NE 0.
002420
002430 MESSAGE e899(mm) WITH 'not possible' space space space.
002440 EXIT.
002450
002460 ELSE.
002470
002480 LOOP AT g_t_vbak.
002490
002500 TRANSFER g_t_vbak TO g_f_file.
002510
002520 LOOP AT g_t_vbap.
> TRANSFER g_t_vbap TO g_f_file.
002540 ENDLOOP.
002550
002560 ENDLOOP.
002570
002580 ENDIF.
002590
002600 ENDFORM. " download_to_application_server
Best Regards,
Sasidhar Reddy Matli. -
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... -
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 -
Generate pdf file on application server
Hi.
I want to get an pdf file on the application server. i use a new output device "PDF_PRINT" with the device type "PDF1".
I get files pdf files on the front-end after input filename in the c:\windows\system32 folder, but i need the files on the application server. where can i control the filename and the destination?
with the host spool access method? and the filename???Hi,
can you look at this
[https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e71cd560-0a01-0010-18a2-a7391f56b4f4?overridelayout=true]
Regards,
Muralidhar -
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 -
Writing smartform output in application server
Hi,
i have a smartform output having logo and other details. After this i am converting the smartform output to PDF file and i tried write into application server using Open Dataset, Close Dataset. The thing is i am unable to see the output in pdf file and when i tried to open am getting some error. Is there any way to write pdf file which having logo into application server.
please guide me.what mode did you use in th open dataset statement?
You should use BIN mode in open dataset statement.
Regards,
Ravi
Maybe you are looking for
-
Help (Timed program)
I�ve done this game, that if the user takes more than 30 sec. to answer, the program, when the user answer, tells that the time has been more that 30 sec. so the answer is not valid; I would like that the program, during the time the user is answerin
-
What is the significance of Quantity reduced in confirmation tab of a PO
I have a PO created for a foreign vendor. after creating a PO ibd is done and then GRN. after GRN user found that he prepared grn against wrong IBD so he cancelled all the GRN he preapred and creates new grn. Now in po The open quantity showing as 85
-
I am using an iPad 3 with iOS 8.1. When I receive a text on my iPhone, it is also displayed on my Macbook, but not my iPad. I do however, receive calls from my iPhone on my iPad. The texts I receive are about half and half from iPhone and non-iPhone
-
I'm experiencing difficulties with Flash 8 not recognizing the majority of a font family. Its strange because Photoshop & Illustrator recognize them & display them just fine. The fonts involved my project include: Helvetica Helvetica Compressed Helve
-
I notice when I laying down read my ipad the screen blinks out and I have to enter password to continue using it.