IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

removing trailling comma from the input field


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dilpreet

New User


Joined: 18 Mar 2008
Posts: 34
Location: INDIA

PostPosted: Mon Nov 29, 2010 6:44 pm
Reply with quote

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
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Mon Nov 29, 2010 6:48 pm
Reply with quote

How about using the REVERSE function to strip the blanks, then trim the first comma, then reverse back...

O.
Back to top
View user's profile Send private message
dilpreet

New User


Joined: 18 Mar 2008
Posts: 34
Location: INDIA

PostPosted: Mon Nov 29, 2010 6:51 pm
Reply with quote

what exactly you mean by strip blanks . could you please provide me with the syntax .
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Nov 29, 2010 7:48 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Nov 29, 2010 10:01 pm
Reply with quote

Hi Anuj,

The "end of field" is the last non-blank. If this is a comma, it should be removed.
Back to top
View user's profile Send private message
dilpreet

New User


Joined: 18 Mar 2008
Posts: 34
Location: INDIA

PostPosted: Mon Nov 29, 2010 11:22 pm
Reply with quote

Could anyone pls help out with the Syntax to the above problem.
it would be a great help!!! thanx
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Nov 29, 2010 11:31 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Nov 30, 2010 12:51 am
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Nov 30, 2010 2:03 pm
Reply with quote

Thanks Dick...hopefully OP is on his way with the logic now...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Nov 30, 2010 9:19 pm
Reply with quote

Hi Anuj,

We can only hope. . . icon_neutral.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts force tablespace using LISTDEF input DB2 1
No new posts Two input files & writing counter... DFSORT/ICETOOL 12
Search our Forums:

Back to Top