Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

where to pass the Internal table for sending mail via ABAP

Hi All,

I have got the code to send my internal table contents as a mail to clients,and it works fine too.

But i face a Problem here with Alignment. Actually the content is not aligned - quite haphazard and getting merged with other columns.

Please find the code below:

TRY.

*     -------- create persistent send request ------------------------

       gv_send_request = cl_bcs=>create_persistent( ).

*     -------- create and set document -------------------------------

*     create text to be sent

       wa_line = text-001.

       APPEND wa_line TO gt_text.

       CLEAR wa_line.

       APPEND wa_line TO gt_text.

       LOOP AT gt_fail ASSIGNING <fs_fail>.

         MOVE <fs_fail>-retry_count TO gv_count.

         CONCATENATE text-002

                     <fs_fail>-setting_id

                     text-003

                     gv_count

                     INTO wa_line SEPARATED BY space.

         APPEND wa_line TO gt_text.

         CLEAR wa_line.

       ENDLOOP.

       APPEND wa_line TO gt_text.

       wa_line = text-007.

       APPEND wa_line TO gt_text.

*     create actual document

       gv_document = cl_document_bcs=>create_document(

                       i_type    = 'RAW'

                       i_text    = gt_text

                       i_length  = '12'

                       i_subject = 'Failed Precalculation Settings!' ).

*     add document to send request

       CALL METHOD gv_send_request->set_document( gv_document ).

*     --------- set sender -------------------------------------------

       gv_sender = cl_sapuser_bcs=>create( sy-uname ).

       CALL METHOD gv_send_request->set_sender

         EXPORTING

           i_sender = gv_sender.

*     --------- add recipient (e-mail address) -----------------------

       LOOP AT s_email INTO wa_email.

         MOVE wa_email-low TO gv_email.

         gv_recipient = cl_cam_address_bcs=>create_internet_address(

                                           gv_email ).

         CALL METHOD gv_send_request->add_recipient

           EXPORTING

             i_recipient = gv_recipient

             i_express   = 'X'.

       ENDLOOP.

*     ---------- set to send immediately -----------------------------

       CALL METHOD gv_send_request->set_send_immediately( 'X' ).

*     ---------- send document ---------------------------------------

       CALL METHOD gv_send_request->send(

         EXPORTING

           i_with_error_screen = 'X'

         RECEIVING

           result              = gv_sent_to_all ).

       IF gv_sent_to_all = 'X'.

         WRITE text-004.

       ENDIF.

       COMMIT WORK.

*   exception handling

     CATCH cx_bcs INTO gv_bcs_exception.

       WRITE: text-005.

       WRITE: text-006, gv_bcs_exception->error_type.

       EXIT.

   ENDTRY.

with the following declarations

* -------------------------------------------------------------------- *

* TABLES                                                               *

* -------------------------------------------------------------------- *

TABLES:

   adr6,

   rsr_prec_sett.

* -------------------------------------------------------------------- *

* INTERNAL TABLES & WORK AREAS                                         *

* -------------------------------------------------------------------- *

DATA:

   gt_fail          TYPE SORTED TABLE OF rsr_prec_sett

                         WITH UNIQUE KEY setting_id run_date,

   gt_text          TYPE bcsy_text,

   wa_fail          LIKE LINE OF gt_fail,

   wa_line(90)      TYPE c.

FIELD-SYMBOLS:

   <fs_fail>        LIKE LINE OF gt_fail.

* -------------------------------------------------------------------- *

* VARIABLES                                                            *

* -------------------------------------------------------------------- *

DATA:

   gv_count(4)      TYPE n,

   gv_send_request  TYPE REF TO cl_bcs,

   gv_document      TYPE REF TO cl_document_bcs,

   gv_sender        TYPE REF TO cl_sapuser_bcs,

   gv_recipient     TYPE REF TO if_recipient_bcs,

   gv_email         TYPE adr6-smtp_addr,

   gv_bcs_exception TYPE REF TO cx_bcs,

   gv_sent_to_all   TYPE os_boolean.

* -------------------------------------------------------------------- *

* SELECTION-SCREEN                                                     *

* -------------------------------------------------------------------- *

SELECT-OPTIONS:

   s_email          FOR adr6-smtp_addr NO INTERVALS MODIF ID sel.

DATA:

   wa_email         LIKE LINE OF s_email.

Also, Could you let me know where in the above code I pass the internal table. I have My own Internal table, Not gt_fail.

Regards

Dileep VT

Former Member
Not what you were looking for? View more on this topic or Ask a question