Application Development and Automation 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: 
Read only

New line functionality - Separate rows inside a email body.

Former Member
0 Likes
4,495

Hi All,

I am building a email body but I need to have the details separated on each row.

Even if I append the details to the email body internal table, they still show on the same row.

Below is my code:

data : subject_text(50) type c,

          w_subject  TYPE so_obj_des,

          w_bodyx           TYPE tdline,

          w_main_text       TYPE bcsy_text,

          c_body_text1(50) TYPE c,

          c_body_text2(50) TYPE c,

          c_body_text3(50) TYPE c,

          c_body_text4(50) TYPE c,

          L_error_CNT(4) TYPE c,

          l_error_WARN(4) TYPE c.

DATA: lo_send_request   TYPE REF TO cl_bcs,

       lo_recipient      TYPE REF TO if_recipient_bcs,

       lo_document       TYPE REF TO cl_document_bcs,

         c_raw TYPE char3 VALUE 'RAW',

         c_x TYPE c VALUE 'X',

         w_sent_to_all     TYPE os_boolean,

       lo_bcs_exception  TYPE REF TO cx_bcs.

      subject_text = 'Code inspector error notification:'.

      l_error_cnt = lr_ci_tests->tree->err_cnt.

      l_error_WARN = lr_ci_tests->tree->warn_cnt.

* Picking up the Subject

      CONCATENATE subject_text request INTO w_subject SEPARATED BY ''.

*   Picking up the body

      c_body_text1 = 'Total number of errors:'.

      c_body_text2 = 'Total number of warnings:'.

      c_body_text3 = 'Transport request details:'.

      c_body_text4 = 'Task number:'.

      data: ls_e070 type e070,

            lv_req_descr type as4text.

      select single * into ls_e070 from e070 where trkorr = request.

      if ls_e070-strkorr is not initial.

        select single AS4TEXT

           into lv_req_descr

           from E07T

           where trkorr =  ls_e070-strkorr.

      endif.

      CONCATENATE c_body_text3 ls_e070-strkorr lv_req_descr INTO W_bodyx SEPARATED BY ''.

      APPEND W_bodyx TO w_main_text.

      clear W_bodyx.

      CONCATENATE c_body_text4 request INTO W_bodyx SEPARATED BY ''.

      APPEND W_bodyx TO w_main_text.

      CLEAR w_bodyx.

      CONCATENATE c_body_text1 l_error_cnt INTO w_bodyx  SEPARATED BY ''.

      APPEND w_bodyx TO w_main_text.

      CLEAR w_bodyx.

      CONCATENATE c_body_text2 l_error_WARN INTO w_bodyx  SEPARATED BY ''.

      APPEND w_bodyx TO w_main_text.


Output shows as below:

Transport request details: PDSK900832 Testing 12 Task number: PDSK901697

Total number of errors: 5

Total number of warnings:   0

How it should look like:

Transport request details: PDSK900832 Testing 12

Task number: PDSK901697

Total number of errors: 5

Total number of warnings:   0

Any help is much appreciated.

Best regards,

Elena

1 ACCEPTED SOLUTION
Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
3,348

Hi Elena,

Please try with below code .


      CONCATENATE c_body_text3 ls_e070-strkorr lv_req_descr INTO W_bodyx SEPARATED BY ''.

      CONCATENATE W_bodyx CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO W_bodyx."-->add new line

      APPEND W_bodyx TO w_main_text.

      clear W_bodyx.

      CONCATENATE c_body_text4 request INTO W_bodyx SEPARATED BY ''.

      CONCATENATE W_bodyx CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO W_bodyx.

      APPEND W_bodyx TO w_main_text.

      CLEAR w_bodyx.

      CONCATENATE c_body_text1 l_error_cnt INTO w_bodyx  SEPARATED BY ''.

      CONCATENATE W_bodyx CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO W_bodyx.

      APPEND w_bodyx TO w_main_text.

      CLEAR w_bodyx.

      CONCATENATE c_body_text2 l_error_WARN INTO w_bodyx  SEPARATED BY ''.

     CONCATENATE W_bodyx CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO W_bodyx.

      APPEND w_bodyx TO w_main_text.

Thanks

Hi All,

I am building a email body but I need to have the details separated on each row.

Even if I append the details to the email body internal table, they still show on the same row.

Below is my code:

data : subject_text(50) type c,

          w_subject  TYPE so_obj_des,

          w_bodyx           TYPE tdline,

          w_main_text       TYPE bcsy_text,

          c_body_text1(50) TYPE c,

          c_body_text2(50) TYPE c,

          c_body_text3(50) TYPE c,

          c_body_text4(50) TYPE c,

          L_error_CNT(4) TYPE c,

          l_error_WARN(4) TYPE c.

DATA: lo_send_request   TYPE REF TO cl_bcs,

       lo_recipient      TYPE REF TO if_recipient_bcs,

       lo_document       TYPE REF TO cl_document_bcs,

         c_raw TYPE char3 VALUE 'RAW',

         c_x TYPE c VALUE 'X',

         w_sent_to_all     TYPE os_boolean,

       lo_bcs_exception  TYPE REF TO cx_bcs.

      subject_text = 'Code inspector error notification:'.

      l_error_cnt = lr_ci_tests->tree->err_cnt.

      l_error_WARN = lr_ci_tests->tree->warn_cnt.

* Picking up the Subject

      CONCATENATE subject_text request INTO w_subject SEPARATED BY ''.

*   Picking up the body

      c_body_text1 = 'Total number of errors:'.

      c_body_text2 = 'Total number of warnings:'.

      c_body_text3 = 'Transport request details:'.

      c_body_text4 = 'Task number:'.

      data: ls_e070 type e070,

            lv_req_descr type as4text.

      select single * into ls_e070 from e070 where trkorr = request.

      if ls_e070-strkorr is not initial.

        select single AS4TEXT

           into lv_req_descr

           from E07T

           where trkorr =  ls_e070-strkorr.

      endif.

      CONCATENATE c_body_text3 ls_e070-strkorr lv_req_descr INTO W_bodyx SEPARATED BY ''.

      APPEND W_bodyx TO w_main_text.

      clear W_bodyx.

      CONCATENATE c_body_text4 request INTO W_bodyx SEPARATED BY ''.

      APPEND W_bodyx TO w_main_text.

      CLEAR w_bodyx.

      CONCATENATE c_body_text1 l_error_cnt INTO w_bodyx  SEPARATED BY ''.

      APPEND w_bodyx TO w_main_text.

      CLEAR w_bodyx.

      CONCATENATE c_body_text2 l_error_WARN INTO w_bodyx  SEPARATED BY ''.

      APPEND w_bodyx TO w_main_text.


Output shows as below:

Transport request details: PDSK900832 Testing 12 Task number: PDSK901697

Total number of errors: 5

Total number of warnings:   0

How it should look like:

Transport request details: PDSK900832 Testing 12

Task number: PDSK901697

Total number of errors: 5

Total number of warnings:   0

Any help is much appreciated.

Best regards,

Elena

3 REPLIES 3
Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
3,349

Hi Elena,

Please try with below code .


      CONCATENATE c_body_text3 ls_e070-strkorr lv_req_descr INTO W_bodyx SEPARATED BY ''.

      CONCATENATE W_bodyx CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO W_bodyx."-->add new line

      APPEND W_bodyx TO w_main_text.

      clear W_bodyx.

      CONCATENATE c_body_text4 request INTO W_bodyx SEPARATED BY ''.

      CONCATENATE W_bodyx CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO W_bodyx.

      APPEND W_bodyx TO w_main_text.

      CLEAR w_bodyx.

      CONCATENATE c_body_text1 l_error_cnt INTO w_bodyx  SEPARATED BY ''.

      CONCATENATE W_bodyx CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO W_bodyx.

      APPEND w_bodyx TO w_main_text.

      CLEAR w_bodyx.

      CONCATENATE c_body_text2 l_error_WARN INTO w_bodyx  SEPARATED BY ''.

     CONCATENATE W_bodyx CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO W_bodyx.

      APPEND w_bodyx TO w_main_text.

Thanks

Read only

0 Likes
3,348

It worked.

Thank you very much.

Have a wonderful day ahead!

Best regards,

Elena

Read only

tharu
Contributor
0 Likes
3,348

Dear Elena,

Send the Email body with HTML format. It is very easy..

Sending a mail in HTML format with multiple images in the body of the mail

Thanks

Tharaka