Preserve a single space at the end of line using spool command
Hi,
Can you please help me to write the result of an sql query into a file with the last column of the row ending with a single space?
For example:
COL1DATA|COL2DATA|COL3DATA<space1>
As mentioned in the example the col3 value in the file should end with a single space. And there should not be any delimiters at the end of the row.
I tried with set trimspool on/off. But, it didn't work. When I say trimspool on - it is trimming all the trailing spaces.
When I say trimspool off - it is retaining all the trailing spaces to the size of the line.
But, I do not wish to modify the file through shell commands once it is written thru spool. I mean I do not wish to append spaces to the end of a line using shell script or any other method.
I do not wish to use other methods like UTL_FILE also.
Please help me how to do it using spool command?
Thank you.
Ramana
My requirement is that all the trailing spaces should be truncated except the last one in the row.Why?
As you have discovered a single column in sqlplus, is always a fixed length regardless of the size of the data, if the length of the data varies the output is padded to the maximum or line size with spaces. The trim and trimpsool commands are there to remove all the spaces from the end of a line if there are any. There are no commands to trim all the spaces except one, or even to trim all the spaces except two, or three even.
If you want such custom processing you should post process the file in the OS using sed, awk or perl or something designed for such things.
Similar Messages
-
DATA TRANSFER - How to get a SINGLE SPACE in the downloaded file from UNIX?
Hi Experts,
Am sending data from SAP to UNIX/ Application server and text file on desk top as well.
So, I am keeping a single character just SPACE at the END of each record.
Then, When I see the downloaded text file, I found a SINGLE SPACE at the end of each record, fine.
Then, by using CG3Y t code, I downloaded the UNIX file to my desk top.
But, When I see this UNIX downloaded file from UNIX, I did NOT find any SPACE at the end of each record!!!
Am doing every thing same in both cases.
So,
1 - Why its happening in case of UNIX file?
2 - How to get a SINGLE SPACE at the END in the downloaded file from UNIX?
thanqHi,
I don't know if this works:
perform SET_TRAIL_BLANKS(saplgrap) using 'X'.
perform SET_FIXLEN(saplgrap) using '0' '060'. "put length of your line from-to
... download ...
It will put space at the end of your line, according to the length.
Hope it works,
Chang -
How to pad spaces at the end of a string
Hi All,
I am new to ABAP and need help to achieve this functionality
I have to build a string with fixed lenth . my input string
is always lesser than equal to X . I need to calculate and
add that many spaces at the end of the input string .
I tried to do this and getting the following error
please help on this :
if strlen( t_resultc ) < 525.
RFILL(t_resultc,' ',525)
endif.
Error : Comma without preceding colon(after RFILL(T_RESULTC ?)
Q: Can I use RFILL with out Select statement in a ABAP program
Thanks & Regards
KLKHi,
Try the following code but kindly make a note..
Note:-USE quote like this ` `, Instead of normal single quotes ‘ ’
WHILE strlen( T_RESULTC ) < 525. “Check the length
CONCATENATE T_RESULTC ` ` INTO T_RESULTC. ”Add spaces at the end
ENDWHILE.
Hope this helps,
Andrew -
How to add spaces at the end of record
Hi Friends,
i am creating a file which contains more than 100 records.
In ABAP i have internal table with on field(135) type c.
some time record have length 120, somtime 130 its vary on each record.
but i would like to add space at the end of each record till 135 length.
Can you please help me how to add speace at the end of record.
regards
MalikSo why did you said that in your first posting? My glass sphere is out for cleaning...
Instead of type c use strings and add spaces until they have the appropriate length.
loop at outtab assigning <pout>.
while strlen( <pout>-val ) < 135.
concatenate <pout>-val `` into <pout>-val.
endwhile.
endloop. -
Blank spaces at the end of an IDoc text field get lost when posted to R/3
Hi Guys,
I am facing the following issue:
In an XML file-to-Idoc scenario, there are spaces at the end of a text field in the inbound XML file, which I can see when I open the inbound file with a text editor like notepad, and they are kept after XI mapping is executed (I can see them in message mapping simulator). However, it seems that these spaces get lost once the IDoc is posted to SAP R/3 and they are not visible on SAP R/3 side.
Do you have any idea ? Thanks.
Best Regards,
Evaggelos GkatziosThat means SAP is removing the spaces from IDoc fields, where you spaces are not allowed. Does it create any problem?
Thanks,
Nabendu. -
Hello,
Is there a way to recognize space sign at the end of a sentence?
The meaning of that is that there is a word that somebody typed at the end of the sentence
and after that pushed the space bar . When looking at the text inside the sap system the text looks fine,
but when transferring to excel the text doesnt equal because the space at the end of the sentence.
Please advise
YifatDo you want to handle that space or just use the text value?
If you just want to use the text value (i.e 1word - space)...u simply say CONDENSE <UR TEXT VARIABLE>.
Else the other option is: Find the string length and then handle it the way u want.
Or if u r sure that every word has that extra space, and u dont want that u can even use SHIFT RIGHT BY 1 PLACE in thet text variable.
Hope this helps.
Thanks
Kiran -
PI removing blank spaces at the end of the lines in a plain text file
Hi -
I have an interface that transfers a file via FTP. I defined both the sender and receiver to transfer either Text or Binary but the interface removes every blank space I have after the last character. The file is a fixed lenght file.
Example:
Original file:
Hello world(space)(space)(space)(space)(space)(space)(space)(space)(eol)
where (space) is the space character and (eol) is the end of line char.
File after it is received.
Hello world(eol)
I already defined the parameter Row.fieldFixedLenghts with 10164 which is the lenght of the lines of the file.
Any ideas why it may be happening?
Thanks,
Carlos.Hi -
I tried both the parameters:
xml.fieldContentFormatting
structure.fieldContentFormatting
The received file still has the problem. All the blank spaces are cleared out.
The file is a plain text file not an XML file. May this be the issue?
Thanks,
Carlos. -
Check space in the end to display warning message.
I am currently working on validations on functional locations in the EDIT MASK. the code is already written for validations on to check for space in the beginning of the each level in the edit mask. however user requirement is that the program should produce warning messages for spaces regardless of where they appear in the Edit Mask. we have not validated to check for space at the end of each level.
I have checked with condense ,shift string right deleting trailing spaces however I am not able to check for space at the end of levels.
when i debugged the program the level8 length shows as 2 even though there is only one char in the level8. i
could you please suggest any possible solution or any keywords that would help. you can go through the below code which is already written for checking space in the begining.
here l_level1
Level 8 errors
l_length = STRLEN( l_level8 ).
IF ( l_level8 = space AND l_dash_count > 6 ) OR
l_dash_count > 7 OR
l_length > 4.
lt_mask_err-error = '8E'.
APPEND lt_mask_err.
l_errlvl8 = c_y.
ENDIF.
Level 8 Warning
IF rb_bdc <> c_on AND p_warn = c_on AND
( l_level8 <> space AND l_level8+0(1) = space ).
lt_mask_err-error = '8W'.
APPEND lt_mask_err.
ENDIF.
i have added this code to display warning message using shift.
l_lev8 = l_level8.
shift l_lev8 right.
l_length = STRLEN( l_lev8 ).
IF rb_bdc <> c_on AND p_warn = c_on AND
( l_lev8 <> space AND l_lev8+0(1) = space ).
lt_mask_err-error = '1W'.
APPEND lt_mask_err.
ENDIF.You can use REGEX for string parsing, it is really handy. If you would like to test it out check out program "demo_regex_toy".
Trailing space:
FIND REGEX '[ ]+$' IN lv_text.
leading space
FIND REGEX '^[ ]+' IN lv_text.
Any space
FIND ALL OCCURRENCES OF REGEX '[ ]+' IN lv_text. -
Adding space at the end of a ritchEditableText line
Hi!
I found an interesting behaviour in my application. I have a RichEditableText component with a fixed width . If I add text till almost the end of the line and then insert spaces, the cursor get's stuck at the end of the line. My surprise was on retreiving the text from that line in the code, where all that spaces existed even if they were not visible in the app. So on screen you see let's say 3 spaces, but then you save the text you can get 10. If you keep inserting any letter the cursor will move itself to the next line, but this does not seem to be the case of " "(space).
I tested it useing the following code. I'm useing 4.1 sdk.
<s:RichEditableText id="richTxt" width="100" height="500" change="richTxt_changeHandler(event)" />
protected function richTxt_changeHandler(event:TextOperationEvent):void
var noOfLines:int = richTxt.textFlow.flowComposer.numLines;
for (var i:int = 0; i < noOfLines; i++)
var startIndex:int = richTxt.textFlow.flowComposer.getLineAt(i).absoluteStart;
var seqLength:int = richTxt.textFlow.flowComposer.getLineAt(i).textLength-1;
var textLine:String = richTxt.text.substr(startIndex, seqLength);
I try to set clipAndEnableScrolling=true; for richTxt but this thid not change anything.
How can I retrieve only the visible text( with the corect number of spaces at the end of the line) from the RET in order to save it ?
Thanks !Do you want to handle that space or just use the text value?
If you just want to use the text value (i.e 1word - space)...u simply say CONDENSE <UR TEXT VARIABLE>.
Else the other option is: Find the string length and then handle it the way u want.
Or if u r sure that every word has that extra space, and u dont want that u can even use SHIFT RIGHT BY 1 PLACE in thet text variable.
Hope this helps.
Thanks
Kiran -
May I run "shrink DB/truncate free space from the end of file" at PROD?
We have a SAP/MSS production system.
The disk is full.
We want to truncate the log file by:
"shrink DB/truncate free space from the end of file"
on the log file.
How risk is it? Can we do it during production is running?
Thanks! Points!Backup the log file (to save the data and keep a consistent backup) Then shrink the file. Its normal for the log not to shrink down to the size you want. Do not shrink past 1GB.
DO NOT TRUNCATE - you are losing/dropping data and recovery will only be possible to the last on-line, or on-line plus last log/s.
You can avoid a full log file by setting a 9002 trap - this will trigger a backup (like oraarch when you back up based on % full). Else you need to change the frequency of the backups for the logs to ensure the system never fills ups.
You can Also add a second log file on a separate F/S if this occurs regular - which it shouldn't if you have a correct backup strategy. -
How to delete the ends of line ["\n"] in a String before parsing
hi, i'd want to parse a String with Regex/Pattern.
This String contains ends of line i want to delete before applying my parsing treatment.
I've tried to do that by replacing the character "\n" with "" :
// the original text
String orgTextToParse = new String(buffer);
//we create a pattern to recognize the ends of line
String regExpEol = "\n";
Pattern patternEol = Pattern.compile(regExpEol);
Matcher matcherEol = patternEol.matcher(orgTextToParse);
// the new text without end of line
StringBuffer newTextToParse = new StringBuffer();
// we replace the "\n" by ""
while(matcherEol.find()) {
String REPLACE = "";
matcherEol.appendReplacement(newTextToParse,REPLACE);
matcherEol.appendTail(newTextToParse);
System.out.println("[new string start] " + (newTextToParse.toString()) + " [end of new string]");Is there an appropriate way to delete "\n" ?
(perhaps a method of the Pattern or Matcher classes... ?)
thanx
Edited by: jfact on Dec 29, 2007 11:05 AM
Edited by: jfact on Dec 29, 2007 11:06 AMThe second (optional) argument to Pattern is a set of flags. Take a look at the Javadoc.
The 'genomic' implication is that the EOL is an arbitrary line break for human consumption so it does look like you need to remove the EOL. I would just use replaceAll() since it can be done with one line of code (or just a couple if you pre-compile the regex) without the need for any looping.
line = line.replaceAll("\n","");Edited by: sabre150 on Dec 29, 2007 10:27 AM -
At the end of line # is coming in output file at application directory
Hi experts,
I am doing a file to file tunneling in which from a file server I am picking the file and putting it into SAP application server nothing is done in IR .However when the file is reaching in application server its end seprator is coming as # .I am surprised from where the #is coming at the end of every line.When i am dowloading the same file to my local directory in that file # is not there.
Please help me as my client is not accepting the file with endsepeartor as # .
Might be # is coming as the apllication server is in uniq env . But how to get rid of it .Please guide me with whatever input you have in this regard.
Regards,
NehaHi Neha,
I think you do not have to do anything because see you said on saving the file locally, you are not able to see the # character at the end of line..........but when you are seeing in SAP window, then this # character is displayed..............so your SAP server can be a UNIX server and it is displaying the End of Line and Carriage Return ASCII characters as # because these are non-displayable characters.....
But still if you do not want this # character to be displayed, then you can try Binary and no character encoding........then see if your file is displayed without # character.
Regards,
Rajeev Gupta -
How to merge 4-iphoto libraries on a iMac back into a single library on the same iMac. Using OS X 10.10
two ways - iPhoto Library Manager - http://www.fatcatsoftware.com/iplm/ - or Aprture
LN -
I allocated too much space on the Windows side when using bootcamp and want to take some space back for the Mac side is there any easy way to do this?
Purchase and use Paragon Camp Tune
-
Extra characters at end of line in spool file
I am trying to generate csv files from SQL Developer using queries written to spool files. I have embedded the queries and associated set commands in script files and call them, as advised elsewhere. This gives csv files that look fine, with headings and data comma separated and enclosed with double quotes. The problem is that the files seem to contain a lot of extra characters at the end of each line. They seem to be spaces, but not sure. This is causing problems for the person trying to load the data.
I'm using version SQL Developer 3.1.07.42, Java 1.6.0_11.
Any ideas on how to avoid the extra spaces appearing? Thanks for any help.
Ben.Jeff,
The SQL in the script file is below. To be honest, I have reduced it down to a simple select from dual and it still puts extra spaces at the end of the single line.
col ord noprint
spool test.csv
SELECT ' ' ord,
'ZONE_ORDER_NUMBER'||','||
'ZONE_NAME'||','||
'ZONE_TYPE'||','||
'DESCRIPTION'||','||
'START_DATE'||','||
'END_DATE'
FROM dual
UNION ALL
SELECT zone_name ord,
'"'||zone_order_number||'"'||','||
'"'||zone_name||'"'||','||
'"'||zone_type||'"'||','||
'"'||description||'"'||','||
'"'||TO_CHAR(start_date,'DD-MON-YY')||'"'||','||
'"'||TO_CHAR(end_date,'DD-MON-YY')||'"'
FROM zones
ORDER BY ord;
spool off
Maybe you are looking for
-
SOAP Sync: HTTP/1.1 500 Internal Server Error
Hi, My scenario is SOAP to SOAP Synchronous. I created WSDL from Id by using (http://<host>:<j2ee-port>/XISOAPAdapter/MessageServlet?channel=:<service>:<channel>. And Sender interface details. I am testing SOAP Synchronous scenario
-
Is it possible to add/change a ViewContainerUIElement during runtime?
Hi all, i want to add/change the content of a ViewContainerUIElement (VCUI) during runtime, but it doesn't work as expected (or hoped;). What i got working so far for an <b>already exising</b> VCUI is: 1. Find the IWDViewContainerInfo for the VCUI 2.
-
How to implement other payment methods like PayPal in CRM 7.0
Hi, I am looking for more payment methods than the (obviously) three available in CRM 7.0. Is there a way to implement payment methads like: PayPal, Mobile Payment, immediate transfer, debit entry, defferd payment etc.? Thanks for helping me out. Lar
-
After upgrading to iOS5.1 on iPad I cannot upgrade apps
Really frustrated, I have an iPad 1 and have been using it very hapily for over a year. I foolishly decided to upgrade to ios5, and since then have nothing but problems. Apps that I have downloaded from the AppStore as free trials work, but when i tr
-
Tomcat5.sh in Tomcat 5.5.7
Hi, I am currently running tomcat as a daemon on linux, so when the computer starts up, tomcat also starts up using the file Tomcat5.sh. Does anyone know what code i need to add to Tomcat5.sh, so it also uses the security manager? Thanks.