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: 

which is a statement used to write a record to a file in ABAP?

Former Member
0 Kudos

which is a statement used to write a record to a file in ABAP?

3 REPLIES 3

Former Member
0 Kudos

TRANSFER.

You can check the documentation to see how to use it.

Rob

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

We write a record to a file on the application server using the following syntax.




report zrich_0001.

parameters: d1 type localfile default '/usr/sap/TST/SYS/Test.txt'.

data: begin of itab occurs 0,
      field1(20) type c,
      field2(20) type c,
      field3(20) type c,
      end of itab.
data: str type string.

constants:
    con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB.

start-of-selection.

itab-field1 = 'ABC'.
itab-field2 = 'DEF'.
itab-field3 = 'GHI'.
append itab.

itab-field1 = '123'.
itab-field2 = '456'.
itab-field3 = '789'.
append itab.

  open dataset d1 for output in text mode.
  loop at itab.
    concatenate itab-field1 itab-field2 itab-field2 into str
                  separated by con_tab.
    transfer str to d1.
  endloop.
  close dataset d1.

Regards,

RIch Heilman

Former Member
0 Kudos

Hi Rama,

Use TRANSFER...

LOOP AT itab INTO e_tab.

TRANSFER e_tab TO '/tmp/test'.

ENDLOOP.

The above code should be inside OPEN DATASET and CLOSE DATASET statements.

Thanks and Best Regards,

Vikas Bittera.

**Points for useful answers**