View previous topic :: View next topic
|
Author |
Message |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
I have following record :
Code: |
100 RECORD1
200 RECD2
300 RECORD3
400 RECD4
500 RECORD5
|
here, 100 is field-1(starting at position 1 and length is 3) and RECORD1 is fieled-2(starting at position 5 and length is 10)
All I want to do is to select only those records whose second fields data length is greater than 5.
in my example , i am intrested in records :
Code: |
100 RECORD1
300 RECORD3
500 RECORD5
|
How do I write the DFSORT control statement to get this done ?
Any help is highly appreciated.
Thanks. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
One way to do what you want is to INCLUDE only records that are non-blank in the last 5 positions (or OMIT those that are blank). |
|
Back to top |
|
|
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
@dick
Thanks for the quick response.
Is there any length function that could serve the purpose.
I have researched on this but couldnt find any results.
Thanks a lot. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Specify the length (which for your question is 5) in the include or omit statement. . . It is part of the required syntax. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
There is no "find the length of the characters up to the first blank" function.
But there are other ways to do what you want. |
|
Back to top |
|
|
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Hi Frank,
Could you please tell me what are the other ways to do this.
Thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If the posted "requirement" and the suggested solution do not do what you want, you need to post the "real" requirement (i.e. What are you really trying to accomplish?).
Suggest you post some "real" sample input and the output you want from that sample input. Post the rules for getting from the input to the output. Mention the recfm and lrecl of the files. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Quote: |
100 is field-1(starting at position 1 and length is 3) and RECORD1 is fieled-2(starting at position 5 and length is 10)
All I want to do is to select only those records whose second fields data length is greater than 5.
|
By your definition, all the second fields have a length of 10. They may be padded with blanks or nulls, but they still have a length of 10.
Any chance you might be dealing with a VB rather than FB file?
Garry. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
Could you please tell me what are the other ways to do this. |
Assuming your input has RECFM=FB and you want to keep the records that have a non-blank in positions 1-6 (> 5 non-blank characters), you can use these DFSORT control statements:
Code: |
OPTION COPY
OMIT COND=(5,6,SS,EQ,C' ')
|
So if your input records were:
Code: |
100 RECORD1
200 RECD2
300 RECORD3
400 RECD4
500 RECORD5
601 A
602 AB
603 ABC
604 ABCD
605 ABCDE
606 ABCDEF
607 ABCDEFG
608 ABCDEFGH
609 ABCDEFGHI
610 ABCDEFGHIJ
|
Your output records would be:
Code: |
100 RECORD1
300 RECORD3
500 RECORD5
606 ABCDEF
607 ABCDEFG
608 ABCDEFGH
609 ABCDEFGHI
610 ABCDEFGHIJ
|
If that's NOT what you want, then you need to do a better job of explaining what you do want with better examples of input and expected output. |
|
Back to top |
|
|
|