2006 Jun 14 9:18 AM
Hi,
I have a pdf file with me, can I store it in application server, through a program.
Regards,
Vijay
Hi,
I have a pdf file with me, can I store it in application server, through a program.
Regards,
Vijay
2006 Jun 14 9:20 AM
Hi vijay,
1. CG3Z
2. U can use the above tcode to upload file
on application server.
3. If u want to write your own z program,
then u can use
GUI_UPLOAD (for uploading from front-end)
OPEN DATASET, TRANSFER , CLOSE DATASET (to write to app server)
regards,
amit m.
2006 Jun 14 9:20 AM
Hai Vijay
Go through the following Code
report zabap_2_pdf.
*-- Enhancements: only allow to be run with variant. Then called
*-- program will be transparent to users
*-- TABLES
tables:
tsp01.
*-- STRUCTURES
data:
mstr_print_parms like pri_params,
mc_valid(1) type c,
mi_bytecount type i,
mi_length type i,
mi_rqident like tsp01-rqident.
*-- INTERNAL TABLES
data:
mtab_pdf like tline occurs 0 with header line,
mc_filename like rlgrap-filename.
*-- SELECTION SCREEN
parameters:
p_repid like sy-repid, " Report to execute
p_linsz like sy-linsz default 132, " Line size
p_paart like sy-paart default 'X_65_132'. " Paper Format
start-of-selection.
concatenate 'c:\'
p_repid
'.pdf'
into mc_filename.
*-- Setup the Print Parmaters
call function 'GET_PRINT_PARAMETERS'
exporting
authority= space
copies = '1'
cover_page = space
data_set = space
department = space
destination = space
expiration = '1'
immediately = space
in_archive_parameters = space
in_parameters = space
layout = space
mode = space
new_list_id = 'X'
no_dialog= 'X'
user = sy-uname
importing
out_parameters = mstr_print_parms
valid = mc_valid
exceptions
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
others = 4.
*-- Make sure that a printer destination has been set up
*-- If this is not done the PDF function module ABENDS
if mstr_print_parms-pdest = space.
mstr_print_parms-pdest = 'LOCL'.
endif.
*-- Explicitly set line width, and output format so that
*-- the PDF conversion comes out OK
mstr_print_parms-linsz = p_linsz.
mstr_print_parms-paart = p_paart.
submit (p_repid) to sap-spool without spool dynpro
spool parameters mstr_print_parms
via selection-screen
and return.
*-- Find out what the spool number is that was just created
perform get_spool_number using sy-repid
sy-uname
changing mi_rqident.
*-- Convert Spool to PDF
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid= mi_rqident
no_dialog = space
dst_device = mstr_print_parms-pdest
importing
pdf_bytecount = mi_bytecount
tables
pdf = mtab_pdf
exceptions
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
others = 12.
call function 'DOWNLOAD'
exporting
bin_filesize = mi_bytecount
filename = mc_filename
filetype = 'BIN'
importing
act_filename = mc_filename
tables
data_tab = mtab_pdf.
----
FORM get_spool_number *
----
Get the most recent spool created by user/report *
----
--> F_REPID *
--> F_UNAME *
--> F_RQIDENT *
----
form get_spool_number using f_repid
f_uname
changing f_rqident.
data:
lc_rq2name like tsp01-rq2name.
concatenate f_repid+0(8)
f_uname+0(3)
into lc_rq2name separated by '_'.
select * from tsp01 where rq2name = lc_rq2name
order by rqcretime descending.
f_rqident = tsp01-rqident.
exit.
endselect.
if sy-subrc ne 0.
clear f_rqident.
endif.
endform." get_spool_number
Thanks & regards
Sreeni
2006 Jun 14 9:25 AM
2006 Jun 14 9:25 AM
Hi,
yes you can . you can upload the PDF file using <b>GUI_UPLOAD</b> with filetype = 'BIN' and then use open dataset , transfer, close dataset , store the fiel in application server.
it_pdf is the internal table to which you uploaded the pdf file using gui_upload fm.
open dataset file for output in binary mode .
if sy-subrc = 0.
loop at it_pdf.
transfer it_pdf file.
endloop.
endif.
close dataset.
Regards
vijay
2010 Nov 08 3:12 PM
Hi Vijay,
I have a spool from adobe form, so spool is already in pdf format, i want to read it and store it to app server in pdf format only. Can you please help.
Regards
Manu
2010 Nov 08 3:18 PM
hi,
try this code it might help u.
as im using some custom classes , modify it according to ur needs.
*--- Selection-Screen
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER : P_SPOOL TYPE RSPOID obligatory.
PARAMETERS: p_folder TYPE localfile obligatory.
* Output filename
PARAMETERS: p_ofile TYPE localfile obligatory .
* No encryption checkbox
PARAMETERS: p_nencr AS CHECKBOX MODIF ID fnm.
SELECTION-SCREEN END OF BLOCK B1 .
DATA: ls_spooljobatt LIKE tsp01.
DATA : L_FLAG.
FIELD-SYMBOLS: <x> TYPE x.
DATA: lv_objtype LIKE rststype-type,
lv_pdf TYPE xstring,
lv_pdfsize TYPE i,
lt_pdf TYPE tline_tab,
ls_pdf TYPE tline.
DATA:
gcl_util TYPE REF TO zcl_hr_ifm_pyout.
data : g_filename TYPE localfile.
*--- Selection screen events
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.
p_folder = zcl_hr_ifm=>f4_serverfile( ).
*--- Start-of-selection
START-OF-SELECTION.
CREATE OBJECT gcl_util.
* Set output filename
g_filename = gcl_util->merge_path_file( im_path = p_folder
im_file = p_ofile ).
SELECT SINGLE * INTO ls_spooljobatt FROM tsp01 WHERE rqident = p_spool.
CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
EXPORTING
authority = 'SP01'
client = ls_spooljobatt-rqclient
name = ls_spooljobatt-rqo1name
part = 1
IMPORTING
objtype = lv_objtype
EXCEPTIONS
fb_error = 1
fb_rsts_other = 2
no_object = 3
no_permission = 4.
IF lv_objtype(3) = 'OTF'.
* OTF
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = ls_spooljobatt-rqident
no_dialog = 'X'
dst_device = ls_spooljobatt-rqdest
IMPORTING
pdf_bytecount = lv_pdfsize
* btc_jobname = e_jobname
* btc_jobcount = e_jobcount
TABLES
pdf = lt_pdf
EXCEPTIONS
err_no_otf_spooljob = 1
err_no_spooljob = 1
err_no_permission = 3
err_conv_not_possible = 4
err_bad_dstdevice = 5
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 9
err_btcjob_close_failed = 9
user_cancelled = 10
OTHERS = 10.
ELSEIF lv_objtype(4) = 'TEXT'.
* Abap
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = ls_spooljobatt-rqident
no_dialog = 'X'
dst_device = ls_spooljobatt-rqdest
IMPORTING
pdf_bytecount = lv_pdfsize
* btc_jobname = e_jobname
* btc_jobcount = e_jobcount
TABLES
pdf = lt_pdf
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 1
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 9
err_btcjob_close_failed = 9
user_cancelled = 10
OTHERS = 10.
Endif.
IF NOT lt_pdf IS INITIAL.
* Convert to xstring
LOOP AT lt_pdf INTO ls_pdf.
ASSIGN ls_pdf TO <x> CASTING TYPE x.
CONCATENATE lv_pdf <x> INTO lv_pdf IN BYTE MODE.
ENDLOOP.
FREE lt_pdf.
endif.
* Download to application server
translate g_filename to lower case.
OPEN DATASET g_filename FOR OUTPUT IN BINARY MODE.
IF SY-SUBRC <> 0.
WRITE : / 'Unable to open filepath', g_filename .
.
L_FLAG = 'X'.
ENDIF.
IF L_FLAG = 'X'.
WRITE : / 'Files Download Incomplete'.
EXIT.
ENDIF.
lv_pdf = lv_pdf+0(lv_pdfsize).
TRANSFER lv_pdf TO g_filename.
.
CLOSE DATASET g_filename.
*--- End of Selection
END-OF-SELECTION.
WRITE : / 'Files Download Complete, file path', g_filename ..
Edited by: mohammed abdul hai on Nov 8, 2010 4:19 PM
2014 Jun 04 3:52 PM
Hi Vijay,
I am down loading sales order as pdf to application server.
during this process, some data is missing out.
I have used open dataset filename for output in binary mode.
after the pdf file generated, i am using CG3Y to read the file from appl server and found that some tax values are missing.
do you any idea on what went wrong.
2014 Jun 04 3:53 PM
Hi,
I am down loading sales order as pdf to application server.
during this process, some data is missing out.
I have used open dataset filename for output in binary mode.
after the pdf file generated, i am using CG3Y to read the file from appl server and found that some tax values are missing.
do you any idea on what went wrong
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |