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

writing data to Dataset

Former Member
0 Likes
842

Hi all,

can i write the data to more than one Dataset at a time ?

if Yes... how ? If not why ?

Thanks in Advance

Malli...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
814

Hello,

You can write to more than one dataset at a time.

data text(100).

open dataset data1 for output.

open dataset data2 for output.

transfer text to data1.

transfer text to data2.

Regards,

Manoj

6 REPLIES 6
Read only

Former Member
0 Likes
814

open multiple datasets

and then use

TRANSFER <FIELD> TO <FILENAME>

then close the datasets.

Message was edited by:

Elanchezhian Balasubramanian

Read only

Former Member
0 Likes
814

hi,

Yes u can write to no. of datasets in a single execution, but take care of whether you have authorization to write to the particular folder.

Read only

Former Member
0 Likes
815

Hello,

You can write to more than one dataset at a time.

data text(100).

open dataset data1 for output.

open dataset data2 for output.

transfer text to data1.

transfer text to data2.

Regards,

Manoj

Read only

Former Member
0 Likes
814

No, But we can write the same value in two Data sets one after another.

NO, Because, if you open one data set we can't open another before closeing the first one.

Regards,

Sunil.Y

Read only

Former Member
0 Likes
814

hI Krish.

check this..

open dataset...

read dataset...

close dataset...

DATA: itab TYPE STANDARD TABLE OF mara,

wa_itab TYPE mara.

SELECT * FROM mara INTO TABLE itab WHERE matnr > '000000000000001000'

AND matnr < '000000000000009010'.

OPEN DATASET 'sharat.pm' FOR APPENDING IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc = 0.

LOOP AT itab INTO wa_itab.

TRANSFER wa_itab-matnr TO 'sharat.pm'.

ENDLOOP.

ENDIF.

CLOSE DATASET 'sharat.pm'.

REWRD IF USEFULL

Read only

former_member199581
Active Participant
0 Likes
814

Hi Krish, try this:

REPORT  YROBTEST.

DATA: dataset_one LIKE rlgrap-filename VALUE '.prova1.txt',
      dataset_two LIKE rlgrap-filename VALUE '.prova2.txt'.
DATA: begin of itab occurs 10,
       line(100) TYPE C,
      end of itab.


DO 10 TIMES.
  TRANSLATE itab-line USING ' 0'.
  APPEND itab.
ENDDO.

TRY.
  OPEN DATASET dataset_one FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
  OPEN DATASET dataset_two FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  LOOP AT itab.
    TRANSFER: itab TO dataset_one,
              itab TO dataset_two.
  ENDLOOP.

  CATCH: cx_sy_file_authority,
         cx_sy_too_many_files,
         cx_sy_file_open_mode.
endtry.

  CLOSE DATASET dataset_one.
  CLOSE DATASET dataset_two.

Remember that you can open up to 100 datasets per session.

Hope this helps!

R.