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

Prob while saving Excel sheet

Former Member
0 Likes
1,208

hai frnds

i used function Gui_download but it getting prob while saving reports saving as a Excel sheet . but it is not supporting. can anybody tell me which function module i have to use. i want save the excel sheet in background tell me .

advance thanks

regards

sindu

12 REPLIES 12
Read only

Former Member
0 Likes
1,165

Hi Sindu

Use the FMs SAP_CONVERT_TO_XLS_FORMAT, ALSM_EXCEL_TO_INTERNAL_TABLE, KCD_EXCEL_DATE_CONVERT.

Pushpraj

Read only

Former Member
0 Likes
1,165

Hi

Use the same function module.But give the File name as ' .XLS' (FOR EXAMPLE - C:/TEMP/FIELNAME.XLS')

Thanks,

Nithya

Read only

Former Member
0 Likes
1,165

Try like this

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'C:\xyz.xls'

  • FILETYPE = 'ASC'

  • APPEND = SPACE

  • WRITE_FIELD_SEPARATOR = SPACE

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = SPACE

  • WRITE_LF = 'X'

  • COL_SELECT = SPACE

  • COL_SELECT_MASK = SPACE

  • DAT_MODE = SPACE

  • CONFIRM_OVERWRITE = SPACE

  • NO_AUTH_CHECK = SPACE

  • CODEPAGE = SPACE

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = SPACE

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = SPACE

  • WK1_N_SIZE = SPACE

  • WK1_T_FORMAT = SPACE

  • WK1_T_SIZE = SPACE

  • IMPORTING

  • FILELENGTH =

CHANGING

DATA_TAB = itab

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Read only

Former Member
0 Likes
1,165

Hi,

Try using the Function Module

ALSM_EXCEL_TO_INTERNAL_TABLE

do not provide any starting col no or ending col parameters

it shall take the complete excel file records.

Thanks

Ravi Aswani

Read only

Former Member
0 Likes
1,165

Hi ,

Please try with the following -


CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

i_field_seperator = 'X'

i_tab_raw_data = fs_truxs

i_filename = 'C:\TEMP\YH1333.XLS'

TABLES

i_tab_converted_data = t_mat

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

CASE sy-subrc.

WHEN 0.

MESSAGE 'File uploaded successfully'(001) TYPE 'S'.

WHEN 1.

MESSAGE 'Conversions failed'(002) TYPE 'I'.

WHEN 2.

MESSAGE 'Error during conversion'(003) TYPE 'I'.

ENDCASE. " CASE SY-SUBRC.

Read only

Former Member
0 Likes
1,165

Hi friend,

PLease use parameters in gui_download file type is file.EXEl.

so u may save file in excel format

Read only

Former Member
0 Likes
1,165

Use function modules,

SAP_CONVERT_TO_XLS_FORMAT Or

ALSM_EXCEL_TO_INTERNAL_TABLE.

It will Work.

Read only

Former Member
0 Likes
1,165

Hi,

try it .

its working




  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*    I_FIELD_SEPERATOR          = 'X'
     i_line_header              = 'X'
      i_tab_raw_data             = it_raw
      i_filename                 =  'c:\temp.xls'  "file name
    TABLES
      i_tab_converted_data       = it_final[]
   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.

Thanks

Arun

Read only

0 Likes
1,165

hai

what is raw data can u tell i_tab_raw_data = it_raw

regards

sindu

Read only

Former Member
0 Likes
1,165

HI Sindu,

Really, your made-to-think question made me wear thinking cap.

Anyways, Sindu try the following code-snap, perhaps you'll get to conclusion.

DATA: BEGIN OF ole_server OCCURS 5.
INCLUDE STRUCTURE tole.
DATA: END OF ole_server.

ole_server-app = 'EXCEL.SHEET'.
APPEND ole_server.

CALL FUNCTION 'OLE_SERVER_CHECK'
IMPORTING
down_load_path = file
TABLES
ole_server_app = ole_server
EXCEPTIONS
unsupported_os = 1
unsupported_server = 2
no_ole_server_found = 3
OTHERS = 4.

IF sy-subrc is initial.
CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
EXPORTING
FILE_NAME = PATH_AND_FILE
TABLES
DATA_TAB = Tab_data
FIELDNAMES = fildnames.
ENDIF.

Moreover RSCRM_BAPI provides you options to set date and time to export report to excel sheet,

For example, you want a program to get executed automatically and export the data in an excel sheet, this really works well.

Thanks: Zahackson

Read only

awin_prabhu
Active Contributor
0 Likes
1,165

Hi Friend,

try this simple code....

Generated excel will be in C: Go and see.

REPORT zawi_demodownload.

*Types

TYPES: BEGIN OF g_r_mara,

matnr LIKE mara-matnr,

ersda LIKE mara-ersda,

laeda LIKE mara-laeda,

mtart LIKE mara-mtart,

mbrsh LIKE mara-mbrsh,

END OF g_r_mara.

*Data

DATA: g_t_mara TYPE TABLE OF g_r_mara,

filename TYPE string,

s TYPE i.

*Tables

TABLES: mara, sscrfields.

*Selection Screen

SELECT-OPTIONS: s_matnr FOR mara-matnr.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN PUSHBUTTON 10(20) name USER-COMMAND ucom.

SELECTION-SCREEN END OF LINE.

INITIALIZATION.

name = 'Spread Sheet'.

AT SELECTION-SCREEN.

IF sscrfields-ucomm = 'UCOM'.

s = 1.

ENDIF.

*Data retrival and populating internal table

IF s = 1.

SELECT matnr ersda laeda mtart mbrsh

INTO CORRESPONDING FIELDS OF TABLE g_t_mara

FROM mara

WHERE matnr IN s_matnr.

filename = 'C:\Testing.xls'.

  • Downloading data from internal table to excel

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = filename

filetype = 'ASC'

write_field_separator = 'X'

TABLES

data_tab = g_t_mara.

ENDIF.

If you still face problem, then problem will be in excel macro security.

Do following....

Open MS-Excel.

Goto Tools -> Macro -> Security -> SecurityLevel -> Low.

Also in Next tab Trusted Publishers -> tick both boxes.

Click ok.

Now go and run your above report.

Thanks....

Read only

Former Member
0 Likes
1,165

HI,

[Communication to Presentation Server in Background Mode|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9831750a-0801-0010-1d9e-f8c64efb2bd2]