Sending PDF to SAP Outbox - Urgent

Hi All,
  I try to send a SAP mail with PDF Attachment throught a Program. Its sending the mail along with the attachment. But when i try to open the PDF in SAP Outbox, its giving formating error and file is not getting opend. The code as follows. Anybody code give us the solution.
[code
*& Report  ZHH_TEST_CODE3                                              *
REPORT  ZHH_TEST_CODE3                          .
DATA: it_attachment TYPE soli OCCURS 0 WITH HEADER LINE.
Hold contents of attachment file for use by email
perform send_email USING '[email protected]' 'C:\TEST1.PDF'.
FORM send_email USING p_email p_filename.
DATA:     lt_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
          lt_objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
          lt_objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
          lt_objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
          lt_reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE,
          l_document_data TYPE sodocchgi1.
DATA: l_att_lines TYPE i.
CHECK NOT ( p_email IS INITIAL ).
CLEAR:    lt_reclist, lt_reclist[],
          lt_objhead, lt_objhead[],
          lt_objtxt, lt_objtxt[],
          lt_objbin, lt_objbin[],
          lt_objpack, lt_objpack[].
CLEAR l_document_data.
Read in file to attach to internal table it_attachment
PERFORM read_attach_file USING p_filename.
CHeck that attach file has been read
CHECK NOT ( it_attachment[] IS INITIAL ).
Body of email
MOVE 'This is the body of email' TO lt_objtxt.
APPEND lt_objtxt.
l_document_data-obj_name = 'Xtract'.
Title of email
MOVE 'This is the title of the email' TO l_document_data-obj_descr.
l_document_data-sensitivty = 'O'.
l_document_data-expiry_dat = sy-datum + 10.
l_document_data-doc_size = STRLEN( lt_objtxt ).
Settings for e-mail body
CLEAR lt_objpack.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = 1.
lt_objpack-doc_type = 'RAW'.
lt_objpack-doc_size = STRLEN( lt_objtxt ).
APPEND lt_objpack.
Settings for e-mail attachment
DESCRIBE TABLE it_attachment LINES l_att_lines.
READ TABLE it_attachment INDEX l_att_lines.
CLEAR lt_objpack.
lt_objpack-transf_bin = 'X'.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_att_lines.
lt_objpack-doc_type = 'PDF'.
lt_objpack-obj_name = 'email'.
lt_objpack-obj_descr = 'KANBAN'.
lt_objpack-doc_size = ( 255 * ( l_att_lines - 1 ) ) + STRLEN( it_attachment-line ).
APPEND lt_objpack.
make recipient list
lt_reclist-receiver = p_email.
lt_reclist-rec_type = 'U'.      "OUT OF SAP user
APPEND lt_reclist.
send mail with attachment
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = l_document_data
put_in_outbox = 'X'
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = it_attachment
contents_txt = lt_objtxt
receivers = lt_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.
write:/ 'successful sending'.
else.
write:/ 'failure in sending'.
endif.
ENDFORM. " send_email
FORM read_attach_file USING p_filename TYPE string.
DATA:   act_filetype LIKE rlgrap-filetype,
        act_filename LIKE rlgrap-filename,
        h_filename LIKE rlgrap-filename,
        doc_length LIKE soxwd-doc_length,
        f_cancelled LIKE sonv-flag,
        file_put_to_kpro LIKE sonv-flag,
        def_filename(12),
        l_filetype TYPE rlgrap-filetype.
l_filetype = 'PDF'.
def_filename = 'TEST1.PDF'.
REFRESH it_attachment.
CALL FUNCTION 'SO_OBJECT_UPLOAD'
EXPORTING
default_filename = def_filename
filetype = l_filetype
path_and_file = 'C:\TEST1.PDF'
*no_dialog = 'X'
IMPORTING
filelength = doc_length
f_cancelled = f_cancelled
act_filename = act_filename
act_filetype = act_filetype
file_put_to_kpro = file_put_to_kpro
TABLES
objcont = it_attachment
EXCEPTIONS
file_read_error = 1
invalid_type = 2
x_error = 3
object_type_not_allowed = 4
kpro_insert_error = 5
OTHERS = 6.
if sy-subrc = 0.
write:/  'file uploaded'.
else.
write:/ 'problem in uploading'.
endif.
ENDFORM. " upload_file
[/code]
And I promise to return and reward the answers.
With Regards,
Raja T.

Hi,
Check the sy-subrc value while reading the attachement in the function module 'SO_OBJECT_UPLOAD'.If it is not zero,then there is problem there itself.
Check these link for sample coding.
http://www.sap-img.com/fu016.htm
Re: Sending e-mails using ABAP
Have a look at this sample coding also.
FORM SEND_MAIL.
  DATA: OBJPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
  DATA: OBJHEAD   LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
  DATA: OBJBIN    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
  DATA: OBJTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
  DATA: RECLIST   LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
  DATA: DOC_CHNG  LIKE SODOCCHGI1.
  DATA: TAB_LINES LIKE SY-TABIX.
  DATA L_NUM(3).
Creation of the document to be sent
File Name
  DOC_CHNG-OBJ_NAME = 'SENDFILE'.
Mail Subject
  DOC_CHNG-OBJ_DESCR = 'Delivered Mail'.
Mail Contents
  OBJTXT = 'Object text'.
  APPEND OBJTXT.
  DESCRIBE TABLE OBJTXT LINES TAB_LINES.
  READ TABLE OBJTXT INDEX TAB_LINES.
  DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creation of the entry for the compressed document
  CLEAR OBJPACK-TRANSF_BIN.
  OBJPACK-HEAD_START = 1.
  OBJPACK-HEAD_NUM = 0.
  OBJPACK-BODY_START = 1.
  OBJPACK-BODY_NUM = TAB_LINES.
  OBJPACK-DOC_TYPE = 'RAW'.
  APPEND OBJPACK.
Creation of the document attachment
  LOOP AT ITAB_DATA.
    CONCATENATE ITAB_DATA-PRODUCTOR
                ITAB_DATA-VBELN
                ITAB_DATA-POSNR
                ITAB_DATA-MATNR INTO OBJBIN.
    APPEND OBJBIN.
  ENDLOOP.
  DESCRIBE TABLE OBJBIN LINES TAB_LINES.
  OBJHEAD = 'ORDERS'.
  APPEND OBJHEAD.
Creation of the entry for the compressed attachment
  OBJPACK-TRANSF_BIN = 'X'.
  OBJPACK-HEAD_START = 1.
  OBJPACK-HEAD_NUM   = 1.
  OBJPACK-BODY_START = 1.
  OBJPACK-BODY_NUM   = TAB_LINES.
  OBJPACK-DOC_TYPE   = 'TXT'.
  OBJPACK-OBJ_NAME   = 'WEBSITE'.
  OBJPACK-OBJ_DESCR  = 'ORDERS.TXT'.
  OBJPACK-DOC_SIZE   = TAB_LINES * 255.
  APPEND OBJPACK.
Completing the recipient list
target recipent
  clear RECLIST.
  RECLIST-RECEIVER = '[email protected]'.
  RECLIST-EXPRESS  = 'X'.
  RECLIST-REC_TYPE = 'U'.
  APPEND RECLIST.
copy recipents
  clear RECLIST.
  RECLIST-RECEIVER = '[email protected]'.
  RECLIST-EXPRESS  = 'X'.
  RECLIST-REC_TYPE = 'U'.
  RECLIST-COPY     = 'X'.
  APPEND RECLIST.
Sending the document
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       EXPORTING
            DOCUMENT_DATA              = DOC_CHNG
       TABLES
            PACKING_LIST               = OBJPACK
            OBJECT_HEADER              = OBJHEAD
            CONTENTS_BIN               = OBJBIN
            CONTENTS_TXT               = OBJTXT
            RECEIVERS                  = RECLIST
       EXCEPTIONS
            TOO_MANY_RECEIVERS         = 1
            DOCUMENT_NOT_SENT          = 2
            OPERATION_NO_AUTHORIZATION = 4
            OTHERS                     = 99.
ENDFORM.                    " SEND_MAIL
Check this link also.
http://www.sapdevelopment.co.uk/reporting/email/emailhome.htm
Message was edited by: Jayanthi Jayaraman

Similar Messages

  • How to send a PDF document to a FAX Server in SAP ? - Urgent

    Dear All
    Can you please provide inputs as to how one can send a PDF document to a FAX server . In my SCOT i have config done for FAX . I am able to send PDF document via e-mail . Wonder how to use FM  'CONVERT_OTF_AND_FAX' for sending fax ? There is a parameter called FAXOPTIONS in export parameter which we need to pass . What all we need to pass in here ? any idea or some other way here?
    Best Regards
    Shovit

    check this sample program
    BCS_EXAMPLE_2
    Regards
    Raja

  • Send PDF Attachment to SAP Mail Inbox.

    Dear all,
    I have problem please help me out.
    i have to  create an PDF file  with
    my own data and that created PDF file
    i have to send it to SAP mail inbox
    (Transaction code : so01).

    hi sudheer,
    Let the data be populated into ur itab ,
    Now in the code just concentrate on
    Perform fill structure.
    the process u need to do is from ur layout convert from
    itab o/p format itab>OTF/OTF->PDF .
    see the function modules .
    on execution of this a mail will be in ur outbox .
    regards,
    vijay.
    tables : vbak.
    type-pools:slis.
    data: begin of it_t1 occurs 0,
          vbeln like vbak-vbeln,
          erdat like vbak-erdat,
          ernam like vbak-ernam,
          netwr like vbak-netwr,
          waerk like vbak-waerk,
          end of it_t1.
          select-options : so_vbeln for vbak-vbeln.
         DATA :  it_fieldcat TYPE slis_t_fieldcat_alv,
                 it_sort TYPE slis_t_sortinfo_alv,
                 it_listheader TYPE slis_t_listheader,
                 it_alvevent TYPE slis_t_event.
         DATA : wa_fieldcat TYPE slis_fieldcat_alv,
                w_pos TYPE i VALUE 1,
                wa_listheader TYPE slis_listheader,
                wa_alvevent TYPE slis_alv_event,
                wa_sort TYPE slis_sortinfo_alv.
         Data:  it_outtab like it_t1 occurs 0 with header line.
    DATA : MAILREC LIKE SOMLRECI1 occurs 0 WITH HEADER LINE,
           MAILBIN LIKE SOLISTI1 occurs 0 WITH HEADER LINE,
           MAILBIN2 LIKE SOLISTI1 occurs 0 WITH HEADER LINE,
           MAILTXT LIKE SOLISTI1 occurs 0 WITH HEADER LINE,
           MAILHEAD LIKE SOLISTI1 occurs 0 WITH HEADER LINE,
           MAILSTRUC LIKE SOPCKLSTI1 occurs 0 WITH HEADER LINE,
           MAILDATA LIKE SODOCCHGI1 occurs 0 WITH HEADER LINE.
    DATA: BEGIN OF GT_OTF OCCURS 0.
            INCLUDE STRUCTURE ITCOO .
    DATA: END OF GT_OTF.
    DATA: ITCPO LIKE ITCPO,
          ITCPP LIKE ITCPP.
    DATA: tlines type i,
          len_in like SOOD-OBJLEN,
          len_out like SOOD-OBJLEN.
    data: gt_pdf    like solisti1   occurs 0  with header line.
    DATA: gt_otfdata LIKE SOLISTI1 occurs 0 WITH HEADER LINE.
        CONSTANTS: c_formname_top_of_page TYPE slis_formname
                              VALUE 'F_TOP_OF_PAGE'.
    select vbeln
           erdat
           ernam
           netwr
           waerk into corresponding fields of table
           it_outtab from vbak where vbeln in so_vbeln.
          loop at it_t1.
            write:/ it_t1-vbeln,
                    it_t1-erdat,
                    it_t1-ernam,
                    it_t1-netwr,
                    it_t1-waerk.
          endloop.
       perform alv_disp.
    *&      Form  alv_disp
          text
    -->  p1        text
    <--  p2        text
    FORM alv_disp.
    PERFORM build_fcat USING '1' 'VBELN' 'IT_OUTTAB' ' ' ' ' ' '
    'SALESNO'.
      PERFORM build_fcat USING '2' 'ERDAT' 'IT_OUTTAB' ' ' ' ' ' '
    'CRTNDATE'.
    PERFORM build_fcat USING '3' 'ERNAM' 'IT_OUTTAB' ' ' ' ' ' '
    'CRNAME'.
    PERFORM build_fcat USING '4' 'NETWR' 'IT_OUTTAB' ' ' ' ' ' '
    'NETPRICE'.
    PERFORM build_fcat USING '5' 'WAERK' 'IT_OUTTAB' ' ' ' ' ' '
    'CURRENCY'.
    ***Top of Page Heading purpose " u can add the date and column over here
    PERFORM buildtop USING it_listheader[].
    perform top_of_page.
    *------Sort The Catalog
    PERFORM sort_cat  TABLES it_outtab USING it_sort[].
    *------Display Table In GRID
    PERFORM disp_grid TABLES it_outtab[].
    **For email stuff follow the perform
         perform fill_struct.
         CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA                    = MAILDATA
        PUT_IN_OUTBOX                    = 'X'
      TABLES
        PACKING_LIST                     = MAILSTRUC
        OBJECT_HEADER                    = MAILHEAD
        CONTENTS_BIN                     = MAILBIN
        CONTENTS_TXT                     = MAILTXT
      CONTENTS_HEX                     =
      OBJECT_PARA                      =
      OBJECT_PARB                      =
        RECEIVERS                        = MAILREC
    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.
    ENDFORM.                    " alv_disp
    *&      Form  build_fcat
          text
         -->P_0104   text
         -->P_0105   text
         -->P_0106   text
         -->P_0107   text
         -->P_0108   text
         -->P_0109   text
         -->P_0110   text
    FORM build_fcat USING     value(col_pos)
                              value(fieldname)
                              value(tabname)
                              value(key)
                              value(no_zero)
                              value(do_sum)
                              value(reptext_ddic).
    CLEAR wa_fieldcat.
      wa_fieldcat-col_pos       = col_pos.
      wa_fieldcat-fieldname     = fieldname.
      wa_fieldcat-tabname       = tabname.
      wa_fieldcat-key           = key.
      wa_fieldcat-no_zero       = no_zero.
      wa_fieldcat-do_sum        = do_sum.
      wa_fieldcat-reptext_ddic  = reptext_ddic.
      APPEND wa_fieldcat TO it_fieldcat.
    ENDFORM.                    " build_fcat
    *&      Form  Top_Of_Page
    Top of page for Grid.
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                it_list_commentary = it_listheader
                I_LOGO             = 'MY_SAP_ENJOY'.
    ENDFORM.                    "top_of_page
          text
         -->P_IT_LISTHEADER[]  text
    FORM buildtop USING IT_LISTHEADER type slis_t_listheader.
    DATA : text(100) TYPE c.
      CLEAR  it_listheader.
      CLEAR wa_listheader.
      wa_listheader-typ  = 'H'.
      wa_listheader-info = 'Sales Details' .
      APPEND wa_listheader TO it_listheader.
      CLEAR wa_listheader.
      wa_listheader-typ  = 'S'.
      wa_listheader-info =  'Demo'.
      APPEND wa_listheader TO it_listheader.
    *CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
       IT_LIST_COMMENTARY       =  it_listheader
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
    ENDFORM.                    " Top_Of_Page
    *&      Form  sort_cat
          text
         -->P_IT_OUTTAB  text
         -->P_IT_SORT[]  text
    FORM sort_cat TABLES   IT_OUTTAB STRUCTURE  IT_OUTTAB  USING IT_SORT
    TYPE
    slis_t_sortinfo_alv.
    CLEAR wa_sort.
      wa_sort-fieldname       = 'VBELN'.
      wa_sort-tabname         = 'IT_OUTTAB'.
      wa_sort-spos            = 1.
      wa_sort-up              = 'X'.
      wa_sort-subtot          = ' '.
      APPEND wa_sort TO it_sort.
    ENDFORM.                    " sort_cat
    *&      Form  disp_grid
          text
         -->P_IT_OUTTAB[]  text
    FORM disp_grid TABLES  IT_OUTTAB STRUCTURE  IT_OUTTAB.
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
           I_CALLBACK_PROGRAM                = 'ZEX2' "sy-repid
           I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
           IT_FIELDCAT                       =  IT_FIELDCAT
          IT_SORT                          =  IT_SORT
         TABLES
           T_OUTTAB                          = IT_OUTTAB
        EXCEPTIONS
          PROGRAM_ERROR                     = 1
          OTHERS                            = 2
       IF SY-SUBRC <> 0.
           MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
    ENDFORM.                    " disp_grid
    *&      Form  fill_struct
          text
    -->  p1        text
    <--  p2        text
    FORM fill_struct.
    Text
      MOVE 'Hi vijay ' TO MAILTXT-LINE.
      APPEND MAILTXT.
    Data
      MAILDATA-OBJ_NAME = 'Document'.
      MAILDATA-OBJ_DESCR = 'E-maiL From vij'.
      MAILDATA-OBJ_PRIO = '1'.
      MAILDATA-DOC_SIZE = strlen( MAILTXT ).
    Structure
      MAILSTRUC-HEAD_START = 1.
      MAILSTRUC-HEAD_NUM = 0.
      MAILSTRUC-BODY_START = 1.
      MAILSTRUC-BODY_NUM = 1.
      mailstruc-obj_name = 'Vijay Simha'.
      MAILSTRUC-DOC_TYPE = 'RAW'.
      APPEND MAILSTRUC.
    Receivers
    **u can use ur mail id(s) overhere
        MOVE '[email protected]' TO MAILREC-RECEIVER.
        MAILREC-REC_TYPE  = 'U'.
      APPEND MAILREC.
      CLEAR ITCPO.
      ITCPO-TDGETOTF = 'X'.
    ***moving to the output/format of the attachment.
    final pdf format in the mail attachemnt
      LOOP AT it_outtab.
       MOVE it_outtab-vbeln TO MAILBIN.
       MOVE it_outtab-erdat TO MAILBIN+18.
       MOVE it_outtab-ernam TO MAILBIN+40.
      MOVE it_outtab-netwr TO MAILBIN+70.
      MOVE it_outtab-waerk TO MAILBIN+78.
       APPEND MAILBIN.
       CLEAR MAILBIN.
      ENDLOOP.
    **convert the scrap to otf.
    CALL FUNCTION 'SX_OBJECT_CONVERT_SCR_OTF'
      EXPORTING
        format_src            = 'RAW'
        format_dst            = 'OTF'
        devtype               = 'POSTSCPT'
        funcpara              = ' '
        len_in                = LEN_IN
    IMPORTING
       LEN_OUT               =  LEN_OUT
      tables
        content_in            = MAILBIN
        content_out           = MAILBIN2
    EXCEPTIONS
      ERR_CONV_FAILED       = 1
      OTHERS                = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    REFRESH MAILBIN.
    CONVERT OTF to PDF
      CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
        EXPORTING
          FORMAT_SRC            = 'OTF'
          FORMAT_DST            = 'PDF'
          DEVTYPE               = 'POSTSCPT'
      FUNCPARA              =
          LEN_IN                = LEN_IN
        IMPORTING
          LEN_OUT               = LEN_OUT
        TABLES
          CONTENT_IN            = MAILBIN2
          CONTENT_OUT           = MAILBIN
    EXCEPTIONS
      ERR_CONV_FAILED       = 1
      OTHERS                = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    REFRESH MAILBIN2.
    DESCRIBE TABLE MAILBIN LINES TLINES.
    Structure
      MAILSTRUC-HEAD_START = 1.
      MAILSTRUC-HEAD_NUM = 1.
      MAILSTRUC-BODY_START = 1.
      MAILSTRUC-BODY_NUM = TLINES.
      MAILSTRUC-TRANSF_BIN = 'X'.
      MAILSTRUC-DOC_TYPE = 'PDF'.
    MAILSTRUC-DOC_TYPE = 'XLS'.
      mailstruc-obj_name = 'Vijay.S.Reddy'.
      MAILSTRUC-DOC_SIZE = tlines * 255.
      APPEND MAILSTRUC.
    ENDFORM.                    " fill_struct

  • Urgent ...how to send output of sap through mail

    Could you please guide me how to send output of SAP Script  through mail in PDF format.
    Thanks in Advance....
    Regards,
    Kumar.

    *& Report  ZSPOOLTOPDF                                                 *
    *& Converts spool request into PDF document and emails it to           *
    *& recipicant.                                                         *
    *& Execution                                                           *
    *& This program must be run as a background job in-order for the write *
    *& commands to create a Spool request rather than be displayed on      *
    *& screen                                                              *
    REPORT  zspooltopdf.
    PARAMETER: p_email1 LIKE somlreci1-receiver,
               p_sender LIKE somlreci1-receiver,
                   p_delspl  AS CHECKBOX.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount LIKE tbtcm-jobcount,
          gd_jobname LIKE tbtcm-jobname,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject   LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des.
    Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Write statement to represent report output. Spool request is created
    if write statement is executed in background. This could also be an
    ALV grid which would be converted to PDF without any extra effort
      WRITE 'Hello World'.
      new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
    Alternative way could be to submit another program and store spool
    id into memory, will be stored in sy-spono.
    *submit ZSPOOLTOPDF2
           to sap-spool
           spool parameters   %_print
           archive parameters %_print
           without spool dynpro
           and return.
    Get spool id from program called above
    IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
        PERFORM convert_spool_to_pdf.
        PERFORM process_email.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
        IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
          FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
          FORM get_job_details                                          *
    FORM get_job_details.
    Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
          FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           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.
      CHECK sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
          FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1.
    perform send_email using p_email2.
    ENDFORM.
          FORM send_email                                               *
    -->  p_email                                                       *
    FORM send_email USING p_email.
      CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = 'Attachname'.
    CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod        = 'Message Body text, line 1'.
      APPEND it_mess_bod.
      it_mess_bod        = 'Message Body text, line 2...'.
      APPEND it_mess_bod.
    If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
          FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            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,
            ld_receiver LIKE  sy-subrc.
    data:   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,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    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'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      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'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    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 it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      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               = it_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
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    regards,
    venkat

  • Urgent : - Some Error in code while sending attachment thru SAP

    hiii,
    i have posted a problem in the following thread.
    How to send PDF file thru SAP
    at some extent Surpreet is able to solve  the problem, but now we r stuck to this that email is coming with attachment but not the exact that i am attching and trying to send the mail.
    can any one check this code and rectify if any error is there.
    REPORT YBALTEST.
    DATA: gd_cnt TYPE i,
    gd_sent_all(1) TYPE c,
    gd_doc_data LIKE sodocchgi1,
    gd_error TYPE sy-subrc.
    DATA: it_message LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
    it_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    it_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    * Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0,
    row(255).
    DATA: END OF it_pdf_output.
    START-OF-SELECTION.
    perform send_email_message .
    *& Form SEND_EMAIL_MESSAGE
    * Send email message
    FORM send_email_message.
    DATA: tab_lines LIKE SY-TABIX.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = 'C:test.pdf'
    filetype = 'BIN'
    TABLES
    data_tab = it_pdf_output .
    * Populate the subject/generic message attributes
    concatenate 'Attached is the '
    ' are waiting for.' into it_message.
    append it_message.
    DESCRIBE TABLE it_message LINES tab_lines.
    READ TABLE it_message INDEX tab_lines.
    gd_doc_data-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( it_message ).
    gd_doc_data-obj_langu = sy-langu.
    gd_doc_data-obj_name = 'SENDFILE'.
    gd_doc_data-obj_descr = 'Attachement'.
    gd_doc_data-sensitivty = 'O'.
    describe table it_pdf_output lines tab_lines.
    * Describe the body of the message
    CLEAR it_packing_list-transf_bin.
    it_packing_list-head_start = 1.
    it_packing_list-head_num = 0.
    it_packing_list-body_start = 1.
    it_packing_list-doc_type = 'RAW'.
    it_packing_list-body_num = tab_lines.
    APPEND it_packing_list.
    describe table it_pdf_output lines tab_lines.
    CLEAR it_packing_list.
    it_packing_list-transf_bin = 'X'.
    it_packing_list-head_start = 1.
    it_packing_list-head_num = 1.
    it_packing_list-body_start = 1.
    it_packing_list-doc_type = 'RAW'.
    it_packing_list-body_num = tab_lines.
    it_packing_list-doc_size = tab_lines * 255.
    it_packing_list-OBJ_DESCR = ' object '.
    it_packing_list-obj_name = 'MAIL'.
    APPEND it_packing_list.
    it_receivers-receiver = '[email protected]'.
    it_receivers-rec_type = 'U'.
    it_receivers-com_type = 'INT'.
    APPEND it_receivers .
    * Call the FM to post the message to SAPMAIL
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = gd_doc_data
    * put_in_outbox = 'X'
    commit_work = 'X'
    * IMPORTING
    * sent_to_all = gd_sent_all
    TABLES
    packing_list = it_packing_list
    contents_txt = it_message
    contents_bin = it_pdf_output
    receivers = it_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
    OTHERS = 8.
    ENDFORM. " SEND_EMAIL_MESSAGE
    thanx
    abhishek suppal

    just unreadable
    like this
    €¥ä™„ã„ã˜®â”î¢íà¨ãˆ±ãŒ¸ã€ æ¼ æ©¢ã° â¼¼æ¥Œæ•®ç‰¡ç©©æ‘¥ã„ ä°¯ãŒ ã”²ã˜²â¼¶âãˆ±ãœ¸ä”¯ã ã¤·ã´ä¸¯ãˆ â¼¹â”ã¤²ã”¹ã€´ä ¯å¬ ã„ ã˜µâ€·ãˆ¹å´¶ã¸¾æ”æ‘®æ‰¯àµªâ€ â€ â€ â€ â€ à¨ç‰¸æ™¥à¨ãˆ±ãŒ¸ã˜ à´±ã€Šã€°ã€°ã€°ã„°â€¶ã€°ã€°â€°àµ®ã€Šã€°ã€°ãˆ°ã¤¶â€¹ã€°ã€°â€°àµ®ã€Šã€°ã€°ãˆ°ãŒ¸â€·ã€°ã€°â€°àµ®ã€Šã€°ã€°ãŒ°ãœ±â€³ã€°ã€°â€°àµ®ã€Šã€°ã€°ãŒ°ãŒ³â€²ã€°ã€°â€°àµ®ã€Šã€°ã€°ãŒ°ã µâ€°ã€°ã€°â€°àµ®ã€Šã€°ã€°ãŒ°ã„¶â€¸ã€°ã€°â€°àµ®ã€Šã€°ã€°ãŒ°ã€¸â€²ã€°ã€°â€°àµ®ã€Šã€°ã€°ãŒ°ã ¸â€°ã€°ã€°â€°àµ®ã€Šã€°ã€°ã˜°ã”µâ€±ã€°ã€°â€°àµ®ã€Šã€°ã€°ãˆ´ãµâ€¹ã€°ã€°â€°àµ®ã€Šã€°ã€°ãˆ´ãˆ¶â€²ã€°ã€°â€°àµ®ã€Šã€°ã€°ãˆ´ã€·â€³ã€°ã€°â€°àµ®ã€Šã€°ã€°ãˆ´ã˜¸â€¶ã€°ã€°â€°àµ®ã€Šã€°ã€°ãˆ´ãˆ¹â€°ã€°ã€°â€°àµ®ã€Šã€°ã€°ãŒ´ã °â€´ã€°ã€°â€°àµ®ã€Šã€°ã€°ãŒ´ãŒ±â€¸ã€°ã€°â€°àµ®ã€Šã€°ã€°ãŒ´ã³â€µã€°ã€°â€°àµ®ã€Šã€°ã€°ãŒ´ã„µâ€¸ã€°ã€°â€°àµ®
    《〰〰㌴㜵′〰〰‰൮《〰〰㌴㐷‸〰〰‰൮《〰〰㌴㐹‵〰〰‰൮《〰〰㐴〱‶〰〰‰൮《〰〰㐴㘱‰〰〰‰൮《〰〰㐴㌳‶〰〰‰൮《〰〰㐴㌴‹〰〰‰൮《〰〰㐴㤴′〰〰‰൮《〰〰㐴㤵‴〰〰‰൮《〰〰㐴㌶‶〰〰‰൮《〰〰㐴㘷‴〰〰‰൮《〰〰㐴ㄸ‸〰〰‰൮《〰〰㔴㈰‴〰〰‰൮《〰〰㔴㔲‰〰〰‰൮《〰〰㔴㠳‶〰〰‰൮《〰〰㔴㐴‰〰〰‰൮《〰〰㔴㜵‷〰〰‰൮《〰〰㔴㌶‱〰〰‰൮《〰〰㔴㠶‵〰〰‰൮《〰〰㔴㌷‹〰〰‰൮《〰〰㔴〹‷〰〰‰൮《〰〰㔴㘹‱〰〰‰൮《〰〰㘴〲‸〰〰‰൮《〰〰㘴㘲′〰〰‰൮《〰〰㘴〵‷〰〰‰൮《〰〰㘴㘵
    â€±ã€°ã€°â€°àµ®ã€Šã€°ã€°ã˜´ãŒ·â€¶ã€°ã€°â€°àµ®ã€Šã€°ã€°ã˜´ã¤·â€°ã€°ã€°â€°àµ®ã€Šã€°ã€°ã˜´ã˜¹â€²ã€°ã€°â€°àµ®ã€Šã€°ã€°ãœ´ã„°â€¶ã€°ã€°â€°àµ®ã€Šã€°ã€°ãœ´ãœ°â€°ã€°ã€°â€°àµ®ã€Šã€°ã€°ãœ´ãˆ±â€´ã€°ã€°â€°àµ®ã€Šã€°ã€°ãœ´ã ²â€¸ã€°ã€°â€°àµ®ã€Šã€°ã€°ãœ´ã³â€²ã€°ã€°â€°àµ®ã€Šã€°ã€°ãœ´ãœ´â€¸ã€°ã€°â€°àµ®ã€Šã€°ã€°ãœ´ãŒµâ€²ã€°ã€°â€°àµ®ã€Šã€°ã€°ãœ´ãŒ·â€·ã€°ã€°â€°àµ®ã€Šã€°ã€°ãœ´ã¤·â€±ã€°ã€°â€°àµ®ã€Šã€°ã€°ãœ´ã¸â€µã€°ã€°â€°àµ®ã€Šã€°ã€°ãœ´ã¤¸â€¹ã€°ã€°â€°àµ®ã€Šã€°ã€°ãˆ°ã¤´â€³ã€°ã€°â€°àµ®ã€Šã€°ã€°ã„°ã˜µâ€·ã€°ã€°â€°àµ®çŠæ…²æ±©ç‰¥à¨ã°¼åŒ¯ç©©â¥ãŒ±ã´å€¯æ•²â¶ã¤²ã”¹ãœ²å ¯æ•’å¦æµ´ãˆ ã¤´â¼³æ½’ç‘¯ã„ ã ²â€µâ€°â½’æ¹…ç‰£ç¹â´ãˆ±ã¸ã€ åˆ ä¤¯æ™®â¯ã˜²â€³â€°â½’ä‘‰ã±›ã‰†ã„·ã€µã„±ãˆ²ã†ä•‚ä‘ƒä‰„ãœµä„³äŒ¸ãˆ¹ã„°ãˆ±ä˜±ã°¾ã”°ã¤°äŒ±ã…ãäŒ¹ãœ³äˆ´ä‰ã™‚ä´äŒµãœ·ä‘‚ãä™å´¾ã¸¾à¨ç‘³ç‰¡ç¡´æ•²àµ¦ã€Š
    à¨â”¥ä½…àµ†â€Šâ€ â€ â€ â€ â€ â€ â€ â€ â€ â€ â€ â€ à´ ã„Šã³â€³â€°æ‰¯ã±ªâ¼¼æ•Œæ®æ¡´ã  ã„²äŒ¯ã„ ãˆ³â¼·æ¥†ç‘¬ç‰¥ä˜¯æ…¬æ•´æ•„æ½£æ•¤ä¤¯ã„ ã´â¼²âŒãŒ±ã„±ä¼¯ã„ ã¤²â¼µâ“ã”¹ã¸¶çŒ¾ç‰´æ…¥àµ#풜鷾姐å‘)Ὕ됑盿##Ἵ슂Ⓑꖓ⎇↦⮍憺஌펙#ëŸ¼ë´ ä·ä¦“îŒˆë½‰ìš°Ø‰æ‚©ë¶£èµ¤èŒ¾é™à·å‡‡á®€à§ªê™«é¢ë‘„åª¸ì¯¨ä¶”â£‚î¡ä”텆䓗鿦콛æžáŠé®½î‹™äŠæŸ¾ï‰ä˜šî ‚ã¥ªæ±£ï…¯ç±½é¡ƒç¨•âªˆä»ê‰ç„“ï·–ä¤˜à³®äŸœé§‚ãƒè©ä ƒæ¡¸î„¦â›³îºç©·ë†¿äŠ¹êŒêºž×¥æ£êŠ½îºŽ#絥쇒뀁劒혣긤㏬䮧䉏㕴箨䔈鲝㟆ꃬ㮁層#個顃æŽå¯¶íž£ä–•à£ªå£ƒä˜â¬ç®²é¼¨í†äœ½é´”ïš·ï‹éƒ¶ì‹¥çŒ‘ë°‰ë°´â‚‡à¹¸é±¤ä‡é®‹æ®¢é”´ã€Šë±ä•»ï±ªÚ„ì·“ç”›ëŠ¢æ¿ á¼žå·»ë€¸âšë¯‡áµ¢æŠî€â¢®ï¥ì£¦î’ë¡¹ê’¼æ¾ é¢¹å‚‹äªè¨¹è‹ê·Žä‰½ì‘Äâ¤é»—î²±â‰æš£ë²¨è™„凾#辍ﮔ
    껆펽㥆⽛䆺㬸睲讀㤓꒜è
    regards
    Message was edited by: Surpreet Singh Bal

  • Sending PDF thru email with password protection in our SAP system

    Need solution for sending PDF thru email with password protection in our SAP ecc 6

    Or maybe you have found any other way? You can check here:
    Password protect PDF file:
    Re: Password protected PDF file 
    pdf with password encryption
    Regards Otto

  • How can we send PDF content from R3 to SAP-UI5 using ODATA

    Hi Experts,
    my PDF content is in XSTRING format on R3, and i am trying to send that content to my UI5 aaps but for that i am not getting any types for my my
    entity type properties.
    Please Help me
    Regards
    Saumya

    Hi,
    Refer this discussion thread Generate PDF file in backend, and "send" it to SAP Gateway
    Regards,
    Chandra

  • Send PDF through BEx Broadcasting in BI - Urgent

    Hi,
    I want to send PDF File through BEx broadcasting in BI,but i am unable to see that option in Output format.
    Do i need to enable any services like adobe etc.
    Thanks in Advance
    Regards,
    Arvind M

    This post could help you:
    document for Information Broadcasting in BW 3.5
    Regards

  • Error while sending PDF file by Email

    Hi All,
    I have a requirement to send multiple files by Email attachement from SAP to internet address.
    All files sent correctly, except one PDF file.
    I have 2 spools, and I am using FM CONVERT_OTFSPOOLJOB_2_PDF to get PDF data for Spool.
    Then I am converting the 134 length PDF data to 255 Email Attachement binary table.
    Now I have 2 file F1.PDF and F2.PDF, in SAP Office outbox and in receivers email, F2.PDF opening fine, however for F1.PDF I am getting some error no 109 in Adobe, which says "There was an error processing a page.There was a problem reading this document. (109)".
    Please help in figuring out the reason for this.
    Additional Information F2.PDF has some text data (SAP Script output) and F1.PDF has some text data with logo (SAP Script Output)
    Thanks in advance

    hi check out following code..
    REPORT ZRICH_0003.
    DATA: ITCPO LIKE ITCPO,
    TAB_LINES LIKE SY-TABIX.
    Variables for EMAIL functionality
    DATA: MAILDATA LIKE SODOCCHGI1.
    DATA: MAILPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    DATA: MAILHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
    DATA: MAILBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILREC LIKE SOMLREC90 OCCURS 0 WITH HEADER LINE.
    DATA: SOLISTI1 LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
    PERFORM SEND_FORM_VIA_EMAIL.
    FORM SEND_FORM_VIA_EMAIL *
    FORM SEND_FORM_VIA_EMAIL.
    CLEAR: MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
    REFRESH: MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
    Creation of the document to be sent File Name
    MAILDATA-OBJ_NAME = 'TEST'.
    Mail Subject
    MAILDATA-OBJ_DESCR = 'Subject'.
    Mail Contents
    MAILTXT-LINE = 'Here is your file'.
    APPEND MAILTXT.
    Prepare Packing List
    PERFORM PREPARE_PACKING_LIST.
    Set recipient - email address here!!!
    MAILREC-RECEIVER = '[email protected]'.
    MAILREC-REC_TYPE = 'U'.
    APPEND MAILREC.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = MAILDATA
    PUT_IN_OUTBOX = ' '
    TABLES
    PACKING_LIST = MAILPACK
    OBJECT_HEADER = MAILHEAD
    CONTENTS_BIN = MAILBIN
    CONTENTS_TXT = MAILTXT
    RECEIVERS = MAILREC
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    OPERATION_NO_AUTHORIZATION = 4
    OTHERS = 99.
    ENDFORM.
    Form PREPARE_PACKING_LIST
    FORM PREPARE_PACKING_LIST.
    CLEAR: MAILPACK, MAILBIN, MAILHEAD.
    REFRESH: MAILPACK, MAILBIN, MAILHEAD.
    DESCRIBE TABLE MAILTXT LINES TAB_LINES.
    READ TABLE MAILTXT INDEX TAB_LINES.
    MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).
    Creation of the entry for the compressed document
    CLEAR MAILPACK-TRANSF_BIN.
    MAILPACK-HEAD_START = 1.
    MAILPACK-HEAD_NUM = 0.
    MAILPACK-BODY_START = 1.
    MAILPACK-BODY_NUM = TAB_LINES.
    MAILPACK-DOC_TYPE = 'RAW'.
    APPEND MAILPACK.
    Creation of the document attachment
    This form gets the OTF code from the SAPscript form.
    If you already have your OTF code, I believe that you may
    be able to skip this form. just do the following code, looping thru
    your SOLISTI1 and updating MAILBIN.
    PERFORM GET_OTF_CODE.
    LOOP AT SOLISTI1.
    MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
    APPEND MAILBIN.
    ENDLOOP.
    DESCRIBE TABLE MAILBIN LINES TAB_LINES.
    MAILHEAD = 'TEST.OTF'.
    APPEND MAILHEAD.
    Creation of the entry for the compressed attachment
    MAILPACK-TRANSF_BIN = 'X'.
    MAILPACK-HEAD_START = 1.
    MAILPACK-HEAD_NUM = 1.
    MAILPACK-BODY_START = 1.
    MAILPACK-BODY_NUM = TAB_LINES.
    MAILPACK-DOC_TYPE = 'OTF'.
    MAILPACK-OBJ_NAME = 'TEST'.
    MAILPACK-OBJ_DESCR = 'Subject'.
    MAILPACK-DOC_SIZE = TAB_LINES * 255.
    APPEND MAILPACK.
    ENDFORM.
    Form GET_OTF_CODE
    FORM GET_OTF_CODE.
    DATA: BEGIN OF OTF OCCURS 0.
    INCLUDE STRUCTURE ITCOO .
    DATA: END OF OTF.
    DATA: ITCPO LIKE ITCPO.
    DATA: ITCPP LIKE ITCPP.
    CLEAR ITCPO.
    ITCPO-TDGETOTF = 'X'.
    Start writing OTF code
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    FORM = 'ZTEST_FORM'
    LANGUAGE = SY-LANGU
    OPTIONS = ITCPO
    DIALOG = ' '
    EXCEPTIONS
    OTHERS = 1.
    CALL FUNCTION 'START_FORM'
    EXCEPTIONS
    ERROR_MESSAGE = 01
    OTHERS = 02.
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    WINDOW = 'MAIN'
    EXCEPTIONS
    ERROR_MESSAGE = 01
    OTHERS = 02.
    Close up Form and get OTF code
    CALL FUNCTION 'END_FORM'
    EXCEPTIONS
    ERROR_MESSAGE = 01
    OTHERS = 02.
    MOVE-CORRESPONDING ITCPO TO ITCPP.
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
    RESULT = ITCPP
    TABLES
    OTFDATA = OTF
    EXCEPTIONS
    OTHERS = 1.
    Move OTF code to structure SOLI form email
    CLEAR SOLISTI1. REFRESH SOLISTI1.
    LOOP AT OTF.
    SOLISTI1-LINE = OTF.
    APPEND SOLISTI1.
    ENDLOOP.
    ENDFORM.

  • How to Sender PDF file as attachment in Payload?

    Hi Experts,
         After I done some of PI scenarios, I'm stuck with one of my requirement... In requirement, "Web service" will send request to "SAP ECC 6" in order to get PO document print out in PDF file by call smartform or any form printing as usual.
         In my understand, I'm using SOAP adapter as sender and RFC adapter in receiver side, in  RFC function, I will call form and generate PDF file by using normal ABAP function, but here, how can I send PDF file as response message of SYNC call from web service.
         I try to search and read some of document and blog, some said I can attach file as Payload attachment, but no clear solution or guide to do so.
        Here is example blog that I found, I really useful
           /people/michal.krawczyk2/blog/2006/04/19/xi-rfc-or-abap-proxy-abap-proxies-with-attachments
        Please suggest me in my case,
    Thanks in advance...
    Cheers,
    Terry

    Hi,
    >>In my understand, I'm using SOAP adapter as sender and RFC adapter in receiver side, in RFC function, I will call form and generate PDF file by using normal ABAP function, but here, how can I send PDF file as response message of SYNC call from web service.
    as per my blog you can attach PDF to a message only if you use abap proxy on ECC and not RFC
    the code is just copy and paste from my blog:
    /people/michal.krawczyk2/blog/2006/04/19/xi-rfc-or-abap-proxy-abap-proxies-with-attachments
    so there is nothing spectacular there
    Regards,
    Michal Krawczyk

  • Sending pdf attachments via e-mail in BSP

    Hi all,
    i have written a code for sending email to a given mailid with some text but
    can anyone tell me step to step procedure for sending pdf attchments to mailid.
    Thanks and Regards,
    Sneha Puppala.

    Hi ravikiran,
    This is my code for sending email with attach:
    <%@page language="abap" %>
    <%@extension name="htmlb" prefix="htmlb" %>
    <%@extension name="bsp"   prefix="bsp"%>
    <htmlb:content id="content" design="classicdesign2002design2003" controlRendering="sap"
                   rtlAutoSwitch    = "true">
      <htmlb:page title = "BSP Extension: HTMLB / Element: fileUpload">
        <htmlb:form method = "post" encodingType = "multipart/form-data">
    <head>
        <link rel="stylesheet" href="../../sap/public/bc/bsp/styles/sapbsp.css">
        <title>mail to </title>
      </head>
        <bsp:testSuite id="testSuite" name = "<fileUpload>" key = "<%=content->design%>">
            <% IF NOT %_testSuite->id_list IS INITIAL.%>
            <bsp:testCase nr="DATA" text = "Data Handling"/>
            <table border="1px" cellpadding="1px" cellspacing="0px" style="font:normal 10pt Arial">
              <tr> <th>id</th> <th>File Name</th> <th>Content Type</th> <th>Length</th> </tr>
              <%-- Notice: It's recommended to do input processing in onInputProcessing
                event block, not in onLayout block like in this case. --%>
                <% DO.
                    DATA: fu        TYPE REF TO CL_HTMLB_FILEUPLOAD,
                        next_id   TYPE STRING.
                   next_id = %_testSuite->next_restore_id( ).
                   IF next_id IS INITIAL. EXIT. ENDIF.
                    fu ?= CL_HTMLB_MANAGER=>GET_DATA( request = request id = next_id name = 'fileUpload' ).
              %>
                <tr>
                    <td><%=next_id%></td>
                    <td><%= cl_http_utility=>escape_html( fu->file_name ) %> </td>
                    <td><%=fu->file_content_type%> </td>
                    <td><%=fu->file_length%></td>
                </tr>
              <% ENDDO. %>
            </table>
          <% ENDIF. %>
          <%----
    %>
          <%
             DATA: event            TYPE REF TO if_htmlb_data,
                   fileUpload_event TYPE REF TO CL_HTMLB_FILEUPLOAD.
             event = cl_htmlb_manager=>get_event_ex( request ).
             IF event IS NOT INITIAL AND event->event_name = htmlb_events=>fileupload.
               fileUpload_event ?= event.
          %>
              <table border="1px" cellpadding="1px" cellspacing="0px" style="font:normal 10pt Arial">
                <tr> <td>Event-Class</td>              <td><%= event->event_class%>                  </td> </tr>
                <tr> <td>Event-ID</td>                 <td><%= event->event_id%>                     </td> </tr>
                <tr> <td>Event-Name</td>               <td><%= event->event_name%>                   </td> </tr>
                <tr> <td>Event-Type</td>               <td><%= event->event_type%>                   </td> </tr>
                <tr> <td>Event-Server Name</td>        <td><%= event->event_server_name%>            </td> </tr>
                <tr> <td>Event-Defined</td>            <td><%= event->event_defined%>                </td> </tr>
                <tr> <td>FileUpload-Name</td>          <td><%= fileUpload_event->file_name%>         </td> </tr>
                <tr> <td>FileUpload-Content_Type</td>  <td><%= fileUpload_event->file_content_type%> </td> </tr>
                <tr> <td>FileUpload-Length</td>        <td><%= fileUpload_event->file_length%>       </td> </tr>
              </table>
          <%
             ENDIF.
          %>
          <%----
    %>
          <bsp:testCase text = "upload attachment" />
          <htmlb:fileUpload id       = "<%= %_testSuite->seq_nr( )%>" />
          <htmlb:button     id       = "submitButton"
                            text     = "Upload"
                            onClick  = "HandleUpload" />
          <%----
    %>
    <html>
    <body class="bspBody1">
      <H1 class="bspH1"> Consultation-Service </H1>
        <form method = "post" action="<%=page->get_page_url( )%>">
          <table class="bspTbvStd" cellpadding="4">
            <tr>
            <td class="bspTbvHdrStd" colspan="2" align="center"><font size="4">Address</font></td>
            </tr>
            <tr class="bspTbvCellStd">
              <td>Name</td>
              <td><input type="text" name="name"
                         value="<% page->write( value = name ). %>" size="40" ></td>
            </tr>
                    <tr class="bspTbvCellStd">
              <td>Mail address1</td>
              <td><input type="text" name="mail_address1"
                         value="<% page->write( value = mail_address1 ). %>" size="40"></td>
            </tr>
            <tr class="bspTbvCellStd">
              <td>Mail address2</td>
              <td><input type="text" name="mail_address2"
                         value="<% page->write( value = mail_address2 ). %>" size="40"></td>
            </tr>
          </table>
          </bsp:testSuite>
        </htmlb:form>
        </htmlb:page>
    </htmlb:content>
        </form>
      </body>
    </html>
    On Input Processing:
    if page->messages->num_messages( ) eq 0.
      if mail_address1 is not initial and mail_address2 is not initial.
          call method application->send
            exporting mail_address = mail_address1
            changing  messages     = page->messages .
        call method application->send
            exporting mail_address = mail_address2
            changing  messages     = page->messages .
        if page->messages->num_messages( ) eq 0.
          data text type string.
          text = application->get_text( ).
          navigation->set_parameter( name = 'mailtext' value = text ).
          navigation->next_page( 'show' ).
        endif.
      else.
        navigation->next_page( 'no_address' ).
      endif.
    endif.
    "method send in defined class":
    method SEND.
    CLASS cl_bcs DEFINITION LOAD.
    DATA:
    lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
    lo_send_request = cl_bcs=>create_persistent( ).
    Message body and subject
    DATA:
    lt_message_body TYPE bcsy_text VALUE IS INITIAL,
    lt_att_content_hex type solix_tab,
    lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
    APPEND 'Dear Vendor,' TO lt_message_body.
    append ' ' to lt_message_body.
    APPEND 'Please find the attached report.'
    TO lt_message_body.
    append ' ' to lt_message_body.
    APPEND 'Thank You,' TO lt_message_body.
    lo_document = cl_document_bcs=>create_document(
    i_type = 'RAW'
    i_text = lt_message_body
    i_subject = 'Visit report' ).
    data: data_tab type solix_tab,
          p_data type XSTRING.
      call function 'SCMS_XSTRING_TO_BINARY'
        EXPORTING
          buffer     = p_data
        TABLES
          binary_tab = data_tab.
    DATA: lx_document_bcs TYPE REF TO cx_document_bcs VALUE IS INITIAL.
    TRY.
    lo_document->add_attachment(
    EXPORTING
    i_attachment_type = 'PDF'
    i_attachment_subject = 'Visit Report'
    I_ATTACHMENT_SIZE =
    I_ATTACHMENT_LANGUAGE = SPACE
    I_ATT_CONTENT_TEXT =
    I_ATTACHMENT_HEADER =
    i_att_content_hex = data_tab ).
    CATCH cx_document_bcs INTO lx_document_bcs.
    ENDTRY.
    Add attachment
    Pass the document to send request
    lo_send_request->set_document( lo_document ).
    Create sender
    DATA:
    lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,
    l_send type ADR6-SMTP_ADDR value '[email protected]'.
    lo_sender = cl_cam_address_bcs=>create_internet_address( l_send ).
    Set sender
    lo_send_request->set_sender(
    EXPORTING
    i_sender = lo_sender ).
    Create recipient
    DATA:
    lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.
    lo_recipient = cl_sapuser_bcs=>create( sy-uname ).
    Set recipient
    lo_send_request->add_recipient(
    EXPORTING
    i_recipient = lo_recipient
    i_express = 'X' ).
    lo_send_request->add_recipient(
    EXPORTING
    i_recipient = lo_recipient
    i_express = 'X' ).
    Send email
    DATA: lv_sent_to_all(1) TYPE c VALUE IS INITIAL.
    lo_send_request->send(
    EXPORTING
    i_with_error_screen = 'X'
    RECEIVING
    result = lv_sent_to_all ).
    COMMIT WORK.
    message 'The visit report has been sent' type 'I'.
    Thanks and Regards,
    Sneha Puppala.

  • Problem to send PDF file

    Hello,
    I try to send pdf file as attachments file to mail with XI.
    I use with this blog
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6d967fbc-0a01-0010-4fb4-91c6d38c5816
    My problems is:
    1. to all mails that I send have another e file Untiteld.doc, how I can avoid this file?
    2. When I received the pdf file I not succeed to open it I received the message:
    Adobe reader could not open 'elad.pdf' because it is either not supported
    File type or because the file has been damaged (for example, it was sent as an
    Email attachment and wasn't correctly decoded)
    Regards
    Elad Peleg

    hi
    ref this
    Receiver Mail Adapter message with PDF attachment
    PDF attachment in mail adapter
    File adapter with attachment to mail
    File with attachment to mail scenario
    File To Mail Scenario With An Attachment

  • Send pdf as email

    hai gurus ,
    my problem is i am sending pdf as email its working fine
    but when i go and check the pdf file in  scot transaction the file is not getting  opened
    plz help me
    thanks in advance
    anji.
    Moderator message: please search for available information/documentation before asking, provide more technical details about errors when posting again.
    Edited by: Thomas Zloch on Oct 28, 2010 10:58 AM

    Hi,
    Check this link [http://wiki.sdn.sap.com/wiki/display/Snippets/ConvertsspoolrequestintoPDFdocumentand+emails]
    BR,
    Lokeswari.
    Moderator message: please do not post just links without any further explanations.
    Edited by: Thomas Zloch on Oct 28, 2010 10:58 AM

  • Function module to send mail from SAP

    Can any one please tell the Function module to send mail from SAP. The scenario is like this,I have a file in local system that i have to send to a particular mail address like [email protected] through a report program.

    Hi shafiq,
    1. There is some trick involved
    in the binary files.
    2. I have made a program (and it works fantastic)
    ONLY 6 LINES FOR EMAILING
    BELIEVE ME
    ITS A FANTASTIC PROGRAM.
    IT WILL WORK LIKE OUTLOOK EXPRESS !
    3. The user is provided with
    a) file name
    b) email address to send mail
    and it sends ANY FILE (.xls,.pdf .xyz..)
    Instantaneously !
    4. Make two things first :
    1. Include with the name : ZAMI_INCLFOR_MAIL
    2. Report with the name : ZAM_TEMP147 (any name will do)
    3. Activate both and execute (2)
    4. After providing filename, email adress
    5. Code for Include :
    10.08.2005 Amit M - Created
    Include For Mail (First Req F16)
    Modification Log
    Data
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    FORM
    FORM ml_customize USING objname objdesc.
    Clear Variables
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    Set Variables
    docdata-obj_name = objname.
    docdata-obj_descr = objdesc.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addtxt USING ptxt.
    CLEAR objtxt.
    objtxt = ptxt.
    APPEND objtxt.
    ENDFORM. "ml_customize
    FORM
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    Fetch List From Memory
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = listobject
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    COMPRESSED_SIZE =
    TABLES
    in = listobject
    out = objbin
    EXCEPTIONS
    OTHERS = 1
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ENDIF.
    Header Data
    Already Done Thru FM
    Main Text
    Already Done Thru FM
    Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    Receiver List
    Already done thru fm
    ENDFORM. "ml_prepare
    FORM
    FORM ml_dosend.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    CONTENTS_HEX = objhex
    OBJECT_PARA =
    object_parb =
    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
    IF sy-subrc <> 0.
    MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_customize
    FORM
    FORM ml_spooltopdf USING whatspoolid.
    DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    Call Function
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = whatspoolid
    TABLES
    pdf = pdf
    EXCEPTIONS
    err_no_otf_spooljob = 1
    OTHERS = 12.
    Convert
    PERFORM doconv TABLES pdf objbin.
    ENDFORM. "ml_spooltopdf
    FORM
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    CODE FOR PROGRAM
    5.
    REPORT zam_temp147 .
    INCLUDE zami_inclfor_mail.
    DATA
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    SELECTION SCREEN
    PARAMETERS : receiver TYPE somlreci1-receiver lower case.
    PARAMETERS : p_file LIKE rlgrap-filename
    OBLIGATORY.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CLEAR p_file.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION
    START-OF-SELECTION.
    PERFORM ml_customize USING 'Tst' 'Testing'.
    PERFORM ml_addrecp USING receiver 'U'.
    PERFORM upl.
    PERFORM doconv TABLES itab objbin.
    PERFORM ml_prepare USING 'X' extension name.
    PERFORM ml_dosend.
    SUBMIT rsconn01
    WITH mode EQ 'INT'
    AND RETURN.
    FORM
    FORM upl.
    file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_name
    filetype = 'BIN'
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    path = file_name.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    CHECK_DOS_FORMAT =
    IMPORTING
    DRIVE =
    EXTENSION = extension
    NAME = name
    NAME_WITH_EXT =
    PATH =
    EXCEPTIONS
    INVALID_DRIVE = 1
    INVALID_EXTENSION = 2
    INVALID_NAME = 3
    INVALID_PATH = 4
    OTHERS = 5
    ENDFORM. "upl
    regards,
    amit m.

  • Problem while opening PDF in SAP Inbox

    I am trying to read the spool from SAP background job and sending to SAP inbox.
    PDF is not opening in th eSAP Inbox...
    Reading from spool using FM
    CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
          EXPORTING
            rqident = w_spool_no
            DESIRED_TYPE = 'RAW'
          TABLES
            buffer  = w_contents
    Converting into Hexadecimal format
    IF w_contents IS NOT INITIAL.
          CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
            EXPORTING
              ip_solitab  = w_contents
            IMPORTING
              ep_solixtab = w_contents_hex.
        ENDIF.
    Sending mail to SAP inbox using
    I am using FM SO_NEW_DOCUMENT_ATT_SEND_API1

    No reply.

Maybe you are looking for

  • [FIX] Yoga 13 Windows 8.1 Touchpad and Pixelated Windows.

    Hello everybody! This would be my first post in this forum. I thought that I had to share this since I wasn't able to find a fix for the Touchpad. And since I was also able to solve the pixelated windows issue, I thought I might want to share it.  [I

  • Extensions Gallery

    Fairly recently, I think following a Safari upgrade, a row of icons appeared on my Safari toolbar, below the main address input box and above the Bookmark tags. I have concluded that these are icons from the extensions gallery. I am at a loss to know

  • Cour shift from aperture to photoshop.

    hi again , Its not been my day today.. [ see last post]. Can somebody point out what I am doing wrong in the following.... Shoot in RAW- adobe rgb - aperture is set to proof adobe rgb. Open image in external editor [ photoshop] - proof is set to on w

  • Disabling Win Key

    I have got a Swing Application implementing KeyListener. While the application isActive() i need amongst others the "WinKey" disabled is that possible?

  • I want to download Photoshop onto my 2 TB hard drive, how do I do that?

    When I download PS I can't do anything because my drives are full, so how do I change the destination folder?