FM TABLE_COMPRESS

Hi,
I have a report that I need to email to certain users. The line length in the report is greater than 255 characters.
When I call fm TABLE_COMPRESS passing table it_table, the new table (it_list) comes back filled with funny characters.
My code is below ...
TYPES: BEGIN OF t_table,
         line(1000),
       END OF t_table.
DATA: it_table   TYPE STANDARD TABLE OF t_table INITIAL SIZE 0 WITH HEADER LINE,
           it_list LIKE solisti1 OCCURS 0 WITH HEADER LINE.
  CALL FUNCTION 'TABLE_COMPRESS'
    TABLES
      in               = it_table
      out             = it_list
    EXCEPTIONS
      OTHERS          = 1.
Thanks
Lindy

Hi Adil,
I did try using ABAPLIST, but got an error when trying to load the table (it_table must be a character-type data object).
Here is my code for loading the table ...
  CONSTANTS:
  con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
  con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
  CONCATENATE 'CUST NO' 'CUST NAME' 'MATERIAL'
  'SUPP INV NO' 'SUPP INV DATE' 'BL NO' 'BL DATE'
  'DOC TYPE' 'PMM PO NO' 'PO QTY' 'SHIP QTY' 'ORDER UNIT'
  'INCOTERM' 'PO UNIT PUR PRICE' 'EDI INV UNIT PUR PRICE'
  'POvsEDI' 'DIFF x SHIPQTY' 'VEND CODE' 'VEND NAME'
  INTO it_table SEPARATED BY con_tab.
  CONCATENATE con_cret it_table INTO it_table.
  APPEND it_table.
CALL FUNCTION 'TABLE_COMPRESS'
TABLES
IN = IT_TABLE
OUT = IT_LIST
EXCEPTIONS
OTHERS = 1.
Thanks
Lindy

Similar Messages

  • Error with function module TABLE_COMPRESS?

    Hi all,
    What is the alternate function module for TABLE_COMPRESS?
    This is going fine in 4.7 version.
    But in ECC 6.0, if we use this function module we r getting SLIN error (Obsolate statements) .
    How can we rectify this SLIN error?
    So we have to use another funtion module for the same purpose.
    Can any one help on this?
    Rewards to all.
    Thanks & Regards
    Anu.

    Hi,
    I you have complex type in the parameter list you will get this error for example generic types, xtrings, strings, object references.
    But, function module can be called from programs.
    Check for Oss notes if you want to solve this problem
    Best regards..

  • What is the replacement for fm table_compress in ECC6

    Hi ,
    I am doing the ABAP remediationn from 4.7 to ECC6. Can you please let me know how to replace the obsolete function module TABLE_COMPRESS. As per the threads in SDN I came to know that there is a class availabe CL_ABAP_GZIP.  But I am not clear how to make use of this. Do we need to implement any OSS note for this.
    Thanks,

    Hi,
    No note needed, CL_ABAP_GZIP is available in ECC 6 (more precisely in NetWeaver 7.0 systems). Search forum for examples.
    BR
    Sandra

  • How to use FM named 'TABLE_COMPRESS'

    i am using FM named 'TABLE_COMPRESS'
    it is sending compressed values via function module  'SO_NEW_DOCUMENT_ATT_SEND_API1' (in attachment)
    but i am not able to see content after mail is sent.

    Hi Manish,
    Check the following link:
    http://www.sap-img.com/abap/sending-email-with-attachment.htm
    Thanks,
    Reward If Helpful.

  • Obsolate statement for function module TABLE_COMPRESS

    Hi all,
    What is the alternate function module for TABLE_COMPRESS?
    This is going fine in 4.7 version.
    But in ECC 6.0, if we use this function module we r getting SLIN error (Obsolate statements) .
    How can we rectify this SLIN error?
    So we have to use another funtion module for the same purpose.
    Can any one help on this?
    Rewards to all.
    Thanks & Regards
    Anu.

    Hello,
    This Function Module belongs to the Function Group SYST. I really doubt if this is going to be made obsolete without providing an alternative. In such a case there would almost certainly have been an OSS Note. However, I could not find any OSS note for this.
    Moreover, the Function Module doesn't have "obsolete" flag set if you see from SE37. Therefore it must be really safe to use this function module in your program.
    Still, I will try to get a confirmation for this.
    Regards,
    Anand Mandalika.

  • Urg. Replacement for the FM's TABLE_COMPRESS & SAPWL_STATREC_READ_FILE

    Hi,
    We are Upgrading Ecc4.7 to Ecc6.
    We found that TABLE_COMPRESS and
    SAPWL_STATREC_READ_FILE are Obsolete.
    Please suggest the Replacement for these Function Modules

    Sandhya,
    As Vasu suggested you can use class <b>cl_abap_gzip</b>
    try.
    call method cl_abap_gzip=>compress_text
      exporting
        text_in                     = xsccpvapitem
      importing
        gzip_out                   = it_attach2
        gzip_out_len             = 255.
    endtry.
    Regards
    Aneesh.

  • Alternativa to TABLE_COMPRESS

    Hi,
    TABLE_COMPRESS is an absolute function module.
    Is there any alternative fucntion module to it.
    Thanks in advance,
    Veeru.

    Hi,
    check the thread
    Re: E-mail in ABAP
    regards,
    keerthi.

  • FM table_compress obsolete ?

    I find TABLE_COMPRESS is obsolete in Netweaver 7.0, what will be alternate fm for this ?
    PS: I know being obsolete , but SAP is using hundreds of programs.
    So please don't suggest to use this.
    My requirement is i am converting a list_from_memory (output list) to PDF.
    a®s
    Edited by: a®s on Aug 25, 2008 1:52 PM

    Hi,
    Pls try to use the CL_ABAP_GZIP. In this we have method called Compress_text.
    Check out this link on it's usage
    Fm TABLE_COMPRESS
    Regards
    Lekha

  • Mail program doubt

    i have used this program for sending mail through SAP.It has two options.First for sending as an html attachement,second for plain text inline with the body of the message.Actually i need the message in html format inline with the body of the message itself(not as an attachement)
    In simple words the body of the message want to be in html format,not an attachement..
    *& Report  ZMAIL                                                       *
    report  zmail                                   .
    tables: soos1.
    *type-pools: sbdst.
    parameters: report like varis-report obligatory.
    parameters: variant like varis-variant obligatory.
    parameters:reptitle like soos1-recrem  obligatory.
    select-options: recnam for soos1-recrem  obligatory.
    *{   INSERT         EDPK900415                                        1
    selection-screen skip 1.
    selection-screen begin of block b1 with frame title text-001.
    selection-screen begin of line.
    parameters: r1 radiobutton group g1.
    selection-screen comment:5(40) text-003 for field r1.
    selection-screen position 35.
    selection-screen end of line.
    selection-screen begin of line.
    parameters: r2 radiobutton group g1.
    selection-screen comment: 5(40) text-002 for field r2.
    selection-screen end of line.
    selection-screen end of block b1.
    *}   INSERT
    data: begin of html_tab occurs 0.
            include structure w3html.
    data: end of html_tab.
    data : it_pack_list  like soxpl occurs 0 with header line.
    data: begin of html_tab_converted occurs 0,
                line(255) type c,
              end of html_tab_converted.
    data:  listobject like abaplist occurs 20 with header line.
    data:  abap_list like abaplist occurs 20 with header line.
    data: icontab(32) occurs 10 with header line.
    data: lineno type i, length type i, size type i,
          l_filename like rlgrap-filename.
    data: icon_wa  type icon,
          internal type icon-internal,
          existing type c.
    data: my_bds type ref to cl_bds_document_set,
          key    type sbdst_object_key,
          files  type sbdst_files,
          wa     type bapifiles.
    data: filename type string,
          filefilter type string,
          path type string,
          fullpath type string.
    data: user_action type i.
    data: cur_guicopdepage(4) type c.
    data: gui_codepage(4) type n,        " added for message 500824
          is_unicode type rststype-sel_ok.
    data: convert_output type xstring,
          convert_buffer type xstring.
    data i type i.
    data tablength type i.
    data dummy type i.
    data list_index like  sy-lsind .
    data begin of new_pack_list occurs 10.
            include structure soxpl.
    data end of new_pack_list.
    data : owner like soud-usrnam.
    data: fg_sysdli like sonv-flag,
    fg_folrg like soxdl-folrg,
    dli_tab_save like soxdl occurs 20 with header line.
    data: rec_count like sy-tabix.
    data: object_type like sood-objtp value 'RAW'.
    data: object_hd_change like sood1 occurs 0 with header line.
    data: objcont like soli occurs 0 with header line.
    data: attcont_tab like soli occurs 0 with header line.
    data: atthead_tab like soli  occurs 0 with header line.
    data  so_ali like soli occurs 100 with header line.
    data  document_data like sodocchgi1.
    data  msg_text(80) type c.           "Message text
    data:  length type i, size type i.
    data  profile like soprd.
    data  subrc like sy-subrc value 0.
    data  so_ali_hex type standard table of solix.   "note 604603
    data: objpara like selc occurs 0 with header line.
    data: objparb like soop1 occurs 0 with header line.
    data: receivers like soos1 occurs 0 with header line.
    *data: receivers like soos5 occurs 0 with header line.
    data: r_dliq type c. "Shared Distrbution List
    data: r_dlip type c. "Private Distrbution list
    data: rep_title(50) type c. "Report Title
    data : begin of dis_lst occurs 10. "Internal table to store DL
            include structure sodm1.
    data : end of dis_lst.
    data : begin of listtab occurs 100. "Internal Table for List CONTAINER
            include structure abaplist.
    data : end of listtab.
    data : begin of downtab occurs 1,
    line(255),
    end of downtab.
    data ls_cnt type n.
    data:begin of it_mailid occurs 0,
         mailid(100), "  TYPE ZSENDINT_MAILID-MAILID,
         end of it_mailid.
    data c1.
    c1 = ' '.
    shift reptitle left deleting leading c1.
    *SELECT MAILID FROM ZSENDINT_MAILID INTO TABLE IT_MAILID WHERE SUBJECT = REPTITLE AND FLAG <> 'X'.
    "IF SY-SUBRC = 0.
    "CLEAR RECNAM.
    "REFRESH RECNAM.
    "LOOP AT IT_MAILID.
    "MOVE 'I' TO RECNAM-SIGN.
    "MOVE 'EQ' TO RECNAM-OPTION.
    "MOVE IT_MAILID-MAILID TO RECNAM-LOW.
    "APPEND RECNAM.
    "ENDLOOP.
    "ENDIF.
    *S.KARTHIKRAJA 07.10.2006
    call function 'LIST_FREE_MEMORY'
      tables
        listobject = listobject
      exceptions
        others     = 1.
    submit (report)
    using selection-set variant
                     exporting list to memory and return.
    import listobject from memory id '%_LIST'.
    if listobject[] is initial.
      exit.
    endif.
    call function 'WWW_HTML_FROM_LISTOBJECT'
           exporting
                  REPORT_NAME   =
                template_name = 'WEBREPORTING_REPORT'
           tables
                html          =  html_tab
                listobject    =  listobject
                listicons     =  icontab.
    call function 'LIST_TO_ASCI'
      exporting
        list_index         = -1
      tables
        listasci           = downtab
        listobject         = listobject
      exceptions
        empty_list         = 1
        list_index_invalid = 2
        others             = 3.
    call function 'TABLE_COMPRESS'       "Schneller Tabellencopy
          tables
               in         = listobject
               out        = so_ali.      "note 604603
               out        = so_ali_hex.   "note 604603
    call function 'SO_SOLIXTAB_TO_SOLITAB'           "note 604603
         exporting
              ip_solixtab = so_ali_hex[]
         importing
              ep_solitab  = so_ali[].
    call function 'SO_DLI_LIST_READ_XDL'
    exporting
    private = 'X'
    public = 'X'
    subscript = 'X'
    tables
    dli_display_tab = dli_tab_save
    exceptions
    communication_failure = 1
    dl_list_no_entries = 2
    owner_not_exist = 3
    system_failure = 4
    x_error = 5
    parameter_error = 6
    others = 7.
    call function 'SO_DLI_EXPAND'
    exporting
    system_dli = fg_sysdli
    convert = 'X'
    tables
    member = dis_lst
    objpara = objpara
    objparb = objparb
    exceptions
    active_user_not_exist = 1
    communication_failure = 2
    component_not_available = 3
    dl_name_not_exist = 4
    folder_not_exist = 5
    folder_no_authorization = 6
    forwarder_not_exist = 7
    object_not_exist = 8
    object_no_authorization = 9
    operation_no_authorization = 10
    owner_not_exist = 11
    parameter_error = 12
    recurrency_exist = 13
    substitute_not_active = 14
    substitute_not_defined = 15
    system_failure = 16
    x_error = 17
    others = 18.
    refresh receivers.
    clear receivers.
    move sy-datum  to receivers-rcdat .
    move sy-uzeit  to receivers-rctim.
    refresh object_hd_change.
    object_hd_change-objla = sy-langu. "Language
    object_hd_change-objcp = ' '. " Object can be changed byUSER
    object_hd_change-objsns = 'F'. " Msg Sensitivity private orbusiness
    object_hd_change-objdes = reptitle.
    object_hd_change-objnam = object_hd_change-objdes.
    append object_hd_change.
    if r1 = 'X'.
      move html_tab[] to objcont[].
    else.
      move downtab[] to objcont[].
    endif.
    describe table objcont lines i.
    it_pack_list-head_start = 1.
    it_pack_list-head_num = 0.
    it_pack_list-body_start = 1.
    it_pack_list-body_num = i.
    it_pack_list-OBJTP = 'RAW'.
    move variant to it_pack_list-objnam.
    move variant to it_pack_list-objdes.
    move 'HTM' to it_pack_list-file_ext.
    append it_pack_list.
    loop at html_tab.
      call function 'SCP_TRANSLATE_CHARS'
        exporting
          inbuff           = html_tab
          outcode          = gui_codepage
          csubst           = 'X'
          substc_space     = 'X'
          substc           = '00035'
        importing
          outbuff          = convert_output
        exceptions
          invalid_codepage = 1
          internal_error   = 2
          cannot_convert   = 3
          fields_bad_type  = 4
          others           = 5.
      concatenate convert_buffer convert_output into convert_buffer in
      byte mode.
    endloop.
    i = 0.
    describe field html_tab_converted length tablength in byte mode.
    while i < xstrlen( convert_buffer ).
      dummy = xstrlen( convert_buffer ) - i.
      if tablength > dummy.
        html_tab_converted-line = convert_buffer+i(dummy).
      else.
        html_tab_converted-line = convert_buffer+i(tablength).
      endif.
      i = i + tablength.
      append html_tab_converted.
    endwhile.
    receivers-sel = 'X'.
    receivers-sndex = ' '. "
    receivers-sndpri = '1'. "Priority of the message
    receivers-deliver = ' '.
    receivers-not_deli = ' '.
    receivers-read = ' '.
    receivers-recnam = 'U-'.
    receivers-mailstatus = 'E'.
    receivers-sortclass = '5'.
    receivers-recesc = 'U'. " U means Internet Address
    receivers-SAP_BODY = 'X'.
    receivers-sndart = 'INT'.
    loop at recnam.
      receivers-adr_name = recnam-low.
      receivers-recextnam = recnam-low.
      append receivers.
    endloop.
    owner = sy-uname.
    if r1  = 'X'.
      call function 'SO_OBJECT_SEND'
      exporting
    object_hd_change = object_hd_change
      object_type = object_type
      outbox_flag = 'X'
      owner = owner
      sender = sy-uname
      tables
      receivers = receivers
    packing_list = it_pack_list
      att_cont = objcont
      att_head = atthead_tab
      exceptions
      active_user_not_exist = 1
      communication_failure = 2
      component_not_available = 3
      folder_not_exist = 4
      folder_no_authorization = 5
      forwarder_not_exist = 6
      note_not_exist = 7
      object_not_exist = 8
      object_not_sent = 9
      object_no_authorization = 10
      object_type_not_exist = 11
      operation_no_authorization = 12
      owner_not_exist = 13
      parameter_error = 14
      substitute_not_active = 15
      substitute_not_defined = 16
      system_failure = 17
      too_much_receivers = 18
      user_not_exist = 19
      x_error = 20
      others = 21.
    else.
      call function 'SO_OBJECT_SEND'
       exporting
      object_hd_change = object_hd_change
       object_type = object_type
       outbox_flag = 'X'
       owner = owner
       sender = sy-uname
       tables
       objcont = objcont
       receivers = receivers
       exceptions
       active_user_not_exist = 1
       communication_failure = 2
       component_not_available = 3
       folder_not_exist = 4
       folder_no_authorization = 5
       forwarder_not_exist = 6
       note_not_exist = 7
       object_not_exist = 8
       object_not_sent = 9
       object_no_authorization = 10
       object_type_not_exist = 11
       operation_no_authorization = 12
       owner_not_exist = 13
       parameter_error = 14
       substitute_not_active = 15
       substitute_not_defined = 16
       system_failure = 17
       too_much_receivers = 18
       user_not_exist = 19
       x_error = 20
       others = 21.
    endif.
    commit work.
    call function 'SO_DEQUEUE_UPDATE_LOCKS'.

    i have not gone thru your source code fully.
    maintain the text in Tcode SO10.
    use the fn module READTEXT* to read the contents of the text.
    cheers
    jayanthi.K

  • How to send a mail as .txt attachment ?

    Hi all,
    I got a requirement to write code for sending mail in oops.
    i have written code for .xls which is working fine. But requirement is to send the mail in the format of txt.
    i just only chnge the .xls to .txt where i can see the output properly in sap but problem is that i am unable to get the proper alignment. when i execute the report and see the output in sost i can see the attachment.i am downloading the attachment there only(Our server is not configured to get the mails directly) .So when i open the saved text file on my pc the output is appearing as follows...
    pernr nachn vorna
            0001 L0001 F0001
                0002 L0002 F0002
                   0003 L0003 F0003
                         0004 L0004 F0004...
    Where it should come in straight line as follows in my o/p code..
    pernr nachn vorna
    0001 L0001 F0001
    0002 L0002 F0002
    0003 L0003 F0003
    0004 L0004 F0004...
    i am puttin g my code ..please correct me where i am wrong .....waiting for your valuabel inputs..
    *& Report  ZGBTEST02
    REPORT  YSAS_MAIL2.
    *Changes done by sas
    *PARAMETERS: P_MAIL TYPE AD_SMTPADR OBLIGATORY, " G C by sas
    *P_MAIL1 TYPE AD_SMTPADR OBLIGATORY." G by sas
    TABLES: ADR6.
    SELECT-OPTIONS:P_EADDR FOR ADR6-SMTP_ADDR NO INTERVALS .
    *end of changes by sas
    DATA: I_GLT0 TYPE STANDARD TABLE OF GLT0.
    *DATA: I_pernr  TYPE STANDARD TABLE OF pa0002.  " MARA Entries
    DATA: BEGIN OF I_PERNR OCCURS 1 ,
    PERNR TYPE PA0002-PERNR,
    NACHN TYPE PA0002-NACHN,
    VORNA TYPE PA0002-VORNA,
    END OF I_PERNR..
    *      I_MARC  TYPE STANDARD TABLE OF MARC.  " MARC Entries
    DATA: L_TEXT  TYPE CHAR255.  " Text
    DATA: L_LINES TYPE I,
          L_SIZE  TYPE SOOD-OBJLEN.
    " Size of Attachment
    * Mail related
    DATA: I_CONTENT         TYPE   SOLI_TAB, " Mail content
          I_ATTACH          TYPE   SOLI_TAB, " Attachment
          I_ATTACH1         TYPE   SOLIX_TAB. " Attachment
    DATA: L_SEND_REQUEST    TYPE REF TO    CL_BCS,
                                                " E-Mail Send Request
          L_DOCUMENT        TYPE REF TO    CL_DOCUMENT_BCS,
                                                " E-Mail Attachment
          L_RECIPIENT       TYPE REF TO    IF_RECIPIENT_BCS,
                                                " Distribution List
          L_SENDER          TYPE REF TO    IF_SENDER_BCS,
                                                " Address of Sender
          L_UNAME           TYPE           SALRTDRCPT,
                                                " Sender Name(SY-UNAME)
          L_BCS_EXCEPTION   TYPE REF TO    CX_DOCUMENT_BCS,
                                                " BCS Exception
          L_ADDR_EXCEPTION  TYPE REF TO    CX_ADDRESS_BCS,
                                                " Address Exception
          L_SEND_EXCEPTION  TYPE REF TO    CX_SEND_REQ_BCS.
    " E-Mail sending Exception
    *Constants------------------------------------------------------------*
    CONSTANTS: C_TAB(1) TYPE C VALUE
               CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
                                         " Tab Character
               C_CR(1)  TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF,
                                         " Line Feed for End-Of_line
               C_EXT    TYPE SOODK-OBJTP VALUE 'TXT'. " XLS Extension
    START-OF-SELECTION.
      SELECT PERNR NACHN VORNA  FROM PA0002 INTO CORRESPONDING FIELDS OF TABLE I_PERNR UP TO 20 ROWS.
    *select * from glt0 into table i_glt0.
    * Preparing body of the Mail
    *  MOVE 'SAP Material Master Records' TO L_TEXT.
    *  APPEND L_TEXT TO I_CONTENT.
    *  CLEAR L_TEXT.
    *  APPEND L_TEXT TO I_CONTENT.
    *  MOVE 'Thanks,' TO L_TEXT.
    *  APPEND L_TEXT TO I_CONTENT.
    *  MOVE 'SAP MM' TO L_TEXT.
    *  APPEND L_TEXT TO I_CONTENT.
      MOVE '<BR>Attached is your HRIS report(s) generated from the Firm''s' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
      MOVE ' Human Resources  Information System (SAP).' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
      MOVE '<BR>  ' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
      MOVE '<BR>This is an automated report.' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
    *        MOVE '<BR>  ' TO l_text.
    *        APPEND l_text TO i_content.
      MOVE '<BR>  ' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
    *        MOVE '<BR>Please do not reply to this email' TO l_text.
    *        APPEND l_text TO i_content.
    *        MOVE '<BR>  ' TO l_text.
    *        APPEND l_text TO i_content.
      MOVE '<BR>Thank you.' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
    * Creates persistent send request
      TRY.
          L_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
    * Creating Document
          L_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
                                        I_TYPE  = 'RAW'
                                        I_TEXT  = I_CONTENT[]
                                        I_SUBJECT = 'Automated HRIS (SAP) Report' ).
    DATA: W_PERNR LIKE I_PERNR.
    * Preparing contents of attachment with Change Log
          PERFORM PREPARE_ATTACHMENT.
          DATA: compressed like solisti1 occurs 10 with header line.
    DATA: decompressed like solisti1 occurs 10 with header line.
          CALL FUNCTION 'TABLE_COMPRESS'
    *   IMPORTING
    *     COMPRESSED_SIZE       =
                        TABLES
    *      in                    = eerec
                          in                    = i_attach
                          out                   = compressed.
          CALL FUNCTION 'TABLE_DECOMPRESS'
            TABLES
              in  = compressed
              out = decompressed.
          DESCRIBE TABLE decompressed LINES L_LINES.
    * Size to multiplied by 2 for UNICODE enabled systems
          L_SIZE = L_LINES * 2 * 255.
    * Adding Attachment
          CALL METHOD L_DOCUMENT->ADD_ATTACHMENT
            EXPORTING
              I_ATTACHMENT_TYPE    = C_EXT
              I_ATTACHMENT_SIZE    = L_SIZE
              I_ATTACHMENT_SUBJECT = 'Hr Details'
    *          i_att_content_hex    = i_attach[].
              I_ATT_CONTENT_TEXT   = decompressed[].
    *      DESCRIBE TABLE I_MARC LINES L_LINES.
    * Size to multiplied by 2 for UNICODE enabled systems
    *      L_SIZE = L_LINES * 2 * 255.
    ** Adding Attachment
    *      CALL METHOD L_DOCUMENT->ADD_ATTACHMENT
    *        EXPORTING
    *          I_ATTACHMENT_TYPE    = C_EXT
    *          I_ATTACHMENT_SIZE    = L_SIZE
    *          I_ATTACHMENT_SUBJECT = 'MARC Details'
    *          I_ATT_CONTENT_HEX    = I_ATTACH1[].
    **          i_att_content_text   = i_attach1[].
    * Add document to send request
          CALL METHOD L_SEND_REQUEST->SET_DOCUMENT( L_DOCUMENT ).
          DATA:LR_SENDER TYPE REF TO IF_SENDER_BCS,
               LR_SEND TYPE REF TO CL_BCS.
    * Preparing the sender object
    *      LR_SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( sy-uname ).
          DATA: L1_UNAME TYPE SY-UNAME.
          L1_UNAME = SY-UNAME.
          LR_SENDER = CL_SAPUSER_BCS=>CREATE( L1_UNAME ).
    * Setting the sender
          CALL METHOD L_SEND_REQUEST->SET_SENDER
            EXPORTING
              I_SENDER = LR_SENDER.
    * E-Mail
          LOOP AT P_EADDR.
            TRANSLATE P_EADDR-LOW TO LOWER CASE.
            L_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( P_EADDR-LOW ).
            CALL METHOD L_SEND_REQUEST->ADD_RECIPIENT
              EXPORTING
                I_RECIPIENT  = L_RECIPIENT
                I_EXPRESS    = 'U'
                I_COPY       = ' '
                I_BLIND_COPY = ' '
                I_NO_FORWARD = ' '.
            IF SY-SUBRC EQ 0.
              WRITE:/'** SUCCESS:  Email Sent to', P_EADDR-LOW COLOR COL_NORMAL.
            ELSE.
              WRITE:/'** ERROR: Failed to send Email to',P_EADDR-LOW COLOR COL_NEGATIVE .
            ENDIF.
          ENDLOOP.
    *Trigger E-Mail immediately
          L_SEND_REQUEST->SET_SEND_IMMEDIATELY( ' ' ).
          CALL METHOD L_SEND_REQUEST->SEND( ).
          COMMIT WORK.
        CATCH CX_DOCUMENT_BCS INTO L_BCS_EXCEPTION.
        CATCH CX_SEND_REQ_BCS INTO L_SEND_EXCEPTION.
        CATCH CX_ADDRESS_BCS  INTO L_ADDR_EXCEPTION.
      ENDTRY.
    *&      Form  PREPARE_ATTACHMENT
    FORM PREPARE_ATTACHMENT .
      FIELD-SYMBOLS: <LFS_TABLE>,    " Internal table structure
                     <LFS_CON>.      " Field Content
      DATA: L_TEXT TYPE CHAR1024.     " Text content for mail attachment
      DATA: L_CON TYPE STRING. "(50) TYPE c.        " Field Content in character format
      DATA: L_STR TYPE STRING,
            L_STR1 TYPE STRING.
    *data: w_pernr type TABLE OF I_PERNR.
      DATA: LS_SOLIX TYPE SOLIX.
    *  CONCATENATE 'PERNR' 'FIRST NAME' 'Last Name' C_CR INTO L_TEXT SEPARATED BY '|'.
    *  append l_text to i_attach.
    *  clear l_text.
    * Columns to be tab delimeted
      LOOP AT I_PERNR ASSIGNING <LFS_TABLE>.
        DO.
          ASSIGN COMPONENT SY-INDEX OF STRUCTURE <LFS_TABLE>
                 TO <LFS_CON>.
          IF SY-SUBRC NE 0.
            CONCATENATE C_CR L_TEXT INTO L_TEXT.
    *        CONCATENATE l_str c_cr l_text INTO l_str.
    *        ls_solix-line = l_text.
    *        APPEND ls_solix TO i_attach.
            APPEND L_TEXT TO I_ATTACH.
            EXIT.
          ELSE.
            CLEAR: L_CON.
            MOVE <LFS_CON> TO L_CON.
            CONDENSE L_CON.
            IF SY-INDEX = 1.
              CLEAR: L_TEXT.
              MOVE L_CON TO L_TEXT.
            ELSE.
              CONCATENATE L_TEXT L_CON INTO L_TEXT
                 SEPARATED BY C_TAB.
            ENDIF.
          ENDIF.
        ENDDO.
      ENDLOOP.
    *  i_attach1[] = i_attach[].
    ENDFORM.                    " PREPARE_ATTACHMENT
    Please if any one having 6.0 version please upload it and see..
    Regards
    Sas

    Hi ,
    Did you downloaded from  SOST  using the display icon and inside that 4th tab for attachment ....
    and see?
    Regards
    sas
    pS: THE FIRST page is not allowing the spaces in sdn...
    i am getting o/p as
    pernr vochn norna
    .........0001 f0001 l0001
    .................0002 F0002 L0002
    .......................0003 F0003 L0003.....
    Please remove dots and understand that is the o/p i am getting in my presenation file
    i just expecting the o/p as told earlier..
    Regards
    sas

  • Submit  ALV report in Background & exporting list to memory and return

    Dear all,
    I created one Z program (ZPROGRAM2). 
    Here i use SUBMIT ZPRORAM1_ALV exporting list to memory and return.
    call function 'LIST_FROM_MEMORY'.
    call function 'TABLE_COMPRESS' .
    ZPRORAM1_ALV output i send mail.
    This all are working in foreground.
    If i schedule ZPROGRAM2 in background. that SUBMIT ZPRORAM1_ALV statement not working.
    Please give me the Solution.
    Thanks,
    Durai.V

    It is because of the ALV output that you are using. Check the condition sy-batch = 'X' (background processing) and then display a classical report. It will work then.
    Thanks,
    Jayant

  • Getting dump with message  CALL_FUNCTION_GET_NAME_FAILED

    Hi,
    My requirement is to write a report which will be run in background every Monday and the result will be sent to a user as email with excel as attachment.
    I tried it by giving the email in 'Spool list recipient' in SM36. ut since the length of the output is more than 255 chars, so i thought of writing the email code as shown below.
    DATA: l_message_content LIKE soli OCCURS 10 WITH HEADER LINE,
            l_receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
            l_packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
            l_listobject LIKE abaplist OCCURS 10,
            l_compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
            lw_object_hd_change LIKE sood1,
            l_compressed_size LIKE sy-index.
      l_receiver_list-recnam = sy-uname .
      l_receiver_list-esc_des = 'B'.
      APPEND l_receiver_list.
      lw_object_hd_change-objla = sy-langu.
      lw_object_hd_change-objnam = 'Selection'.
      lw_object_hd_change-objsns = 'P'.
    Mail subject
      lw_object_hd_change-objdes = 'KRB SAP Inconsistency Report'.
    Mail body
      APPEND 'Consisteny report between KRB and SAP' TO l_message_content.
      CALL FUNCTION 'TABLE_COMPRESS'
        IMPORTING
          compressed_size = l_compressed_size
        TABLES
          in              = <fs_table>
          out             = l_compressed_attachment.
      DESCRIBE TABLE l_compressed_attachment.
      CLEAR l_packing_list.
      l_packing_list-transf_bin = 'X'.
      l_packing_list-head_start = 0.
      l_packing_list-head_num = 0.
      l_packing_list-body_start = 1.
      l_packing_list-body_num = sy-tfill.
      l_packing_list-objtp = 'ALI'.
      l_packing_list-objnam = 'Selection'.
      l_packing_list-objdes = 'SAP KRB Consistency Report'.
      l_packing_list-objlen = l_compressed_size.
      APPEND l_packing_list.
      CALL FUNCTION 'SO_OBJECT_SEND'
        EXPORTING
          object_hd_change = lw_object_hd_change
          object_type      = 'RAW'
          owner            = sy-uname
        TABLES
          objcont          = l_message_content
          receivers        = l_receiver_list
          packing_list     = l_packing_list
          att_cont         = l_compressed_attachment.
    I am getting the mail which i checked in SBWP but when i clicked on the attachment i am getting  dump with message CALL_FUNCTION_GET_NAME_FAILED.
    Short text
        Error when starting a Remote Function Call.
    What happened?
        "CPIC-CALL: 'ThSAPCMRCV' : cmRc=20 thRc=223#CPIC program connection ended (read
         error) "
        An error occurred when executing a Remote Function Call.
    Error analysis
        An error occurred when executing a Remote Function Call.
        "CPIC-CALL: 'ThSAPCMRCV' : cmRc=20 thRc=223#CPIC program connection ended (read
         error) "
        Status of connection.... "RFC DRV=??? ???"
        Internal error code.... "RFC_IO4"
        Internal error: Invalid RFC handle.
    Trigger Location of Runtime Error
        Program                                 SAPMSSY1
        Include                                 SAPMSSY1
        Row                                     266
        Module type                             (FORM)
        Module Name                             XAB_RUN_DRIVER
    Please help in this.
    <removed by moderator>
    Edited by: Thomas Zloch on Sep 14, 2011 11:57 AM

    Hi,
    Check your RFC Connection Configuration. Also, check the used username & password.
    Reward points if the asnwer is helpful.
    Regards,

  • Email and fax a form

    Hi ,
           how can we send a form output as email and fax ? How to do the config for this? Can you explain the process to be done?
    Rama.

    Hi,
    See following code :
    REPORT zmail_att NO STANDARD PAGE HEADING LINE-SIZE 200.
    DATA : BEGIN OF ITAB OCCURS 0,
    PERNR LIKE PA0001-PERNR,
    ENAME LIKE PA0001-ENAME,
    END OF ITAB.
    DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,
    receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
    packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
    listobject LIKE abaplist OCCURS 10,
    compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
    w_object_hd_change LIKE sood1,
    compressed_size LIKE sy-index.
    START-OF-SELECTION.
    SELECT PERNR ENAME
    INTO CORRESPONDING FIELDS OF TABLE ITAB
    FROM PA0001
    WHERE PERNR < 50.
    LOOP AT ITAB.
    WRITE :/02 SY-VLINE , ITAB-PERNR, 15 SY-VLINE , ITAB-ENAME, 50
    SY-VLINE.
    ENDLOOP.
    Receivers
    receiver_list-recextnam = 'XXXXX@X...'. --> EMAIL ADDRESS
    RECEIVER_list-RECESC = 'E'. "<-
    RECEIVER_list-SNDART = 'INT'."<-
    RECEIVER_list-SNDPRI = '1'."<-
    APPEND receiver_list.
    General data
    w_object_hd_change-objla = sy-langu.
    w_object_hd_change-objnam = 'Object name'.
    w_object_hd_change-objsns = 'P'.
    Mail subject
    w_object_hd_change-objdes = 'Message subject'.
    Mail body
    APPEND 'Message content' TO message_content.
    Attachment
    CALL FUNCTION 'SAVE_LIST'
    EXPORTING
    list_index = '0'
    TABLES
    listobject = listobject.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    compressed_size = compressed_size
    TABLES
    in = listobject
    out = compressed_attachment.
    DESCRIBE TABLE compressed_attachment.
    CLEAR packing_list.
    packing_list-transf_bin = 'X'.
    packing_list-head_start = 0.
    packing_list-head_num = 0.
    packing_list-body_start = 1.
    packing_list-body_num = sy-tfill.
    packing_list-objtp = 'ALI'.
    packing_list-objnam = 'Object name'.
    packing_list-objdes = 'Attachment description'.
    packing_list-objlen = compressed_size.
    APPEND packing_list.
    CALL FUNCTION 'SO_OBJECT_SEND'
    EXPORTING
    object_hd_change = w_object_hd_change
    object_type = 'RAW'
    owner = sy-uname
    TABLES
    objcont = message_content
    receivers = receiver_list
    packing_list = packing_list
    att_cont = compressed_attachment.
    Reward points if helpful.
    Regards.
    Srikanta Gope

  • E-mail of PDF issue TLINE structure but SOLISTI1 needed

    Hi,
    So far I have done the following. I have prepared a SMARTFORM and an ABAP. My ABAP calls the Smartform and gives the data to the function module “CONVERT_OTF”. This function creates a PDF file from the Smartform data. The output of "CONVERT_OTF" is a table with the format of structure “TLINE”. In a first step I save these data into a PDF file with the function module "GUI_DOWNLOAD".
    Now the issue.
    In the second step I am trying to send the output with the function “SO_DOCUMENT_SEND_API1”. The function is recommended by SAP for release 6.4 instead of the former function "SO_NEW_DOCUMENT_ATT_SEND_API1".
    The attachment must be delivered either with the structure “SOLISTI1” or “SOLIX” to be sent with the e-mail function “SO_DOCUMENT_SEND_API1”. I have tried to put my data with structure TLINE into the function. In these case I get short dumps. If I put the output of the function “CONVERT_OTF” in a table with the format “SOLISTI1” instead of a table with structure “TLINE” a PDF file is still created and also send out with the e-mail function, but the file can’t be opened anymore. Acrobat delivers an error message that the file is damaged.
    I have tried to convert the file with structure TLINE in a hexadecimal file with structure SOLIX. For this purpose I used the function “TABLE_COMPRESS”. This worked fine. But the file which has been sent by the e-mail was still damaged. Even if I have downloaded the file I got the message that the file was damaged.
    Are there any other suggestions how the attachment could be sent instead of using the function “SO_DOCUMENT_SEND_API1”? Is there a function available, which could be used to sent attachments with structure TLINE? Or are there any suggestions, how I can convert my smartform output in a SOLIX or SOLISTI1 structure?
    Thank you and best regards
    Karsten

    Hi Arold,
    <b>1</b>.
    Have a look at this program.
    This program is sending PDF file as attachment thru mail
    <b>2</b>.
    REPORT  zvenkat_mail.
    TABLES :
       tsp01.
    Itabs and variables .
    *Tables
    DATA:
       BEGIN OF i_mard OCCURS 0,
         matnr TYPE mard-matnr,
         werks TYPE mard-werks,
         lgort TYPE mard-lgort,
         labst TYPE mard-labst,
         umlme TYPE mard-umlme,
         insme TYPE mard-insme,
         einme TYPE mard-einme,
       END OF i_mard.
    DATA :
       g_sy_spono LIKE sy-spono.
    Mail related Variables and i tabs.
    DATA:
       w_subject       LIKE sodocchgi1,
       i_pack_list     LIKE sopcklsti1 OCCURS  1  WITH HEADER LINE,
       i_objhead       LIKE solisti1   OCCURS  1  WITH HEADER LINE,
       i_contents_text LIKE solisti1   OCCURS 10  WITH HEADER LINE,
       i_cont_bin      LIKE solisti1   OCCURS 10  WITH HEADER LINE,
       i_objhex        LIKE solix      OCCURS 10  WITH HEADER LINE,
       i_receiver      LIKE somlreci1  OCCURS  1  WITH HEADER LINE,
       i_listobject    LIKE abaplist   OCCURS  1  WITH HEADER LINE,
       pdf             LIKE tline      OCCURS 100 WITH HEADER LINE,
       content_out     LIKE solisti1   OCCURS 0 WITH HEADER LINE.
    DATA:
       tab_lines       TYPE i,
       doc_size        TYPE i,
       att_type        LIKE soodk-objtp,
       obj_desc        LIKE w_subject-obj_descr,
       sent_to_all     LIKE sonv-flag,
       client          LIKE tst01-dclient,
       name            LIKE tst01-dname,
       objtype         LIKE rststype-type,
       type            LIKE rststype-type,
       is_otf          TYPE c ,
       no_of_bytes     TYPE i,
       pdf_spoolid     LIKE tsp01-rqident,
       jobname         LIKE tbtcjob-jobname,
       jobcount        LIKE tbtcjob-jobcount,
       pn_begda        LIKE sy-datum,
       val(1)          TYPE c,
       pripar          TYPE pri_params,
       arcpar          TYPE arc_params,
       lay             TYPE pri_params-paart,
       lines           TYPE pri_params-linct,
       cols            TYPE pri_params-linsz,
       spool_name      TYPE pri_params-plist.
    *&      START-OF-SELECTION.
    START-OF-SELECTION.
      PERFORM get_data_from_database.
      PERFORM output_for_pdf.
    *&      END-OF-SELECTION.
    END-OF-SELECTION.
      PERFORM send_mail..
    *&      Form  get_data_from_database
    FORM get_data_from_database .
      SELECT matnr
             werks
             lgort
             labst
             umlme
             insme
             einme
        FROM mard
        INTO TABLE i_mard
        UP TO 20 ROWS.
    ENDFORM.                    " get_data_from_database
    *&      Form  output_for_pdf
    FORM output_for_pdf .
      PERFORM get_print_params.
      LOOP AT i_mard.
        WRITE:/ sy-vline, i_mard-matnr,
                sy-vline, i_mard-werks,
                sy-vline, i_mard-lgort,
                sy-vline, i_mard-labst,
                sy-vline, i_mard-umlme,
                sy-vline, i_mard-insme,
                sy-vline, i_mard-einme,
                sy-vline.
      ENDLOOP.
      ULINE .
      g_sy_spono = sy-spono.
      NEW-PAGE PRINT OFF.
      CALL FUNCTION 'ABAP4_COMMIT_WORK'.
    ENDFORM.                    " output_for_pdf
    *&      Form  send_mail
    FORM send_mail .
      PERFORM mail_without_attachment.
      PERFORM mail_with_pdf_attachment.
      PERFORM mail_with_exel_attachment.
      PERFORM mail_with_text_attachment.
    ENDFORM.                    " send_mail
    *&      Form  mail_with_pdf_attachment
    FORM mail_with_pdf_attachment .
      CLEAR :w_subject,
             sent_to_all,
             i_pack_list[],
             i_objhead[],
             i_cont_bin[],
             i_contents_text[],
             i_receiver[].
      i_cont_bin = '  |  '.
      APPEND i_cont_bin.
    Subject of the mail.
      obj_desc  = 'Hello SDN Friends ' .
      w_subject-obj_name  = 'MAIL_ALI'.
      w_subject-obj_descr = obj_desc.
    Body of the mail
      DATA :head_desc LIKE i_contents_text,
            body_desc LIKE i_contents_text.
      i_contents_text = space.
      APPEND i_contents_text.
      CLEAR  i_contents_text.
      CONCATENATE
      'This mail has been generated for Test purpose.'
      'Please dont hesitate to ask any type of question in the forum.'
      INTO body_desc
      SEPARATED BY space.
      i_contents_text = body_desc.
      APPEND i_contents_text.
      CLEAR  i_contents_text.
      CLEAR body_desc.
      i_contents_text = 'Thank You.'.
      APPEND i_contents_text.
      CLEAR  i_contents_text.
      i_contents_text = 'Fellow SDN member,'.
      APPEND i_contents_text.
      CLEAR  i_contents_text.
      i_contents_text = 'Venkat.O'.
      APPEND i_contents_text.
      CLEAR  i_contents_text.
      i_contents_text = space.
      APPEND i_contents_text.
      CLEAR  i_contents_text.
      CONCATENATE '(Note: This is system generated message, please'
                  'do not reply'
                  'to this Email.)'
               INTO i_contents_text
               SEPARATED BY space.
      APPEND i_contents_text.
      CLEAR  i_contents_text.
    Write Packing List (Body)
      DESCRIBE TABLE i_contents_text LINES tab_lines.
      READ     TABLE i_contents_text INDEX tab_lines.
      w_subject-doc_size = ( tab_lines - 1 ) * 255 + STRLEN(
      i_contents_text ).
      CLEAR i_pack_list-transf_bin.
      i_pack_list-head_start = 1.
      i_pack_list-head_num   = 0.
      i_pack_list-body_start = 1.
      i_pack_list-body_num   = tab_lines.
      i_pack_list-doc_type   = 'RAW'.
      APPEND i_pack_list.
      CLEAR  i_pack_list.
    Create receiver list
      i_receiver-receiver = '[email protected]'..
      i_receiver-rec_type = 'U'.
      APPEND i_receiver.
      CLEAR  i_receiver.
    Select query for Spool requests
      REFRESH content_out.
      IF sy-subrc = 0.
        SELECT  SINGLE *
          FROM  tsp01
          WHERE rqident = g_sy_spono.
        IF sy-subrc <> 0.
          MESSAGE s000(0k) WITH 'Spool Number does not exist'.
          EXIT.
        ELSE.
          client = tsp01-rqclient.
          name   = tsp01-rqo1name.
        ENDIF.
      ENDIF.
      CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
        EXPORTING
          authority     = 'SP01'
          client        = client
          name          = name
          part          = 1
        IMPORTING
          type          = type
          objtype       = objtype
        EXCEPTIONS
          fb_error      = 1
          fb_rsts_other = 2
          no_object     = 3
          no_permission = 4
          OTHERS        = 5.
      IF objtype(3) = 'OTF'.
        is_otf = 'X'.
      ELSE.
        is_otf = space.
      ENDIF.
    Convert Spool job to PDF
      IF is_otf = 'X'.
        CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
          EXPORTING
            src_spoolid              = tsp01-rqident "Spool req number
            no_dialog                = ' '
          IMPORTING
            pdf_bytecount            = no_of_bytes
            pdf_spoolid              = pdf_spoolid
            btc_jobname              = jobname
            btc_jobcount             = jobcount
          TABLES
            pdf                      = pdf
          EXCEPTIONS
            err_no_otf_spooljob      = 1
            err_no_spooljob          = 2
            err_no_permission        = 3
            err_conv_not_possible    = 4
            err_bad_dstdevice        = 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.
        CASE sy-subrc.
          WHEN 0.
          WHEN 1.
            MESSAGE s000(0k) WITH 'No OTF Spool Job'.
            EXIT.
          WHEN 2.
            MESSAGE s000(0k) WITH 'Spool Number does not exist'.
            EXIT.
          WHEN 3.
            MESSAGE s000(0k) WITH 'No permission for spool'.
            EXIT.
          WHEN OTHERS.
            MESSAGE s000(0k) WITH 'Error in Function CONVERT_OTFSPOOLJOB_2_PDF'.
            EXIT.
        ENDCASE.
      ELSE.
        CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
          EXPORTING
            src_spoolid              = tsp01-rqident
            no_dialog                = ' '
          IMPORTING
            pdf_bytecount            = no_of_bytes
            pdf_spoolid              = pdf_spoolid
            btc_jobname              = jobname
            btc_jobcount             = jobcount
          TABLES
            pdf                      = pdf
          EXCEPTIONS
            err_no_abap_spooljob     = 1
            err_no_spooljob          = 2
            err_no_permission        = 3
            err_conv_not_possible    = 4
            err_bad_destdevice       = 5
            user_cancelled           = 6
            err_spoolerror           = 7
            err_temseerror           = 8
            err_btcjob_open_failed   = 9
            err_btcjob_submit_failed = 10
            err_btcjob_close_failed  = 11
            OTHERS                   = 12.
        CASE sy-subrc.
          WHEN 0.
          WHEN 1.
            MESSAGE s000(0k) WITH 'No ABAP Spool Job'.
            EXIT.
          WHEN 2.
            MESSAGE s000(0k) WITH 'Spool Number does not exist'.
            EXIT.
          WHEN 3.
            MESSAGE s000(0k) WITH 'No permission for spool'.
            EXIT.
          WHEN OTHERS.
            MESSAGE s000(0k)
               WITH 'Error in Function CONVERT_ABAPSPOOLJOB_2_PDF'.
            EXIT.
        ENDCASE.
      ENDIF.
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
        EXPORTING
          line_width_src              = 134
          line_width_dst              = 255
        TABLES
          content_in                  = pdf
          content_out                 = content_out
        EXCEPTIONS
          err_line_width_src_too_long = 1
          err_line_width_dst_too_long = 2
          err_conv_failed             = 3
          OTHERS                      = 4.
      IF sy-subrc <> 0.
        MESSAGE s000(0k) WITH 'Conversion Failed'.
        EXIT.
      ENDIF.
    ---------------------Create Message Attachment
      DESCRIBE TABLE i_cont_bin LINES tab_lines.
      i_pack_list-transf_bin = 'X'.
      i_pack_list-head_start = tab_lines + 1.
      i_pack_list-head_num   = 0.
      i_pack_list-body_start = tab_lines + 1.
      APPEND LINES OF content_out[] TO i_cont_bin[].
      DESCRIBE TABLE content_out LINES tab_lines.
      i_pack_list-doc_size =  tab_lines * 255.
      i_pack_list-body_num = tab_lines.
      i_pack_list-doc_type = 'PDF'.
      i_pack_list-obj_name = 'ATTACHMENT'.
      i_pack_list-obj_descr = 'Materials and their Quantities' .
      APPEND i_pack_list.
      CLEAR  i_pack_list.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = w_subject
          put_in_outbox              = 'X'
          commit_work                = 'X'
        IMPORTING
          sent_to_all                = sent_to_all
        TABLES
          packing_list               = i_pack_list
          object_header              = i_objhead
          contents_bin               = i_cont_bin
          contents_txt               = i_contents_text
          receivers                  = i_receiver
        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 NE 0.
      ENDIF.
    ENDFORM.                    " mail_with_pdf_attachment
    *&      Form  get_print_params
    FORM get_print_params .
      lay = 'X_65_132'.
      lines = 65.
      cols  = 132.
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING
          in_archive_parameters  = arcpar
          in_parameters          = pripar
          layout                 = lay
          line_count             = lines
          line_size              = cols
          no_dialog              = 'X'
        IMPORTING
          out_archive_parameters = arcpar
          out_parameters         = pripar
          valid                  = val
        EXCEPTIONS
          archive_info_not_found = 1
          invalid_print_params   = 2
          invalid_archive_params = 3
          OTHERS                 = 4.
      IF val <> space AND sy-subrc = 0.
        pripar-prrel = space.
        pripar-primm = space.
        NEW-PAGE PRINT ON
          NEW-SECTION
          PARAMETERS pripar
          ARCHIVE PARAMETERS arcpar
          NO DIALOG.
      ENDIF.
    ENDFORM.                    " get_print_params
    I hope it helps u .
    <b>Thanks,
    Venkat.O</b>

  • Urgent - Sending mail with .txt attachment

    Hi
    I am having all the required data to be sent as attachment (.txt) in an internal table.  How do I attach this data to the mail by using the FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    Regards,
    Vijay

    Hi
    Check this one
    first create a Include report with the following coding
    *&  Include           ZPA1_INCLFOR_MAIL                                *
    * 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
    <b>
    Then include that report in the following report and copy the same code and paste it there </b>
    *& Report  ZPA_TEMP147                                                 *
    REPORT  ZPA_TEMP147                             .
    INCLUDE zpa1_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
    Pavan

Maybe you are looking for