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

problem with open dataset

Former Member
0 Likes
610

hi,

i am trying to generate file in the system,it is working fine when we execute through front end ,but when we are trying to execute through backend it is not working,can any body help me on this.following is the code i have used.

&----


*& Report ZPFA_HIER_LOAD

*&

&----


*& This program is directly fetch the data from Comshare Unit_tree table

*& Will create a text file logical directory

*&

*& Author :Shirisha Bandi.

*& Date :20.08.2006

&----


REPORT ZFPA_HIER_LOAD.

*---- Declaration of Oracle connectioN

DATA con_name LIKE dbcon-con_name VALUE 'COMSHARE'.

DATA: MFL1(9),MFL2(5),MFL3(9),MFL4(2),MFL5(8) TYPE c.

DATA : mfilename type string.

data: begin of matab1 occurs 0,

MFL1(9) TYPE C,

MFL2(5) TYPE C,

MFL3(9) TYPE C,

MFL4(2) TYPE C,

MFL5(8) TYPE C ,

end of matab1 .

data: setid(8) type c.

data: begin of source occurs 0,

setid(8) type c,

end of source.

*PARAMETERS : p_pfile LIKE filename-FILEEXTERN.

*PARAMETERS : m_bsenty(8). " type c obligatory.

*mfilename = P_PFILE.

EXEC SQL.

SET CONNECTION :con_name

ENDEXEC.

EXEC SQL.

CONNECT TO :con_name

ENDEXEC.

EXEC SQL PERFORMING get_source.

SELECT set_id FROM UNIT_SET INTO

:setid

ORDER BY SET_ID

ENDEXEC.

LOOP AT SOURCE.

REFRESH matab1. CLEAR matab1.

EXEC SQL PERFORMING evaluate.

SELECT TO_CHAR(MEM_ID),TRIM(TO_CHAR(MEM_PID)) FROM UNIT_TREE INTO :MFL1,

:MFL5

where set_id = :SOURCE-SETID ORDER BY MEM_ID

ENDEXEC.

if SOURCE-SETID = '80000000'.

mfilename = 'C:\aesorg.csv'.

elseif SOURCE-SETID = '80000006'.

mfilename = 'C:\Consolidation_Manager.csv'.

elseif SOURCE-SETID = '80000010'.

mfilename = 'C:\10org.csv'.

elseif SOURCE-SETID = '80000012'.

mfilename = 'C:\20org.csv'.

elseif SOURCE-SETID = '80000018'.

mfilename = 'C:\30org.csv'.

elseif SOURCE-SETID = '80000025'.

mfilename = 'C:\40org.csv'.

Endif.

open dataset mfilename for INPUT IN TEXT MODE ENCODING DEFAULT.

if sy-subrc <> 0.

exit.

endif.

close dataset mfilename.

  • CALL FUNCTION 'GUI_DOWNLOAD'

  • EXPORTING

  • FILENAME = MFILENAME

  • FILETYPE = 'ASC'

  • TABLES

  • data_tab = matab1

  • EXCEPTIONS

  • file_write_error = 1

  • invalid_type = 2

  • no_authority = 3

  • unknown_error = 4

  • OTHERS = 10.

*

  • clear matab1.

*

ENDLOOP.

*

MFL5 = '0'.

CLEAR MFL5.

FORM evaluate.

if MFL5 = -1.

MFL5 = ''.

ENDIF.

concatenate MFL1 ',' into MFL1.

concatenate MFL1 ',' into MFL3.

matab1-MFL1 = MFL1.

matab1-MFL2 = 'ZBUE,'.

matab1-MFL3 = MFL3.

matab1-MFL4 = ' ,'.

matab1-MFL5 = MFL5.

append matab1 .

CLEAR MFL1.

CLEAR MFL2.

CLEAR MFL3.

CLEAR MFL4.

CLEAR MFL5.

ENDFORM.

"evaluate

&----


*& Form GET_SOURCE

&----


  • text

----


FORM GET_SOURCE.

source-setid = setid.

append source.

clear source.

ENDFORM. "GET_SOURCE

5 REPLIES 5
Read only

Former Member
0 Likes
568

One thing is the file name that u give doesn't make any sense to me. Becuse the files in the SAP application server are stored in unix OS. SO the file naming convention u have followed is incorrect. One more thing r u trying to download file to Presentation server???

Read only

0 Likes
568

hi,

you must transfer matab1 to file mfilename

with:

loop at matab1.
 transfer matab1 to mfilename.
endloop.

Message was edited by: Andreas Mann

Read only

Former Member
0 Likes
568

no where you given TRANSFER <DATA> TO FILENAME.

then how you can store data in the file..

<b>open dataset mfilename for INPUT IN TEXT MODE ENCODING DEFAULT.
if sy-subrc <> 0.
exit.
endif.
close dataset mfilename.</b>

here you are opening the file and then closing it.in between you should use TRANSFER to transfer itab data to the file.

Read only

Former Member
0 Likes
568

Thanks for fast response.

I am trying to genarate file in presentation server ,but when it is foreground it is working fine,but in background it is not generating file.

Read only

0 Likes
568

you can NOT directly download data to the presentation server in BACKGROUND mode.

here is the link how to do this,with this way you can download it to the presentation server.

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9831750a-0801-0010-1d9e-f8c64efb2bd2">Download data to Presentation server in Background Mode</a>

Regards

srikanth

Message was edited by: Srikanth Kidambi