R/3 spool on pdf file
Hi forum,
is it possibile in R/3 to generate a pdf file for each spool into a particular file system ? I would to create a pdf file in directory for each delivery spool output.
Regards.
Ganimede Dignan.
Hi,
Actually for manual PDF file generation there is a program called RSTXPDFT2. You need to make an ABAP program to make it "automatic" conversion for particular spools. Technically, if you need it for every spool, then we need to little workaround:
1. Install SAPGUI to a PC, to have SAPLPD on it installed in the correct way.
2. Create a printer on the PC and the result should be a PDF file. It is something like "print to PDF file". You may need a third party program.
3. Create a printer type 'U' on SAP, pointing to the PC host and the "print to PDF file" printer.
4. The spools that need to be converted to PDF should have this output device as the destination.
Bare in mind that SAPLPD on the PC host must be active.
Regards,
Agoes
Similar Messages
-
Convert Screen(spool) to PDF file sending mail with attach file
Hi :
I'd like convert spool list to pdf and sending file...
so, I read thread about spool convert to PDF before,
and know how to convert Spool to PDF file and send mail with attach file.
but I have a problem.
my solution as:
step 1. Call function: "CONVERT_ABAPSPOOLJOB_2_PDF"
step 2. Call function: "SO_NEW_DOCUMENT_ATT_SEND_API1"
then, I got a mail with attached PDF file, but the PDF file display limited 255 line.( SO_NEW_DOCUMENT_ATT_SEND_API1 limited)
I want to showing word is wider that 255.
and then I find a manual method as:
After program finished.
Function Menu -> system -> List -> Send
use Prog: "Create Document and Send"
I use this prog sending mail and attached file ,
PDF file do <b>NOT</b> have 255 word limit !
finally. my question is, If I want sending mail as Prog: "Create Document and Send", how to do?
which Function I have to use?...
Please help me, Thanks!Hi,
Check this sample code of sending spool as attachment to an email address..
Parameters.
PARAMETERS: p_email(50) LOWER CASE.
PARAMETERS: p_spool LIKE tsp01-rqident.
Data declarations.
DATA: plist LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: document_data LIKE sodocchgi1.
DATA: so_ali LIKE soli OCCURS 100 WITH HEADER LINE.
DATA: real_type LIKE soodk-objtp.
DATA: sp_lang LIKE tst01-dlang.
DATA: line_size TYPE i VALUE 255.
DATA: v_name LIKE soextreci1-receiver.
DATA rec_tab LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
Get the spool data.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = p_spool
first_line = 1
last_line = 0
desired_type = ' '
IMPORTING
real_type = real_type
sp_lang = sp_lang
TABLES
buffer = so_ali
EXCEPTIONS
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE s208(00) WITH 'Error'.
LEAVE LIST-PROCESSING.
ENDIF.
Prepare the data.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 0.
plist-body_num = 0.
plist-doc_type = 'RAW'.
plist-obj_descr = 'Test ALV'.
APPEND plist.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 1.
DESCRIBE TABLE so_ali LINES plist-body_num.
plist-doc_type = real_type.
Get the size.
READ TABLE so_ali INDEX plist-body_num.
plist-doc_size = ( plist-body_num - 1 ) * line_size
+ STRLEN( so_ali ).
APPEND plist.
Move the receiver address.
MOVE: p_email TO rec_tab-receiver,
'U' TO rec_tab-rec_type.
APPEND rec_tab.
IF NOT sp_lang IS INITIAL.
document_data-obj_langu = sp_lang.
ELSE.
document_data-obj_langu = sy-langu.
ENDIF.
v_name = sy-uname.
Send the email.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = document_data
sender_address = v_name
sender_address_type = 'B'
TABLES
packing_list = plist
contents_bin = so_ali
receivers = rec_tab
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE e208(00) WITH 'Error'.
ENDIF.
COMMIT WORK.
Send the email immediately.
SUBMIT rsconn01
WITH mode = 'INT'
AND RETURN.
Thanks,
Naren -
Problem in converting spool to PDF file
Hi guys,
My spool contains Russian characters which are shown as one special char in pdf file. I guess the russian char. are not recognized by pdf.
I convert the spool to pdf using following FM
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = wa_spool-spool
no_dialog = ' '
IMPORTING
pdf_bytecount = v_numbytes
pdf_spoolid = v_pdfspoolid
btc_jobname = v_jobname
btc_jobcount = v_jobcount
TABLES
pdf = pdf.
Then i download the file using FM:
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
bin_filesize = v_numbytes
filename = v_return1
filetype = 'BIN'
TABLES
data_tab = pdf
Help me....
Point will be rewarded on helpful answers.
Regards,
GURUHI
use my code
it will do the entire job
*& Report Z8VM_SPOOL2PDF *
report z8vm_spool2pdf .
**---- Author : vivekanand meghmala
**---- Purpose : Create Single PDF file with outputs of
**---- Multiple Spools.
**---- Create Date: July 05th, 2006
**---- Analyst : Vivek Maheshwari
**---- Tables
tables : tsp01.
**---- Select Options for Multiple spools
select-options :
s_spool for tsp01-rqident obligatory.
**---- Parameters for File Path.
parameters :
p_file type localfile default 'C:combined.pdf' obligatory.
**---- Get the Spool Requests entered in Select-options for Spools.
data : i_tsp01 like tsp01 occurs 0 with header line.
**---- Work Areas and Variables
data: wa_eof type soli, "----- End of File Work Area
v_file type string, "----- String
v_size type i, "----- Size
v_lines type i. "----- Lines in Internal Table
**---- Internal Table for Spool Details and PDF and Document Details
data : i_spool_table type table of soli,
i_spool_total type table of soli with header line,
i_otf type table of itcoo with header line,
i_doc like table of docs,
i_pdf like table of tline.
**---- Move File name to Variable
v_file = p_file.
**---- Clear and Refresh Internal Tables before first use
clear i_tsp01. refresh i_tsp01.
clear i_spool_table. refresh i_spool_table.
clear i_spool_total. refresh i_spool_total.
**---- Get Spool ID Details from TSP01
select * from tsp01 into table i_tsp01 where rqident in s_spool.
**---- Sort Table in Ascending order based on Spool Id
sort i_tsp01 by rqident.
**---- Get information about Multiple spools
loop at i_tsp01.
**---- Get Multiple Spool information
call function 'RSPO_RETURN_SPOOLJOB'
exporting
rqident = i_tsp01-rqident
tables
buffer = i_spool_table
exceptions
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
others = 8.
if sy-subrc = 0.
endif.
**---- Get the Last line index (Number of Lines)
describe table i_spool_table lines v_lines.
**---- Clear Work Area for End of File (EOF) and read
**---- End of File String into it and Delete it
clear wa_eof.
read table i_spool_table index v_lines into wa_eof.
delete i_spool_table index v_lines.
**---- Collect All individual Spool Details into one internal table.
append lines of i_spool_table to i_spool_total.
at last.
**---- Append End of File information to Internal table
**---- Containing information about all the invidual spools -
**---- Thus forming one single spool
append wa_eof to i_spool_total.
endat.
endloop.
**---- Clear OTF tables before initial use
clear i_otf. refresh i_otf.
**---- Fill in the OTF internal table
loop at i_spool_total.
clear i_otf.
i_otf = i_spool_total.
append i_otf.
endloop.
**---- Convert the OTF information to PDF.
call function 'CONVERT_OTF_2_PDF'
exporting
use_otf_mc_cmd = 'X'
importing
bin_filesize = v_size
tables
otf = i_otf
doctab_archive = i_doc
lines = i_pdf
exceptions
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
others = 3.
if sy-subrc <> 0.
message i002(sy) with 'Cannot convert to PDF, exiting....'.
leave program.
endif.
**---- Download PDF file thus formed onto frontend
call method cl_gui_frontend_services=>gui_download
exporting
filename = v_file
filetype = 'BIN'
changing
data_tab = i_pdf
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
others = 24.
if sy-subrc <> 0.
message i002(sy) with 'Cannot download PDF, exiting....'.
leave program.
endif. -
I have sevaral spools and I need to transform them to one PDF. is it possible to put all the spool and to create only one ''big spool'' and then transform it to pdf (or to have several pdf files and concatenate them to one pdf file).
BenjaminHi,
You can convert the SPOOL to PDF using the beelow function module
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
So,lets say you want 3 spools in a single PDF,
DO 3 TIMES.
Call the function module and create an internal table, in another internal table append the data. do like this in 3 times.
ENDDO.
After the END DO , you will get all the data in a Single PDF.
http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
Regards
Sudheer -
Problem in converting Spool to PDF file, having non-English characters
Hi All,
I have problem in converting Spool to PDF format.
Scenario : I have a spool which has non-English characters. I am using CONVERT_ABAPSPOOLJOB_2_PDF FM to perform conversion. But my output is having junk values( ie # ) for non-English characters. Any pointers to solve this issue will be appreciated.
I even tried with report RSTXPDFT4 , it also gives me the same junk characters.
Regards,
Navin.Hi All,
I have problem in converting Spool to PDF format.
Scenario : I have a spool which has non-English characters. I am using CONVERT_ABAPSPOOLJOB_2_PDF FM to perform conversion. But my output is having junk values( ie # ) for non-English characters. Any pointers to solve this issue will be appreciated.
I even tried with report RSTXPDFT4 , it also gives me the same junk characters.
Regards,
Navin. -
Spool List more than 99 pages to PDF File to Mail
Hi All,
I want to convert a big spool list (342 Pages) to PDF file to send it by e-mail.
I use the following code to convert my spool to PDF file:
Convert to PDF file*
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = w_spool_id
no_dialog = 'X'
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings*
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
The problem with the FM 'CONVERT_ABAPSPOOLJOB_2_PDF' is when my spool have more than 99 pages. In this case, the FM generate a backscreen job (sm37) to convert my spool and generate a binary PDF spool.
After this step, the 'FM SO_DOCUMENT_SEND_API1' send an e-mail with the binary PDF File recovered in the spool list but i can't open the file with Adobe Reader because the format is wrong.
Someone knows how could i convert my big spool list to PDF file to send it by e-mail adress ?
Thanks a lot for your precious help that i need so much !Generate big spool list
REPORT ZGEN_SPOOL.
tYPE-POOLS: slis.
TYPES: BEGIN OF str_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
laeda TYPE mara-laeda,
aenam TYPE mara-aenam,
vpsta TYPE mara-vpsta,
END OF str_mara.
DATA: i_mat TYPE TABLE OF str_mara,
wa_mat LIKE LINE OF i_mat.
DATA:params LIKE pri_params.
DATA: days(1) TYPE n VALUE 2,
valid TYPE c.
DATA: obj TYPE REF TO cl_salv_table.
SELECT matnr
ersda
ernam
laeda
aenam
vpsta
UP TO 4999 ROWS
FROM mara INTO CORRESPONDING FIELDS OF TABLE i_mat.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = obj
CHANGING
t_table = i_mat.
CATCH cx_salv_msg .
ENDTRY.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
* destination = 'QAS'
list_name = 'ZTEST_VERTEX'
list_text = 'TEST'
no_dialog = 'X'
immediately = ' '
expiration = days
IMPORTING
* OUT_ARCHIVE_PARAMETERS =
out_parameters = params
valid = valid
* VALID_FOR_SPOOL_CREATION =
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4
IF sy-subrc ne 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
TRY .
NEW-PAGE PRINT ON PARAMETERS params NO DIALOG.
CATCH cx_sy_nested_print_on .
ENDTRY.
CALL METHOD obj->display.
NEW-PAGE PRINT OFF. -
Convert PDF File to ASCII / Text File
Hello,
I have a PDF File that was created from a Spools (Output of Smart Form to begin with and run in background) using the SAP Function module - CONVERT_OTFSPOOLJOB_2_PDF and I have the pdf file archived.
Now, I need to do Reverse process. The original Spool is gone, and I need to extract some data from the pdf file - say, for example:
I need to extract A/c numbers where the Label is "Account No:" followed by value of the Account No.
I opened the pdf file in Binary mode, stored into an internal table of type Hex and then LOOP ed through this table.
Moved the Hex data to a long enough data field of Type C to use "CS" operator in an IF Statement to look for the String "4163636F756E74204E6F3A" which is Hex representation of 'Account No:' (without the single quotes).
I can see 'Account No:' in the PDF File but my IF Statement with CS fails. I even tried to find the Zip Code using CS Statement - it fails too.
Some sample codes that I used are as follows:
LV_TAG_1_C = '4163636F756E74204E6F3A'.
refresh: T_DATA_FILE_C.
LOOP AT T_DATA_FILE_X.
ASSIGN T_DATA_FILE_C-DATA TO <FS_C>.
T_DATA_FILE_C-DATA = T_DATA_FILE_X-DATA.
IF T_DATA_FILE_C-DATA CS LV_TAG_1_C.
* The Above IF Statement NEVER became TRUE - even though I can see the "Account No:"
LV_VAL_1_C = <FS_C>+SY-FDPOS(6).
APPEND T_DATA_FILE_C.
ENDIF.
ENDLOOP.
Outside LOOP, T_DATA_FILE_C is still EMPTY.
Please let me know if you know of any example where I can extract data in ASCII format from a PDF File.
Please NOTE - I do NOT need to convert a spool to PDF File (whole website is full of this) - I need the opposite !!!
Help will be much appreciated.
Regards,
Tarun
Message was edited by: Matthew Billingham - email address removedHello Manish,
Thanks a lot for your suggestion. This pdf file is really not a 1 to 1 representation of ASCII to Hex and vice verse. Your suggestion is really good.
I think, we are very close. Do you know the Function Module name that I need to use - this is what we have in ECC / R/3. An example with which Function module I need to use with some sample code - basically, what I need to supply and where does the result go - will be great.
Thanks again Manish.
INCLUDE LSSXPU01. "SXPG_STEP_XPG_START
INCLUDE LSSXPU02. "SXPG_STEP_END
INCLUDE LSSXPU03. "SXPG_STEP_COMMAND_START
INCLUDE LSSXPU04. "SXPG_JOB_END
INCLUDE LSSXPU05. "SXPG_STEP_START_UPDATE
INCLUDE LSSXPU06. "SXPG_STEP_END_UPDATE
INCLUDE LSSXPU07. "SXPG_JOB_END_UPDATE
INCLUDE LSSXPU08. "SXPG_COMMAND_CHECK
INCLUDE LSSXPU09. "SXPG_DUMMY_COMMAND_CHECK
INCLUDE LSSXPU10. "SXPG_APPSERV_RFCDEST_GET_INT
INCLUDE LSSXPU11. "SXPG_RFCDEST_OPEN_INT
INCLUDE LSSXPU12. "SXPG_COMMAND_CHECK_INT -
Problem in converting spool to pdf
Hi Experts,
I want an internal table to be converted to the PDF. For this RSPO_OPEN_SPOOLREQUEST, RSPO_WRITE_SPOOLREQUEST and RSPO_CLOSE_SPOOLREQUEST to create the spool. However, somehow the table tsp01 does not gets updated as a result i could not convert the data to PDF. Can any one help me how this problem could be solved.
Thank.
Warm Regards,
Harshad.Hi,
you can refer this sample code.
DATA: t_otfdata_tab LIKE ITCOO OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'CLOSE_FORM'
TABLES
OTFDATA = t_otfdata_tab
fill the exceptions..
IF SY-SUBRC = 0.
ENDIF.
then pass the t_otfdata_tab to this function module..
CONSTANTS: c_pdf(03) VALUE 'PDF'.
PDF File size
DATA: w_file_size TYPE I.
Internal Table to hold Form contents in PDF format
DATA: t_pdfdata_tab LIKE tline OCCURS 0 WITH HEADER LINE.
for converting. the output format from OTF to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT eq c_pdf
IMPORTING
BIN_FILESIZE = w_file_size
TABLES
OTF eq t_otfdata_tab
LINES eq t_pdfdata_tab
EXCEPTIONS...
use these links, hope it will be useful to you....
Problem in converting spool to PDF file
Problem in converting the spool to PDF.
Thanks and Regards,
Ahamed. -
How to use PO message type to output 'Form' as PDF file
Dear experts,
I am working for a topic of how to use PO message type to output 'Form' as 'PDF file', and save to external file system automatically.
Any one familiar to this topic, please kindly give me some guide, thank you!
Regards,
JoyceHi,
Go through the program RSTXPDFT4 (Converting SAPscript (OTF) or ABAP List Spool Job to PDF), you will get some idea. Using this program you can convert spool into PDF file.
-Alpesh -
Hello experts,
I am using <b>RSTXPDFT4</b> to convert SPOOL(<b>Script</b>) to PDF. It works fine in foreground if the number of pages is < 100.
But, if the pages are > 100 then it asks for running in background. I have chosen to run in background. But It did not ask me to specify the file path for creating the pdf file!
I am wondering where the pdf file is stored in this case ?? !!!. Anybody has encountered this before ????
It also noticed that it is creating one more spool number (<b>binary format</b>) when u specify it run the program <b>RSTXPDFT4</b> in background.Hello experts,
RSTXPDFT4 works fine for me if i want to convert spools to pdf files in foreground mode.
If i want to do this in background mode as a daily job i am not able to use RSTXPDFT4.
With report RSTXPDFT5 i am able to download in background as binary data but not as pdf.
So, i want to download spools to network shared folder in pdf formaat.
Thanks for suggestions & Regards
Janez -
While converting spool to PDF, no data is coming in the PDF file.
Hi All,
I am submitting a z program ZPR022_INNCOMETAX_REPORT_COPY1 (which has some output display) from Z_ITSLIP_MAIL. I am creating a job, submitting the above program via JOB to SAP-SPOOL.
In program ZPR022_INNCOMETAX_REPORT_COPY1 , I am getting the run time job information and from there I am getting the spool id. Now I am converting the spool id to a PDF. This PDF should contain the output of the program ZPR022_INNCOMETAX_REPORT_COPY1. This output is normal output using Write statement only. But once the program is executed, I could find no data in the PDF file. When I check in SM37 and SP02, both the JOB and the SPOOL are created. What I feel is the program is not picking the spool id at the run time. Could any one help me in this regard how to proceed.
Please find the code below.
Program 1.
LOOP AT pernr.
CLEAR p_job.
p_stim = p_stim + 120.
CONCATENATE'ITSlip' pernr-low p_job sy-datum INTO p_job SEPARATED BY
space.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = p_job
sdlstrtdt = p_sdat
sdlstrttm = p_stim
IMPORTING
jobcount = l_jobcount.
SUBMIT ZPR022_INNCOMETAX_REPORT_COPY1
WITH pnptimr6 = 'X'
WITH pnpbegda = period-low
WITH pnpendda = period-high
WITH pnppernr-low = pernr-low
WITH pnpabkrs-low = 'IN'
VIA JOB p_job
NUMBER l_jobcount
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS ls_params
WITH immediately = 'X'
KEEP IN SPOOL = 'X'
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = l_jobcount
jobname = p_job
strtimmed = 'X'
PRDMINS = 2.
sdlstrtdt = p_sdat
sdlstrttm = p_stim.
ENDLOOP.
Program 2.
IF sy-batch EQ 'X'.
LOOP AT pnppernr.
SELECT SINGLE * FROM pa0105
WHERE pernr EQ pnppernr-low
AND subty EQ '0010'
AND endda EQ '99991231'.
p_email1 = pa0105-usrid_long..
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
IF sy-sysid = c_dev.
WAIT UP TO 5 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ENDLOOP.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool'
'request to be created.'.
EXPORT gd_spool_nr TO MEMORY ID 'SPOOLTOPDF'.
ENDIF.
ENDFORM. " SEND_MAIL
*& Form get_job_details
text
--> p1 text
<-- p2 text
FORM get_job_details .
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM. " get_job_details
*& Form obtain_spool_id
text
--> p1 text
<-- p2 text
FORM obtain_spool_id .
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
MESSAGE s004(zdd) WITH gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM. " obtain_spool_id
*& Form convert_spool_to_pdf
text
--> p1 text
<-- p2 text
FORM convert_spool_to_pdf .
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM. " convert_spool_to_pdf
*& Form process_email
text
--> p1 text
<-- p2 text
FORM process_email .
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
ENDFORM. "process_email
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'IT Declaration'.
CONCATENATE 'ITSLIP' ' ' INTO gd_attachment_name.
it_mess_bod = 'IT FORM for this month'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
TABLES it_mess_bod
it_mess_att
USING p_email1
'MindTree Payroll team'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
CHANGING gd_error
gd_reciever.
ENDFORM. " process_email
*& Form send_file_as_email_attachment
text
-->P_IT_MESS_BOD text
-->P_IT_MESS_ATT text
-->P_P_EMAIL text
-->P_4422 text
-->P_4423 text
-->P_GD_ATTACHMENT_NAME text
-->P_GD_ATTACHMENT_DESC text
-->P_P_SENDER text
-->P_GD_SENDER_TYPE text
<--P_GD_ERROR text
<--P_GD_RECIEVER text
FORM send_file_as_email_attachment TABLES it_message
it_attach
USING p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
CHANGING p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM. "send_file_as_email_attachment
Points will be rewarded.
Regards,
BalajiHi,
I think you are retrieving the spool before the entire spool is generated.
Put the following logic to retrieve spool iD
CHECK WHETHER STATUS OF JOB IS COMPLETED OR CANCELLED
WHILE 1 = 1.
GET THE JOB STEPLIST WHICH HAS THE SPOOL NUMBER
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = w_jobname
job_read_opcode = '35'
JOB_STEP_NUMBER =
IMPORTING
job_read_jobhead = wa_jobhead
TABLES
job_read_steplist = i_jobsteplist
CHANGING
RET =
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
BEGIN OF INSERTION U179942 E1BK928781
IF STATUS OF JOB IS COMPLETED(F) OR CANCELLED(A)
READ THE JOBSTEPLIST & GET THE SPOOL NUMBER
IF wa_jobhead-status = c_a OR wa_jobhead-status = c_f.
READ TABLE i_jobsteplist INTO wa_jobsteplist INDEX 1.
CHECK wa_jobsteplist-listident <> space.
w_spool_number = wa_jobsteplist-listident.
EXIT.
ENDIF.
ENDWHILE.
Best regards,
Prashant -
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 -
Merge Different Spools containing a Single PDF page into a Single PDF file.
Greetings,
I am developing a custom object where in i need to read PDF file from many different Spools(Range given on Input Screen), where each spool has a single PDF page in it. I need to combine all these PDF Pages into a single PDF file & either create a new Spool or save it on an Application Server.
At present i have developed the code where in i am able to read the PDF files from different spools & convert them into Binary but i am not able to generate it back to PDF file.
Kindly find my code for your reference.
CODE:-
START-OF-SELECTION.
PERFORM f_get_spool_1000 .
PERFORM g_conv_pdf_to_bin_2000 .
*& Form F_GET_SPOOL_1000
text
FORM f_get_spool_1000 .
SELECT * FROM tsp01
INTO TABLE gt_tsp01
WHERE rqident IN s_spool
ORDER BY rqcretime DESCENDING.
IF sy-subrc = 0.
SORT gt_tsp01 BY rqident .
ENDIF.
ENDFORM.
*& Form G_CONV_PDF_TO_OTF_2000
text
DATA: lv_filename_out TYPE string,
lv_len TYPE i,
lt_tab TYPE tsfixml .
DATA: lwa_print_parms LIKE pri_params,
lv_valid(1) TYPE c .
DATA: lv_linsz LIKE sy-linsz VALUE 132, " Line size
lv_paart LIKE sy-paart VALUE 'X_65_132'. " Paper Format
DATA : lt_tsp01 TYPE STANDARD TABLE OF tsp01 ,
lwa_tsp01 TYPE tsp01 .
CLEAR : gv_pdf, gwa_tsp01, gv_renderpagecount .
LOOP AT gt_tsp01 INTO gwa_tsp01.
CALL FUNCTION 'FPCOMP_CREATE_PDF_FROM_SPOOL'
EXPORTING
i_spoolid = gwa_tsp01-rqident
i_partnum = 1
IMPORTING
e_pdf = gv_pdf
e_renderpagecount = gv_renderpagecount
e_pdf_file = gv_pdf_file
EXCEPTIONS
ads_error = 1
usage_error = 2
system_error = 3
internal_error = 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.
CLEAR lv_len .
REFRESH gt_bin .
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = gv_pdf
IMPORTING
output_length = lv_len
TABLES
binary_tab = gt_bin.
CLEAR gwa_bin .
LOOP AT gt_bin INTO gwa_bin.
APPEND gwa_bin TO gt_listout.
CLEAR gwa_bin .
ENDLOOP.
ENDLOOP.
Get FP reference
DATA: lo_fp TYPE REF TO if_fp VALUE IS INITIAL,
lo_pdfobj TYPE REF TO if_fp_pdf_object VALUE IS INITIAL,
lo_exc TYPE REF TO cx_root,
lv_xslt_message TYPE string .
lo_fp = cl_fp=>get_reference( ).
For handling exceptions
DATA: lo_fpex TYPE REF TO cx_fp_runtime VALUE IS INITIAL.
TRY.
lo_pdfobj = lo_fp->create_pdf_object( connection = 'ADS' ).
Set document
lo_pdfobj->set_document(
EXPORTING
pdfdata = gt_listout ).
Tell PDF object to extract data
lo_pdfobj->set_extractdata( ).
Execute the call to ADS
lo_pdfobj->execute( ).
CATCH cx_root INTO lo_exc.
lv_xslt_message = lo_exc->get_text( ).
ENDTRY.
Your quick reply would be of great help.
Regards.Thank Your for your concern, there are many replies & posts but all of them points only to Try what they have said. As being said that trying to convert PDF to binary & appending many PDF similarly would not let you generate a single PDF again.
Your Kind guidance would be really appreciable.
Regards. -
Not able to convert spool output to PDF file properly
Hi guys,
i have got spool which contains russian characters which needs to be converted to PDF file.
Note: ******Assuming user enters only one spool in S_Spool*******
I am using following code to do this:
**---- Get Spool ID Details from TSP01
select * from tsp01 into table i_tsp01 where rqident eq s_spool.
**---- Sort Table in Ascending order based on Spool Id
sort i_tsp01 by rqident.
**---- Get information about Multiple spools
loop at i_tsp01.
**---- Get Multiple Spool information
call function 'RSPO_RETURN_SPOOLJOB'
exporting
rqident = i_tsp01-rqident
tables
buffer = i_spool_table
exceptions
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
others = 8.
if sy-subrc = 0.
endif.
**---- Get the Last line index (Number of Lines)
describe table i_spool_table lines v_lines.
i_otf[] = i_spool_table[].
endloop.
**---- Convert the OTF information to PDF.
call function 'CONVERT_OTF_2_PDF'
importing
bin_filesize = v_size
tables
otf = i_otf
doctab_archive = i_doc
lines = i_pdf
exceptions
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
others = 3.
if sy-subrc <> 0.
message i002(sy) with 'Cannot convert to PDF, exiting....'.
leave program.
endif.
DATA: v_numbytes TYPE i.
DATA : v_return1(128).
CONCATENATE 'C:\' 'F_spool' '.pdf' INTO v_return1.
CONDENSE v_return1.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
bin_filesize = v_size
filename = v_return1
filetype = 'BIN'
IMPORTING
filelength = v_numbytes
TABLES
data_tab = i_pdf
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
OTHERS = 10 .
IF sy-subrc NE 0.
EXIT.
ENDIF.
i have already tried standard pgm : RSTXPDFT4. But it does not work.
Suitable answers will be rewarded.
Thanks,
GURUHi Guru,
Use FM 'CONVERT_ABAPSPOOLJOB_2_PDF'.
Refer this code:
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Regards,
Hemant -
Page format problem while converting spool job to PDF file
Hi,
I convert the sapscript from spoollist to pdf with the FM CONVERT _ OTFSPOOLJOB _ 2 _ PDF giving the spool id but I can not get the file properly. It adds a raigth margin to the PDF file.
Should I call aany other FM to format the PDF file ?
Thanks.
Utku.Hi,
I have executed the report and the PDF file has the right margin.
In the properties of PDF file it says PDF version 1.3 (Acrobat 4.x) and Page Size 11.69 in x 11.69 in
Also I open the PDF file with Acrobat 5.0
Thanks.
Utku.
Maybe you are looking for
-
What you know about this?
Well first of all hi, ok...im interested in buying the nano ipod, but i have recently read that it scratches easily and that the battery is too short( i mean the period of time that you use it). I would apreciatte all your answers, and opinions about
-
Is it just me???
Ok, I know this has been discussed probably millions of times... but I'm going to throw it back out there one more time. This COMPRESSION thing *****!!! It is a broken system. It should never be this difficult to get a decent end product. How do the
-
How to read .wmv files on a MacBook?
Hello, Are you able to read .wmv files on a Mac? It keeps opening Picasa, which does not work obviously. Thanks
-
Web Services 2.0 Update Method
Hi, I'm using the update method but I'm only able to make it work with string value, it doesn't work with bool, number, currency, date....Any thoughts??? Thanks
-
Java does not have pointer ..the reason
Although java allows reference variable to objects... it does not allow pointers...... because Java byte code runs on the excution environment of host pc.. Applets are run on the embedded programs (webbrowser or else) in client pc. so if ....... if j