on 02-12-2009 6:57 AM
Hi All,
Currently i am having customized sapscript.
1.) I have to convert it to PDF. How to convert to PDF.
2.) Then i need to send PDF to FAX. How.
What are the code required to change and add.
What is OTF output, which is easier to fax. PDF or OTF output.
With Regards,
Vinoth
Hi Code,
Refer this sample code.
DATA: t_otf LIKE itcoo OCCURS 100 WITH HEADER LINE,
t_pdf LIKE tline OCCURS 100 WITH HEADER LINE,
t_opt like itcpo occurs 0 with header line.
data:
w_flag type i, " Temporary flag
w_control type ssfctrlop, " Control parameters
w_output type ssfcompop, " Output options
w_return type ssfcrescl, " Job output info
w_filesize type sood-objlen, " Bin file size
w_string type string, " To convert from 132 to 255
w_msg type i, " Message length
w_docdata type sodocchgi1, " Document data
w_objbin type i, " Contents bin
w_sender type soextreci1-receiver. " Sender
t_opt-TDGETOTF = 'X'.
append t_opt.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
FORM = 'ZTEST_SCRIPT1'
LANGUAGE = SY-LANGU
OPTIONS = t_opt
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
ARCHIVE_ERROR = 7
INVALID_FAX_NUMBER = 8
MORE_PARAMS_NEEDED_IN_BATCH = 9
SPOOL_ERROR = 10
CODEPAGE = 11
OTHERS = 12
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TEXT'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'HEADER'
* IMPORTING
* PENDING_LINES =
* EXCEPTIONS
* ELEMENT = 1
* FUNCTION = 2
* TYPE = 3
* UNOPENED = 4
* UNSTARTED = 5
* WINDOW = 6
* BAD_PAGEFORMAT_FOR_PRINT = 7
* SPOOL_ERROR = 8
* CODEPAGE = 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.
ENDIF.
CALL FUNCTION 'CLOSE_FORM'
* IMPORTING
* RESULT =
* RDI_RESULT =
TABLES
OTFDATA = t_otf
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 6
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
* IMPORTING
* BIN_FILESIZE =
* BIN_FILE =
TABLES
otf = t_otf
lines = t_line
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.
loop at t_line.
concatenate w_string t_line into w_string.
endloop. " LOOP AT T_LINE
*" convert the 132 line character to 255 character ....................
do.
t_attach = w_string.
append t_attach.
shift w_string left by 255 places.
if w_string is initial.
exit.
endif. " IF W_STRING IS INITIAL
enddo. " DO
t_objbin[] = t_attach[].
*" Body of the mail..................................................
clear t_message. refresh t_message.
t_message = 'This is a mail from SAP ECC6'.
append t_message.
t_message = 'Thanks and Regards'.
append t_message.
t_message = 'Sravanthi'.
append t_message.
describe table t_message lines w_msg.
*" Document data.......................................................
w_docdata-obj_name = 'SAPRPT'.
w_docdata-expiry_dat = sy-datum + 10.
w_docdata-obj_descr = 'This mail from Sravanthi'.
w_docdata-sensitivty = 'F'.
w_docdata-doc_size = w_msg * 255.
w_docdata-obj_langu = sy-langu .
*" Fill the packing list...............................................
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.
t_packing_list-body_num = w_msg.
t_packing_list-doc_type = 'RAW'.
append t_packing_list.
t_packing_list-transf_bin = 'X'.
describe table t_objbin lines w_objbin.
*" doc_size = (lines in pdf table) * 255...............................
t_packing_list-doc_size = w_objbin * 255.
t_packing_list-body_num = w_objbin.
t_packing_list-doc_type = 'PDF'.
t_packing_list-obj_name = 'smart'.
t_packing_list-obj_descr = 'test'.
append t_packing_list.
*" Fill the receiver parameters........................................
if p_mail eq 'X'.
clear t_receivers.
t_receivers-receiver = p_mailid.
t_receivers-rec_type = 'U'.
append t_receivers.
*" Fax.................................................................
elseif p_fax eq 'X'.
clear t_receivers.
t_receivers-receiver = p_faxno.
t_receivers-rec_type = 'F'.
t_receivers-com_type = 'FAX'.
append t_receivers.
endif. " IF P_MAIL EQ 'X'
w_sender = 'SAPDEV02'.
*---------------------------------------------------------------------*
* FUNCTION MODULE SO_DOCUMENT_SEND_API1 *
*---------------------------------------------------------------------*
* This function module enables you send a new document including any *
* existing attachments. The document and the attachments are *
* transferred in the same table. They are created when sent and can *
* also be placed in the sender's outbox. *
*---------------------------------------------------------------------*
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = w_docdata
put_in_outbox = 'X'
sender_address = w_sender
commit_work = 'X'
tables
packing_list = t_packing_list
contents_bin = t_objbin
contents_txt = t_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.
if sy-subrc ne 0.
write:/ 'Error When Sending the File', sy-subrc.
else.
write:/ 'Mail sent'.
endif.
elseif p_fax eq 'X'.
endif.
Regards,
Sravanthi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi try this link.
i found it helpfull
[https://forums.sdn.sap.com/click.jspa?searchID=22202893&messageID=6829680]
Regards
Hareesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
To fax your PDF file Please refer following link:-
[http://www.interfax.net/en/help/sap_sapscript_example.html]
Hope this works for you.
Thanks........
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
First you have to execute your calling program which internally calls your customized SAPscript . here you have to take print preview for the required output.
Then use SP01 tcode to check your spool request which include your customized sap script print preview.
Then goto SE38 tcode and enter program name as RSTXPDFT4 which is used to * Read spool job contents (OTF or ABAP list) and convert * to PDF, download PDF.
Before executing this program, you have to enter following parameters:-
1) Enter spool request number.
2) File name where you download PDF file.
Hope this works for you.
Thanks.........
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.