cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error while sending email using custom email template using ABAP program.

kiran_jakkaraju
Contributor
0 Likes
634

I have created an email template using CDS View and calling the email Template using ABAP and using below code to send email where I am getting " No data supplied to the template" error. Here is the Code Dump. Any suggestions?

ABAP Code:

    DATA : email_template_name TYPE smtg_tmpl_id VALUE 'ZZ1_DEMO_TEMP',
           sales_order_id TYPE VBAK-VBELN VALUE '0000000040'.


    DATA(bcs) = cl_bcs=>create_persistent( ).

    DATA(email_api) =  cl_smtg_email_api=>get_instance(
            iv_template_id = email_template_name  ).

	DATA(sales_order_cds_key) =
             VALUE if_smtg_email_template=>ty_gt_data_key(
                  ( name = 'SalesDocument'
                    value = sales_order_id ) ).

    TRY.

        " Integrate E-Mail subject and body with email instance
        email_api->render_bcs(
                  io_bcs = bcs
                 iv_language = 'E'
                  iv_language_default = 'E'
                  it_data_key =  sales_order_cds_key

                 ).


        DATA(email_receipient)  =
                   cl_cam_address_bcs=>create_internet_address(
                          'test@email.com' ).

        bcs->add_recipient(
                    EXPORTING i_recipient  = email_receipient    ).

        bcs->send( ) .

        COMMIT WORK .

      CATCH cx_bcs INTO DATA(lx_bcs).
        " Handle the exception, e.g., log or output error message
        out->write( lx_bcs->get_text( ) ).
    ENDTRY.

Code Dump

An exception has occurred in class "CX_SMTG_EMAIL_COMMON". This exception was not caught
in procedure "IF_OO_ADT_CLASSRUN~MAIN" "(METHOD)" or propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated this
exception, the current program was terminated.
The reason for the exception occurring was:
The reason for the exception is:
No data supplied to render email template "ZZ1_DEMO_TEMP"

 

Information on where terminated

The termination occurred in ABAP program or include "CL_SMTG_EMAIL_RENDERER========CP", in "APPLY". The
main program was "SAPMSSY1".

In the source code, the termination point is in line 55 of include "CL_SMTG_EMAIL_RENDERER========CM001".
include "CL_SMTG_EMAIL_RENDERER========CM001".
The termination is due to exception "CX_SMTG_EMAIL_COMMON" occurring in procedure "IF_OO_ADT_CLASSRUN~MAIN" "(METHOD)",
but not being handled locally there or being declared in the RAISING
clause.
The procedure is in program "ZABAP_TEMP=============CP". Its source code begins in line 1 of
include "ZABAP_TEMP=============CM001".

Accepted Solutions (0)

Answers (0)