View previous topic :: View next topic
|
Author |
Message |
dilpreet
New User
Joined: 18 Mar 2008 Posts: 34 Location: INDIA
|
|
|
|
My requirement is that i am reading a field from a input file and need to
remove the trailling commas from the field if present .
e.g.
WS-field = bank of india, (So need to remove the comma after india)
WS-field = Bank,of india (no need to do anything)
What is the possible way to use INSPECT command in this case.
Only comma at the end of the field needs to be removed.
Thanks. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
How about using the REVERSE function to strip the blanks, then trim the first comma, then reverse back...
O. |
|
Back to top |
|
|
dilpreet
New User
Joined: 18 Mar 2008 Posts: 34 Location: INDIA
|
|
|
|
what exactly you mean by strip blanks . could you please provide me with the syntax . |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
O is talking about a general case - If the field is of nature:
Code: |
1. bank of india,$$$$$
2. bank of india,$$$$
3. bank of india,$$$
4. bank of india,$$
5. bank of india,$
6. bank of india, |
where $ represent "a space". Then, reverse the string. check for first comma and reverse-back...
If that does not make sense, please tell
dilpreet wrote: |
Only comma at the end of the field needs to be removed. |
When do you say that "end of field" is reached? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Anuj,
The "end of field" is the last non-blank. If this is a comma, it should be removed. |
|
Back to top |
|
|
dilpreet
New User
Joined: 18 Mar 2008 Posts: 34 Location: INDIA
|
|
|
|
Could anyone pls help out with the Syntax to the above problem.
it would be a great help!!! thanx |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
use reference modification backwards...
I do not speak COBOLESE here is a hint
start from the last char of the field
check ( using the reference modification construct ) the char at the index position
if it is a blank iterate ( decrementing the index )
if it is a comma store a blank in that position and leave the iteration loop
else leave the iteration loop |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Could anyone pls help out with the Syntax to the above problem. |
You need to develop the syntax. . .
We can help if you have questions/problems.
You basically have 2 choices both of which have been mentioned in the replies to your topic:
1. REVERSE the value in field and look at the first non-blank to see if it is a comma.
2. Parse the field using REFERENCE MODIFICATION to start from the "end" of the field until the first non-blank is found. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Thanks Dick...hopefully OP is on his way with the logic now... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Anuj,
We can only hope. . .
d |
|
Back to top |
|
|
|