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: 

Problem with the Excel File sent as a E-Mail Attachment from SAP

Former Member
0 Kudos

Hi,

I'm sending an Excel(.XLS) file as an attachment to an E-Mail from SAP by using the CL_BCS class.

The problem with the attached Excel file is that it has a column which consists of MATERIAL number.

I've material numbers like "575121.010".

These are being displayed as "575121.01" with the trailing zeros being truncated in the excel file.

When I open the Excel file from the E-Mail, the Material Number is Not being formatted as a text.

Instead all the columns are being formatted as 'General'.

Is there a way in SAP which allows me to format the Excel column properties as TEXT while creating the File.

FYI.

I'm creating the EXCEL document in SAP by using the process below.

I'm creating the document by using the cl_document_bcs=>create_document( ) with type as "RAW".

After that I'm attaching the document to the mail and sending the document as an attachment with the mail.

Please help me with this one.

Regards,

Narayana Reddy A V L.

1 ACCEPTED SOLUTION

Emre_tr
Active Participant
0 Kudos

we used 'HTM'  for I_TYPE parameter, maybe it solves your problem.

10 REPLIES 10

Former Member
0 Kudos

Hi Narayana,

Please check the following link. It may helpful for your scenario.

http://wiki.sdn.sap.com/wiki/display/Snippets/Formatted+Excel+as+Email+Attachment

Regards,

Vanita

0 Kudos

Hi vanita,

Thanks for the early reply.

I've gone through the link given by you.

Is there any other possibility to format the excel column as TEXT by not using the XML concept ( OLE will not be helpful as I'm scheduling my program as a background job) .

As of now I'm sending it using CL_BCS class. Is there any possibility to use the CL_BCS class to format the excel attachment.

Thank you.

Regards,

Narayana Reddy A V L.

Emre_tr
Active Participant
0 Kudos

we used 'HTM'  for I_TYPE parameter, maybe it solves your problem.

Former Member
0 Kudos

Hi Emre,

Thanks for the reply.

I have tried using 'HTM'. But still the problem is there. The excel file columns are being formatted as "General" only and the trailing zeros are being truncated in the excel file.

Is there any other way to format the columns.

Thanks.

Regards,

Narayana  Reddy A V L.

Former Member
0 Kudos

Hi

try to this code.

LV_MATNR = '575121.010'.

CONCATENATE '=REPLACE("' LV_MATNR '";1;20;"'
       LV_MATNR '")'  INTO LV_MATNR_OUT .

EXCEL_TAB-MATNR = LV_MATNR_OUT.

Former Member
0 Kudos

Thanks Luis,

I've solved my problem by using the above piece of code and the excel file is now displaying the Trailing Zeros without any problem.

The below statement is the one which I had used in my program and it solved my issue.

CONCATENATE '=REPLACE("' lv_matnr '",1,40,"' lv_matnr '")' INTO lv_matnr.

Thanks for the help.

Regards,

Narayana Reddy A V L.

Emre_tr
Active Participant
0 Kudos

Hi,

if the last method isn't solved your problem, i think you must use OLE to create excel file then attach and send mail.

with your method you can't format excel format because you create a tab delimated file and change extention to xls, it's a tricky method.

Former Member
0 Kudos

Thanks Emre,

My issue has been resolved by using the code given by Luis.

Thanks again for all the help.

Regards,

Narayana Reddy A V L.

Emre_tr
Active Participant
0 Kudos

Former Member
0 Kudos

Thank you everyone for all the support.

I'm closing the Discussion.

Regards,

Narayana Reddy A V L.