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

GUI_DOWNLOAD Problem

Former Member
0 Likes
1,049

Hi,

I am using GUI_DOWNLOAD FM to download my internal table entries into .xls file. It is downloading the file to my local system. But it is not saving in plain .xls file.

Most of the times, the excel file will be downloaded, converted to tab delimited text file. But I need it as a plain .xls file.

Because my client needs to modify the same file and uses to upload it. But they are unable to modify it. It is throwing error like "the document is not compatable with text(tab delimeter)".

Please help me on this situation...

Regards

Ramesh.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
970

Hi,

Use the function module

SAP_CONVERT_TO_XLS_FORMAT

Here is a sample code:

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
             EXPORTING
*              I_FIELD_SEPERATOR          =
*              I_LINE_HEADER              =
               i_filename                 = '<<File-Path>>>
*              I_APPL_KEEP                = ' '
             tables
               i_tab_sap_data             =<Table-Name>
*            CHANGING
*              I_TAB_CONVERTED_DATA       =
*            EXCEPTIONS
*              CONVERSION_FAILED          = 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.

Hope this solves the issue.

Regards,

Rajani

Hi,

I am using GUI_DOWNLOAD FM to download my internal table entries into .xls file. It is downloading the file to my local system. But it is not saving in plain .xls file.

Most of the times, the excel file will be downloaded, converted to tab delimited text file. But I need it as a plain .xls file.

Because my client needs to modify the same file and uses to upload it. But they are unable to modify it. It is throwing error like "the document is not compatable with text(tab delimeter)".

Please help me on this situation...

Regards

Ramesh.

7 REPLIES 7
Read only

Former Member
0 Likes
970

HI,

You can use Concatenate statement before using GUI_DOWNLOAD

function module.Kindly check the sample code below:



  data: v_path     type rlgrap-filename,
        v_pathname type string         .

*func mod to select path for downloading file
 call function 'KD_GET_FILENAME_ON_F4'
exporting
program_name        = syst-repid
dynpro_number       = syst-dynnr
*       FIELD_NAME          = ' '
*       STATIC              = ' '
*       MASK                = ' '
changing
file_name           = v_path
exceptions
mask_too_long       = 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.

*assigning path value to another var to be passed in gui_download
v_pathname = v_path.


*if user gives the value in path var then only download will be called
if v_pathname is not initial.

*TO CONCATENATE EXTENSION WITH THE FILE PATH NAME
concatenate v_pathname '.xls' into v_pathname.

call function 'GUI_DOWNLOAD'
exporting
*   BIN_FILESIZE                    =
    filename                        = v_pathname
    filetype                        = 'ASC'
    append                          = 'X'
    write_field_separator           = 'X'
*   HEADER                          = '00'
*   TRUNC_TRAILING_BLANKS           = 'X'
*   WRITE_LF                        = 'X'
*   COL_SELECT                      = ' '
*   COL_SELECT_MASK                 = ' '
*   DAT_MODE                        = ' '
*   CONFIRM_OVERWRITE               = ' '
*   NO_AUTH_CHECK                   = ' '
*   CODEPAGE                        = ' '
*   IGNORE_CERR                     = ABAP_TRUE
*   REPLACEMENT                     = '#'
*   WRITE_BOM                       = ' '
*   TRUNC_TRAILING_BLANKS_EOL       = 'X'
   wk1_n_format                    = '22'
   wk1_n_size                      = '18'
*   WK1_T_FORMAT                    = ' '
*   WK1_T_SIZE                      = ' '
* IMPORTING
*   FILELENGTH                      =
    tables
    data_tab                        = <dyn_table>
*   FIELDNAMES                      =
  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
others                          = 22
                                    .
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.

endif.

clear: v_pathname, v_path.

Hope it helps

Regards

Mansi

Read only

Former Member
0 Likes
970

Hello,

You can try using XXL_FULL_API function module. It will download the abap data into xls with full details.

also, you can try one more function module:

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'

EXPORTING

  • I_FIELD_SEPERATOR =

  • I_LINE_HEADER =

I_FILENAME =

  • I_APPL_KEEP = ' '

TABLES

I_TAB_SAP_DATA =

  • CHANGING

  • I_TAB_CONVERTED_DATA =

  • EXCEPTIONS

  • CONVERSION_FAILED = 1

  • OTHERS = 2

.

Hope this resolves your issue.

Thanks,

Augustin.

Read only

Former Member
0 Likes
970

Hi ,

Try using FM

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'

this will help u

regards

Prashant

Read only

Former Member
0 Likes
971

Hi,

Use the function module

SAP_CONVERT_TO_XLS_FORMAT

Here is a sample code:

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
             EXPORTING
*              I_FIELD_SEPERATOR          =
*              I_LINE_HEADER              =
               i_filename                 = '<<File-Path>>>
*              I_APPL_KEEP                = ' '
             tables
               i_tab_sap_data             =<Table-Name>
*            CHANGING
*              I_TAB_CONVERTED_DATA       =
*            EXCEPTIONS
*              CONVERSION_FAILED          = 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.

Hope this solves the issue.

Regards,

Rajani

Read only

Former Member
0 Likes
970

Thanks to All...

The FM is working fine but it is not writing the COLUMN (HEADING) Names...do needful on this.

Regards,

Ramesh.

Read only

0 Likes
970

check exporting parameter I_LINE_HEADER

Read only

0 Likes
970

Hi, Ramesh

Test my Sample Code in the [This Link|] hope it will solve out your problem,

Best Regards,

Faisal