Skip to Content

Part 1: Introduction

Part 2: Configuration table and rendering class

Part 3: Creating a template and a demo report

Part 4: Conclusion

After creating the configuration table and the email rendering class in Part 2. Now, we are going to generate the first template and write a DEMO report.

Open a new Word document, and type-in whatever you wish.

1. Set &&<fieldname>&& for dynamic values. That is, values that you want to get at runtime from the SAP system.

2. As an image tag, you just type in the name of the picture which you will later set in the configuration table.
/wp-content/uploads/2014/04/mail_435849.png
Save the file as Web Page, Filtered:

save as.png

Check in the document into the SAP system using DMS (I want show you the steps as they might differ from system or DMS version). But remember the document information record (DIR) key.

Component Description
DOKAR Document Type
DOKNR Document Number
DOKTL Document Part
DOKVR Document Version

You will need to fill this in the configuration table afterwards:

/wp-content/uploads/2014/04/table_435857.png

To try out how it works, just copy-paste the following code into a new report:

report yrisctu1_app5.

” as an example, a nested structure
types:
 
begin of ts_struct1,
      scarr
type scarr_tab,
   
end of ts_struct1,
 
begin of ts_struct2,
      struct1
type ts_struct1,
      dir_id
type /plmb/s_dir_id,
   
end of ts_struct2,
 
begin of ts_struct3,
      struct2
type ts_struct2,
      matnr  
type /plmb/matnr,
   
end of ts_struct3.

data:

  lo_mail       type ref to ycl_erf_request,
  lt_recipients
type yerf_tty_recipient,
  ls_config_id 
type yerf_str_config_id,
  ls_data      
type ts_struct3.

field-symbols:
  <fs_recipient>
type yerf_str_recipient.

” object name is unique in the system (you have to maintain database table YERF_T_CONFIG)
ls_config_id
applicationid = `YERF_DEMO`.
ls_config_id
counter       = `001`.

” set recipient(s)
append initial line to lt_recipients[] assigning <fs_recipient>.
<fs_recipient>
smtp          = syuname.   ” OR `myEmailAddress@Company.com`
<fs_recipient>
is_copy       = abap_false. ” abap_true for CC
<fs_recipient>
is_blind_copy = abap_false. ” abap_true for BCC

perform fill_data.

try.
  
” create email request
   
create object lo_mail
     
exporting
        iv_subject    
= `TEST`
        iv_sender     
= `test_mail@xyz.com`
        it_recipients 
= lt_recipients[]
*       it_attachments = ” for this example, I didn’t use any attachments
        is_data       
= ls_data
        is_config_id  
= ls_config_id.

    if lo_mail is bound.
      lo_mail
->send( ).
   
endif.

  catch ycx_erf_not_created
        ycx_erf_not_sent
.
   
” handle exception
endtry.

*&———————————————————————*
*&      Form  FILL_DATA
*&———————————————————————*
form fill_data.

  ls_datamatnr = `12345600`.
  ls_data
struct2dir_iddocumenttype    = `D11`.
  ls_data
struct2dir_iddocumentnumber  = `1234567890123456789012345`.
  ls_data
struct2dir_iddocumentpart    = `001`.
  ls_data
struct2dir_iddocumentversion = `01`.

  select *
        
up to 10 rows
        
from scarr
        
into corresponding fields of table ls_datastruct2struct1scarr[].

endform.

This is basically it. If I missed something, please comment bellow and I’ll answer ASAP. I know I didn’t explain very thing, but it’s not really that complicated. I’ll let you figure it out by yourself 🙂

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply