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

Does we need to Create a file Before using Open dataSet

Former Member
0 Likes
2,142

Hi Guys,

Can any body tell me whether we have to create a File before using Open dataset for writing files in Application Server.

Can anybody write a program for EKPO table to store it in application Server using OpendatasSet ?Is there any specific care we have to take for Executing pgm in Background?

I wrote the pgm for Foreground using GUI- Download.

PGM.

*******

select * into table it_ekpo from ekpo .

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename ='c:\EKPO.xls'

filetype = 'ASC'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

data_tab = it_ekpo

*fieldnames = l_heading

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3 .

Plzzzzzzzzz Make the changes for existing Pgm.any help is awarded with points.Its Urgent.

Thanks,

Gopi.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,385

open dataset p_fil for output in text mode .

the above command work like if file already exits then it will overwrite the recrds ,if not it create new file

Hi Guys,

Can any body tell me whether we have to create a File before using Open dataset for writing files in Application Server.

Can anybody write a program for EKPO table to store it in application Server using OpendatasSet ?Is there any specific care we have to take for Executing pgm in Background?

I wrote the pgm for Foreground using GUI- Download.

PGM.

*******

select * into table it_ekpo from ekpo .

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename ='c:\EKPO.xls'

filetype = 'ASC'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

data_tab = it_ekpo

*fieldnames = l_heading

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3 .

Plzzzzzzzzz Make the changes for existing Pgm.any help is awarded with points.Its Urgent.

Thanks,

Gopi.

5 REPLIES 5
Read only

Former Member
0 Likes
1,386

open dataset p_fil for output in text mode .

the above command work like if file already exits then it will overwrite the recrds ,if not it create new file

Read only

Former Member
0 Likes
1,385

Hi

yes Create a file: p_file

and put your data in ITAB after fetching from table EKPO.

Open dataset p_file for appending in text mode.

if sy-subrc = 0.

loop at itab.

transfer itab to p_file.

endloop.

close dataset p_file.

endif.

Reward points if useful

Regards

Anji

Read only

former_member194669
Active Contributor
0 Likes
1,385

Hi,

Here sample code to write data to app. server.


 DATA FILENAME(20) VALUE '/USR/TEMP/TEST.DAT'.

OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE.
LOOP AT ITAB.                           " ITAB here is contains EKPO data
TRANSFER ITAB TO FILENAME.
ENDLOOP.
CLOSE DATASET FILENAME. 

aRs

Read only

Former Member
0 Likes
1,385

Hi,

open dataset <file> for output in text mode encoding non-unicode.

if sy-subrc eq 0.

loop at it_ekpo. "Internal Table with header line

transfer it_ekpo to <file>.

endloop.

close dataset <file>.

endif.

there are several changes you can make:

open dataset ... in legacy text mode.

or open .. fo appending.

Read only

0 Likes
1,385

Hi Guys,

Thanks for ur immediate response.I am sending the code just confirm me whether is correct r not?

DATA : wa_EKPO_file TYPE file_table-filename.

select * into table it_ekpo from ekpo .

OPEN DATASET wa_EKPO_file FOR OUTPUT "Write to appl. server

IN TEXT MODE

ENCODING DEFAULT. "Open dataset Return code

IF sy-subrc = 0.

LOOP at IT_EKPO into WA_EKPO.

TRANSFER wa_ekpo to wa_ekpo_file.

ENDLOOP.

ENDIF.

I want write the data into SPREAD Sheet .Can u guys tell me how to write into Spread Sheet using Open data Set.

Thanks,

Gopi.