Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Benchwarmer

New User

Joined: 16 Jul 2016
Posts: 22
Location: desk

Posted: Wed Feb 22, 2017 2:49 am    Post subject: Need help in building a logic

I am working on a logic which is to assign a unique ID for records matched using a date and flag (Y/N).

It has following rules to assign a unique number

1. If date match
2. If Year in the date match with either month or day along with flag
3. If month and day match with difference in year is 1 along with flag

Initially we assigned unique numbers for a set of records. Now any population comes after need to be matched against the existing population to determine the unique ID.

But am unable to determine how to handle certain situations

e.g., Record from set1 with date 01/17/2017 and flag 'N' is assigned a unique value 008

New population comes in with date and flag as.
 Code: 01/01/2017 Y 01/17/2017 Y

Based on the sequence and matching logic record 1 is not matching with any previous record and assigned a unique value 009, when record 2 is processed it matched with two unique value 008 & 009.

Ideally both the records should have to match with 008.

Thanks

Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8526
Location: Dubuque, Iowa, USA

Posted: Wed Feb 22, 2017 3:05 am    Post subject:

 Quote: Based on the sequence and matching logic record 1 is not matching with any previous record and assigned a unique value 009, when record 2 is processed it matched with two unique value 008 & 009.
According to your 3 rules, yes record 2 matches both -- so why do you think it should only match record 8?

Since you did not post any of the logic you are using, how can we help you? Are the rules prioritized?
Benchwarmer

New User

Joined: 16 Jul 2016
Posts: 22
Location: desk

Posted: Wed Feb 22, 2017 3:41 am    Post subject:

 Quote: According to your 3 rules, yes record 2 matches both -- so why do you think it should only match record 8?

The ultimate goal of establishing this logic is to assign unique ID based on specified rules and it becomes failure in this case.
 Quote: Since you did not post any of the logic you are using, how can we help you? Are the rules prioritized?

Apologies for that, Record ID is unique to each record.
 Code: WS-DATE = '2017-01-01' WS-FLAG = 'Y' SELECT UNIQUE_ID   FROM RECORD_TABLE  INNER   JOIN UNIQUE_ID_TABLE B     ON A.RECORD_ID = B.RECORD_ID  WHERE (A.DATE     = WS-DATE --> Rule 1     OR (YEAR(DATE) = YEAR(WS-DATE)  AND (MONTH(DATE) = MONTH(WS-DATE)  OR  DAY(DATE) = DAY(WS-DATE)) AND  A.FLAG = WS-FLAG) --> Rule 2     OR (YEAR(DATE) BETWEEN YEAR(WS-DATE) - 1 AND YEAR(WS-DATE) + 1  AND (MONTH(DATE) = MONTH(WS-DATE)  AND  DAY(DATE) = DAY(WS-DATE)) AND  A.FLAG = WS-FLAG)) --> Rule 3

Even if I prioritize the rules, it is not going to help since the record 1 from previous post does not match for unique number '008' until the record 2 is going to be processed first. I considered using some sort sequence and I don't think it is going to help either.

Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7312

Posted: Wed Feb 22, 2017 4:22 am    Post subject: Reply to: Need help in building a logic

Make the conditions mutually exclusive, you can only get (at most) a match on one condition.

 Code: ( condition 1 ) or ( ( condition 2 ) and ( not condition 1 ) ) or ( ( condition 3 ) and ( ( not condition 2 )  and ( not condition 1 ) ) )
Rohit Umarjikar

Senior Member

Joined: 21 Sep 2010
Posts: 2343
Location: NY,USA

Posted: Thu Feb 23, 2017 1:44 am    Post subject:

 Quote: Ideally both the records should have to match with 008

Why will 01/01/2017 be a match as it has 'Y' flag instead of 'N' to get matched?
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Compare two files logic in COBOL Nishant Singhal COBOL Programming 4 Sun Aug 25, 2019 2:25 am use daylight logic in REXX maxsubrat CLIST & REXX 1 Wed Jan 30, 2019 5:08 pm Removing the period or dot from the v... gopinak COBOL Programming 6 Wed May 09, 2018 1:53 pm Logic to skip Maximum time-stamp and ... vickey_dw DB2 2 Thu Feb 01, 2018 11:15 pm Is CICS BMS logic on z/OS different ... Andi1982 CICS 2 Fri Dec 01, 2017 1:56 pm

 © 2003-2020 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us