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

Issue with Header data while downloading internal table to excel.

suneel_uggina
Participant
0 Likes
4,256

Hi all,

I have a requirement to download internal table to excel sheet including header.In my method cl_gui_fronted_services=>gui_download I used file type DBF. But when I download data to presentation sever header field names truncated to 10 characters. Anyone could you please suggest  how to get full length header using file type DBF.

Code:

CALL METHOD cl_gui_frontend_services=>gui_download

      EXPORTING

        filename                = lv_file_path1

        filetype                = 'DBF'

        write_field_separator   = 'X'

        fieldnames              = gt_header[]

      CHANGING

        data_tab                = gt_finaldata[]

      EXCEPTIONS

        file_write_error        = 1

        no_batch                = 2

        gui_refuse_filetransfer = 3

        invalid_type            = 4

        no_authority            = 5

        unknown_error           = 6

        header_not_allowed      = 7

        separator_not_allowed   = 8

        filesize_not_allowed    = 9

        header_too_long         = 10

        dp_error_create         = 11

        dp_error_send           = 12

        dp_error_write          = 13

        unknown_dp_error        = 14

        access_denied           = 15

        dp_out_of_memory        = 16

        disk_full               = 17

        dp_timeout              = 18

        file_not_found          = 19

        dataprovider_exception  = 20

        control_flush_error     = 21

        not_supported_by_gui    = 22

        error_no_gui            = 23

        OTHERS                  = 24.

    IF sy-subrc <> 0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

Thanks in Advance,

Suneel.Uggina.

Hi all,

I have a requirement to download internal table to excel sheet including header.In my method cl_gui_fronted_services=>gui_download I used file type DBF. But when I download data to presentation sever header field names truncated to 10 characters. Anyone could you please suggest  how to get full length header using file type DBF.

Code:

CALL METHOD cl_gui_frontend_services=>gui_download

      EXPORTING

        filename                = lv_file_path1

        filetype                = 'DBF'

        write_field_separator   = 'X'

        fieldnames              = gt_header[]

      CHANGING

        data_tab                = gt_finaldata[]

      EXCEPTIONS

        file_write_error        = 1

        no_batch                = 2

        gui_refuse_filetransfer = 3

        invalid_type            = 4

        no_authority            = 5

        unknown_error           = 6

        header_not_allowed      = 7

        separator_not_allowed   = 8

        filesize_not_allowed    = 9

        header_too_long         = 10

        dp_error_create         = 11

        dp_error_send           = 12

        dp_error_write          = 13

        unknown_dp_error        = 14

        access_denied           = 15

        dp_out_of_memory        = 16

        disk_full               = 17

        dp_timeout              = 18

        file_not_found          = 19

        dataprovider_exception  = 20

        control_flush_error     = 21

        not_supported_by_gui    = 22

        error_no_gui            = 23

        OTHERS                  = 24.

    IF sy-subrc <> 0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

Thanks in Advance,

Suneel.Uggina.

10 REPLIES 10
Read only

Former Member
0 Likes
2,839

Truncation of column names is an issue with GUI_DOWNLOAD. you can either use column names that are 10 characters or less or use a different method of downloading.

FM XXL_SIMPLE_API comes to mind.

Rob

Read only

Former Member
0 Likes
2,839

I guess the header field name in dbf file is kind of a column name in the table and the length of that is 10. That is the reason why you were not able to create the header with more than 10 characters.

Moreover you can not have spaces in the header field, even if you give it will not take it.

-Chandra

Read only

0 Likes
2,839

Thank you Rob and Chandra.Could you please suggest any other alternative way to download excel including header to my presentation server.

Regards,

Suneel.uggina

Read only

0 Likes
2,839

Try the FM I suggested. It's documented.

Rob

Read only

0 Likes
2,839

I guess the approach you are following is right. What is the issue if the header length is less than or equal to 10? What are you trying to do with this file once you download?

If you change the file format to 'ASC' then you will NOT have the restriction for header length of 10.

Read only

0 Likes
2,839

Yes Chandra. If I changed the file format to 'ASC' or 'DAT' then I am not getting any restrictions on 

Header length.   While opening the downloaded file getting a prompt message  " your file is not in .xls format. Click on YES to open.If I opened the file I am not getting exact number of records. that is the reason I am using 'DBF' Format.

Read only

0 Likes
2,839

Give the file name with extension .xls (eg: C:\...\test.xls), it should solve your problem. I tried it and it is not a giving any popup message.

Read only

former_member241258
Active Participant
0 Likes
2,839

hi.

may be check ur alv grid field catalogs settings.

output length mentioned as 10 char?

or

u mentioned long, medium, and short descriptions.

if mentioned  output length mentioned as 10 char , remove that.

if mentioned u mentioned long, medium, and short descriptions, then use only long description only.

if mentioned ref table and ref field then use long, medium, and short descriptions, and  reptext_ddic  description ALSO

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,839

You never actually worked on dBase young padawan, field names were limited to 10 characters (as of dBaseIV ) all capitals with no blanks or special characters other than the underscore.

Hint: Use another type of file as already suggested (xml is cool)

Regards,

Raymond

Read only

suneel_uggina
Participant
0 Likes
2,839

Hi all,

Thanks everyone.. I solved the issue. I used file format 'DAT' for downloading internal table data to Excel including Header having Field length more than 10 characters..When I download internal table data to Excel sheet  the fields which consists '#' causes the data corruption.

For this issue I replaced '#' with Horizontal tab. Now I am getting data in Excel sheet as expected.

Regards,
Suneel.Uggina