I want to write a Sort card to extract record having name field value( last_Name or First_Name) only one or two character, We need to consider Space as well. The requirement i have tried to show in the form of Input and output file
The field Length is 40 and record length 1000(FB)
Input:
last_Name, First_Name
1) Rahul, Kumar
2) Rahul, A
3) Rajesh,B N
4) Suresh, B Y
5) AM, Tomeu
Output:
1) Rahul, A
2) Rajesh,B N
3) Suresh, B Y
4) AM, Tomeu
String Comparision with multiple condition
Moderators: Frank Yaeger, Moderator Group
-
- Member
- Posts: 2
- Joined: Tue Feb 02, 2016 9:36 pm
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
-
- Member
- Posts: 2
- Joined: Tue Feb 02, 2016 9:36 pm
[quote="William Collins"]So, when the first-name is an initial or the last-name is two characters, you want to extract?[/quote]
We need to compare the string "," in the name record. If the first name or the last name is having single or double character after or before the string "," then we have to fetch the record.
We need to compare the string "," in the name record. If the first name or the last name is having single or double character after or before the string "," then we have to fetch the record.
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
The fact that you show data which is irregular implies that you have to deal with anything being irregular with your name data.
This would include a comma being missing, and if there is a comma in the data following, that will cause you problems.
So, first use OVERLAY to relocate your 40-byte field to a temporary extension to the record.
Then use PARSE to create two PARSEd fields, with ABSPOS=1001 to look only at your extended data.
Use ENDBEFR=C',' for the first PARSEd field, FIXLEN=40, and use FIXLEN=40 for the second PARSEd field.
Further extend the record to include the two PARSEd fields. Use JFY with SHIFT=LEFT on both fields.
If the second PARSEd field is entirely blank, there is either no comma or no first name. What do you want to do with that?
You can then test the second or third byte of the first PARSEd field for blank. Test the second byte of the second PARSEd field for blank. This can be on INCLUDE= on OUTFIL, then BUILD=(1,1000) to drop off the extensions to the record.
This would include a comma being missing, and if there is a comma in the data following, that will cause you problems.
So, first use OVERLAY to relocate your 40-byte field to a temporary extension to the record.
Then use PARSE to create two PARSEd fields, with ABSPOS=1001 to look only at your extended data.
Use ENDBEFR=C',' for the first PARSEd field, FIXLEN=40, and use FIXLEN=40 for the second PARSEd field.
Further extend the record to include the two PARSEd fields. Use JFY with SHIFT=LEFT on both fields.
If the second PARSEd field is entirely blank, there is either no comma or no first name. What do you want to do with that?
You can then test the second or third byte of the first PARSEd field for blank. Test the second byte of the second PARSEd field for blank. This can be on INCLUDE= on OUTFIL, then BUILD=(1,1000) to drop off the extensions to the record.
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page