Hi there, I have come to see that DFSORT helps to retain between a PAIR , but is there an option that can be turned on to remove blanks only between a PAIR
The below code retains a space between two apostrophes.
Can this be modified to consider only spaces between apostrophes some how ?
I have tried to looking into User Guide for DFSORT PTFs UK90007 and UK90006 but I am not able to figure it out. Pardon me if it is out there and I have missed it.
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello mohanaraj_e and welcome to the forums,
Quote:
Can this be modified to consider only spaces between apostrophes some how ?
Please post some sample input and the output you want from that input.
Please mention the dsorg and lrecl of the data as well as the positons within the record you want to work with - if it is the entire record, mentio that as well.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
I don't understand what you're trying to do. You say "Can this be modified to consider only spaces between apostrophes some how ?".
But your example doesn't have any apostrophes.
You need to explain more clearly what you're trying to do with an example that fits what you say.
It looks like you want to remove blanks in some cases but not others, but it's not clear from you example what the rules are and they don't seem consistent. For example:
Code:
~John Doe ~ becomes
~John Doe~
~1234 ~ is not changed.
So in one case you're keeping a blank in the middle but removing the trailing blanks and in the other case you're keeping the trailing blank.
What rule would the program use to know which blanks you want to remove and which blanks you want to keep? DFSORT is not a mind reader ... it must follow rules you give it. If you can't explain the rules, then there's no way we can "encode" them.
Apologies for the confusion. I had tried to make a general statement regarding pair and used apostrophes but gave a different input on files .Didnt realise that i messed it up.
What I was looking for was whether a blanks between a pair,Let me say in this case what I am looking for is a tilde delimited file from a file which has been created by a COBOL program with fixed copy book.
My requirements are twofold
1.Any blanks between two tildes should be squeezed out i.e if there is no data between those two all blanks must be removed.
2.If there is data between two tildes, only trailing blanks before the next Tilde should be removed
My earlier details should be read as
Input
--------
Code:
~1234~James Anderson~ ~TELNO1~XX~
~ ~John Doe ~1234 ~ ~YY~
The original file I am actually looking contains nearly 120 fields , LRECL is 909 and RECFM is FB .
But I feel that these 5 fields can be used for reference with a LRECL of 38 and RECFM of FB and the solution can be extrapolated to the entire file.But do let me know if you need more fields.
The maximum length of first field will be 4 characters
The maximum length of Second field will be 14 characters
The maximum length of third field will be 8 characters
The maximum length of fourth field will be 6 characters
The length of fifth field will be 2 characters
To answer your other question, any field in the file can have blanks in the middle.
I took a look at the file again and realised that there are are ~ in the first and last positions
The file looks like below
Code:
1234~James Anderson~ ~TELNO1~XX
~John Doe ~1234 ~ ~YY
And expected output is
Code:
1234~James Anderson~~TELNO1~XX
~John Doe~1234~~YY
My apologies for the confusion and lengthy post.Didnt want make you go on the wrong path.
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
mohanaraj_e wrote:
My requirements are twofold
1.Any blanks between two tildes should be squeezed out i.e if there is no data between those two all blanks must be removed.
2.If there is data between two tildes, only trailing blanks before the next Tilde should be removed
or to make it simpler any blanks preceeding a tilde should be removed.
Thank you very much Frank for all your effort on this . I see that its working fine.
But as I said earlier the file is made up of more than 100 fields and I feel that writing a card like you have written may not be a good option. Thats my opinion though.
Now as Craq has put forth , my requirement can be simplified into any blanks preceding the delimiter(~) should be removed. Let me do some analysis to see if the guide provides some help on this. would be great if there is a silver bullet solution to this.
Let me give the back ground of why I have come up with such a requirement. I am re-engineering an Oracle-Unix system into an COBOL-DB2-JCL system.The earlier interface used to interact with a lot of external systems through delimited Variable Length files. But now when we have designed the new system we find that we may need the file in many other places internally and it might be a good option to create it based on a fixed copy book for internal use rather than a Variable one. The same file can be to be sent to external systems after squeezing out all the trailing blanks between the delimiters
Frank and Craq,Appreciate all your effort on this.