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 email dynamic table in email body & as attachment

amar_parab
Discoverer
0 Kudos

Hi Sir,

I need some help in sending dynamic internal table content in email body & as excel attachment. I am able to generate dynamic table, but not getting any clue on how to accomplish emailing. It would be really great, If you can help me with some logic or code.

Below is the dynamically generated table. Columns/Row count may vary.

7 REPLIES 7

amar_parab
Discoverer
0 Kudos

Hi Guru's, please help with some solution.

Tomas_Buryanek
Active Contributor

Where exactly do you have problem? What have you already tried? There are MANY answered questions (with examples and codes) on the forum about the same topic/s.

  • For creating excel file I suggest try SALV (CL_SALV_TABLE and its method TO_XML, which can create excel file quite easily) or ABAP2XLSX (little complicated if it is new for you, but it good investment for your future work with XLSX files in ABAP).
  • As for e-mail, you can not go wrong with cl_bcs.
-- Tomas --

0 Kudos

Hi Thomas,

Firstly thanks for the revert. Herewith I am sharing the downloaded program code from SAP & snapshot of sample output. I need some code to put output contents of dynamic table in Email Body & same need to email as xls attachment to multiple users. I commented the message body in code since not getting any clue on how to add dynamic table contents in it. Also final table which is getting displayed in alv report, I want this to email as excel attachment.

Can you provide some solution with maybe some code to refer.

output.png

reportcode.txt

0 Kudos
amar.parab
  • Table to excel file - check my answer. It will work with dynamic table too.
  • Table to e-mail body - you would probably need to program this (simple HTML table string - concatenate <table>, <tr>, <td> tags with values...). Loop the dynamic table to structure, and then loop through components of structure (since it is dynamic). Here is example of code how to get dynamic table values.
-- Tomas --

0 Kudos

Hi Frederic,

Need help on sending dynamic internal table as email body & excel attachment. How to accomplish this.

Thanks.

0 Kudos

For translating your Dynamic table to Excel file, tomas.buryanek gives you the solution with Abap2Xls

For the email with attachment, I give you my blog url