on 02-13-2008 11:29 AM
problem in opening attached smart form pdf from mail,showing some erros and by scroling up and down all datas are getting errased.
i dont know y this is happening when i am saving to a folder its opening correctly but when attaching to sap user id its giving this kind of problem can any body tell me about this.
plz help me out.
am sending the code that i have coded to attach that smart form pdf to the mail id .
To hold the value of tab index
SPOOL = TSPOOLID2-SPOOLIDS.
READ TABLE SPOOL INTO WA_SPOOL INDEX 1.
BREAK-POINT.
SUBMIT RSTXPDFT4 USING SELECTION-SCREEN '1000'
WITH SPOOLNO EQ WA_SPOOL
WITH P_FILE EQ 'C:\temp\file.pdf'
AND RETURN.
BREAK-POINT.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = WA_SPOOL
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
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 'CONVERT_OTF_2_PDF'
EXPORTING
USE_OTF_MC_CMD = 'X'
ARCHIVE_INDEX =
IMPORTING
BIN_FILESIZE = V_LEN_IN
TABLES
OTF = I_OTF
DOCTAB_ARCHIVE = P_DOCS
LINES = I_TLINE
EXCEPTIONS
ERR_CONV_NOT_POSSIBLE = 1
ERR_OTF_MC_NOENDMARKER = 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.
LOOP AT PDF.
# REPLACING SPACE BY ~
TRANSLATE PDF USING '~'.
CONCATENATE GD_BUFFER PDF INTO GD_BUFFER.
ENDLOOP.
TRANSLATE GD_BUFFER USING '~'.
DO.
I_RECORD = GD_BUFFER.
APPEND I_RECORD.
SHIFT GD_BUFFER LEFT BY 255 PLACES.
IF GD_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
REFRESH: I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR W_OBJHEAD.
# Object with PDF.
I_OBJBIN[] = I_RECORD[].
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
Object with main text of the mail.
I_OBJTXT = 'Find attached the output of the smart form.'.
APPEND I_OBJTXT.
I_OBJTXT = 'Regards,'.
APPEND I_OBJTXT.
I_OBJTXT = 'XYZ'.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_OBJTXT INDEX V_LINES_TXT.
Document information.
W_DOC_CHNG-OBJ_NAME = 'Smartform'.
W_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
W_DOC_CHNG-OBJ_DESCR = 'Smart form output'.
W_DOC_CHNG-SENSITIVTY = 'F'. "Functional object
W_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
*WA_DOC_CHNG-DOC_SIZE = ( V_LINES_TXT - 1 ) * 255 + STRLEN( I_OBJTXT ).
Pack to main body as RAW.
Obj. to be transported not in binary form
CLEAR I_OBJPACK-TRANSF_BIN.
Start line of object header in transport packet
I_OBJPACK-HEAD_START = 1.
Number of lines of an object header in object packet
I_OBJPACK-HEAD_NUM = 0.
Start line of object contents in an object packet
I_OBJPACK-BODY_START = 1.
Number of lines of the object contents in an object packet
I_OBJPACK-BODY_NUM = V_LINES_TXT.
Code for document class
I_OBJPACK-DOC_TYPE = 'RAW'.
APPEND I_OBJPACK.
Packing as PDF.
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 = 'Smartform'.
CONCATENATE 'Smartform_output' '.pdf'
INTO I_OBJPACK-OBJ_DESCR.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255.
APPEND I_OBJPACK.
Document information.
CLEAR I_RECLIST.
e-mail receivers.
I_RECLIST-RECEIVER = 'xyz@gmail.com'.
I_RECLIST-REC_TYPE = 'U'.
APPEND I_RECLIST.
I_RECLIST-RECEIVER = SY-UNAME.
I_RECLIST-EXPRESS = 'X'.
I_RECLIST-REC_TYPE = 'B'. "SAP User
APPEND I_RECLIST.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = W_OBJHEAD
CONTENTS_BIN = I_OBJBIN
CONTENTS_TXT = I_OBJTXT
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF SY-SUBRC = 0.
WRITE:/ 'This is successful'.
CLEAR : I_OBJPACK.
ENDIF.
REFRESH : I_OBJPACK,I_OBJBIN,I_OBJTXT,I_RECLIST.
hi
You have problems with conversion OTF to PDF.
u can use this FM SX_OBJECT_CONVERT_OTF_PDF for do it.
part of code:
data: i_objbin like solisti1 occurs 0 with header line,
i_otf type solisti1 occurs 0 with header line.
call function 'SX_OBJECT_CONVERT_OTF_PDF'
exporting
format_src = 'OTF'
format_dst = 'PDF'
devtype = 'PRINTER'
FUNCPARA =
len_in = '1234'
IMPORTING
LEN_OUT =
tables
content_in = i_otf ""your table OTF Format
content_out = i_objbin
exceptions
err_conv_failed = 1
others = 2
Regards
Gregory
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.