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: 

Export to excel characters truncated

Former Member
0 Kudos

Dear Experts,

I have KUNNR as 3rd column in ALV output. When I export ALV data to excel using standard alv functionality I can see that the last digit gets truncated. Assume KUNNR has value 0000123456. In excel its coming as 12345 and last number 6 gets truncated. I found many threads for this. Solution proposed was to use conversion exit. I did the same. Now in excel I am getting all numbers. But in report output the leading zeroes are removed because of conversion exit.

Is there a way to get all numbers without conversion exit so that my excel data is not truncated as well as my report output has leading zeroes.

I have tried below,

WA_FIELDCAT-OUTPUTLEN = 12.
WA_FIELDCAT-ddic_outputlen = 12.
WA_FIELDCAT-datatype = 'CHAR'.
WA_FIELDCAT-REF_TABNAME = 'IT_OUT'.
WA_FIELDCAT-REF_FIELDNAME = 'KUNNR'.

I tried all above 5 options suggested in different threads one after the other. But I can see that only conversion exit option works and the rest of the above are not. I actual data type of KUNNR is CHAR 10. I increased it to 12 characters. Still no effect.

Please share your valuable inputs.

Br,

Bharath

Edited by: bharath padmanabhan on Oct 13, 2011 4:06 PM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI..

wa_fieldcat-outputlen = 12. means it gives 12 characher spaces to display the value only.

for displaying zero's try..

wa-fieldcat-no_zero = SPACE.

try it i am not sure about that.

12 REPLIES 12

Former Member
0 Kudos

HI..

wa_fieldcat-outputlen = 12. means it gives 12 characher spaces to display the value only.

for displaying zero's try..

wa-fieldcat-no_zero = SPACE.

try it i am not sure about that.

0 Kudos

Dear Anurag,

Thanks for your reply. Currently preceeding zeroes are coming perfectly in my report. Say if there is a KUNNR 0000012345 its getting displayed in report output properly with zeroes. But problem in this case is that if i download that output to excel then in excel I am getting KUNNR as 1234 alone and there are no preceeding zeroes which is fine but the last number 5 gets truncated. As I have said before to avoid this if i use the conv. exit the data in excel is coming correctly without truncation. But problem in this case the output of report is displayed without preceeding zeroes since I have used conv. exit. Say for eg KUNNR is displayed in report output as 12345 without zeroes. But in excel I am getting the value correctly as 12345.

My customer is asking whether there is way where I can get the preceeding zeroes also in report output & also when I download the data to excel the data should not be without any truncation.

Br,

Bharath

0 Kudos

Hi ,

SAve data in Unconverted Format => .txt and open file in XLS .

regards

Deepak.

0 Kudos

Hi,

I think you have more options if you save in unconverted format as Deepak said, but then start Excel and use function Import external data where you can fix the different format for any column. Text columns shouldn't be converted.

Regards,

Klaus

0 Kudos

Dear Deepak,

Thanks for your reply. I tried you suggestion. I observed that,

1. The number is still getting truncated when I open in excel

2. The data in excel is not easily readable compared to the way I used to get when I directly download it as excel. Lot of

separators are coming in excel and the columns are not neatly arranged which makes it difficult for user to understand.

Br,

Bharath

0 Kudos

Dear klaus,

Thanks for your reply.

With help from google I learnt how to import data in excel and I tried your suggestion. But I feel that it involves lot of steps to achieve the functionality. This demands a separate training for the users but with a large userbase I fear its not possible to educate every user about the same. Is there some way in coding wise wherein we as a developer can achieve the same so that end users can directly download the excel and see the KUNNR column without any truncation.

Br,

Bharath

Edited by: bharath padmanabhan on Oct 13, 2011 5:49 PM

0 Kudos

Hi ,

Steps to Follow :

1) Open blank excel

2) import TXT file

3) select Delimited

4) Then go next

I DOn't Think there will be more problem .

regards

Deepak.

0 Kudos

Dear Deepak,

Thanks for your reply. Customer is not ready to download the details in TXT file and then look for a way to open it in excel. He wants to see the details directly in Excel.

Since I could not find any option I have convinced the customer with the conversion exit option using which the leading zeroes in

report output will be truncated but the customer no in excel will come without truncation.

Br,

Bharath

arseni_gallardo
Active Participant
0 Kudos

Bharath,

KUNNR has a length of 10 characters in the dictionary so I do not understand why you are forcing it to be 12 characters long. Anyway maybe the ALV is not working properly because you have passed a wrong value to REF_TABNAME. Try this:


*COMMENT WA_FIELDCAT-OUTPUTLEN = 12.
*COMMENT WA_FIELDCAT-ddic_outputlen = 12.
*COMMENT WA_FIELDCAT-datatype = 'CHAR'.
WA_FIELDCAT-REF_TABNAME = 'KNA1'.
WA_FIELDCAT-REF_FIELDNAME = 'KUNNR'.

or this:


WA_FIELDCAT-OUTPUTLEN = 12.
WA_FIELDCAT-ddic_outputlen = 12.
WA_FIELDCAT-datatype = 'CHAR'.
WA_FIELDCAT-REF_TABNAME = 'KNA1'.
WA_FIELDCAT-REF_FIELDNAME = 'KUNNR'.

Edited by: Arseni Gallardo on Oct 13, 2011 1:22 PM

0 Kudos

Dear Arseni,

I have given the right internal table name. It refers to the correct KUNNR field from KNA1 table as you have mentioned. But still it does not have any effect in stopping the truncation.

Br,

Bharath

0 Kudos

Bharath,

In the fieldcatalog REF_TABNAME must refer to a dictionary table or structure, not to an internal table in the program.

ref_tabname (field name of the reference table/structure)

Value range: SPACE, name of a structure or table in the Data

Dictionary

Structure or table name of the referenced field in the Data

Dictionary.

This parameter is only required if the field in the internal output

table that is described by the current entry in the field catalog

has a reference to the Data Dictionary (that is, is not a program

field).

0 Kudos

Dear Arseni,

Thanks for your reply. I am so sorry. I did not properly read your earlier reply where in you have clearly asked me to refer to DB table name for REF_tablename field and not internal table.

As you have suggested I referred to KNA1-KUNNR field. Now what happens is in output,

1. For the customer no column automatically a heading customer is displayed (I believe this is from the field label of data element)

2. The customer no displayed in output is without preceeding zeroes. (I am surprised because in KNA1 table I can see records containing customer no with preceeding zeroes. But in my report output despite referring to same DB table field the zeroes are not coming). But good news is that excel data is coming without truncation. But I have 2 problems now with this option 1) I am getting a heading customer from the data element field label which I do not want 2) The preceeding zeroes are not coming (I believe since the zeroes are missing that is why the data in excel is coming correctly)

Br,

Bharath

Edited by: bharath padmanabhan on Oct 14, 2011 5:03 PM