‎2006 Sep 12 10:45 AM
I need to write data to a text file in a particular format. I am not passing records of an internal table to the text file. I need to pass fields of a single row in a tabular format. For this, I need to use the new line character...I want fields of a single row to be displayed one below the other.
Any idea on how we could do this?
‎2006 Sep 12 10:51 AM
Hi vidya,
1. There are two things :
a) if we have opened the file in text mode (on app server)
then whenever we do TRANSFER,
a new line will automatically be appended.
b) To ensure that fields come one below other with proper alignment,
we have to ensure that the data in work area of transfer,
is properly aligned within it.
ie. 12345678~~~~~123456~
(where~ may be spaces if the field is not full length)
regards,
amit m
‎2006 Sep 12 10:50 AM
You can use
<b>CL_ABAP_CHAR_UTILITIES=>VERTICAL_TAB</b> as a separator between your row fields.
‎2006 Sep 12 10:53 AM
Hi,
Will this work while writing data to a text file on the presentation server, using open-dataset-transfer-close-dataset statements?
‎2006 Sep 12 10:57 AM
Hi you can do something like this :
DATA: gd_result(50) type c.
constants:
cl_abap_char_utilities=>VERTICAL_TAB,
con_tab can then be concatenated to create tab spaces.
CONCATENATE 'text1' con_tab 'text2' con_tab 'text3' into gd_result.
‎2006 Sep 12 11:30 AM
To download data to the presentation server, you have to use GUI_DOWNLOAD function module. to download data to Application server, you have to use open-dataset-transfer-close-dataset statements.
if you see the methods of CL_ABAP_CHAR_UTILITIES, there is a method CR_LF to do your requirement. its like Carriage return and Linefeed. if you add this at the end of each record,automatically next record will appear on the next line.
if you want to give any TAB space between the fields, then vertical tab method of the same class.
or if you are in a NON unicode system, then you can use
DATA : V_TAB TYPE X VALUE '09'. as V_TAB is a horizantal tab.
Regards
srikanth
‎2006 Sep 12 10:51 AM
Hi vidya,
1. There are two things :
a) if we have opened the file in text mode (on app server)
then whenever we do TRANSFER,
a new line will automatically be appended.
b) To ensure that fields come one below other with proper alignment,
we have to ensure that the data in work area of transfer,
is properly aligned within it.
ie. 12345678~~~~~123456~
(where~ may be spaces if the field is not full length)
regards,
amit m
‎2006 Sep 12 10:51 AM
Hi,
use :
do.
assign component sy-index of structure itab to <f>.
if sy-subrc <> 0. exit. endif.
concatenate string <f> into string separated by CL_ABAP_CHAR_UTILITIES=>VERTICAL_TAB .
endif.
enddo.
transfer string to file.A.
Message was edited by: Andreas Mann
‎2006 Sep 12 11:53 AM
Hi vidya,
1. For application server,
we have to use open dataset, transfer, close dataset,
(and take care of the spacing between the fields)
2. For presentation server,
we have to use the fm GUI_DOWNLOAD
and do not pass the parameter
WRITE_FIELD_SEPARATOR = 'X'
(when we do not pass this parameter,
the data is written in FIXED-LENGTH
including spaces)
(So when we view the data in notepad,
the fields will be very much aligned,
one below the other)
regards,
amit m.
‎2006 Sep 12 12:31 PM
thanks to everyone who has tried to help me! i could solve the problem by opening the file in text mode, wherein a new line is added for every 'transfer' statement.
Thanks once again!