IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

OVERLAY several fields if non-blank


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
autobox

New User


Joined: 19 Aug 2005
Posts: 51

PostPosted: Fri Jul 10, 2015 12:42 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jul 10, 2015 1:42 pm
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: 51

PostPosted: Fri Jul 10, 2015 2:16 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jul 10, 2015 3:31 pm
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: 213
Location: Chennai

PostPosted: Fri Jul 10, 2015 4:37 pm
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: 51

PostPosted: Mon Jul 13, 2015 11:20 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Merge files with a key and insert a b... DFSORT/ICETOOL 6
No new posts Help, trying to use OVERLAY to get a ... DFSORT/ICETOOL 3
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts File transfer from host with filler f... TSO/ISPF 15
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top