Skip to Content

Error while sending smartform as PDF to mail

Hi All,

I am sending smartform output as PDF to Mail, but I am getting error "Error occurred during transmission - return code: <KPRO_DOC> ".

I converted output OTF to PDF by using CONVERT_OTF FM & then I m getting XSTRING and then converting it to binary by using

CALL METHOD cl_document_bcs=>xstring_to_solix

EXPORTING

ip_xstring = gt_binfile

RECEIVING

rt_solix = lt_solixtab.

I am sending the binary to mail as attachment but I m getting error.

So pls do the needful.

Regards,

Bharath

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2014 at 08:01 AM

    This message was moderated.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2014 at 08:03 AM

    This message was moderated.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 03, 2014 at 10:50 AM

    check your SOST settings as well ..

    for your reference .

    l_subject = 'Screen Attached'.

    lo_bcs = cl_bcs=>create_persistent( ).

    lo_doc_bcs = cl_document_bcs=>create_document(

    i_type = 'HTM'

    i_text = lt_solix1

    i_subject = l_subject ).

    CALL METHOD lo_doc_bcs->add_attachment

    EXPORTING

    i_attachment_type = 'png' "" here give your PDF type

    i_attachment_subject = 'Screenshot'

    i_att_content_hex = lt_solix.

    "Create Document

    lo_bcs->set_document( i_document = lo_doc_bcs ).

    "create Sender

    l_uname = sy-uname.

    CALL FUNCTION 'HR_FBN_GET_USER_EMAIL_ADDRESS'

    EXPORTING

    user_id = l_uname

    reaction = 'X'

    IMPORTING

    email_address = email

    subrc = subrc

    TABLES

    error_table = error_table.

    IF subrc NE 0.

    MESSAGE 'Please Maintain Email Address in SU01 for User' TYPE 'E' DISPLAY LIKE 'I'.

    ELSE.

    lo_sender = cl_cam_address_bcs=>create_internet_address( email ).

    ENDIF.

    * Set sender

    lo_bcs->set_sender(

    EXPORTING

    i_sender = lo_sender ).

    "Create Recipient

    lo_recipient = cl_cam_address_bcs=>create_internet_address( i_address_string = 'abc@abc.com.sa' ).

    lo_bcs->add_recipient( i_recipient = lo_recipient ).

    lo_bcs->send( ).

    COMMIT WORK AND WAIT.

    IF sy-subrc = 0.

    MESSAGE 'Email Sent Successfully ' TYPE 'S' DISPLAY LIKE 'S'.

    CLEAR ok_code.

    LEAVE TO SCREEN 0.

    ENDIF.

    Thanks & Regards,

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 03, 2014 at 11:03 AM

    Hi,

    Convert OTF to PDF using FM CONVERT_OTF_TO_PDF

    and while attaching use object type as 'BIN'

    Regards,

    Ashish

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2014 at 10:46 AM

    This message was moderated.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2014 at 12:54 PM

    Hi,

    REPORT Z_SEND_MAIL.

    ********Variable Declarations ****************************

    DATA: GV_FORM_NAME TYPE RS38L_FNAM, " Used to store the function module generated by Smartform

    GV_BIN_FILESIZE TYPE I, " Store the file size

    GV_POS TYPE I,

    GV_LEN TYPE I,

    GV_TAB_LINES TYPE I.

    *******Constants ******************************************

    DATA : GC_TEXT(11) TYPE C VALUE 'Form Output',

    GC_TST(3) TYPE C VALUE 'TST',

    GC_TESTING(7) TYPE C VALUE 'Testing'.

    ********Work Area Declarations ****************************

    DATA: GS_DOCDATA TYPE SODOCCHGI1, " Data of an object which can be changed

    GS_CTRLOP TYPE SSFCTRLOP, " Smart Forms: Control structure

    GS_OUTOPT TYPE SSFCOMPOP, " SAP Smart Forms: Smart Composer (transfer) options

    GS_OTFDATA TYPE SSFCRESCL, " Smart Forms: Return value at end of form printing

    GS_RECLIST TYPE SOMLRECI1, " SAPoffice: Structure of the API Recipient List

    GS_PDF_TAB TYPE TLINE, " Workarea for SAP Script Text Lines

    GS_OBJBIN TYPE SOLISTI1, " SAPoffice: Single List with Column Length 255

    GS_OBJPACK TYPE SOPCKLSTI1. " SAPoffice: Description of Imported Object Components

    ********Internal tables Declarations ****************************

    DATA: GT_RECLIST TYPE TABLE OF SOMLRECI1, " SAPoffice: Structure of the API Recipient List

    GT_PDF_TAB TYPE TABLE OF TLINE, " SAPscript: Text Lines

    GT_OTF TYPE TABLE OF ITCOO, " OTF Structure

    GT_OBJBIN TYPE TABLE OF SOLISTI1, " SAPoffice: Single List with Column Length 255

    GT_OBJPACK TYPE TABLE OF SOPCKLSTI1. " SAPoffice: Description of Imported Object Components

    DATA: CUSTOMER TYPE SCUSTOM,

    BOOKINGS TYPE TY_BOOKINGS,

    CONNECTIONS TYPE TY_CONNECTIONS.

    CLEAR : GV_FORM_NAME,

    GS_CTRLOP,

    GS_OUTOPT,

    GS_OTFDATA,

    GV_BIN_FILESIZE,

    GV_POS,

    GV_LEN,

    GV_TAB_LINES.

    START-OF-SELECTION.

    * Generate Function Module name

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

    FORMNAME = 'SF_EXAMPLE_01'

    IMPORTING

    FM_NAME = GV_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.

    * Assigning values to Form Control Structure and Form Composer

    GS_CTRLOP-GETOTF = 'X'.

    GS_CTRLOP-DEVICE = 'PRINTER'.

    GS_CTRLOP-PREVIEW = ''.

    GS_CTRLOP-NO_DIALOG = 'X'.

    GS_OUTOPT-TDDEST = 'LOCL'.

    * Getting the OTFDATA

    CALL FUNCTION GV_FORM_NAME

    EXPORTING

    CONTROL_PARAMETERS = GS_CTRLOP

    OUTPUT_OPTIONS = GS_OUTOPT

    USER_SETTINGS = ' '

    CUSTOMER = CUSTOMER

    BOOKINGS = BOOKINGS

    CONNECTIONS = CONNECTIONS

    IMPORTING

    JOB_OUTPUT_INFO = GS_OTFDATA

    EXCEPTIONS

    FORMATTING_ERROR = 1

    INTERNAL_ERROR = 2

    SEND_ERROR = 3

    USER_CANCELED = 4.

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    * Assigning the OTFDATA to OTF Structure table

    CLEAR GT_OTF.

    GT_OTF[] = GS_OTFDATA-OTFDATA[].

    * Convert the OTF DATA to SAP Script Text lines

    CLEAR GT_PDF_TAB.

    CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

    FORMAT = 'PDF'

    MAX_LINEWIDTH = 132

    IMPORTING

    BIN_FILESIZE = GV_BIN_FILESIZE

    TABLES

    OTF = GT_OTF

    LINES = GT_PDF_TAB

    EXCEPTIONS

    ERR_MAX_LINEWIDTH = 1

    ERR_FORMAT = 2

    ERR_CONV_NOT_POSSIBLE = 3

    OTHERS = 4.

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    * Assigning the Description of the object sent in the mail

    CLEAR GS_DOCDATA.

    GS_DOCDATA-OBJ_NAME = GC_TST.

    GS_DOCDATA-OBJ_DESCR = GC_TESTING.

    * Assigning the email id to Structure of the API Recipient List table

    CLEAR : GT_RECLIST, GS_RECLIST.

    * IF internal mail id

    GS_RECLIST-RECEIVER = SY-UNAME.

    GS_RECLIST-REC_TYPE = 'B'.

    * if external mail id

    * gs_reclist-receiver = 'shakti.agnihotri@gmail.com'.

    * gs_reclist-rec_type = 'U'.

    APPEND GS_RECLIST TO GT_RECLIST.

    * Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table

    CLEAR : GS_OBJBIN, GS_PDF_TAB.

    LOOP AT GT_PDF_TAB INTO GS_PDF_TAB.

    GV_POS = 255 - GV_LEN.

    IF GV_POS > 134. "length of pdf_table

    GV_POS = 134.

    ENDIF.

    GS_OBJBIN+GV_LEN = GS_PDF_TAB(GV_POS).

    GV_LEN = GV_LEN + GV_POS.

    IF GV_LEN = 255. "length of out (contents_bin)

    APPEND GS_OBJBIN TO GT_OBJBIN.

    CLEAR: GS_OBJBIN, GV_LEN.

    IF GV_POS < 134.

    GS_OBJBIN = GS_PDF_TAB+GV_POS.

    GV_LEN = 134 - GV_POS.

    ENDIF.

    ENDIF.

    ENDLOOP.

    IF GV_LEN > 0.

    APPEND GS_OBJBIN TO GT_OBJBIN.

    ENDIF.

    * Filling the details in SAPoffice: Description of Imported Object Components table

    DESCRIBE TABLE GT_OBJBIN LINES GV_TAB_LINES.

    CLEAR GS_OBJBIN.

    READ TABLE GT_OBJBIN INTO GS_OBJBIN INDEX GV_TAB_LINES.

    IF SY-SUBRC = 0.

    GS_OBJPACK-DOC_SIZE = ( GV_TAB_LINES - 1 ) * 255 + STRLEN( GS_OBJBIN ).

    GS_OBJPACK-TRANSF_BIN = 'X'.

    GS_OBJPACK-HEAD_START = 1.

    GS_OBJPACK-HEAD_NUM = 0.

    GS_OBJPACK-BODY_START = 1.

    GS_OBJPACK-BODY_NUM = GV_TAB_LINES.

    GS_OBJPACK-DOC_TYPE = 'PDF'.

    GS_OBJPACK-OBJ_NAME = 'ATTACHMENT'.

    GS_OBJPACK-OBJ_DESCR = 'test'.

    APPEND GS_OBJPACK TO GT_OBJPACK.

    ENDIF.

    * Sending the Form Output in the PDF format to email

    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

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

    ELSE.

    WRITE 'Sent Successfully'.

    ENDIF.

    SUBMIT RSCONN01

    WITH MODE EQ 'INT'

    AND RETURN.

    END-OF-SELECTION.

    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.