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: 

Download to Excel Multiple Sheets in background

Former Member
0 Kudos

Hi,

I am trying to download data into Multiple Sheets of an Excel File.I could download the data into Multiple sheets, but this is working fine in foreground. I want this to be done in Background. Can Someone give an idea of how to do this.

Thanks,

Sri.

17 REPLIES 17

Former Member
0 Kudos

Hi,

(Gui)-Download works only in foreground.

Regards, Dieter

0 Kudos

Yes. but how to download the data in background mode or any way of sending that file to Application Server

Former Member
0 Kudos

Hi,

If you want to download data in back ground, you need to create the file into application server(using open datasets concept) then use CG3Y transaction to save file in XL sheet with .xls file extension or

open the generated file in application server and manually transfer(save) the generated file contents into spreadsheet(for creating excel).

Reward points if needful...

0 Kudos

Hi Ramesh,

Thanks for the response. I tried using CG3Z. But after uploading to Application Server, when we are downloading the excel file, I am getting the whole data in 1 sheet instead of multiple sheets. I want this data to be displayed in multiple sheets.

Thanks,

Sri

former_member189059
Active Contributor
0 Kudos

Step 1. Create the file in the forground

Step 2. Upload it to the application server using...

  CALL FUNCTION 'C13Z_FRONT_END_TO_APPL'
       EXCEPTIONS
            OTHERS  = 1.

Now the file will be there in the application server as an excel file (presuming you keep the same filename)

what is your next step ?

0 Kudos

Hi Kris,

Thanks a lot for the Ans. But after uploading the file to application Server , to download that, i used AL11's system->List->Save->LocalFile->SpreadSheet.

but i am getting the whole data in single sheet instead of Multiple sheets. so Can u please tell me , how to upload the multiple sheet excel file into application server (i.e. the data should be in multiple sheets only.. even when we download the file from application server.)

Thanks ,

Sri

0 Kudos

Hi,

I guess the fault is not in the uploading, but in the downloading

try downloading the file using the transaction CG3Y or the following function module

  CALL FUNCTION 'C13Z_APPL_TO_FRONT_END'
       EXCEPTIONS
            OTHERS  = 1.

0 Kudos

Hi Kris,

thanks a lot. Thats a very userful point for me. But i have one more problem now with this. I am unable to run this report in background. Can u please help me.

Thanks,

Siri

0 Kudos

Hi,

The application server has no access to your local PC

hence any code which deals with the front end (presentation server) will not run in the background

0 Kudos

Right Kris. Thats the problem i am facing. So can u suggest any other method. to download the data into multiple sheets of Excel that runs in background.

Thanks,

Sri

0 Kudos

Well... what you want cannot exactly be achieved

one method that can be used is to write to the application server in a different format (such as csv)

use the normal open dataset commands for this

this can be run in the background

then, you will need a separate program to read this csv file and convert it to excel with multiple sheets

the code for reading the csv file will begin as follows...

you will have to use your custom logic to decide where to separate the sheets

  DATA : BEGIN OF itab OCCURS 0,
          col1(1024) TYPE c,
         END OF itab,
         wa_itab LIKE LINE OF itab.

  DATA: BEGIN OF itab_2 OCCURS 0,
    field01(256),
    field02(256),
    field03(256),
    field04(256),
    field05(256),
    field06(256),
    field07(256),
    field08(256),
    field09(256),
    field10(256),
    field11(256),
    field12(256),
    field13(256),
    field14(256),
    field15(256),
    field16(256),
   END OF itab_2.
  DATA: wa_2 LIKE LINE OF itab_2.

    OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.
    IF sy-subrc = 8.
      WRITE:/ 'File' , file , 'cannot be opened'.
      EXIT.
    ENDIF.
    WHILE sy-subrc <> 4.
      READ DATASET file INTO wa_itab.
      APPEND wa_itab TO itab.
    ENDWHILE.

    CLOSE DATASET file.

  IF sy-subrc <> 0.
    WRITE:/ 'No files specified'.
    EXIT.
  ENDIF.

  LOOP AT itab INTO wa_itab.
    SPLIT wa_itab-col1 AT ',' INTO wa_2-field01 wa_2-field02 wa_2-field03 wa_2-field04
     wa_2-field05 wa_2-field06 wa_2-field07 wa_2-field08 wa_2-field09
     wa_2-field10 wa_2-field11 wa_2-field12 wa_2-field13 wa_2-field14
     wa_2-field15 wa_2-field16.
    APPEND wa_2 TO itab_2.
    CLEAR wa_2.
  ENDLOOP.

0 Kudos

Hi Kris,

Thanks once again. As per your suggestion i worked on this method. Again to download the CSV file into multiple sheets of an Excel, i used OLE objects. This is also working fine in foreground. But failed in Background.

Thanks.

Sri

0 Kudos

Yes it will fail

to execute OLE in the background, your application server would need to have access to your local PC, which isn't the case

whatever you do, you cannot run OLE in the background

the idea for using csv files as an intermediary is for speed to execution

this csv file can later be converted to excel on any server

0 Kudos

Hi Kris, The CSV files can be converted to Excel files.. right. But is there any way to get the data into multiple Sheets?

Thanks,

Sri.

0 Kudos

For that you will have to use logic while writing and reading the csv file

for example, whenever you want a new sheet, you could use a blank line or a line such as 'new sheet'

then before writing to excel, check the line read for that string

if found, then create a new sheet

0 Kudos

Hi All,

I have the same problem. Could you please provide the solution for this?

Thanks in advance.

Regards,

Kalyan

Former Member
0 Kudos

Hi kavitha,

Why don't you try the ABAP2XSLX ?

http://wiki.sdn.sap.com/wiki/display/ABAP/abap2xlsx

Regards,

Christian