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

convert attachment format from HTML to EXCEL

Former Member
0 Likes
5,367

Hi All,

I have existing program which sends email with HTML attachment. I would like to convert the attachment format to EXCEL format. Do you have any idea on how to do this?

I did some research and found that it can be done via SCOT config. But i just want to make sure that there's no abap code change. The program used FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'. Packing list documnet type is HTM.

Please advice.

Thanks so much in advance.

Hi All,

I have existing program which sends email with HTML attachment. I would like to convert the attachment format to EXCEL format. Do you have any idea on how to do this?

I did some research and found that it can be done via SCOT config. But i just want to make sure that there's no abap code change. The program used FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'. Packing list documnet type is HTM.

Please advice.

Thanks so much in advance.

15 REPLIES 15
Read only

venkat_o
Active Contributor
0 Likes
3,122

Hi, <li>I think that you have to modify code to send mail with XLS attachment, set below one after attachment table is built.

w_packing_list-doc_type   = 'XLS'.
<li>Check the existing packing table how the data is passed when docutype is HTM. Thanks Venkat.O

Read only

Former Member
0 Likes
3,122

Thanks for prompt reply.

I have changed the document type to 'XLS'. But the problem now, the excel doesn't contain correct output. I think is more of unicode characters.

Can you help me on this? Thanks

Read only

0 Likes
3,122

Hi, <li>There are 3 exp parameters related to attachments in FM


CONTENTS_BIN	LIKE	SOLISTI1	Obsolete: See Contents_Hex
CONTENTS_TXT	LIKE	SOLISTI1	ASCII contents of object and attachments
CONTENTS_HEX	LIKE	SOLIX	Binary contents of object and attachments
<li>If you are sending text file or xls file as attachments, use CONTENTS_TXT parameter instead of CONTENTS_BIN and CONTENTS_HEX. Thanks Venkat.O

Read only

Former Member
0 Likes
3,122

I still get the wrong excel contents. The excel contains the html codes. what would I need to correct the values on excel.

Appreciate your help. Thanks a lot.

Read only

0 Likes
3,122

Dear friend, <li>Go through the program where attachment is being built, there you will see HTML tags, then decide instead of HTML tags, what needs to be replaced. Thanks Venkat.O

Read only

0 Likes
3,122

2 things you can do!!

1) First write a sample program for sending excel attachment mail

->You can definetly tons of programs here or in your own system also you can see ...its easy way

-> Then you can Compare the Excel mail attachment program with the Existing HTML program

2) At last nothing works out ..Please past your code !! But make it as final option

Best wishes

sas

Read only

praveen_hannu
Contributor
0 Likes
3,122

Hi

First you need to check in your program, how they are filling the attachement table while passing the "SO_NEW_DOCUMENT_ATT_SEND_API1"

Define a new internal table type solisti1 and try to fill the contents seperated by '#' or CL_ABAP_CHAR_UTILITIES-HORIZONTAL_TAB

packlist-doc_type 'XLS' and try to execute the fm.

Thanks

Praveen

Read only

Former Member
0 Likes
3,122

Hi,

SAP_CONVERT_TO_XLS_FORMAT function module converts data to excel format.

Read only

Former Member
0 Likes
3,122

hi Akaira,

you can use the following function module "SO_NEW_DOCUMENT_ATT_SEND_API1"

use the fiollowing class "cl_abap_char_utilities" to build the Excel data table from this class use the attributes "CR_LF" and "HORIZONTAL_TAB",

or

if you kow the SpoolID then you can do the following thing

Use Function "RSPO_DISPLAY_SPOOLJOB" to automate the process of display.

u then can download to Excel.

"RSPO_DOWNLOAD_SPOOLJOB" downloads to a flat fileThat could be processed to CSV & captured into Excel.

Try "SE37 RSPO_DOWNLOAD_SPOOLJOB" single test nothing could be easier.

and simple and easy manual process is :

1. SP01 and see your entry

2. Click on Type or Display Button or F6

3. It may show 1st 10 pages

4. Click on settings in the display

Change last page

5. Ignore memory warning - whisper 'Joy Ma Kaali'

6. Right click & Save to Local File as Excel!

************************************************************************************************

if it is not clear then please let me know I will provide you the example program

Regards,

Arif

Read only

0 Likes
3,122

Hi,

what ever way you go, it will never work in background. The excel installation on your client (PC) must be used to create MS excel proprietary format.

If you do not want proprietary binary MS excel format but something excel can read (tab-delimited, CSV, mhtmlm...) there are more ways. But first you need to know what you want.

Regards,

Clemens

Read only

OttoGold
Active Contributor
0 Likes
3,122

I don´t understand exactly why do you need to do this. But if you want to generate the Excel programatically, you can use approach presented in my blog here: /people/otto.gold/blog/2010/02/11/happy-reporting-with-excel-ii

Otto

Read only

Former Member
0 Likes
3,122

thanks to all your replies.

I need to convert the html format because it caused too big file attachment which exceeds to 20 MB.

Now, i am able to get the html file but the contents are displayed in the first line of the excel.

Do you have any ideas on this?

Thanks again.

Read only

0 Likes
3,122

Hi akira,

if size is the issue, i wonder why any excel shouls be significantly smaller.

You can use Class CL_ABAP_GZIP and its static methods

COMPRESS_TEXT
DECOMPRESS_TEXT
COMPRESS_BINARY
DECOMPRESS_BINARY

to shrink to an appropriate size.

Regards,

Clemens

Read only

OttoGold
Active Contributor
0 Likes
3,122

what ever way you go, it will never work in background

This is not true!! If you would read a blog I have mentioned above (part 2), you would understand that works the way it generates the xml file which is then interpreted as Excel file. Maybe you can do a little check first.

Otto

Read only

Clemenss
Active Contributor
0 Likes
3,122

Hi Otto,

what ever way you go, it will never work in background is what I wrote. And I continued

The excel installation on your client (PC) must be used to create MS excel proprietary format.

If you do not want proprietary binary MS excel format but something excel can read (tab-delimited, CSV, mhtmlm...) there are more ways. But first you need to know what you want.

And this is still true. more ways includes background processing.

Anyway, obviously file size is the issue, not file format. As I said, need to know what you want is quite important.

do a little check first is always helpful, but: People do not always have the time for such things

Regards,

Clemens