Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

removing trailling comma from the input field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: removing trailling comma from the input field
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: 2360
Location: Israel

PostPosted: Mon Nov 29, 2010 6:48 pm    Post subject:
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    Post subject:
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

Senior Member


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

PostPosted: Mon Nov 29, 2010 7:48 pm    Post subject: Re: removing trailling comma from the input field
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

Site Director


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

PostPosted: Mon Nov 29, 2010 10:01 pm    Post subject:
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    Post subject: Reply to: removing trailling comma from the input field
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Mon Nov 29, 2010 11:31 pm    Post subject: Reply to: removing trailling comma from the input field
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

Site Director


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

PostPosted: Tue Nov 30, 2010 12:51 am    Post subject:
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

Senior Member


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

PostPosted: Tue Nov 30, 2010 2:03 pm    Post subject:
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

Site Director


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

PostPosted: Tue Nov 30, 2010 9:19 pm    Post subject: Reply to: removing trailling comma from the input field
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us