SO_NEW_DOCUMENT_ATT_SEND_API1

Dear all,
I am using SO_NEW_DOCUMENT_ATT_SEND_API1 for sending mail and my contents are in OBJBIN
But in tht mail all the data comes in one single line rather than coming one below the other.
the code in that part is
  DESCRIBE TABLE OBJTXT LINES TAB_LINES.
  READ TABLE OBJTXT INDEX TAB_LINES.
  CLEAR OBJPACK-TRANSF_BIN.
  OBJPACK-HEAD_START = 1.
  OBJPACK-HEAD_NUM = 0.
  OBJPACK-BODY_START = 1.
  OBJPACK-BODY_NUM = 7.
  OBJPACK-DOC_TYPE = 'RAW'.
  OBJPACK-doc_size = STRLEN( OBJTXT ).
  APPEND OBJPACK.
LOOP AT ITAB.
VAR1 = ITAB-FKIMG.
CONCATENATE ITAB-VBELN ITAB-FKDAT ITAB-KUNAG ITAB-NAME1 ITAB-MATNR ITAB-MAKTX
             VAR1 ITAB-WERKS ITAB-EXNUM ITAB-RDOC  ITAB-EXDAT
             ITAB-KSCHL INTO OBJBIN SEPARATED BY SPACE.
  APPEND OBJBIN.
ENDLOOP.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
  OBJHEAD = 'ORDERS'.
  APPEND OBJHEAD.
   DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJBIN-LINE ).
  OBJPACK-TRANSF_BIN = 'X'.
  OBJPACK-HEAD_START = 1.
  OBJPACK-HEAD_NUM   = 1.
  OBJPACK-BODY_START = 1.
  OBJPACK-BODY_NUM   = TAB_LINES.
  OBJPACK-DOC_TYPE   = 'PDF'.
  OBJPACK-OBJ_NAME   = 'WEBSITE'.
  OBJPACK-OBJ_DESCR  = 'ORDERS.PDF'.
  OBJPACK-DOC_SIZE   = ( 255 * ( TAB_lines - 1 ) ) + STRLEN( OBJBIN-line ).
  APPEND OBJPACK.
           email_receivers-receiver = 'test @ dantal.in'.
            email_receivers-rec_type = 'U'.
            email_receivers-express = 'X'.
            email_receivers-to_answer = 'X'.
            APPEND email_receivers.
            CLEAR email_receivers.
if not email_receivers[] is initial.
*perform attachment.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
  EXPORTING
    DOCUMENT_DATA                    = doc_chng
   PUT_IN_OUTBOX                    = 'X'
   COMMIT_WORK                      = 'X'
IMPORTING
   SENT_TO_ALL                      = sent
   NEW_OBJECT_ID                    = newid
  TABLES
    PACKING_LIST                    = OBJPACK
   OBJECT_HEADER                    = OBJHEAD
     CONTENTS_BIN                     = OBJBIN
    CONTENTS_TXT                    = OBJTXT
  CONTENTS_HEX                    =
  OBJECT_PARA                      =
  OBJECT_PARB                      =
    RECEIVERS                        = email_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
    IF SY-SUBRC <> 0.
         write / : 'Mail Cannot be sent to Dealer' .
      else.
         write / : 'Mail Sent Successfully To Dealer.' .

hiii
try using following code
*   Add Packing List (attachment) for PDF...
    DESCRIBE TABLE t_con_bin LINES h_tab_cntr.
    READ TABLE t_con_bin INDEX h_tab_cntr.
    h_doc_data-doc_size = h_doc_data-doc_size
                        + ( ( h_tab_cntr - 1 )
                        * 255 + STRLEN( t_con_bin ) ).
    h_doc_data-obj_descr  = mail_subject.
    h_body_start = 1.
    h_body_num = h_tab_cntr.
*   Write RAW data if that's what it is (adds to TEXT)...
    IF h_real_type = 'RAW'.
      DESCRIBE TABLE t_con_text LINES h_body_start.
      h_body_start = h_body_start + 1.
      h_transf_type = space.           " Transfer type TEXT...
      LOOP AT t_con_bin.               " Zip thru TEXT stuff
        t_con_text = t_con_bin.        " set TEXT table header..
        APPEND t_con_text.             " add to what's there!
      ENDLOOP.
      CLEAR: t_con_bin.                " clear BINARY header..
      REFRESH: t_con_bin.              " reset BINARY table...
    ENDIF.
    CLEAR t_pak_list.
    IF h_transf_type = 'X'.            " Binary=PDF/ALI?
      t_pak_list-transf_bin = 'X'.
      t_pak_list-head_start = 1.
      t_pak_list-head_num   = 0.
      t_pak_list-body_start = 1.
      t_pak_list-body_num   = h_tab_cntr.
      t_pak_list-doc_type   = h_real_type.
      t_pak_list-obj_name   = 'ATTACHMENT'.
      t_pak_list-obj_descr  = 'Document'(001).
      t_pak_list-doc_size   = ( h_tab_cntr - 1 )
                            * 255 + STRLEN( t_con_bin ).
    ELSE.
      DESCRIBE TABLE t_con_text LINES h_tab_cntr.
      READ TABLE t_con_text INDEX h_tab_cntr.
      t_pak_list-transf_bin = ' '.     " Binary=RAW
      t_pak_list-head_start = 1.
      t_pak_list-head_num   = 0.
      t_pak_list-body_start = h_body_start.
      t_pak_list-body_num   = h_tab_cntr.
      t_pak_list-doc_type   = h_real_type.
      t_pak_list-obj_name   = 'ATTACHMENT'(002).
      t_pak_list-obj_descr  = 'Report'(003).
      t_pak_list-doc_size   = ( h_body_num - 1 )
                            * 255 + STRLEN( t_con_text ).
    ENDIF.
    APPEND t_pak_list.
  ENDIF.
* Send the EMAIL out with SAP function...
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data              = h_doc_data
      put_in_outbox              = 'X'
*      commit_work                = 'X'
    TABLES
      packing_list               = t_pak_list
      contents_bin               = t_con_bin
      contents_txt               = t_con_text
      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.
  IF syst-subrc NE 0.
*    RAISE send_failed.
    CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
      EXPORTING
        msg_arbgb = '00'
        msg_nr    = '001'
        msg_ty    = 'E'
        msg_v1    = 'O/P Could not be issued '(001)
        msg_v2    = ' Due to No Mail ID'(002)
        msg_v3    = syst-msgv3
        msg_v4    = syst-msgv4
      EXCEPTIONS
        OTHERS    = 1.
reward if useful
thx
twinkal

Similar Messages

  • Attaching text file using SO_NEW_DOCUMENT_ATT_SEND_API1

    hello guys, i'm a newbie here.
    I'm having trouble attaching an existing text file using function 'SO_NEW_DOCUMENT_ATT_SEND_API1'. It seems i can't find the right combination of parameters that are being passed to this function.
    first, i'm using WS_UPLOAD to upload the text file to an internal table then i'm creating all the neccessary internal tables that will be use by this function..
    By the way, i'm trying to send mail w/ attachments to external mail and SAPids. Below is my code.
    REPORT ZHR_TESTEMAIL .
    TABLES: USR02, PA0105, SOSU, SOUC, RLGRAP, IBIPPARMS, DYNPREAD, RSCSEL.
    DATA: FOLD_YR(2) TYPE C,
          FOLD_TYPE(3) TYPE C,
          G_HEADER LIKE SOOD2,
          G_FOLMAM LIKE SOFM2,
          METHOD1 LIKE SY-UCOMM,
          G_DOCUMENT LIKE SOOD4,
          G_USER LIKE SOUDNAMEI1,
          FOLD_NUMBER(12) TYPE C,
          G_NEW_PARENT LIKE SOODK,
          G_OWNER LIKE SOUD-USRNAM,
          G_REF_DOCUMENT LIKE SOOD4,
          G_USER_DATA LIKE SOUDATAI1,
          G_AUTHORITY LIKE SOFA-USRACC,
          G_OBJCNT LIKE SOLI OCCURS 0 WITH HEADER LINE,
          G_OBJHEAD LIKE SOLI OCCURS 0 WITH HEADER LINE,
          G_OBJPARA LIKE SELC OCCURS 0 WITH HEADER LINE,
          G_OBJPARB LIKE SOOP1 OCCURS 0 WITH HEADER LINE,
          G_RECIPIENTS LIKE SOOS1 OCCURS 0 WITH HEADER LINE,
          G_REFERENCES LIKE SOXRL OCCURS 0 WITH HEADER LINE,
          G_ATTACHMENTS LIKE SOOD5 OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF G_FILES OCCURS 10 ,
          TEXT(4096) TYPE C,
          END OF G_FILES.
    DATA: BEGIN OF IT_WS_FILE OCCURS 0,
          WS_FILE LIKE RLGRAP-FILENAME,
          END OF IT_WS_FILE.
    DATA: BEGIN OF IT_SAPID OCCURS 0,
          SAPID LIKE USR02-BNAME,
          END OF IT_SAPID.
    DATA: BEGIN OF IT_EMAIL OCCURS 0,
          EMAILADD LIKE PA0105-USRID_LONG,
          END OF IT_EMAIL.
    DATA: BEGIN OF IT_TSP01 OCCURS 0.
            INCLUDE STRUCTURE TSP01.
    DATA: END OF IT_TSP01.
    DATA: BEGIN OF TAB2 OCCURS 50,
          TEXT(200) TYPE C,
          END OF TAB2.
    DATA: V_DOCDATA TYPE SODOCCHGI1,
          V_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
          V_OBJHEAD LIKE SOLISTI1   OCCURS 0 WITH HEADER LINE,
          V_OBJTXT  LIKE SOLISTI1   OCCURS 0 WITH HEADER LINE,
          V_OBJBIN  LIKE SOLISTI1   OCCURS 0 WITH HEADER LINE,
          V_OBJHEX  LIKE SOLIX      OCCURS 0 WITH HEADER LINE,
          IT_RECVRS TYPE SOMLRECI1  OCCURS 0 WITH HEADER LINE,
          IT_CONTNT TYPE SOLISTI1   OCCURS 0 WITH HEADER LINE,
          IT_BODY   LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE,
          V_TLIN    TYPE I,
          V_LINE    TYPE I.
    DATA: BEGIN OF IT_TEXTLINE OCCURS 500,
          TEXTLINE(5000),
          END OF IT_TEXTLINE.
    DATA: FYL LIKE RLGRAP-FILENAME,
          GV_SUBNO LIKE SOSU-SUBNO,
          GV_EMAIL LIKE PA0105-USRID_LONG,
          GV_NEXTDAY LIKE SY-DATUM,
          YEAR(4) TYPE C,
          RECFLAG TYPE C.
    SELECTION-SCREEN BEGIN OF BLOCK PARAM WITH FRAME TITLE TEXT-001.
    PARAMETERS: SUBJ(254) TYPE C OBLIGATORY,            "Subject
                DESC(254) TYPE C.                       "Message
    SELECT-OPTIONS: SAPID FOR USR02-BNAME NO INTERVALS. "Recipient's SAP ID
    SELECT-OPTIONS: EMAILADD FOR PA0105-USRID_LONG NO INTERVALS.
    SELECTION-SCREEN END OF BLOCK PARAM.
    SELECTION-SCREEN BEGIN OF BLOCK PARAM2 WITH FRAME TITLE TEXT-002.
    SELECT-OPTIONS: WS_FILE FOR DYNPREAD-FIELDNAME NO INTERVALS.
    SELECTION-SCREEN END OF BLOCK PARAM2.
    SELECTION-SCREEN BEGIN OF BLOCK PARAM3 WITH FRAME TITLE TEXT-003.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: RBUT1 RADIOBUTTON GROUP A USER-COMMAND BUT. "Local PC
    SELECTION-SCREEN COMMENT 5(20) FOR FIELD RBUT1.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: RBUT2 RADIOBUTTON GROUP A.                  "Server
    SELECTION-SCREEN COMMENT 5(20) FOR FIELD RBUT2.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: RBUT3 RADIOBUTTON GROUP A.                  "Spool
    SELECTION-SCREEN COMMENT 5(20) FOR FIELD RBUT3.
    PARAMETERS: SPOOLNUM LIKE RSPOTYPE-RQNUMBER.            "Spool Number
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK PARAM3.
    SELECTION-SCREEN BEGIN OF BLOCK PROC WITH FRAME TITLE TEXT-004.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETER: BPROC AS CHECKBOX USER-COMMAND BCK. "Background Processing
    SELECTION-SCREEN COMMENT 5(50) FOR FIELD BPROC.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK PROC.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR WS_FILE-LOW.
      DATA: WS_FILE_TEMP TYPE IBIPPARMS-PATH.
      CLEAR: WS_FILE_TEMP.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                PROGRAM_NAME  = SY-REPID
                DYNPRO_NUMBER = SY-DYNNR
                FIELD_NAME    = 'WS_FILE'
           IMPORTING
                FILE_NAME     = WS_FILE_TEMP.
      WS_FILE-LOW = WS_FILE_TEMP.
    AT SELECTION-SCREEN.
      SELECT SAPNAM FROM SOUC
          INTO TABLE IT_SAPID
          WHERE SAPNAM IN SAPID
            AND DELETED = ''.
      GV_NEXTDAY = SY-DATUM + 1.
      LOOP AT EMAILADD.
        IT_EMAIL-EMAILADD = EMAILADD-LOW.
        APPEND IT_EMAIL.
        CLEAR: IT_EMAIL.
      ENDLOOP.
      IF NOT BPROC IS INITIAL.
        CLEAR: RBUT1, RBUT3.
        RBUT2 = 'X'.
      ELSE.
        CLEAR: RBUT2.
      ENDIF.
      IF NOT RBUT3 IS INITIAL.
        REFRESH: WS_FILE.
      ENDIF.
      IF SAPID IS INITIAL AND EMAILADD IS INITIAL.
        MESSAGE E000(ZZ) WITH TEXT-201.
      ELSEIF NOT SAPID IS INITIAL AND EMAILADD IS INITIAL.
        CLEAR IT_SAPID.
        READ TABLE IT_SAPID.
        SELECT SINGLE SUBNO FROM SOSU
          INTO GV_SUBNO
          WHERE USRNO IN ( SELECT USRNO FROM SOUC
                             WHERE SAPNAM = IT_SAPID-SAPID ).
        IF SY-SUBRC NE 0.
          MESSAGE E000(ZZ) WITH TEXT-202.
        ENDIF.
        CLEAR: IT_SAPID.
      ELSEIF NOT SAPID IS INITIAL AND NOT EMAILADD IS INITIAL.
        CLEAR: IT_SAPID, IT_EMAIL.
        READ TABLE IT_SAPID.
        READ TABLE IT_EMAIL.
        SELECT SINGLE SUBNO FROM SOSU
          INTO GV_SUBNO
          WHERE USRNO IN ( SELECT USRNO FROM SOUC
                             WHERE SAPNAM = IT_SAPID-SAPID ).
        IF SY-SUBRC NE 0.
          SUBMIT RSSOADM0 WITH USRNAM EQ IT_SAPID-SAPID
                          WITH NEW_SUBS EQ IT_EMAIL-EMAILADD
                          WITH SUB_ESC EQ 'U'
                          WITH EDAT EQ SY-DATUM
                          WITH BDAT EQ SY-DATUM
                         WITH BDAT EQ GV_NEXTDAY
                         WITH EDAT EQ '99991231'
                          WITH BTIM EQ SY-UZEIT
                          WITH ETIM EQ '240000'
                          WITH FORW_ALL EQ 'X'
                          WITH PSTHR2 EQ ''
                          AND RETURN.
        ENDIF.
        CLEAR: IT_SAPID.
      ELSEIF NOT EMAILADD IS INITIAL AND SAPID IS INITIAL.
        RECFLAG = 'X'.
      ENDIF.
    START-OF-SELECTION.
        PERFORM B_SENDMAIL.
    FORM B_SENDMAIL.
      YEAR = SY-DATUM+0(4).
      LOOP AT WS_FILE.
        CLEAR: FYL.
        FYL = WS_FILE-LOW.
        REFRESH: TAB2.
        CALL FUNCTION 'WS_UPLOAD'
             EXPORTING
                  FILENAME = FYL
                  FILETYPE = 'BIN'
             TABLES
                  DATA_TAB = TAB2.
        IT_TEXTLINE[] = TAB2[].
    DOCUMENT_DATA (SUBJECT OF MAIL)
        V_DOCDATA-OBJ_NAME   = DESC.
        V_DOCDATA-OBJ_DESCR  = SUBJ.
        V_DOCDATA-OBJ_LANGU  = SY-LANGU.
        V_DOCDATA-SENSITIVTY = 'C'.
        V_DOCDATA-OBJ_PRIO   = '1'.
    BODY OF MAIL
        IT_BODY-LINE = 'Collection Report'.
        APPEND IT_BODY.
    CONTENTS_TXT (Attachments)
        IT_CONTNT[] = IT_TEXTLINE[].
        DESCRIBE TABLE IT_CONTNT LINES V_LINE.
        READ TABLE IT_CONTNT INDEX V_LINE.
    PACKING_LIST
        V_OBJPACK-DOC_SIZE = ( V_LINE - 1 ) * 255 + STRLEN( IT_CONTNT ).
        V_OBJPACK-TRANSF_BIN = 'X'.
        V_OBJPACK-HEAD_START = 1.
        V_OBJPACK-HEAD_NUM   = 0.
        V_OBJPACK-BODY_START = 1.
        V_OBJPACK-BODY_NUM   = V_LINE.
        V_OBJPACK-DOC_TYPE   = 'TXT'.
        V_OBJPACK-OBJ_NAME   = 'ATTACHMENT'.
        V_OBJPACK-OBJ_DESCR  = 'Attached Document'.
        APPEND V_OBJPACK.
        CLEAR  V_OBJPACK.
    RECEIVERS of mail
        IF RECFLAG IS INITIAL.
          LOOP AT IT_SAPID.
            IT_RECVRS-RECEIVER   = IT_SAPID-SAPID.
            IT_RECVRS-REC_TYPE   = 'B'.
            IT_RECVRS-COM_TYPE   = ''.
            IT_RECVRS-EXPRESS    = 'X'.
            IT_RECVRS-NO_FORWARD = ''.
            IT_RECVRS-NO_PRINT   = ''.
            APPEND IT_RECVRS.
            CLEAR IT_RECVRS.
          ENDLOOP.
        ELSE.
          LOOP AT EMAILADD.
            IT_RECVRS-RECEIVER   = EMAILADD-LOW.
            IT_RECVRS-REC_TYPE   = 'U'.
            IT_RECVRS-COM_TYPE   = 'INT'.
            IT_RECVRS-EXPRESS    = 'X'.
            APPEND IT_RECVRS.
            CLEAR IT_RECVRS.
          ENDLOOP.
        ENDIF.
    OBJECT_HEADER (Filename)
        CONCATENATE 'Collection Report' '_'
                     SY-DATUM+4(4) YEAR '.TXT'
                     INTO V_OBJHEAD-LINE.
       V_OBJHEAD-LINE = FYL+16(25).
        APPEND V_OBJHEAD.
        CLEAR V_OBJHEAD.
    Function Module For Sending Mail with Attachment
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
             EXPORTING
                  DOCUMENT_DATA              = V_DOCDATA
             TABLES
                  PACKING_LIST               = V_OBJPACK
                  OBJECT_HEADER              = V_OBJHEAD
                  CONTENTS_HEX               = IT_CONTNT
                  CONTENTS_TXT               = IT_BODY
                  RECEIVERS                  = IT_RECVRS
             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 S000(ZZ) WITH TEXT-005.
        ELSE.
          MESSAGE S000(ZZ) WITH TEXT-006.
        ENDIF.
      ENDLOOP.
    end of my code *
    please help me guys... when i run this program,    DOCUMENT_NOT_SENT is what i always get.. 
    waiting for ur reply... thank you vey much and godbless.

    Hi,
    Try this sample code.
    FORM SEND_TO_EMAIL USING zFName.
      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: ctmp(50) TYPE C.
    Creation of the document to be sent
      DOC_CHNG-OBJ_NAME = 'JOURNAL'.
      CONCATENATE 'SAP Payroll Journal file Period' pybegda INTO ctmp
                  SEPARATED BY SPACE.
      DOC_CHNG-OBJ_DESCR = cTmp.
      OBJTXT = 'SAP Payroll Journal'.
      APPEND OBJTXT.
      CONCATENATE 'For Period' pybegda INTO ctmp
                  SEPARATED BY SPACE.
      OBJTXT = ctmp.
      APPEND OBJTXT.
      CONCATENATE 'Attached File :' zFname INTO ctmp
                  SEPARATED BY SPACE.
      OBJTXT = ctmp.
      APPEND OBJTXT.
      OBJTXT = 'Please find the attachment.'.
      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
      <b>LOOP AT xMail.
        CONDENSE xMail-aline.
        OBJBIN = xMail-aline.
        APPEND OBJBIN.
        CLEAR OBJBIN.
      ENDLOOP.</b>
      DESCRIBE TABLE OBJBIN LINES TAB_LINES.
      OBJHEAD = zFname. 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 = 'RAW'.
      OBJPACK-OBJ_NAME = 'DATA'.
      OBJPACK-OBJ_DESCR = 'SAP Payroll File'.
      OBJPACK-DOC_SIZE = TAB_LINES * 255.
      APPEND OBJPACK.
    Completing the recipient list
      LOOP AT PENERIMA.
        CONDENSE PENERIMA-PNRM.
        RECLIST-RECEIVER = PENERIMA-PNRM.
        RECLIST-REC_TYPE = 'U'.
        APPEND RECLIST.
      ENDLOOP.
    Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                DOCUMENT_DATA              = DOC_CHNG
                PUT_IN_OUTBOX              = ' '
           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.
      CASE SY-SUBRC.
        WHEN 0.
          WRITE: / 'Result of the send process:'.
          LOOP AT RECLIST.
            WRITE: / RECLIST-RECEIVER(48), ':'.
            IF RECLIST-RETRN_CODE = 0.
              WRITE / 'The document was sent'.
            ELSE.
              WRITE / 'The document could not be sent'.
            ENDIF.
          ENDLOOP.
        WHEN 1.
          WRITE: / 'Too many receiver'.
        WHEN 2.
          WRITE: / 'Document could not be sent to any recipient'.
        WHEN 4.
          WRITE: / 'No send authorization'.
        WHEN OTHERS.
          WRITE: / 'Error occurred while sending'.
      ENDCASE.
    ENDFORM.

  • Text File in SO_NEW_DOCUMENT_ATT_SEND_API1

    Hello!
    We're using SO_NEW_DOCUMENT_ATT_SEND_API1 to send txt files attached to an e-mail.
    My problem is that whenever a text file with less than 500 characters is attached to e-mail, the last line of this text file is filled with many blank characters (spaces)
    I can only see this if I open the file by the e-mail, and I'm not able to see this blank line in debug.
    I think this is related to table CONTENTS_BIN, due to it's line size of char255, but i'm not 100% sure.
    Does any one knows how to solve this? We don't want that blank line at the end of the file.
    Mauricio

    Hi Mauricio,
    Did you pass xs_gd_doc_data and xt_packing_list in your FM
    Constant : lc_name    TYPE string VALUE 'Test Mail',
                 lc_descr   TYPE string VALUE 'Test Mail',
                 lc_f       TYPE c      VALUE 'F',
                 lc_zero    TYPE c      VALUE '0',
                 lc_one     TYPE c      VALUE '1',
                 lc_doctype TYPE string VALUE 'RAW'.
      CLEAR: lv_cnt.
    xy_message-line = lc_string.
      APPEND xyt_message.
      CONCATENATE lc_text_01 xv_premise INTO lv_message_premise SEPARATED BY space.
      xt_message-line = lv_message_premise.
      APPEND xt_message.
      CONCATENATE lc_text_02 xv_address INTO lv_message_address SEPARATED BY space.
      xt_message-line = lv_message_address.
      APPEND xt_message.
      CONCATENATE lc_text_03 xv_auszdat INTO lv_message_auszdat SEPARATED BY space.
      xt_message-line = lv_message_auszdat.
      APPEND xt_message.
      DESCRIBE TABLE xt_message LINES lv_cnt.
      xys_gd_doc_data-doc_size =
         ( lv_cnt - 1 ) * 255 + STRLEN( xt_message ).
      xys_gd_doc_data-obj_langu = sy-langu.
      xys_gd_doc_data-obj_name  = lc_name.
      xys_gd_doc_data-obj_descr = lc_descr.
      xys_gd_doc_data-sensitivty = lc_f.
      CLEAR xyt_packing_list.
      REFRESH xyt_packing_list.
      xyt_packing_list-transf_bin = space.
      xyt_packing_list-head_start = lc_one.
      xyt_packing_list-head_num = lc_zero.
      xyt_packing_list-body_start = lc_one.
      DESCRIBE TABLE xt_message LINES xyt_packing_list-body_num.
      xyt_packing_list-doc_type = lc_doctype.
      APPEND xyt_packing_list.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = xs_gd_doc_data
          put_in_outbox              = lc_true
          commit_work                = lc_true
        IMPORTING
          sent_to_all                = lv_sent_all
        TABLES
          packing_list               = xt_packing_list
          contents_txt               = xt_message
          receivers                  = xt_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.
      IF sy-subrc <> 0.
    *Do Nothing
      ENDIF.
    Hope this resolve your query.
    Regards,
    Manish

  • SO_NEW_DOCUMENT_ATT_SEND_API1:How to correctly attach a PDF file

    I have an ABAP report that will send an email and attach the PDF file.
    - convery spool to PDF     : CONVERT_ABAPSPOOLJOB_2_PDF
    - to send email          : SO_NEW_DOCUMENT_ATT_SEND_API1
    How I execute SM36:
    1. SM36
    2. Job Name
    3. Spool List Recipient : select my own address as internal user (I didn't tick any of the check box for the general attributes)
    When I go to TCODE SO01(SAP Inbox)
    The attachment I see is just a link to the output of my classic ABAP view report, it's not a PDF File.
    But I in SO01, I create a mail and attach PDF file, receive it my SAP inbox and can also open the attached PDF directly by just double clicking it.
    Thanks.

    Hi  Jaime Cabanban,
    Please find the Below Sample Program,
    BCS_EXAMPLE_8
    Thanks
    Surendra

  • So_new_document_att_send_api1....please give me test data

    Hi Experts,
    i am using so_new_document_att_send_api1 FM for send a mail to users with out any attachment,
    plz give me test data , why i am using so_new_document_att_send_api1    instead of so_new_document_send_api1 , due to i need text in BOLD.  i can send data in HTML format.
    plz help me on this issue.
    Thanks.

    Hi,
    I have mentioned the use of u r FM's are
    SO_NEW_DOCUMENT_ATT_SEND_API1 - Sends emails with texts and attachments
    SO_NEW_DOCUMENT_SEND_API1 - Sends emails with texts.
    check the follwing example..
    It will be useful to u....
    CONSTANTS : C_HIGH TYPE SODOCCHGI1-PRIORITY VALUE '1' .
    DATA : I_CONTENT TYPE TABLE OF SOLISTI1  ,
    I_REC TYPE TABLE OF SOMLRECI1 .
    DATA : WA_DOCDATA TYPE SODOCCHGI1 ,
    WA_CONTENT TYPE SOLISTI1   ,
    WA_REC     TYPE SOMLRECI1  .
    FILL DOCUMENT DATAWA_DOCDATA-OBJ_NAME    = 'MESSAGE' .
    WA_DOCDATA-OBJ_DESCR   = 'test'    .
    WA_DOCDATA-OBJ_LANGU   = 'E'       .
    WA_DOCDATA-SENSITIVTY  = 'F'       .
    WA_DOCDATA-OBJ_PRIO    = C_HIGH    .
    WA_DOCDATA-NO_CHANGE   = 'X'       .
    WA_DOCDATA-PRIORITY    = C_HIGH    .
    FILL OBJECT CONTENTCLEAR WA_CONTENT .
    WA_CONTENT-LINE = 'test mail' .
    APPEND WA_CONTENT TO I_CONTENT .
    FILL RECEIVERSCLEAR WA_REC .
    WA_REC-RECEIVER = SY-UNAME .
    WA_REC-REC_TYPE = 'B'.
    APPEND WA_REC TO I_REC .
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA              = WA_DOCDATA
      TABLES
        OBJECT_CONTENT             = I_CONTENT
        RECEIVERS                  = I_REC
      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.
    Regards
    Kiran

  • SO_NEW_DOCUMENT_ATT_SEND_API1, how to save a copy of send item if i use thi

    I  am using SO_NEW_DOCUMENT_ATT_SEND_API1 , this FM to send employ details through mail as pdf, but i want a copy of all send details in my computer also, can any one help me for this , to achieve

    Hi Kiran,
        You can use transaction 'SOST' to view the sent items.
        Enter your mail id in the 'Sender Tab', Enter the Dates 
        under period tab. Use 'Send status' tab aptly to view the sent
        mails.
        Alternatively, Why dont you give the 'user' email id in the
        mailing list along with other recipients so that the user can
        have the mail in his Inbox. For getting the User email id,
        read PERSNUMBER and ADDRNUMBER from USR21table
        by passing BNAME = Sy-uname.
        Go to ADR6 table, pass the USR21-PERSNUMBER and  
        USR21-ADDRNUMBER and read the SMTP_ADDR which
        will be the users email id. Include this Email id alongwith the
        email recipient list to recieve the same copy into your inbox.
    <REMOVED BY MODERATOR>
    Regards
    Nanda
    Edited by: Alvaro Tejada Galindo on Feb 22, 2008 3:50 PM

  • SO_NEW_DOCUMENT_ATT_SEND_API1 : How to use it to support multibyte

    Hi -,
    I am using SO_NEW_DOCUMENT_ATT_SEND_API1 to send excel file as an attachment . I am  able to submit in the excel file with both english & russian characters. But when i am recieving the same file in output, english characters are looking fine. But multibyte characters (russian , japanses...) are coming as junk.
    Do i need to do any additional setting.
    Are there any SAP NOTES to be implemented for this F.M to support multibyte?
    Any helpful solutions will be highly appreciatable.
    Thanks,
    Raj

    Hi -
    Any response to this question..
    Thanks,
    Gyanaraj

  • Using the FM SO_NEW_DOCUMENT_ATT_SEND_API1

    Hi Gurus,
    I am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    My requirement needs me to email an attachment.
    Why is it that when I input
    A
    B
    C
    in my table, the value I am getting is
    A                         B                        C
    wherein I should get an attachment that should look like this one
    A
    B
    C
    My output file is a TXT file. I understand that this is using the CONTENT_BIN that uses the binary format.
    What I need is an attachment that is using the ASCII format. But when I use the ASCII format, I am getting an error: "error occurred during sending !".
    Do I need to make enhacements on the FM?
    Thanks in advance.
    Benedict

    Hi Benedict,
    Please refer to the below code.
    Program:  ZRAT                 Creation Date: 12.04.2007 *
    Program Title :  Retirement Age Trigger                  *
    Program Author:  Puneet Jhari                            *
    Program Type  :   Executable                             *
    Object ID     :                                          *
    Technical Specification Version:                         *
    Technical Specification Author:                          *
    Code Quality Reviewer     :                              *
    Transport No.          :  SRDK906499                     *
    Program Description:                                     *
    Inputs                                                   *
       Tables:                                               *
       Parameters                                            *
       External files:                                       *
    Outputs                                                  *
       Reports:                                              *
       Tables:                                               *
       Databases:                                            *
       Screens:                                              *
       Parameters                                            *
       External files:                                       *
       Other objects:                                        *
    Return codes set by ABAP:                                *
    Modification Informaion                                  *
    Program Version:                                         *
    Date         : DD-MMM-YYYY                               *
    Author       :                                           *
    Description  :                                           *
    Transport No.:                                           *
    REPORT  zrat NO STANDARD PAGE HEADING.
    *DATA DECLARATION
    DATA : BEGIN OF wa_ccode,
            bukrs TYPE t001-bukrs,
           END OF wa_ccode.
    DATA : itab_ccode LIKE TABLE OF wa_ccode.
    DATA : BEGIN OF wa_emp,
            pernr TYPE pa0001-pernr,
            sachp TYPE pa0001-sachp,
            sname TYPE pa0001-sname,
           END OF wa_emp.
    DATA : itab_emp LIKE TABLE OF wa_emp.
    DATA : BEGIN OF wa_bdate,
            nachn LIKE pa0002-nachn,
            vorna LIKE pa0002-vorna,
            pernr TYPE pa0002-pernr,
            gbdat TYPE pa0002-gbdat,
           END OF wa_bdate.
    DATA : itab_bdate LIKE TABLE OF wa_bdate.
    DATA : new_date LIKE sy-datum.
    DATA : diff TYPE i.
    DATA : years LIKE p0347-scryy,
           months LIKE p0347-scrmm,
           days LIKE p0347-scrdd.
    DATA : sup_code LIKE pa0001-sachp,
           itab_usrid LIKE t526-usrid,
           sup_pernr LIKE pa0105-pernr.
    DATA : BEGIN OF wa_email,
           usrid_long LIKE pa0105-usrid_long,
           END OF wa_email.
    DATA : sup_email LIKE TABLE OF wa_email.
    DATA : gwa_document_data LIKE sodocchgi1,
           gc_name  TYPE so_obj_nam VALUE 'RETIREMENT',
           gc_senst TYPE so_obj_sns VALUE 'P',
           gc_size  TYPE so_doc_siz VALUE '510',
           gi_obj_cnt LIKE TABLE OF solisti1 WITH HEADER LINE,
           gi_recievers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
           gwa_obj_cnt LIKE LINE OF gi_obj_cnt.
    DATA : smtp_addr LIKE adr6-smtp_addr.
    DATA : wa_date LIKE sy-datum,
           entries LIKE sy-tabix,
           name(15),
           line1(18) TYPE c,
           line2(20) TYPE c,
           line3(20) TYPE c,
           line4(23) TYPE c,
           line5(10) TYPE c,
           line6(45) type c,
           date(2) TYPE c,
           month(2) TYPE c,
           year(4) TYPE c.
    *START OF SELECTION
    SELECT bukrs
    FROM t001
    INTO TABLE itab_ccode
    WHERE land1 EQ 'GB'.
    SORT itab_ccode.
    DELETE ADJACENT DUPLICATES FROM itab_ccode.
    SELECT pernr sachp sname
    FROM pa0001
    INTO TABLE itab_emp
    FOR ALL ENTRIES IN itab_ccode
    WHERE bukrs EQ itab_ccode-bukrs AND begda LE sy-datum AND
    endda GE sy-datum and persg eq '1'.
    SELECT nachn vorna pernr gbdat
    FROM pa0002
    INTO TABLE itab_bdate
    FOR ALL ENTRIES IN itab_emp
    WHERE pernr EQ itab_emp-pernr.
    *TO CHECK EMPLOYEES WHOSE AGE IS NEAR 75 YEARS.
    LOOP AT itab_bdate INTO wa_bdate.
      new_date = wa_bdate-gbdat.
    *TO CALCULATE THE AGE TILL DATE
      CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
        EXPORTING
          date1                         = sy-datum
          date2                         = new_date
         output_format                 = '05'
       IMPORTING
         years                         = years
         months                        = months
         days                          = days
      IF sy-subrc <> 0.
      ENDIF.
      IF years EQ 64 AND months EQ 4.
        IF days GE 23 AND days LE 31.
    *FETCH THE DATA IF THE AGE IS NEARING 75 YEARS
          SELECT SINGLE sachp FROM pa0001 INTO sup_code WHERE pernr EQ
          wa_bdate-pernr AND begda LE sy-datum AND endda GE sy-datum.
          SELECT SINGLE usrid FROM t526 INTO itab_usrid WHERE sachx EQ
          sup_code.
          SELECT SINGLE pernr FROM pa0105 INTO sup_pernr WHERE usrid EQ
          itab_usrid AND subty EQ '0001'.
          clear sup_email[].
          SELECT usrid_long FROM pa0105 INTO TABLE sup_email WHERE pernr EQ
          sup_pernr AND subty EQ '0010'.
    *EMAIL ADDRESS OF THE SUPERVISOR TO BE NOTIFIED
          CLEAR gi_obj_cnt.
          CLEAR gi_recievers.
          CLEAR gwa_document_data.
          Loop at sup_email into wa_email.
          write sy-uline+0(5).
          write sy-uline+10(5).
          write sy-uline+20(5).
          write sy-uline+30(5).
          write sy-uline+40(5).
          write sy-uline+50(5).
          write sy-uline+60(5).
          write sy-uline+70(5).
          smtp_addr = wa_email-usrid_long.
          gi_recievers-receiver = smtp_addr.
          gi_recievers-rec_type = 'U'.
          gi_recievers-com_type = 'INT'.
          APPEND gi_recievers.
          Endloop.
          smtp_addr = '[email protected]'.
          gi_recievers-receiver = smtp_addr.
          gi_recievers-rec_type = 'U'.
          gi_recievers-com_type = 'INT'.
          APPEND gi_recievers.
          gwa_document_data-obj_name    = gc_name.
          gwa_document_data-obj_descr   = 'RETIRE'.
          gwa_document_data-sensitivty  = gc_senst.
          gwa_document_data-obj_langu = sy-langu.
    *CONTENT OF THE EMAIL TO BE SENT
          line1 = 'Please note that  '.
          line2 = wa_bdate-vorna.
          line3 = wa_bdate-nachn.
          line4 = ' will be 65 years on  '.
          line50(4) = wa_bdate-gbdat4(4).
          date = line5+2(2).
          month = line5+0(2).
          year = wa_bdate-gbdat+0(4) + 65.
          CONCATENATE date month year INTO line5 SEPARATED BY '.'.
          line6 = '.Please complete the Retirement Procedure.'.
          CONCATENATE line1 line2 line3 line4 line5 line6 INTO gwa_obj_cnt
          SEPARATED BY space.
          APPEND gwa_obj_cnt TO gi_obj_cnt.
          CLEAR gwa_obj_cnt.
          DESCRIBE TABLE gi_obj_cnt LINES entries.
          READ TABLE gi_obj_cnt INDEX entries.
    gwa_document_data-doc_size = ( entries - 1 ) * 255 + STRLEN( gi_obj_cnt
    *FUNCTION MODULE TO SEND THE EMAIL TO THE CONCERNED PERSONS
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
      EXPORTING
        document_data                    = gwa_document_data
        document_type                    = 'RAW'
             commit_work                      = 'X'
            TABLES
             object_content                   = gi_obj_cnt
              receivers                        = gi_recievers
      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
    *MESSAGE TO BE DISPLAYED AFTER THE EXECUTION
         endif.
          CASE sy-subrc.
            WHEN 0.
              LOOP AT gi_recievers.
                IF gi_recievers-receiver = space.
                  name = gi_recievers-rec_id.
                ELSE.
                  name = gi_recievers-receiver.
                ENDIF.
                IF gi_recievers-retrn_code = 0.
                  WRITE: / name, ': succesfully sent'.
                ELSE.
                  WRITE: / name, ': error occured'.
                ENDIF.
              ENDLOOP.
            WHEN 1.
              WRITE: / 'Too many receivers specified !'.
            WHEN 2.
              WRITE: / 'No receiver got the document !'.
            WHEN 4.
              WRITE: / 'Missing send authority !'.
            WHEN OTHERS.
              WRITE: / 'Unexpected error occurred !'.
          ENDCASE.
        ENDIF.
      ENDIF.
    ENDLOOP.
    In case you have any further clarifications,do let me know.
    Regards,
    Puneet Jhari.

  • Send email to external user using fm 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    Hi friends,
    I wrote this code to send mail to external user from sap.
    It did not work properly can anyone help me to send email to extenal user.
    The return code after executing the function module is 2.
    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.
    Creating the document to be sent
    DOC_CHNG-OBJ_NAME = 'OFFER'.
    DOC_CHNG-OBJ_DESCR = 'abcd'.
    OBJTXT = 'aaaaaaaaaaa:'.
    APPEND OBJTXT.
    OBJTXT = 'bbbbbbbbbb'.
    APPEND OBJTXT.
    OBJTXT = 'ccccccccccccc.'.
    APPEND OBJTXT.
    DESCRIBE TABLE OBJTXT LINES TAB_LINES.
    READ TABLE OBJTXT INDEX TAB_LINES.
    DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    RECLIST-RECEIVER = mail address.
    RECLIST-REC_TYPE = 'U'.
    RECLIST-COM_TYPE = 'INT'.
    RECLIST-NOTIF_DEL = 'X'.
    RECLIST-NOIF_NDEL = 'X'.
    APPEND RECLIST.
    Creating 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.
    Creating the document attachment
    (Assume the data in OBJBIN are given in BMP format)
    OBJBIN = ' \O/ '. APPEND OBJBIN.
    OBJBIN = '     '. APPEND OBJBIN.
    OBJBIN = ' / \ '. APPEND OBJBIN.
    DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    OBJHEAD = 'picasso.bmp'. APPEND OBJHEAD.
    Creating 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   = 'BMP'.
    OBJPACK-OBJ_NAME   = 'ATTACHMENT'.
    OBJPACK-OBJ_DESCR = 'Reproduction object 138'.
    OBJPACK-DOC_SIZE   = TAB_LINES * 255.
      APPEND OBJPACK..
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
         EXPORTING
              DOCUMENT_DATA = DOC_CHNG
              PUT_IN_OUTBOX = 'X'
              COMMIT_WORK   = 'X'
         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.
    IF SY-SUBRC NE 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    Hi,
    Check in SCOT t-code whether it has been properly configred to send the mails
    Regards,
    siva chalasani.

  • Send multiple email attachments using FM SO_NEW_DOCUMENT_ATT_SEND_API1.How?

    Hi All,
    I have a requirement to send email to an external ID for which I am using FM SO_NEW_DOCUMENT_ATT_SEND_API1.Can anyone give a sample code to send multiple excel attachments using this function module.
    Points would be rewarded.
    Thanks
    Archana.

    Check the Thread,,
    Re: more than 1 attachements/sheets in SO_DOCUMENT_SEND_API1

  • Send attachment though mail using FM SO_NEW_DOCUMENT_ATT_SEND_API1

    Hello Gurus,
    Please help me with the mail sending attachment(excel file) using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    Here is the actual problem.
    I am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1 in my prog.
    My attachment(excel sheet which is taken from internal table) contains the 10 records with one header description and data related to that description.
    I am able to send the attachment but the records in the attachment has more than 255 characters nearly 700 character length.
    So I spilt up each internal table record(with structure type solisti1) into 3 internal table records and populated it.
    It is showing the entire record in the attached file but I am not able to see some fields which are embeded deeply inside the cells.
    And they are not having any proper allignment.
    Please do help me.
    Promise to reward points.
    Mac

    Here is the sample code....
    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.
    Creating the document to be sent
    DOC_CHNG-OBJ_NAME = 'OFFER'.
    DOC_CHNG-OBJ_DESCR = 'Auction of a Picasso jr'.
    OBJTXT = 'Reserve price : $250000'.
    APPEND OBJTXT.
    OBJTXT = 'A reproduction of the painting to be auctioned'.
    APPEND OBJTXT.
    OBJTXT = 'is enclosed as an attachment.'.
    APPEND OBJTXT.
    DESCRIBE TABLE OBJTXT LINES TAB_LINES.
    READ TABLE OBJTXT INDEX TAB_LINES.
    DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    Creating 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.
    Creating the document attachment
    (Assume the data in OBJBIN are given in BMP format)
    OBJBIN = ' \O/ '. APPEND OBJBIN.
    OBJBIN = '     '. APPEND OBJBIN.
    OBJBIN = ' / \ '. APPEND OBJBIN.
    DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    OBJHEAD = 'picasso.bmp'. APPEND OBJHEAD.
    Creating 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   = 'BMP'.
    OBJPACK-OBJ_NAME   = 'ATTACHMENT'.
    OBJPACK-OBJ_DESCR = 'Reproduction object 138'.
    OBJPACK-DOC_SIZE   = TAB_LINES * 255.
    APPEND OBJPACK..
    Entering names in the distribution list
    RECLIST-RECEIVER = '<name>@yahoo.com'.
    RECLIST-REC_TYPE = 'U'.
    APPEND RECLIST.
    RECLIST-RECEIVER = 'DLI-NEUREICH'.
    RECLIST-REC_TYPE = 'P'.
    APPEND RECLIST.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
             DOCUMENT_DATA = DOC_CHNG
             PUT_IN_OUTBOX = 'X'
             COMMIT_WORK   = 'X'
        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.
         CASE SY-SUBRC.
           WHEN 0.
             WRITE: / 'Result of the send process:'.
             LOOP AT RECLIST.
               WRITE: / RECLIST-RECEIVER(48), ':'.
               IF RECLIST-RETRN_CODE = 0.
                 WRITE 'sent successfully'.
               ELSE.
                 WRITE 'not sent'.
               ENDIF.
             ENDLOOP.
           WHEN 1.
         WRITE:
         / 'no authorization to send to the specified number recipients!'.
           WHEN 2.
             WRITE: / 'document could not be sent to any of the recipient'.
           WHEN 4.
             WRITE: / 'no authorization to send !'.
           WHEN OTHERS.
             WRITE: / 'error occurred during sending !'.
         ENDCASE.
    Regards,
    Pavan.

  • Send excel attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1

    Hi ABAPers,
    I managed to send excel attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    Let say I send it to my own email account.
    But, when try to open the excel document, from lotus notes, there is warning message produced by the microsoft excel saying:
    "The file is not in a recognizable format.
    and so on....."
    Anyway, when I click button 'OK', excel sheet will be opened and no information lost.
    How can we code the abap program so that the message will not come each time I open the attachment from my lotus notes?
    Or this is just the tab delimited issue?
    Thank you.
    Regards,
    Edward.

    Hi Shan,
    Thank you for replying.
    I have the same as follows:
      DESCRIBE TABLE lt_contents_hex LINES lv_lines.
      lt_packing_list-transf_bin = 'X'.
      lt_packing_list-head_start = 1.
      lt_packing_list-head_num   = 1.
      lt_packing_list-body_start = 1.
      lt_packing_list-body_num   = lv_lines.
      lt_packing_list-doc_type   = 'XLS'.
      lt_packing_list-obj_name   = 'ATTACHMENT'.
      lt_packing_list-obj_descr  = 'Attachment'.
      lt_packing_list-doc_size   = lv_lines * 255.
      APPEND lt_packing_list.
    I'm using lt_contents_hex instead of lt_contents_bin.
    Still the problem is there.
    Is there any other way to calculate the doc size correctly?
    Regards,
    Edward.

  • SO_NEW_DOCUMENT_ATT_SEND_API1- problem in mail text

    Hi All,
    I am using FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send emails.
    I have taken the reference program from the documentation of this function module given by SAP.
    I want to send two attachments in text format using this FM and I am able to send the same.
    The problem I am facing is that every character of text is seprated by one space. i.e. between any two characters one space is inserted in the attachement.
    e.g. if I need to display :::
    "This is test mail" -->
    I am gettting the output as
    "T h i s  i s  t e s t  m a i l".
    Is there any parameter which I need to set to avoid this problem.
    Any input would be highly appreciated.
    regards,
    Lalit

    Hi,
    I tried the solutions given to me but I am sorry to say that still my problem persists.
    I am pasting my test code below. Request your help.
    Regards,
    Lalit
    REPORT  ZTEST_LALIT2.
    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: OBJBIN1  type soli_tab. "   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.
    Creating the document to be sent
    DOC_CHNG-OBJ_NAME = 'OFFER'.
    DOC_CHNG-OBJ_DESCR = 'Auction of a Picasso jr'.
    OBJTXT = 'Reserve price : $250000'.
    APPEND OBJTXT.
    OBJTXT = 'A reproduction of the painting to be auctioned'.
    APPEND OBJTXT.
    OBJTXT = 'is enclosed as an attachment.'.
    APPEND OBJTXT.
    DESCRIBE TABLE OBJTXT LINES TAB_LINES.
    READ TABLE OBJTXT INDEX TAB_LINES.
    DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    Creating the entry for the compressed document
    CLEAR OBJPACK-TRANSF_BIN.
    OBJPACK-HEAD_START = 1.
    OBJPACK-HEAD_NUM   = 0.
    OBJPACK-BODY_START = 0.
    OBJPACK-BODY_NUM   = TAB_LINES.
    OBJPACK-DOC_TYPE   = 'RAW'.
    APPEND OBJPACK.
    Creating the document attachment
    (Assume the data in OBJBIN are given in BMP format)
    OBJBIN = 'This is a test mail'. condense objbin. APPEND OBJBIN.
    OBJBIN = '  |  '. APPEND OBJBIN.
    OBJBIN = 'test '. APPEND OBJBIN.
    DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    OBJHEAD = 'picasso.txt'. APPEND OBJHEAD.
    Creating 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   = 'ATTACHMENT'.
    OBJPACK-OBJ_DESCR = 'Reproduction object 138'.
    OBJPACK-DOC_SIZE   = TAB_LINES * 132.
    APPEND OBJPACK..
    CALL FUNCTION 'QCE1_CONVERT'
            TABLES
              t_source_tab         = OBJBIN
              t_target_tab         = OBJBIN1[]
            EXCEPTIONS
              convert_not_possible = 1
              OTHERS               = 2.
    Entering names in the distribution list
    RECLIST-RECEIVER = 'LALITK'.
    RECLIST-REC_TYPE = 'B'.
    APPEND RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
         EXPORTING
              DOCUMENT_DATA = DOC_CHNG
              PUT_IN_OUTBOX = 'X'
              COMMIT_WORK   = 'X'
         TABLES
              PACKING_LIST  = OBJPACK
              OBJECT_HEADER = OBJHEAD
              CONTENTS_BIN  = OBJBIN1[]
              CONTENTS_TXT  = OBJTXT
              RECEIVERS     = RECLIST
         EXCEPTIONS
              TOO_MANY_RECEIVERS = 1
              DOCUMENT_NOT_SENT  = 2
              OPERATION_NO_AUTHORIZATION = 4
              OTHERS = 99.

  • SO_NEW_DOCUMENT_ATT_SEND_API1          ( I need  text  + zattachment )

    i am using the the below fm  but the output in the mail is coming as attachment .pdf and .txt .
    SO_NEW_DOCUMENT_ATT_SEND_API1
    But i need the text in the table  CONTENT_TXT must come as  written text in email and data in the CONTENT_BIN as 
    attachment  .
    How can i achieve that??
    Edited by: AJAY SHARMA on Feb 8, 2010 5:54 AM

    Thanks for your reply ..
    I am  passing the  Content_txt in the packed list table as a raw data  and contentbin data as a pdf. data .
    But it display both data as attachment .
    2ndly
    in the packed_list table if put raw format  data in 2nd index and pdf data in the firstindex .
    then  the pdf is not opening but the raw data is  comming  as text  .

  • SO_NEW_DOCUMENT_ATT_SEND_API1 and txt file problem

    Hi
    I'm using FM SO_NEW_DOCUMENT_ATT_SEND_API1 for sending a txt file attachment, but the format of data is wrong.
    U s e r   :   T F R A N C O 
    D a t e   :   1 8 / 0 5 / 2 0 1 0
    clear objpack-transf_bin.
      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_descr = 'Document'.
      objpack-doc_size = tab_lines * 255.
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          Document_data              = doc_chng
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          Packing_list               = objpack
          object_header              = objhead
          contents_bin               = objbin
          contents_txt               = objtxt
          Receivers                  = reclist
        EXCEPTIONS
          too_many_receivers         = 1
          Document_not_sent          = 2
          Document_type_not_exist    = 3
          Operation_no_authorization = 4
          others                     = 99.
    Thanks in advance.

    Hi Carlos
    I've could delete space between letters but I need how to make for put new line in text format
    USER:TFRANCO   FECHA:25/05/2010.
    Format must be:
    USER:TFRANCO 
    FECHA:25/05/2010.
    code:
    DATA: hexa(1) TYPE c VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
      CONCATENATE hexa text-H02 SY-UNAME INTO objbin-line . APPEND objbin.
      CONCATENATE hexa text-H03 SY-DATUM INTO objbin-line . APPEND objbin.
    Thanks in advance.

  • SO_NEW_DOCUMENT_ATT_SEND_API1 Text attachment issue after upgrade 4.7 to ECC6

    Hi,
      We are using function module so_new_document_att_send_api1 for sending mail with text document. It was working fine 4.7 system but in ECC system it is sending blank attachement with mail. Program remain same and no changes in that. I have attached code. please advise how to resolve this issue.
    Thanks

    Hello Venu,
    Move attachment to packinglist internal table and clear lt_packing_list-transf_bin as below.
    I copied your code and did some correction.
    *  lt_packing_list-transf_bin  = 'X'.
       lt_packing_list-head_start  = 2.
       lt_packing_list-head_num    = 1.
       lt_packing_list-body_start  = LINES( lt_mailtxt ) + 1.
       APPEND LINES OF lt_attachment TO lt_mailtxt.
       lt_packing_list-body_num    = LINES( lt_attachment ).
       lt_packing_list-doc_type    = 'RAW'. " You can give RAW incase if you want just a txt file.
       lt_packing_list-obj_name    = 'data.txt'.
       lt_packing_list-obj_descr   = 'data.txt'.
       lt_packing_list-doc_size    = lt_packing_list-body_num * 255.
       APPEND lt_packing_list. CLEAR lt_packing_list.
    In FM SO_NEW_DOCUMENT_ATT_SEND_ATI1, no need to pass the ITAB attachment i fyou can merge everything to ITAB packing list.

Maybe you are looking for

  • Installing Boot Camp 3.0

    Hi there. I installed a 32bit Windows 7 Ultimate on my Mac book using boot camp.  I downloaded BootCamp 3.2 and asked me to install 3.1.  I also downloaded that but now it is telling me to install 3.0.  I am new to all this, and never used Boot Camp

  • Can't print wirelessly since Java for Mac OS X 10.5 Update 4

    I have an HP Officejet J4680 All-in-One, and have been printing wirelessly from my Macintosh (OS 10.5.7) since I purchased the printer in December 2008. However, after I installed the Java for Mac OS X 10.5 Update 4, I suddenly lost the ability to pr

  • Any ideas on why 4s brightness control won't work (not auto brightness)

    Within the past week or so my brightness control stopped working. Restored OS but that didn't fix it.  I suppose it is just broken but seems an unlikely failure when everthing else still works. I've read all the threads on the auto brightness issues

  • Connecting an amp with XLR outputs to GB

    Hi, I'm new to the forum, to Mac world and to recording as well, so please be patient... I'm trying to find out what would be the best way to record an amp guitar into GB. Right now I'm using the amp XLR right and left outputs directly into the Mac's

  • Apple Remote Desktop version 3.5.1. to version 3.5.2

    I originally purchased Apple Remote Desktop version 3.5.1 from the App Store.  Apparently Apple Remote Desktop version 3.5.2 has been released.  Guess what???  The App Store does not have the update for version 3.5.2.  I downloaded the update from th