ITAB to PDF without spool request
Hi Experts,
I have a requirement where I need to convert internal table data into PDF format and send it as an E-Mail with PDF attachment.
How do I achieve this .
I dont have any smart form or SCript...
In Fact I don't want to use SPOOL....
Is there any way to convert Internal Table to PDF.....
Please Guide....
Edited by: Thomas Zloch on Sep 29, 2011 1:50 PM
Hi,
try below stuff,
http://wiki.sdn.sap.com/wiki/display/Snippets/SENDALVGRIDASPDFATTACHMENTTOSAPINBOXUSINGCLASSES
some more info like this at ,
http://wiki.sdn.sap.com/wiki/display/ABAP/SendingMails-HomePage
Thanks,
Chandra
Edited by: Chandrashekhar Mahajan on Sep 29, 2011 3:25 PM
Similar Messages
-
Convert ABAP list output to PDF without spool
Hi All,
We have used the FM 'CONVERT_ABAPSPOOLJOB_2_PDF' to convert the list output to PDF. It creates the spool number in SP01 and PDF is getting generated.
But, in our SAP ECC 6.0 server all spools are redirected to printer by default and get printed because it configured like that. We requested BASIS people to reconfigure but they said no for a single report.
So we need to find the alternate solution to generate the PDF without spool. We have searched in sdn, but didnot get any alternate solution.
Please help us in this regard.
Thanks in advance.data: begin of i_list occurs 0,
line(255),
end of i_list.
data:i_mara like mara occurs 0 with header line.
parameters: p_matnr like mara-matnr.
start-of-selection.
set pf-status 'PDFFILE'.
select *
from mara
into table i_mara
where matnr = p_matnr.
loop at i_mara.
write:i_mara-matnr,i_mara-ernam,i_mara-pstat.
endloop.
at user-command.
if sy-ucomm = 'PDF'.
DO.
READ LINE SY-INDEX.
IF SY-SUBRC NE 0.
EXIT.
ELSE.
I_LIST = SY-LISEL.
APPEND I_LIST.
ENDIF.
ENDDO.
NEW-PAGE PRINT ON DESTINATION 'LP03' IMMEDIATELY ' ' COVER TEXT ' ' KEEP IN SPOOL 'X' NEW LIST IDENTIFICATION 'X' LINE-SIZE 132 LINE-COUNT 65 NO DIALOG.
LOOP AT I_LIST.
IF I_LIST-LINE IS INITIAL.
SKIP.
ELSE.
at first.
write: TEXT-001.
endat.
WRITE: I_LIST-LINE+0(132).
ENDIF.
ENDLOOP.
NEW-PAGE PRINT OFF.
data:filename like RLGRAP-filename value 'C:\PDFFILE.PDF'.
DATA: SPOOL TYPE TSP01-RQIDENT.
SPOOL = SY-SPONO.
SUBMIT rstxpdft4
WITH spoolno = spool
WITH download = 'X'
WITH p_file = filename
AND RETURN.
if sy-subrc = 0.
write: 'pdf file generated'.
else.
write:'pdf file not generated'.
EXIT.
endif.
endif.
please paste this code and check once ,if it works modify the code according to ur requirement.
regards,
padmaja -
Smartforms to pdf without spool
Hello,
Is it possible to convert a smartform to pdf without a spool id ? I need to generate a pdf file from a smartform without print it.
Thanks.Hi Julián Moreno Luna,
Please check this link
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/smartform%2bto%2bmail%2bas%2bpdf%2battachment
*& Report ZTEST_NREDDY_PDF_MAIL
REPORT ZTEST_NREDDY_PDF_MAIL.
* Internal Table declarations
DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
* Objects to send mail.
I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
* Work Area declarations
WA_OBJHEAD TYPE SOLI_TAB,
W_CTRLOP TYPE SSFCTRLOP,
W_COMPOP TYPE SSFCOMPOP,
W_RETURN TYPE SSFCRESCL,
WA_DOC_CHNG TYPE SODOCCHGI1,
W_DATA TYPE SODOCCHGI1,
WA_BUFFER TYPE STRING, "To convert from 132 to 255
* Variables declarations
V_FORM_NAME TYPE RS38L_FNAM,
V_LEN_IN LIKE SOOD-OBJLEN,
V_LEN_OUT LIKE SOOD-OBJLEN,
V_LEN_OUTN TYPE I,
V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZTEST'
IMPORTING
FM_NAME = V_FORM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
W_CTRLOP-GETOTF = 'X'.
W_CTRLOP-NO_DIALOG = 'X'.
W_COMPOP-TDNOPREV = 'X'.
CALL FUNCTION V_FORM_NAME
EXPORTING
CONTROL_PARAMETERS = W_CTRLOP
OUTPUT_OPTIONS = W_COMPOP
USER_SETTINGS = 'X'
IMPORTING
JOB_OUTPUT_INFO = W_RETURN
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 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.
I_OTF[] = W_RETURN-OTFDATA[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = V_LEN_IN
TABLES
OTF = I_OTF
LINES = I_TLINE
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
ENDIF.
LOOP AT I_TLINE.
TRANSLATE I_TLINE USING '~'.
CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
DO.
I_RECORD = WA_BUFFER.
APPEND I_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
* Attachment
REFRESH: I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR WA_OBJHEAD.
I_OBJBIN[] = I_RECORD[].
* Create Message Body Title and Description
I_OBJTXT = 'test with pdf-Attachment!'.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_OBJTXT INDEX V_LINES_TXT.
WA_DOC_CHNG-OBJ_NAME = 'smartform'.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
WA_DOC_CHNG-SENSITIVTY = 'F'.
WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
* Main Text
CLEAR I_OBJPACK-TRANSF_BIN.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
I_OBJPACK-BODY_NUM = V_LINES_TXT.
I_OBJPACK-DOC_TYPE = 'RAW'.
APPEND I_OBJPACK.
* Attachment (pdf-Attachment)
I_OBJPACK-TRANSF_BIN = 'X'.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
READ TABLE I_OBJBIN INDEX V_LINES_BIN.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
I_OBJPACK-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_TYPE = 'PDF'.
I_OBJPACK-OBJ_NAME = 'smart'.
I_OBJPACK-OBJ_DESCR = 'test'.
APPEND I_OBJPACK.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = 'Write Mail ID Here'.
I_RECLIST-REC_TYPE = 'U'.
APPEND I_RECLIST.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = I_OBJBIN
CONTENTS_TXT = I_OBJTXT
RECEIVERS = I_RECLIST
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.
WRITE:/ 'Error When Sending the File', SY-SUBRC.
ELSE.
WRITE:/ 'Mail sent'.
ENDIF.
If you want to send some text as Body of the Mail then follow this once
when u r callin the FM'SO_NEW_DOCUMENT_ATT_SEND_API1'.. points to remember
1.u have to pass the body of content in table CONTENTS_TXT(ia m using I_OBJBIN) (each line a record) then. suppose i have appended 11 records to the table CONTENTS_TXT .
2.PACKING_LIST(iam usign I_OBJPACK) table u ahve to append a redord as follows
I_OBJPACK-TRANSF_BIN = ' '.
I_OBJPACK-HEAD_START = 000000000000001.
I_OBJPACK-HEAD_NUM = 000000000000001.
I_OBJPACK-BODY_START = 000000000000002
I_OBJPACK-BODY_NUM = 000000000000010.
I_OBJPACK-DOC_TYPE = 'RAW'.
append I_OBJPACK-.
by the above code system treat the first line in table I_OBJBIN as header and the 2nd line to 10 lines tread as body.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOC_CHNG
PUT_IN_OUTBOX = 'X'
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = I_OBJBIN
CONTENTS_TXT = I_OBJTXT
RECEIVERS = I_RECLIST
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.
Best regards,
raam -
PDF generation without spool requests
Hi gurus,
Can I generate a PDF document bypassing spool. Is there any way we can create PDF document without sending it to spool. If yes, just let me know about the procedure.
Thanks in advance,
D. MallickU can directly download an internal table in PDF format with FM GUI_DOWNLOAD
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\test.pdf'
FILETYPE = 'BIN'
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
OTHERS = 5.
Regards,
Joy. -
Convert Spool request to PDF and send as e-mail
Hi all,
Can any one please provide me a sample code for converting spool request to pdf?
Thanks in advance,
Suneela.HI,
Try this
Hi all,
Can any one please provide me a sample code for converting spool request to pdf?
*& Report ZSPOOLTOPDF *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program must be run as a background job in-order for the write *
*& commands to create a Spool request rather than be displayed on *
*& screen *
REPORT zspooltopdf.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
Alternative way could be to submit another program and store spool
id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
Get spool id from program called above
IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
FORM obtain_spool_id *
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.
FORM get_job_details *
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.
FORM convert_spool_to_pdf *
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.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_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 = 'Attachname'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
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_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
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 = 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.
Reward points if found helpfull....
Venkoji. -
Generate spool request and PDF
Hello Friends,
I have the below requirement in Scripts.
I need to generate spool request and also download the form as pdf simultaneously.
I can able to generate spool request and able to download as PDF separately, but I want to do both in a single open_form is it possible?
Regards.
Krishna.Copy and Paste following code in a Z program type executable:
REPORT ZRSTXPDFT4 LINE-SIZE 80.
Read spool job contents (OTF or ABAP list) and convert
to PDF, download PDF
B20K8A0IKH replace WS_DOWNLOAD with GUI_DOWNLOAD
SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-015.
SELECTION-SCREEN SKIP.
PARAMETERS:
SPOOLNO LIKE TSP01-RQIDENT.
SELECTION-SCREEN SKIP.
PARAMETERS : DOWNLOAD AS CHECKBOX DEFAULT 'X',
P_FILE LIKE RLGRAP-FILENAME DEFAULT 'C:\temp\file.pdf' NO-DISPLAY."#EC NOTEXT
SELECTION-SCREEN END OF BLOCK B.
DATA OTF LIKE ITCOO OCCURS 100 WITH HEADER LINE.
DATA CANCEL.
DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
DATA DOCTAB LIKE DOCS OCCURS 1 WITH HEADER LINE.
DATA: NUMBYTES TYPE I,
ARC_IDX LIKE TOA_DARA,
PDFSPOOLID LIKE TSP01-RQIDENT,
JOBNAME LIKE TBTCJOB-JOBNAME,
JOBCOUNT LIKE TBTCJOB-JOBCOUNT,
IS_OTF.
DATA: CLIENT LIKE TST01-DCLIENT,
NAME LIKE TST01-DNAME,
OBJTYPE LIKE RSTSTYPE-TYPE,
TYPE LIKE RSTSTYPE-TYPE.
TABLES: TSP01.
DATA : RETFIELD TYPE DFIES-FIELDNAME.
DATA : SPOOL TYPE HELP_INFO-DYNPROFLD.
DATA : BEGIN OF ITAB OCCURS 0,
SPOOL TYPE TSP01-RQIDENT,
END OF ITAB.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR SPOOLNO.
RETFIELD = SPOOLNO.
SPOOL = 'SPOOLNO'.
SELECT RQIDENT FROM TSP01 INTO TABLE ITAB."#EC CI_NOWHERE
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
RETFIELD = RETFIELD
PVALKEY = ' '
DYNPPROG = SY-REPID
DYNPNR = SY-DYNNR
DYNPROFIELD = SPOOL
STEPL = 0
WINDOW_TITLE =
VALUE = ' '
VALUE_ORG = 'S'
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
CALLBACK_PROGRAM = SY-CPROG
CALLBACK_FORM = ' '
MARK_TAB =
IMPORTING
USER_RESET =
TABLES
VALUE_TAB = ITAB[]
FIELD_TAB =
RETURN_TAB =
DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
START-OF-SELECTION.
SELECT SINGLE * FROM TSP01 WHERE RQIDENT = SPOOLNO.
IF SY-SUBRC <> 0.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Spoolauftrag existiert nicht'(003).
EXIT.
ENDIF.
CLIENT = TSP01-RQCLIENT.
NAME = TSP01-RQO1NAME.
CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
EXPORTING
AUTHORITY = 'SP01'
CLIENT = CLIENT
NAME = NAME
PART = 1
IMPORTING
CHARCO =
CREATER =
CREDATE =
DELDATE =
MAX_CREDATE =
MAX_DELDATE =
NON_UNIQ =
NOOF_PARTS =
RECTYP =
SIZE =
STOTYP =
TYPE = TYPE
OBJTYPE = OBJTYPE
EXCEPTIONS
FB_ERROR = 1
FB_RSTS_OTHER = 2
NO_OBJECT = 3
NO_PERMISSION = 4.
IF OBJTYPE(3) = 'OTF'.
IS_OTF = 'X'.
ELSE.
IS_OTF = SPACE.
ENDIF.
IF IS_OTF = 'X'.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOLNO
NO_DIALOG = ' '
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
PDF_BYTECOUNT = NUMBYTES
PDF_SPOOLID = PDFSPOOLID
OTF_PAGECOUNT =
BTC_JOBNAME = JOBNAME
BTC_JOBCOUNT = JOBCOUNT
TABLES
PDF = PDF
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 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.
CASE SY-SUBRC.
WHEN 0.
PERFORM BD_TEXTBOX_MSG(RSTXPDFT) USING 80
'Funktion CONVERT_OTFSPOOLJOB_2_PDF erfolgreich'(001).
WHEN 1.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Kein OTF- und kein ABAP-Spoolauftrag'(002).
EXIT.
WHEN 2.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Spoolauftrag existiert nicht'(003).
EXIT.
WHEN 3.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Keine Berechtigung zum Lesen Spoolauftrag'(004).
EXIT.
WHEN OTHERS.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Fehler bei Funktion CONVERT_OTFSPOOLJOB_2_PDF'(005).
EXIT.
ENDCASE.
ELSE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOLNO
NO_DIALOG = ' '
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
PDF_BYTECOUNT = NUMBYTES
PDF_SPOOLID = PDFSPOOLID
LIST_PAGECOUNT =
BTC_JOBNAME = JOBNAME
BTC_JOBCOUNT = JOBCOUNT
TABLES
PDF = 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.
CASE SY-SUBRC.
WHEN 0.
PERFORM BD_TEXTBOX_MSG(RSTXPDFT) USING 80
'Funktion CONVERT_ABAPSPOOLJOB_2_PDF erfolgreich'(006).
WHEN 1.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Kein OTF- und kein ABAP-Spoolauftrag'(002).
EXIT.
WHEN 2.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Spoolauftrag existiert nicht'(003).
EXIT.
WHEN 3.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Keine Berechtigung zum Lesen Spoolauftrag'(004).
EXIT.
WHEN OTHERS.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Fehler bei Funktion CONVERT_ABAPSPOOLJOB_2_PDF'(007).
EXIT.
ENDCASE.
ENDIF.
download PDF file ***********
CHECK DOWNLOAD = 'X'.
IF NOT ( JOBNAME IS INITIAL ).
PERFORM BD_TEXTBOX_VAR2_MSG(RSTXPDFT) USING 80
'Konvertierung per Hintergrundjob'(008)
JOBNAME
JOBCOUNT.
EXIT.
ENDIF.
PERFORM DOWNLOAD_W_EXT(RSTXPDFT) TABLES PDF
USING P_FILE
'.pdf'
'BIN'
NUMBYTES
CANCEL.
IF CANCEL = SPACE.
DATA: S(80).
S = NUMBYTES. CONDENSE S.
CONCATENATE S 'Bytes heruntergeladen in Datei'(009)
INTO S SEPARATED BY SPACE.
PERFORM BD_TEXTBOX_VAR1_MSG(RSTXPDFT) USING 80
S
P_FILE.
ENDIF.
Regards,
Jeet K Bhatt -
Problem in converting Spool Request into PDF format
Hi,
I am facing problem to convert spool request (which store output of sap script) in to PDF format. Actually I have converted it with function module 'CONVERT_OTFSPOOLJOB_2_PDF' and it is working properly but the problem occurs where the BOLD fonts are used. I am unable to see the Text/Address where i have used Bold Font in script (PDF FORMAT). Even though in (SPO1) spool request shows every thing perfectly (along with Bold Font). It will great if you could suggest me something.
Thanks,
PradeepHi Pradeep,
Use ,
Closing the Sapscript, we save data (OTF) in a table
CALL FUNCTION 'CLOSE_FORM'
TABLES
otfdata = t_otfdata
EXCEPTIONS
unopened = 1
bad_pageformat_for_print = 2
send_error = 3
spool_error = 4
OTHERS = 5.
DATA: BEGIN OF t_otfdata2 OCCURS 0.
INCLUDE STRUCTURE solisti1.
DATA: END OF t_otfdata2.
Move OTF data to another table with lenght 255
LOOP AT t_otfdata.
CONCATENATE t_otfdata-tdprintcom t_otfdata-tdprintpar INTO t_otfdata2.
APPEND t_otfdata2.
ENDLOOP.
Convert OTF format to PDF
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
format_src = 'OTF'
format_dst = 'PDF'
devtype = 'PRINTER'
FUNCPARA =
len_in = len_in
IMPORTING
len_out = len_out
TABLES
content_in = t_otfdata2
content_out = t_pdfdata
EXCEPTIONS
err_conv_failed = 1
OTHERS = 2.
Have a look at Progs. RSTXPDF4 and RSTXPDFT2 for converting the Spool to PDF.
Regards,
Raj
Message was edited by: Rajasekhar Dinavahi
Message was edited by: Rajasekhar Dinavahi -
Converting spool request into multiple pdf formated documents
Hi Guys,
I am designing a report with several pages of output and running it in background.
Is there a possibility to convert each page into an separate pdf format document ?
If I use ALV report as output, if its more than page, do I face any issue with pdf conversion.
ThanksCheck the Following code, This might be helpful:
form rstxpdft4 using filename.
* Read spool job contents (OTF or ABAP list) and convert
* to PDF, download PDF
data: download value 'X'.
data: lv_filename like rlgrap-filename.
lv_filename = filename.
data otf like itcoo occurs 100 with header line.
data cancel.
data pdf like tline occurs 100 with header line.
data doctab like docs occurs 1 with header line.
data: numbytes type i,
arc_idx like toa_dara,
pdfspoolid like tsp01-rqident,
jobname like tbtcjob-jobname,
jobcount like tbtcjob-jobcount,
is_otf.
data: client like tst01-dclient,
name like tst01-dname,
objtype like rststype-type,
type like rststype-type.
select single * from tsp01 where rqident = gt_rq-rqident.
if sy-subrc <> 0.
write: / 'Spool request does not exist', gt_rq-rqident
color col_negative.
exit.
endif.
client = tsp01-rqclient.
name = tsp01-rqo1name.
call function 'RSTS_GET_ATTRIBUTES'
exporting
authority = 'SP01'
client = client
name = name
part = 1
importing
type = type
objtype = objtype
exceptions
fb_error = 1
fb_rsts_other = 2
no_object = 3
no_permission = 4.
if objtype(3) = 'OTF'.
is_otf = 'X'.
else.
is_otf = space.
endif.
if is_otf = 'X'.
call function 'CONVERT_OTFSPOOLJOB_2_PDF'
exporting
src_spoolid = gt_rq-rqident
no_dialog = ' '
importing
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
btc_jobname = jobname
btc_jobcount = jobcount
tables
pdf = pdf .
else.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = gt_rq-rqident
no_dialog = ' '
importing
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
btc_jobname = jobname
btc_jobcount = jobcount
tables
pdf = pdf
*************** download PDF file ***********
v_filename = lv_filename.
* call function 'WS_DOWNLOAD'
* exporting
* bin_filesize = numbytes
* filename = lv_filename
* filetype = 'BIN'
* tables
* data_tab = 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 <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* else.
* gv_count = gv_count + 1.
* endif.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = numbytes
FILENAME = v_filename
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
* SHOW_TRANSFER_STATUS = ABAP_TRUE
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = pdf .
* FIELDNAMES =
Thanks. -
Converting the spool request to PDF format
Dear All ,
I am using RSTXPDF4 to convert a spool request to PDF format , when I execute this program by giving the spool number and dstdevic as Local , its giving the message as " Spool request XXXXX with PDF data created ".
But the problem is when I open this spool request its printing the Junk characters ..!!!
What could be the problem ?
Please give me the solution for this...
Thanks in advance.Hi Prem ,
I have checked the tranx SCOT there I have found the following settings..
Output Dev Type USE
format
PCL HPLJIIID Not Yet Used in Node Maintenance
PDF PDF1 Already Used in Node Maintenance
PS POST2 Not Yet Used in Node Maintenance
TXT ASCIIPRI Already Used in Node Maintenance
Is this OK ...or am I need to do any changes in the settings...??
One more thing when I tries to give this PDF1 Dev type in my RSTXPDF4 input parameters its not taking !!!
Please help... -
How to submit a PDF document to spool request by coding
Hi experts,
I have a pdf document that is stored somewhere in SAP system, for example MIME repository. So I can read this PDF document and get its content as an xstring.
I know SAP can print a smartform directly by calling its function module, or submit a program (list output) to SAP-SPOOL to generate a spool request.
But how can I submit a document or an xstring which presents the content of a document to spool request in order to print it out?
Or should I do it in some other way?
Any of the suggestion or hint will be help.
Thanks!We have checked it with SAP and it seems no solution for printing a pdf doc by coding.
The final workaround is to use an virtual printer or some converter on PC to convert the pages in that pdf document into BMP files. Then upload those BMP files in t-code se78 and build a smartform to include them.
It is convenient to use the printing function of smartforms in ABAP coding. -
Converting spool request into PDF forms
Hi gurus
i am working on upgrade project from 4.6C to ECC 6.0. Business had the functionality developed in 4.6C to " Convert the spool request into PDF forms and can be downloaded into local PC".
Moving to ECC 6.0, is there any standard functionality available in ECC 6.0 to "Convert spool request to PDF forms and download"?
Any help towards this is appreciable.
Thanks
AleemHello,
Yes. The program is RSTXPDFT4.
Sourabh -
How to convert spool request to pdf format (to send mail) - SAP 3.1H
Hi,
I am working in 3.1H version. How to convert spool request into pdf cormat to send a mail?. Spool request is in TEXT format.
regards,
sundaram J.Hi sundaram,
1. I suppose u know how to send
mail with attachment.
2. If that is the case,
then no need to do anything.
3. Bcos
There is setting in SCOT,
for INTERNET
ABAP List ---> PDF
Raw TEXT -
PDF
(Your basis team will help u)
4. text data will get automatically converted
to pdf and get mailed.
regards,
amit m. -
I want read PDF file from SAP directory and create a spool request or print
Hi all,
I want read PDF file from SAP directory and create a spool request or print the pdf through SAP. Can any body help me in this.
Also please write to me if its possible to open PDF from SAP directory to adobe pdf reader.
Thanks in advance,
SunnyHi Sunny,
Check these links.
http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
http://www.erpgenie.com/sap/abap/pdf_creation.htm
http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html
http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp
http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
Hope this resolves your query.
Reward all the helpful answers.
Regards -
Direct Conversion of smartform into PDF system has to take spool request ?
does anybody know:
Direct Conversion of smartform into PDF, system has to take spool request dynamically..
i don't mean to use the SE38 calling PRG RSTXPDFT4 to transfer SAP sript into PDF.
thanks
SRIDHAR--strike Yes this is what I understood.
In the structure job_output_info of your function you'll find your OTF data :
st_ssfcrescl-otfdata --
CALL FUNCTION smartform_fonction_name
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
control_parameters = st_ssfctrlop
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
output_options = st_ssfcompop
user_settings = ' '
IMPORTING
document_output_info = st_ssfcrespd
job_output_info = st_ssfcrescl " This is the one which contains OTF data
job_output_options = st_ssfcresop
TABLES
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
-- Then you just have to convert, using something like that : --
* Convert OTF to PDF
LOOP AT otf_data INTO w_otf.
CONCATENATE w_otf-tdprintcom w_otf-tdprintpar
INTO w_pdf.
APPEND w_pdf TO i_content_txt.
ENDLOOP.
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
format_src = 'OTF'
format_dst = 'PDF'
CHANGING
transfer_bin = w_transfer_bin
content_txt = i_content_txt
content_bin = i_content_bin
objhead = i_objhead
len = v_len_in
EXCEPTIONS
err_conv_failed = 1
OTHERS = 2.
v_size = v_len_in.
pdf_itab_size = v_size.
it_pdfout[] = it_pdf[].
* Create the PDF File
CLEAR it_pdfdata.
REFRESH it_pdfdata.
* it_pdfdata[] = it_pdfout[].
LOOP AT it_pdfout.
MOVE it_pdfout-tline TO it_pdfdata-line.
APPEND it_pdfdata.
CLEAR it_pdfdata.
ENDLOOP.
-- The smartform creation and the PDF creation are done in the same time...--
OK, So what do'nt you want to use the RSTXPDFT4 program ?
Hope this helps,
Erwan
Edited by: Erwan LE BRUN on Aug 28, 2008 12:02 PM
Edited by: Erwan LE BRUN on Aug 28, 2008 12:03 PM -
Convert Spool Request in chinese Language to PDF
kindly help me to solve the issues.
is there any way to convert the spool request which is in chinese langauge,
Requirement is to download SAP Script to PDF, where the PDF file should be in Chinese format.
i used the following FM
1)CONVERT_OTFSPOOLJOB_2_PDF
2)CONVERT_ABAPSPOOLJOB_2_PDF
in the spool the chinese format is visible, but in the PDF instead of the chinese language, v r getting Junk values.
Thanks in Advance.
KesavHi,
Try executing the Program: 'RSTXPDFT4'.
This Program will generate a PDF file when spool request is given in the selection screen.
Regards,
Ravi Kiran..
Maybe you are looking for
-
Sender SOAP adapter - WSDL not working
Hi, I am doing Sender SOAP and receiver RFC adapter for SOAP-BAPI scenario.The WSDL is generated after IR and ID config. URL http://host:port/XISOAPAdapter/MessageServlet?Sender.Service=BS_VCT_Sender&Interface=urn:abb-com:vct:sap:ven%5EUSER_MI But by
-
Hello, I am a photographer interested in designing a photo gallery website.My question is how are the special effects created in Flash for when a thumbnail is clicked and the photo downloads into the picture viewer? (such as the photo fading in , the
-
How can I get iphoto to work again in my main admin account?
iphoto does not work in my main account. it works in other accounts but it just hangs when launched on my admin account. I have tried rebuild and deleted com.apple.iphoto.plist still no luck. it is iphoto 11 thanks
-
N96 Photo Editor - Edited image won't save
When I open a photo, and select 'Edit' from options, I rotate my photos to the correct composition (as they were taken upside down!) and then from options I select 'Save'. The progress bar appears to indicate the device is processing the change. Howe
-
Release strategy does not reset after PO change - tried changeability 4 & 6
Hi, After my PO is released, I change the item quantity/price such that the net PO value (increased) is changed MORE than the tolerance % set in the changeability. I expect that the PO release should be reset but it does not. However if my PO value