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: 

Using opendata set to output a file

Former Member
0 Kudos
145

Hi,

I have a query in using open dataset command.

let us consider this scenario as an example.

I need to select 5 fields from mara table and I want to display the output in a flat file.Later, I have to read the data from the flat file and to display the output in sap screen.

Can someone help me on doing this and also if you send me the code , it will be useful for me to understand.

Thanks,

Stal.

3 REPLIES 3

SantoshKallem
Active Contributor
0 Kudos
55

READ DATASET (reading) and TRANSFER (writing)

OPEN DTASET <dataset name> for <input output appending> in <binary text > mode at POSITION <position> MESSAGE <field>

READ DATASET <dataset name > INTO <field>

CLOSE DATASET <dataset name>

DELETE DATASET <dataset name>

TRANSFER <field> to <dataset name>

select the required data and place in internal table

use DATASET to write into application server.

when ever u want READ the DATASET and write into flatfile/

regards.

santhosh reddy

Former Member
0 Kudos
55

Hi Stalin,

Download data to a unix file :

1) Declare parameter p_file LIKE rlgrap-filename OBLIGATORY.

(convert logical file to physical file using FM file_get_name)

2) Declare internal table and work area

3) OPEN DATASET <dsn> FOR OUTPUT

4) Retrieve data and store in internal table

5) For each record use statemet Transfer <f> to <dsn>

Upload data from unix file :

1) OPEN DATASET <dsn> FOR INPUT IN TEXT MODE.

2) Within statement Do... Enddo use READ DATASET <dsn> INTO internal table

3) Using internal table display the data in screen

With Regards,

Gandhi Subramani

0 Kudos
55

Thanks for your reply Gandhi.

Since I started learning now, i couldnt able to follow it clearly.

Can you please send me a code for this task .

my task is to select first 5 fields from mara keeping matnr as selection-screen and make an output in a flat file.

And then, read in a internal table and display the output in a sap screen.

I really appreciate if you could send me the code for this.

Help me.

Thanks,

Stalin