Comparing records within same file

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
Basav
Member
Posts: 7
Joined: Thu Sep 10, 2015 3:26 pm

Comparing records within same file

Post by Basav » Thu Sep 10, 2015 3:36 pm

I have requirement like below input file , At end i need to write GAIN and NON-GAIN combination of same accnt_num

i/P:
accnt_num cust_num status
0192002682|0000001004931|GAIN
0192002682|0000000706570|NON-GAIN
4000000018|0001935277780|GAIN
4000000018|0001943580989|GAIN
5192002681|0000001004932|GAIN
5192002681|0000000706570|NON-GAIN
6792002686|0000000706570|NON-GAIN
6992002688|0000000706570|GAIN
7192002683|0000001004932|NON-GAIN
7192002683|0000000706570|GAIN

Desired output :
O/P:
0192002682|0000001004931|GAIN
0192002682|0000000706570|NON-GAIN
5192002681|0000001004932|GAIN
5192002681|0000000706570|NON-GAIN
7192002683|0000001004932|NON-GAIN
7192002683|0000000706570|GAIN


Can soemone please help me on this.
efge

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

Post by William Collins » Thu Sep 10, 2015 9:11 pm

Will there always be no more than two records per account?

Basav
Member
Posts: 7
Joined: Thu Sep 10, 2015 3:26 pm

Post by Basav » Fri Sep 11, 2015 9:31 am

William Collins wrote:Will there always be no more than two records per account?
Thank you William for your reply.

Yeah, We can expect more than two records per account.
efge

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

Post by William Collins » Fri Sep 11, 2015 11:51 am

OK, can you show some variations of the more than two in your sample data, with expected output?

Basav
Member
Posts: 7
Joined: Thu Sep 10, 2015 3:26 pm

Post by Basav » Fri Sep 11, 2015 9:51 pm

William Collins wrote:OK, can you show some variations of the more than two in your sample data, with expected output?
Sure William,

I/P:
accnt_num cust_num status
0192002682|0000001004931|GAIN
0192002682|0000000706570|NON-GAIN
0192002682|0000001004931|GAIN
0192002800|0000001004931|GAIN
4000000018|0001935277780|GAIN
4000000018|0001943580989|GAIN
5192002681|0001004932|GAIN
5192002681|0000000706570|NON-GAIN
6792002686|0000000706570|NON-GAIN
6992002688|0000000706570|GAIN
7192002683|0000001004932|NON-GAIN
7192002683|0000000706570|GAIN
7192002683|0000001004932|NON-GAIN

Desired output :
O/P:
0192002682|0000001004931|GAIN
0192002682|0000000706570|NON-GAIN
0192002682|0000001004931|GAIN
5192002681|0000001004932|GAIN
5192002681|0000000706570|NON-GAIN
7192002683|0000001004932|NON-GAIN
7192002683|0000000706570|GAIN
7192002683|0000001004932|NON-GAIN
efge

Basav
Member
Posts: 7
Joined: Thu Sep 10, 2015 3:26 pm

Post by Basav » Mon Sep 14, 2015 12:00 pm

Hi William ,

Is it possible to get it using ICETOOL ?.

Please help me on this.

Thanks in advance.
efge

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

Post by William Collins » Mon Sep 14, 2015 5:49 pm

A JOINKEYS, with the same dataset for both inputs.

Use a JNF2CNTL DD.

Extend each record, with INREC to have two counts. Set the count to 1 for GAIN (with non-gain-count count being zero) and vice versa.

SUM those two fields.

The JOINKEYS will match on the key, and if both counts are non-zero you have an account you want.

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