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

Spool to Excel - Wrong format

arpita_churi3
Active Participant
0 Likes
2,226

Dear All,

I have scheduled a background job for IW37N in custom report to generate the spool.
And trying to download the spool data into excel file.

I am using following FM.

RSPO_RETURN_ABAP_SPOOLJOB
cl_gui_frontend_services=>gui_download

But the issues is excel file is not coming in proper format. Excel contains '|' after each data.

Could you please help?

Thanks,

Arpita

1 ACCEPTED SOLUTION
Read only

arpita_churi3
Active Participant
0 Likes
1,920

issue Solved..

read each line of spool data internal table and  use below code

replace all occurrences of '|' in  ls_data-line with cl_abap_char_utilities=>horizontal_tab.

modify spool itab.

and use GUI_DOWNLOAD to download..

BUt now I have one more issue..How to do this in background. I have scheduled this program

in background but GUI_DOWNLOAD function don't work in bg.

is there any alternative to download file on presentation server in bg..

14 REPLIES 14
Read only

former_member188724
Contributor
0 Likes
1,920

Hi Arpita,

Paste the code that you are using for gui_download.
You may have issues only with that.

Rgds,

KS

Read only

0 Likes
1,920

Hi K S,

I am using Function module 'RSPO_RETURN_ABAP_SPOOLJOB' to convert spool to excel and then using GUI_DOWNLOAD to download it to excel.

But all data is coming in single column with separator "|".

Please help.

Thanks,

Arpita

Read only

0 Likes
1,920

Hi Arpita,

Did you use the WRITE_FIELD_SEPARATOR in the FM?

Regards,

KS

Read only

arpita_churi3
Active Participant
0 Likes
1,921

issue Solved..

read each line of spool data internal table and  use below code

replace all occurrences of '|' in  ls_data-line with cl_abap_char_utilities=>horizontal_tab.

modify spool itab.

and use GUI_DOWNLOAD to download..

BUt now I have one more issue..How to do this in background. I have scheduled this program

in background but GUI_DOWNLOAD function don't work in bg.

is there any alternative to download file on presentation server in bg..

Read only

0 Likes
1,920

Hi Arpita,

your presentation server is only available in dialogue thru SAP GUI. In dialog and batch you will both have access to your application server using OPEN DATASET - TRANSFER - CLOSE DATASET.


But if you have for example a MS Windows presentation server and a LINUX or UNIX application server, then you can mount a MS Windows net drive to your application server and create your file directly on it. (The mount must be done by the administration of your application server!)

Otherwise you can create the file on the application server in batch and write a program or use an existing tool to read it in dialogue and download it to presentation server in an additional dialogue step.

Regards,

Klaus

Read only

0 Likes
1,920

Thanks for your reply.

I am trying to do the same now. Reading application file into internal table and trying to

download it to presentation server.

I am facing issue in that also.

My excel file has dynamic data.. Columns keeps on changing. there is no fixed number of columns.

Following is code:

p_fname  FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF  sy-subrc = 0.
 
DO.
   
read DATASET p_fname into gs_app-line LENGTH len.
   
IF sy-subrc = 0.
     
append gs_app to t_app_data.
   
ELSE.
     
EXIT.
   
ENDIF.
 
ENDDO.
 
CLOSE DATASET fname.
ENDIF.

itab t_app_data has data but all columns are not coming. I have tried using MAXIMUM LENGTH , ACTUAL LENGTH and LENGTH but it is not working.

Please help.

Thanks,

Arpita

Read only

0 Likes
1,920

How did your solution for GUI_DOWNLOAD in dialogue work? Also there you had to solve the issue to separate the columns.

Next question: How did you create your file on application server? I think, the solution for column separation has to be done already when downloading your data to application server. Do you know the number of columns at this point? You can use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL TAB as an separator for field separation here.

Regards,

Klaus

Read only

0 Likes
1,920

Thanks..

I will use field separator but the issue is different.

My issue is in READ DATASET. It is taking only 600 chars in single line.

So if my internal table has more columns then some columns are not  coming into

internal table t_app_data.

read DATASET p_fname into gs_app-line LENGTH len.
   
IF sy-subrc = 0.
     
append gs_app to t_app_data.
   
ELSE.

I tried using  following:

len = 1000.

read DATASET p_fname into gs_app-line LENGTH len.

Still problem is there.


Read only

0 Likes
1,920

I don't know number of columns , as number of columns keep on changing based on variant selection.


Read only

0 Likes
1,920

Hi, please tell us the definition of gs_app-line. Is it of character type and length 600 ?

Please try to read it into a type string field. Do you get all data in this case?

Read only

0 Likes
1,920

I tried with string but it is not working....

Read only

0 Likes
1,920

Then please try it with a character filed of length 1000, 1024 or longer like

  • TEXT1000
  • TEXT1024
  • TEXT2048
  • TEXT4096

Regards,

Klaus.

Read only

0 Likes
1,920

Could you read into a STRING type and remove the LENGTH option.


Regards,

Raymond



Read only

0 Likes
1,920

Thanks..

I have solved issue.

Even though in internal tab it is showing few columns. I tried download to presentation server using GUI_DOWNLOAD fm, all columns are coming perfectly.

Thanks for helping..