06-29-2007 12:54 AM
Hi Guys,
Can anybody tell me how to insert trailing spaces for a character field which is already having a value?
Thanks,
Gopi.
06-29-2007 1:05 AM
06-29-2007 1:23 AM
Hi Rich,
But when i am downloading that data into aplication server, suppose if the filed length is 20 and the data is of only 10 and for the rest 10 digits spaces is not getting inserted .so how to insert spaces into the filed.
Thanks,
Gopi.
06-29-2007 1:28 AM
Hi Gopi,
Use WRITE ......TO with offset to write into an internal table.
like:
WRITE dobj TO itab[+off][(len)]
Try this..
Regards
Subramanian
06-29-2007 1:36 AM
06-29-2007 1:37 AM
Hi Gopi,
When you download the data on application server and that field is the last field then the spaces are automatically removed.
Just try with END of line character at end, may you get the spaces in application server after that.
Regards,
Atish
06-29-2007 1:53 AM
Hi Rich ,
I am using Transfer statement like what u told .
"TRANSFER ls_EBKN_temp TO wa_PurchReq_AcntAssgmnt_file length 450 ."
but also not solved the problem.
Thanks,
Gopi.
06-29-2007 1:33 AM
Check with below links :
if you use concatenate command ,it will remove spaces,
http://www.sapfans.com/forums/viewtopic.php?t=200517&highlight=filedownloadspace
http://www.sapfans.com/forums/viewtopic.php?t=123275&highlight=filedownloadspace
Thanks
Seshu
06-29-2007 1:49 AM
Hi Seshu,
In the reply u send me Links.There they told not to use Concatenate ,Then how can i transfer the data with Trailing Spaces.He told me to use
" move: fieldval1 to string+0(500),
fieldval2 to string+500(12) *field2 consists of 12 characters "
but the Q'n is how to insert Tab delimited Spaces ?can u plz help.
Thanks,
Gopi.
06-29-2007 1:53 AM
<i>but the Q'n is how to insert Tab delimited Spaces</i>
Ok, so you want to put tabs in between the fields? You can do so, like this.
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
06-29-2007 2:29 AM
Hi Rich,
The logic which u gave doesn't worked.There was no trailing spaces in the fineal output.Can u suggest me the alternate solution?
Thanks,
Gopi.
06-29-2007 2:30 AM
06-29-2007 2:39 AM
Hi Rich ,
I mean b/w the columns there must be Trailing spaces for each filed like 17 spaces (becoz u meantioned size as 20 and only 3 characters are used)u must have b/w each column and also tab delimiter.
the output is
ABC DEF DEF
123 456 456
Thanks,
Gopi
06-29-2007 2:49 AM
Ok, this will work, but if there are any spaces in any fields, it will be a problem.
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.
translate itab using '# '.
concatenate itab-field1 itab-field2 itab-field2 into str
separated by con_tab.
translate str using ' #'.
transfer str to d1.
endloop.
close dataset d1.
You need to translate the spaces and use a placeholder, then after the concatenation, translate it back.
06-29-2007 3:14 AM
Hi rich,
I got data in this format for the logic which u told
"ABC##DEF##GHI#######################################################################################
123##467##798#######################################################################################
"
Thanks,
Gopi.
06-29-2007 3:35 AM
06-29-2007 4:22 AM
Hi rich ,
It worked well i got spaces ,But how to include in my program?
Thanks,
Gopi.
06-29-2007 4:32 AM
This may help you.
WRITE 'ABC' To char Right-justified.
Reward points if useful.
Regards,
SaiRama
06-29-2007 4:54 AM
try with this in your program
* Download internal table to Application server file(Unix)
DATA: e_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.
open dataset e_file for output in text mode.
lOOP AT it_datatab......
transfer it_datatab to e_file.
ENDLOOP.
close dataset e_file.
reward points if it is usefull ...
Girish