String Comparision with multiple condition

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
rakeshverma060
Member
Posts: 2
Joined: Tue Feb 02, 2016 9:36 pm

String Comparision with multiple condition

Post by rakeshverma060 » Tue Feb 02, 2016 9:47 pm

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

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Tue Feb 02, 2016 11:02 pm

So, when the first-name is an initial or the last-name is two characters, you want to extract?

academyindia4

Topic deleted by Admin

Post by academyindia4 » Wed Feb 03, 2016 12:37 am

<< Content deleted By Admin >>

rakeshverma060
Member
Posts: 2
Joined: Tue Feb 02, 2016 9:36 pm

Post by rakeshverma060 » Wed Feb 03, 2016 6:35 am

[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.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Feb 03, 2016 4:19 pm

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.

Post Reply

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



Other References
Mainframe Tools and others