Skip to Content
0
Former Member
Jan 26, 2007 at 05:20 AM

Need help in sending sapscript/smartform as body of email, No attachment

36 Views

Hi exports,

I am trying to send my SAPscript/smartform as email body. But it is taking as PDF attachemnt or some garbage coming as attachment.

Please help me how to send the SAPscript/smartforms as body of email not at all attachment. I am able to send as attachement but not as a body.

Here is my conversion rule

ALI HTM 2 SX_OBJECT_CONVERT_ALI_HTM

ALI PS 3 SX_OBJECT_CONVERT_ALI_PRT

ALI RAW 1 SX_OBJECT_CONVERT_ALI_RAW

ALI TXT 9 SX_OBJECT_CONVERT_ALI_TXT

ICS RAW 8 SX_OBJECT_CONVERT_ICS_RAW

INT RAW 8 SX_OBJECT_CONVERT_INT_RAW

OBJ HTM 2 SX_OBJECT_CONVERT_OBJ_HTM

OTF PDF 1 SX_OBJECT_CONVERT_OTF_PDF

OTF PS 3 SX_OBJECT_CONVERT_OTF_PRT

OTF RAW 2 SX_OBJECT_CONVERT_OTF_RAW

RAW SCR 1 SX_OBJECT_CONVERT_RAW_SCR

RAW TXT 9 SX_OBJECT_CONVERT_RAW_TXT

SCR OTF 1 SX_OBJECT_CONVERT_SCR_OTF

TXT INT 7 SX_OBJECT_CONVERT_TXT_INT

URL HTM 2 SX_OBJECT_CONVERT_OBJL_HTM

My code is below

&----


*& Form SPOOL_JOB

&----


FORM SPOOL_JOB.

CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'

EXPORTING

RQIDENT = GV_SPOOL

FIRST_LINE = 1

LAST_LINE = 1000

DESIRED_TYPE = 'RAW'

TABLES

BUFFER = GT_SPOOL_FILE.

GV_CLIENT = TSP01-RQCLIENT.

GV_NAME = TSP01-RQO1NAME.

CALL FUNCTION 'RSTS_GET_ATTRIBUTES'

EXPORTING

AUTHORITY = 'SP01'

CLIENT = GV_CLIENT

NAME = GV_NAME

PART = 1

IMPORTING

TYPE = GV_TYPE

OBJTYPE = GV_OBJTYPE.

IF GV_OBJTYPE(3) = 'OTF'.

GV_IS_OTF = 'X'.

ELSE.

GV_IS_OTF = SPACE.

ENDIF.

ENDFORM. " SPOOL_JOB

&----


*& Form CONVERT_PDF

&----


*

FORM CONVERT_PDF.

IF GV_IS_OTF EQ 'X'.

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = GV_SPOOL

NO_DIALOG = ' '

IMPORTING

PDF_BYTECOUNT = GV_NUMBYTES

PDF_SPOOLID = GV_PDFSPOOLID

BTC_JOBNAME = GV_JOBNAME

BTC_JOBCOUNT = GV_JOBCOUNT

TABLES

PDF = GT_PDF.

ELSE.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = GV_SPOOL

NO_DIALOG = ' '

IMPORTING

PDF_BYTECOUNT = GV_NUMBYTES

PDF_SPOOLID = GV_PDFSPOOLID

BTC_JOBNAME = GV_JOBNAME

BTC_JOBCOUNT = GV_JOBCOUNT

TABLES

PDF = GT_PDF.

ENDIF.

ENDFORM. " CONVERT_PDF

&----


*& Form pDF_ATTACH_EMAIL

&----


FORM PDF_ATTACH_EMAIL.

  • Title and Description

CLEAR GS_DOCDATA.

GS_DOCDATA-OBJ_NAME = 'WOM ORDER'.

  • Subject of the email

GS_DOCDATA-OBJ_DESCR = 'Order confirm'.

GS_DOCDATA-OBJ_PRIO = 1.

CLEAR GT_OBJBIN.

REFRESH GT_OBJBIN.

CALL FUNCTION 'QCE1_CONVERT'

TABLES

T_SOURCE_TAB = GT_PDF

T_TARGET_TAB = GT_OBJBIN.

*Filling the contents into internal table obtxt,

*whose contents will be displayed as the body of email

  • DESCRIBE TABLE gt_spool_file LINES gv_lin1.

DESCRIBE TABLE GT_OBJBIN LINES GV_LIN1.

IF GV_LIN1 GT 0.

GT_OBJTXT-LINE = 'Order details '.

APPEND GT_OBJTXT.

CLEAR GT_OBJTXT.

ENDIF.

DESCRIBE TABLE GT_OBJTXT LINES GV_TAB_LINES.

  • creation of the entry for the compressed document

CLEAR GT_OBJPACK.

GT_OBJPACK-TRANSF_BIN = ' ' .

GT_OBJPACK-HEAD_START = 1.

GT_OBJPACK-HEAD_NUM = 0.

GT_OBJPACK-BODY_START = 1.

GT_OBJPACK-BODY_NUM = GV_TAB_LINES.

GT_OBJPACK-DOC_TYPE = 'RAW'.

GT_OBJPACK-DOC_SIZE = ( GV_TAB_LINES - 1 ) * 255 + STRLEN( GT_OBJTXT )

.

APPEND GT_OBJPACK.

  • creation of the entry for the attachment

DESCRIBE TABLE GT_OBJBIN LINES GV_TAB_LINES.

CLEAR GT_OBJPACK.

GT_OBJPACK-TRANSF_BIN = 'X'.

GT_OBJPACK-HEAD_START = 1.

GT_OBJPACK-HEAD_NUM = 1.

GT_OBJPACK-BODY_START = 1.

GT_OBJPACK-BODY_NUM = GV_TAB_LINES.

GT_OBJPACK-DOC_TYPE = 'RAW'.

CONCATENATE 'Document'(002) '.PDF' INTO GT_OBJPACK-OBJ_NAME.

GT_OBJPACK-OBJ_DESCR = GT_OBJPACK-OBJ_NAME.

GT_OBJPACK-DOC_SIZE = ( GV_TAB_LINES - 1 ) * 255 + STRLEN( GT_OBJBIN )

.

APPEND GT_OBJPACK.

  • READ TABLE objtxt INDEX gv_tab_lines.

DESCRIBE TABLE GT_OBJTXT LINES GV_TAB_LINES.

  • Calculating doc. size which is email

GS_DOCDATA-DOC_SIZE = ( GV_TAB_LINES - 1 ) * 255 + STRLEN( GT_OBJBIN )

.

  • creating the Recipients list which are to be emailed

CLEAR WA_RECLIST.

REFRESH GT_RECLIST.

SELECT SINGLE * FROM USR21

WHERE BNAME = VBAK-ERNAM.

IF SY-SUBRC EQ 0.

SELECT SMTP_ADDR FROM ADR6 INTO ADR6-SMTP_ADDR UP TO 1 ROWS

WHERE ADDRNUMBER = USR21-ADDRNUMBER

AND PERSNUMBER = USR21-PERSNUMBER.

ENDSELECT.

IF SY-SUBRC EQ 0.

WA_RECLIST-RECEIVER = ADR6-SMTP_ADDR.

ENDIF.

ENDIF.

WA_RECLIST-REC_TYPE = 'U'.

WA_RECLIST-COPY = ''.

WA_RECLIST-BLIND_COPY = ''.

APPEND WA_RECLIST TO GT_RECLIST.

CLEAR WA_RECLIST.

  • Mail is sent using the below called F.M.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = GS_DOCDATA

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = GT_OBJPACK

CONTENTS_BIN = GT_OBJBIN

CONTENTS_TXT = GT_OBJTXT

RECEIVERS = GT_RECLIST.

ENDFORM. " pDF_ATTACH_EMAIL

I want send sapscript/smartform as body of email.