2007 Oct 01 10:51 AM
Hello,
When i transfer a tab delimited file from pre. server(windows) to app. server(windows) using CG3Z , the tab delimitation is not working.
for eg : the file with below layout
01.04.2007 31.03.2008 1 120
01.05.2007 31.07.2008 2 140
is getting changed like
01.04.2007#31.03.2008#1#120
01.05.2007#31.07.2008#2#140
All i need is a tab delimited file in app server also . Wats that i need to do for this ? Also how can i write a tab delimited file on app server through my program using open dataset.
Thanks for ur time.
Jeeva.
2007 Oct 01 10:56 AM
Hi Jeeva,
You can use the attribute of class cl_abap_char_utilities.
Attribute is horizontal_tab....
then you can split at value at tab. Tab appreas as "#" in application server. use this class, will solve your problem
Jayant Sahu
2007 Oct 01 10:54 AM
Hi..
Check this code: you will find the solution:
Using the Static Attribute <b>CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB</b>
Example:
This is the Simple way you can download the ITAB with Tab delimiter:
DATA : V_REC(200).
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT ITAB INTO WA.
Concatenate WA-FIELD1 WA-FIELD2
INTO V_REC
SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
TRANSFER V_REC TO P_FILE.
ENDLOOP.
CLOSE DATASET P_FILE.
Note: if there are any Numeric fields ( Type I, P, F) In your ITAB then before CONCATENATE you have to Move them to Char fields ..
Reward if Helpful.
Example:
DATA: V_RECORD(200).
OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
DO.
READ DATASET P_FILE INTO V_RECORD.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
SPLIT V_Record at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
INTO WA-FIELD1 WA-FIELD2.
APPEND WA TO ITAB.
ENDDO.
<b>reward if Helpful.</b>
2007 Oct 01 10:56 AM
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
Vasu
2007 Oct 01 10:56 AM
Hi Jeeva,
You can use the attribute of class cl_abap_char_utilities.
Attribute is horizontal_tab....
then you can split at value at tab. Tab appreas as "#" in application server. use this class, will solve your problem
Jayant Sahu
2007 Oct 01 11:27 AM
i tried to write a file on app server using CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB, but i could see the file still separated by # instead of tab.
I read the same # file from app server using CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB and im able to get right data.This says # is considered as tab.
Does this mean that , when we use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB , a tab delimited file gets created but the tab appears as # in app server ???
2007 Oct 01 11:33 AM
Hi,
yes Tab appreas as "#" in application server.
Regards,
Nagaraj
2007 Oct 01 11:39 AM