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

Application Server tab Delimiter ?

Former Member
0 Likes
560

Hi Guys,

Can anybody tell me how to Transfer the data from Final Internal table to text file in Tab Delimited Format? Is there any FM for converting the final internal table into Tab Delimited ?

Urgent.

Thanks,

Gopi.

2 REPLIES 2
Read only

Former Member
0 Likes
493

NO FM Is available

you have to work programtically.

data v_text(1024) type c.

loop at i_final. -> This is Final Internal table

concatenate i_final-field1 ',' i_final-field2 ',' i_final-field3 into v_text.

transfer v_text to v_file.

clear v_text.'

endloop.

Here delimeter is ',' ,you can keep what ever you want.

If internal table has more field ,you need keep each and every field like this.

One more thing concatenate will not work for currency,qty,Packed,Float data type,so before concatenate ,move the value to charcter field and use concatenate.

Thanks

Seshu

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
493

Here is an example program showing how to write a tab delimited file to application server.



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 x value '09'.

* if you have a newer version, then you can use this instead.
*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