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: 

ALV download to excel problem

Former Member
0 Kudos

Dear Gurus a problem in alv report downloading to excel:

on executing the report works fine but when downloading to excel there last digit of bpvno is getting truncated.

ex: actual bpvno:'4000010' but excel o/p shows as '400001'

I have declared a field in final internal table as:

data: bpvno as bseg-belnr,

.......

(in field catalog)

fieldcatalog-fieldname = 'BPVNO'.

fieldcatalog-seltext_m = 'BPV No.'.

fieldcatalog-seltext_L = 'BPV No.'.

fieldcatalog-col_pos = I1.

fieldcatalog-emphasize = 'X'.

append fieldcatalog .

clear fieldcatalog.

I1 = I1 + 1.

but after specifying the REF_TABLENAME & REF_FIELDNAME the downloaded excel o/p is correct.

My questions is:

1) i want to know what all are mandatory fields to be specified in fieldcatalog & is it compulsory to specify REF_TABLENAME & REF_FIELDNAME .

if not complusory why the downloaded excel value is being truncated ???

plz dont send materilas on alv and answer specific to the question....

6 REPLIES 6

Former Member
0 Kudos

Hi,

REF_TABLENAME & REF_FIELDNAME is not mandatory in the field catalogue.

Based on the data type the value will be downloaded.

And If your excel sheet default settings the final '0's value will be truncated.

Regards,

Nandha

Former Member
0 Kudos

Hi,

What I think might be happening is. Since your

fieldcatalog-seltext_m & fieldcatalog-seltext_L have only 6 characters, i.e 'BPV No.'.

Only 6 characters from the field are downloaded to excel as well.

But when you give the reftabname and fieldname, the fieldcatalog knows what is the length it has to use when downloading to excel etc and it transfers the data accordingly.

If you dont want to use the reftabnam and refieldname, try giving outputlen and see what happens.

regards,

Advait.

0 Kudos

i have tried giving the outputlen ...as...

fieldcatalog-fieldname = 'BPVNO'.

fieldcatalog-seltext_m = 'BPV No.'.

fieldcatalog-seltext_L = 'BPV No.'.

fieldcatalog-col_pos = I1.

fieldcatalog-outputlen = 10.

fieldcatalog-emphasize = 'X'.

append fieldcatalog .

clear fieldcatalog.

I1 = I1 + 1.

but still while downloading the same problem of truncation is occuring.

plz suggest the any possible way without using : ref_tabname , ref_fieldname as there is no complusion to use them.....

0 Kudos

Hi,

I wrote a small program, and for me it worked. My assumption about the seltext was wrong. And I also didn't use output lenght.

Here is the code.


REPORT  ZALVTOEXCEL                                                 .
type-pools slis.

data : gt_fcat type slis_t_fieldcat_alv.

data fieldcatalog like line of gt_fcat.

types : begin of t_belnr,
        bpvno like bseg-belnr.
types end of   t_belnr.

data gt_belnr type table of t_belnr.
data gwa_belnr type t_belnr.


gwa_belnr-bpvno = '4000010'.
append gwa_belnr to gt_belnr.


fieldcatalog-fieldname = 'BPVNO'.
fieldcatalog-seltext_m = 'BPV No.'.
fieldcatalog-seltext_L = 'BPV No.'.
fieldcatalog-col_pos = 1.
fieldcatalog-emphasize = 'X'.
append fieldcatalog to gt_fcat.
clear fieldcatalog.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
   IT_FIELDCAT                        =  gt_fcat
    I_SAVE                            = 'A'
  TABLES
    t_outtab                          =  gt_belnr
 EXCEPTIONS
   PROGRAM_ERROR                     = 1
   OTHERS                            = 2
          .
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

regards,

Advait.

former_member541575
Participant
0 Kudos

hi

i think u have defined the length 6 therefore last digit is not downloaded in the excel

increase the size of the BPVNO field.

regards

atul

Former Member
0 Kudos

i think seltext_l, seltext_m, seltext_s should be provided with text of length >20, 1-20, 10 character length.Then when we download to excel truncation can be avoided.