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.
But I need the above record as shown below:
So that i can unstring the data shown in exapmle 2 using just ','.
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?
Joined: 20 Oct 2006 Posts: 6970 Location: porcelain throne
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.
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
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.