Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

OVERLAY several fields if non-blank

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
autobox

New User


Joined: 19 Aug 2005
Posts: 48

PostPosted: Fri Jul 10, 2015 12:42 pm    Post subject: OVERLAY several fields if non-blank
Reply with quote

Hi All

I want to compute several fields of one record based on the key field, for example the input is:

Code:
----+----1-
0001  11.11
000202     
00033333.33
00044444.44
00040404.04


1~4: the key field
5~6: field 1 with ZD format
7~10: field 2 with free format

If the key field is '0001', then field 1 & 2 divide a number, say 5, respectively, if not blanks.
If the key field is '0002', then field 1 & 2 divide a number, say 6, respectively, if not blanks.
If the key field is '0003', then field 1 & 2 divide a number, say 7, respectively, if not blanks.
If the key field is '0004', then field 1 & 2 divide a number, say 8, respectively, if not blanks.
...
And the output keep the same format as input.

I used IFTHEN and OVERLAY to handle this so far:
Code:
//SYSIN   DD *                                                     
  OPTION COPY                                                     
  INREC  IFTHEN=(WHEN=(1,4,CH,EQ,C'0001',AND,5,2,CH,NE,C'  '),     
                 OVERLAY=(5:5,2,ZD,DIV,+5,TO=ZD,LENGTH=2)),       
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0001',AND,7,5,CH,NE,C'     '), 
                 OVERLAY=(7:7,5,SFF,DIV,+5,EDIT=(TT.TT),LENGTH=5)),
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0002',AND,5,2,CH,NE,C'  '),     
                 OVERLAY=(5:5,2,ZD,DIV,+6,TO=ZD,LENGTH=2)),       
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0002',AND,7,5,CH,NE,C'     '), 
                 OVERLAY=(7:7,5,SFF,DIV,+6,EDIT=(TT.TT),LENGTH=5)),
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0003',AND,5,2,CH,NE,C'  '),     
                 OVERLAY=(5:5,2,ZD,DIV,+7,TO=ZD,LENGTH=2)),       
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0003',AND,7,5,CH,NE,C'     '), 
                 OVERLAY=(7:7,5,SFF,DIV,+7,EDIT=(TT.TT),LENGTH=5)),
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0004',AND,5,2,CH,NE,C'  '),     
                 OVERLAY=(5:5,2,ZD,DIV,+8,TO=ZD,LENGTH=2)),       
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0004',AND,7,5,CH,NE,C'     '), 
                 OVERLAY=(7:7,5,SFF,DIV,+8,EDIT=(TT.TT),LENGTH=5))
/*                                                                 


But the output is:
Code:
----+----1-
0001  02.22
000200     
00030433.33
00040544.44
00040004.04


So my questions are that:
1. How to handle several fields of one record at the same time for one, for example field 2 of record 0003 and 2 records 0004 did not overlay?
2. Any better DFSORT keyword to do this for solution and performance?

Thanks in advance!
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Jul 10, 2015 1:42 pm    Post subject: Reply to: OVERLAY several fields if non-blank
Reply with quote

What's your expected output?

The first IFTHEN=(WHEN=(logicalexpression) which is true stops the remaining IFTHEN=(WHEN=(logicalexpression) processing for that record. You can consider a number of IFTHEN=(WHEN=(logicalexpression) to be equivalent to an EVALUATE if you are familiar with COBOL.

To modify this behaviour, your need to use HIT=NEXT. This allows one further IFTHEN=(WHEN=(logicalexpession) to be true for that record (HIT=NEXT can be used multiple times).

On the first of your IFTHEN= pairs, you need to code ,HIT=NEXT before the closing bracket of the IFTHEN.
Back to top
View user's profile Send private message
autobox

New User


Joined: 19 Aug 2005
Posts: 48

PostPosted: Fri Jul 10, 2015 2:16 pm    Post subject:
Reply with quote

Hi Bill,

Added HIT=NEXT to each IFTHEN, it works!

Thanks so much, I spent 2 days on this already.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Jul 10, 2015 3:31 pm    Post subject: Reply to: OVERLAY several fields if non-blank
Reply with quote

OK, you went a little over-the-top with the HIT=NEXT.

You are looking at four different values in the same position, so that can only possibly be true for one of those four on any given record. So no HIT=NEXT needed there.

The problem you have is that you have a second test subordinate to a mutually-exclusive value, such that of those pairs there can be none, first only, second only or both true for any given record.

It is when both of the pair may logically be true that you have the problem. To allow for that, the first IFTHEN of the pair requires the HIT=NEXT. The second does not, as no subsequent IFTHEN can be true, as the values of the first part of each test are mutually exclusive.

In your case putting HIT=NEXT everywhere will work as you intend (because of the mutually-exclusive nature) but unnecessary processing will take place, and the code/data will be harder to understand.
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 158
Location: Chennai

PostPosted: Fri Jul 10, 2015 4:37 pm    Post subject: Reply to: OVERLAY several fields if non-blank
Reply with quote

Here is the code for you.
Code:

//SYSIN   DD *                                                     
  OPTION COPY                                                     
  INREC  IFTHEN=(WHEN=(1,4,CH,EQ,C'0001',AND,5,2,CH,NE,C'  '),     
                 OVERLAY=(5:5,2,ZD,DIV,+5,TO=ZD,LENGTH=2),HIT=NEXT),       
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0001',AND,7,5,CH,NE,C'     '), 
                 OVERLAY=(7:7,5,SFF,DIV,+5,EDIT=(TT.TT),LENGTH=5)),
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0002',AND,5,2,CH,NE,C'  '),     
                 OVERLAY=(5:5,2,ZD,DIV,+6,TO=ZD,LENGTH=2),HIT=NEXT),       
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0002',AND,7,5,CH,NE,C'     '), 
                 OVERLAY=(7:7,5,SFF,DIV,+6,EDIT=(TT.TT),LENGTH=5)),
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0003',AND,5,2,CH,NE,C'  '),     
                 OVERLAY=(5:5,2,ZD,DIV,+7,TO=ZD,LENGTH=2),HIT=NEXT),       
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0003',AND,7,5,CH,NE,C'     '), 
                 OVERLAY=(7:7,5,SFF,DIV,+7,EDIT=(TT.TT),LENGTH=5)),
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0004',AND,5,2,CH,NE,C'  '),     
                 OVERLAY=(5:5,2,ZD,DIV,+8,TO=ZD,LENGTH=2),HIT=NEXT),       
         IFTHEN=(WHEN=(1,4,CH,EQ,C'0004',AND,7,5,CH,NE,C'     '), 
                 OVERLAY=(7:7,5,SFF,DIV,+8,EDIT=(TT.TT),LENGTH=5))
/*
Back to top
View user's profile Send private message
autobox

New User


Joined: 19 Aug 2005
Posts: 48

PostPosted: Mon Jul 13, 2015 11:20 am    Post subject:
Reply with quote

Thanks Bill and Magesh!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Need Help to Define 36 Input Fields (... satish.ms10 CLIST & REXX 2 Sat May 07, 2016 3:08 pm
No new posts FileAid to compare(logical operations... anand1204 Compuware & Other Tools 3 Wed Apr 06, 2016 2:55 am
No new posts Fields in File-Aid Browse menu screen boyti ko Compuware & Other Tools 5 Mon Apr 04, 2016 4:51 pm
No new posts Overlay with right shift Bill Woodger DFSORT/ICETOOL 3 Thu Jan 28, 2016 7:49 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us