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
 

 

Unstring in Cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Govardhana krishna

New User


Joined: 29 Apr 2008
Posts: 9
Location: INDIA

PostPosted: Thu Oct 17, 2013 8:52 pm    Post subject: Unstring in Cobol
Reply with quote

Hi,
The data in the sting is mixed with Alpha numeric & numeric and every field is separated by comma. (,). but all the alphanumeric fields has a additional quotes in it.

But i need to remove the additioanl quotes from Alphanumeric fields in order to perform unstring by comma to use the data.

Example 1:
'"600","CY",8,"3787660","000043877",14099.83,1166.96,"USD"'.

But I need the above record as shown below:
EXAMPLE2:
'600,CY,8,3787660,000043877,14099.83,1166.96,USD'.

So that i can unstring the data shown in exapmle 2 using just ','.


Note:
I managed to remove the quotes using ICETOOL Replace command but it takes 4 step procedure to remove . But is there any way using Inspect or any cobol command to remove the additional quotes in alphanumeric fields?

Thanks,
Govi.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Thu Oct 17, 2013 9:19 pm    Post subject: Reply to: Unstring in Cobol
Reply with quote

Well, you don't need to remove the quotes to get the UNSTRING to work.

If the quotes are not "protecting" a potential embedded comma, then they are useless anyway, and you can request that the provider of the data drops them.

If they are potentially protecting a comma, then your UNSTRING is not going to be reliable anyway.

So which is it?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 18, 2013 6:26 pm    Post subject:
Reply with quote

INSPECT REPLACE, replaces, does not remove (simple look in the reference would have answered that.)

as Bill said, the easiest would be to have double quotes removed at file creation time,
but often this is not easy to organize,
especially in a big organization.

casual inspection of your data (what little you have provided)
shows that there are probably NO imbedded commas,
so blindly removing the double quotes is probably your solution.

the actual code that SORT would generate probably is the fastest,
(though why it requires 4 steps is beyond me, simple replace '"' with '')
though it involves invoking another program and
a father-son of the file (input and output)

so, fastest would probably be to
write a simple COBOL PERFORM
to run an index down the source string
moving only non-double quote characters to a destination string via a second index.
Small strings (less than 256) could be also addressed thru subscripts without a performance hit.


then UNSTRING from the new area populated by the above routine.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Fri Oct 18, 2013 7:24 pm    Post subject:
Reply with quote

I have never tried it, but would following not work?
Code:
UNSTRING xx DELIMITED BY ALL ',' OR ALL '"'...

or does that only work with ,,, and """ but not with a combination of " and , ?

or maybe try
Code:
UNSTRING xx DELIMITED BY '","' OR '",' or ',"' or ',' or '"' ...

not sure how this would respond.


(don't want to test this on my new clients mainframe)
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Fri Oct 18, 2013 9:13 pm    Post subject: Reply to: Unstring in Cobol
Reply with quote

With the first you'd get a pile of "empty" fields interspersed with data (and assuming the previous values had been cleared first). You'd not want the ALL either, as multiple commas would not be correctly processed.

The second is a good shot and would work, since you have taken care with the order of the delimiters.

Another possibility is

Code:
group-item.
  subordinate filler length one
  subordinate data with final quote


UNSTRING into fields like that, then deal with the trailing ".

TS has a SORT solution already. Choosing how to do it in COBOL also depends on how the data is to be processed afterwards.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Sat Oct 19, 2013 1:41 am    Post subject: Reply to: Unstring in Cobol
Reply with quote

You're standing there cutting mushrooms, when suddenly it comes to you.

It would need "WITH POINTER" to get over the fact that there may be a delimiter as the first character of the data areas.
Back to top
View user's profile Send private message
madprasy

New User


Joined: 08 Apr 2008
Posts: 31
Location: Chennai

PostPosted: Sat Oct 19, 2013 11:24 am    Post subject:
Reply with quote

Inspect will help if the record length and positiion of the fields are constant..
Else go for SORT, using <competitor link removed>
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Sat Oct 19, 2013 2:14 pm    Post subject: Reply to: Unstring in Cobol
Reply with quote

There is already a SORT solution for this requirement here.
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
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


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