Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass records with length more than 255 in an excel sheet

former_member199650
Participant
0 Kudos

Hi all,

Please guide: while sending email through an abap report, i am not able to send an excel sheet with record length more than 255 characters. kindly guide me in doing that.

Thanks and Regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello,

Check this wiki code snippet [https://wiki.sdn.sap.com/wiki/display/Snippets/Tosendamailattachmentwithmorethan255charactersinaline]

Vikranth

3 REPLIES 3

Former Member
0 Kudos

Hello,

Check this wiki code snippet [https://wiki.sdn.sap.com/wiki/display/Snippets/Tosendamailattachmentwithmorethan255charactersinaline]

Vikranth

Former Member
0 Kudos

Hi , Try out this code

data :      i_objtxt          TYPE TABLE OF solisti1,
               wa_i_objtxt  LIKE LINE OF i_objtxt,

                i_reclist        TYPE TABLE OF somlreci1 ,
               wa_i_reclist  LIKE LINE OF i_reclist,

                i_doc_chng  TYPE sodocchgi1,
                g_lines         TYPE sy-tabix,

                i_objpack     TYPE TABLE OF sopcklsti1,
               wa_i_objpack LIKE LINE OF i_objpack,

                i_mail_att     TYPE STANDARD TABLE OF solix,

                g_string       TYPE string,
                g_xstring     TYPE xstring,
                l_mail_data TYPE string.


constants :  c_tab                     TYPE x VALUE '09',            
                    c_tabname            TYPE c VALUE cl_abap_char_utilities=>cr_lf.


*t_grid is an outpppput table .

LOOP AT t_grid.


    CONCATENATE  t_grid-matnr
                               t_grid-atwrt
                               t_grid-maktx
                               t_grid-lgtyp
                               t_grid-lgpll
                               INTO l_mail_data SEPARATED BY c_tab
                               CONDENSE l_mail_data.
                               CONCATENATE g_string l_mail_data INTO g_string SEPARATED BY  c_tabname.
    ENDLOOP.


    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
      EXPORTING
        text   = g_string
        IMPORTING
        buffer = g_xstring.


    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        buffer     = g_xstring
      TABLES
        binary_tab = i_mail_att.


pass i_mail_att, along with other tables to below FM.


  CLEAR wa_i_objpack-transf_bin.

  wa_i_objpack-head_start = 1.

  wa_i_objpack-head_num = 0.

  wa_i_objpack-body_start = 1.

  wa_i_objpack-body_num = g_lines.

  "Formating of XLS should only be applied to attchment ,
  "While body of email should remain RAW to distinguish the
  "attchment.
*  wa_i_objpack-doc_type = 'XLS'.
  wa_i_objpack-doc_type = 'RAW'.

  APPEND wa_i_objpack TO i_objpack.
  CLEAR wa_i_objpack.


  DESCRIBE TABLE  i_mail_att LINES g_lines.
*  DESCRIBE TABLE i_objbin LINES g_lines.

*Creating the entry for the compressed attachment

  wa_i_objpack-transf_bin = c_x.

  wa_i_objpack-head_start = 1.

  wa_i_objpack-head_num   = 1.

  wa_i_objpack-body_start = 1.

  wa_i_objpack-body_num   = g_lines.

  wa_i_objpack-doc_type   = 'XLS'.

  wa_i_objpack-obj_name   = 'ATTACHMENT'.

  wa_i_objpack-obj_descr  = 'Stock View Report'.

  wa_i_objpack-doc_size   = g_lines * 255.

  APPEND wa_i_objpack TO i_objpack.


  CLEAR i_reclist[].
  wa_i_reclist-rec_type = 'U'.
  wa_i_reclist-receiver = p_id.
  PERFORM touppercase CHANGING wa_i_reclist.
  APPEND wa_i_reclist TO i_reclist.




CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data              = i_doc_chng
      put_in_outbox                = c_x
      commit_work                  = c_x
    TABLES
      packing_list                     = i_objpack
      contents_txt                    = i_objtxt
      contents_hex                  = i_mail_att
      receivers                         = i_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                                  = 99.



IF  sy-subrc. = 0.

      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                      AND RETURN.
ENDIF.

Edited By

Tejaswini Khante

former_member199650
Participant
0 Kudos

Please keep on sending ur valuable replies. Thanks and Regards