Skip to Content
author's profile photo Former Member
Former Member

PDF is not showing in MAIL

Hi Frineds,

i am writing a Report .. to Send the Spool Request into the PDF and again i am sending this PDF into MAIL with Attchnments.. but report genarating PDF FORMAT,

but the PDF is not showing in MAIL ..

pls. any one help me .. it is an Urgent.

Here is the Code:

Report zmailformat.

data SENT_TO_ALL LIKE SONV-FLAG.

data: w_ident like tsp01-rqident,

w_doctype like tsp01-rqdoctype,

w_bytecount type i.

data: itab_pdf like tline occurs 0 with header line.

DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,

OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,

OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,

RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE,

LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,

LD_FORMAT TYPE SO_OBJ_TP ,

W_DOC_DATA LIKE SODOCCHGI1,

LD_EMAIL LIKE SOMLRECI1-RECEIVER,

W_SENT_ALL(1) TYPE C,

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,

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.

  • 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'.

  • * 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 P_IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.

T_PACKING_LIST-DOC_TYPE = 'RAW'.

APPEND T_PACKING_LIST.

LD_EMAIL = 'MAIL'.

LD_MTITLE = 'MAIL TEXT'.

LD_FORMAT = 'MAILFORMAT'.

  • LD_ATTDESCRIPTION = P_ATTDESCRIPTION.

LD_ATTFILENAME = 'FILENAME'.

LD_SENDER_ADDRESS = 'SENDER_ADDRESS'.

LD_SENDER_ADDRESS_TYPE = 'SENDER_ADDRES_TYPE'.

selection-screen begin of block a2 with frame TITLE TEXT-001.

parameters: spoolnum like tsp01-rqident obligatory,

P_MAIL(130) TYPE C.

selection-screen end of block a2.

*******************************

at selection-screen on spoolnum.

*******************************

select single rqident rqdoctype

into (w_ident, w_doctype)

from tsp01

where rqident = spoolnum.

if sy-subrc ne 0.

message e398(00) with 'Spool' spoolnum 'not found'.

endif.

*******************

start-of-selection.

*******************

if w_doctype = 'LIST'.

perform get_abap_spool_in_pdf.

endif.

perform mail.

************************************************************************

form get_abap_spool_in_pdf.

refresh itab_pdf.

call function 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = w_ident

IMPORTING

pdf_bytecount = w_bytecount

TABLES

pdf = itab_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.

endform.

************************************************************************

&----


*& Form mail

&----


FORM mail.

loop at itab_pdf.

T_ATTACHMENT-line = itab_pdf-tdline.

append T_ATTACHMENT.

clear T_ATTACHMENT.

endloop.

reclist-RECEIVER = P_MAIL.

reclist-REC_TYPE = 'U'.

reclist-COM_TYPE = 'INT'.

reclist-NOTIF_DEL = 'X'.

reclist-NOTIF_NDEL = 'X'.

APPEND reclist.

*

*

  • 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'.

  • *

    *

    • * 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 P_IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.

    • T_PACKING_LIST-DOC_TYPE = 'RAW'.

  • APPEND T_PACKING_LIST.

  • *

    *

    • LD_EMAIL = 'MAIL'.

    • LD_MTITLE = 'MAIL TEXT'.

    • LD_FORMAT = 'MAILFORMAT'.

    • LD_ATTDESCRIPTION = P_ATTDESCRIPTION.

  • LD_ATTFILENAME = 'FILENAME'.

  • LD_SENDER_ADDRESS = 'SENDER_ADDRESS'.

  • LD_SENDER_ADDRESS_TYPE = 'SENDER_ADDRES_TYPE'.

  • 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 = P_IT_MESSAGE

    RECEIVERS = 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.

    Add a comment
    10|10000 characters needed characters exceeded

    Assigned Tags

    Related questions

    1 Answer

    • author's profile photo Former Member
      Former Member
      Posted on Jan 09, 2008 at 03:39 PM

      Hi venu,

      Pass the value of Dest_Device into the function module. Hope it works.

      DST_DEVICE = 'LP01'

      Regards,

      Kishore.

      Add a comment
      10|10000 characters needed characters exceeded

    Before answering

    You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
    You must be Logged in to submit an answer.

    Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.