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

Next max


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

New User


Joined: 01 Aug 2007
Posts: 42
Location: Hyderabad

PostPosted: Thu Jun 16, 2016 10:50 am
Reply with quote

Hi,
I searched forums but could not find. Could you please help me.

I have a input file with below layout

Code:
CLIENT-1   2016-01-01   HMO
CLIENT-2   2016-01-01   090
CLIENT-2   2016-02-01   520
CLIENT-2   2016-02-03   HMO
CLIENT-2   2016-03-01   
CLIENT-2   2016-04-01   520
CLIENT-2   2016-05-01   090

( Imagine: cleint filed is 8 char, date is 10 char, client_ty is 3 charaters and file is sorted on client, date ( asec))

when the 3rd field is has spaces, the output has to be like this

Code:
CLIENT-1   2016-01-01   HMO   NS
CLIENT-2   2016-01-01   090   NS
CLIENT-2   2016-02-01   520   NS
CLIENT-2   2016-02-03   HMO   NS
CLIENT-2   2016-03-01   520   SP
CLIENT-2   2016-04-01   520   NS
CLIENT-2   2016-05-01   090   NS

That is next client_ty of that client has to be updated ( in this case 520) and 4th field should be SP ( means spaces) and for non spaces ( NP).
In case we have spaces and there is only one record for that client, we have to update HMO and 4th field as SP

Kindly help me on this. Thanks

code' d
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Jun 16, 2016 1:53 pm
Reply with quote

Apart from the fact that you did not help the helpers by using the code tags, and you say NP should be inserted into the 4th field when the third field is not blank but you show NS, and that you have a dataset not a file and you did not specify LRECL or RECFM (either, or both, of which could affect the solution), and you say that the next client_ty has to be updated when I suspect that that should say that if the client_ty is blank it should be updated with the client_ty of the next client record. But what if there is no 'next' client_ty?
Back to top
View user's profile Send private message
kgumraj2

New User


Joined: 01 Aug 2007
Posts: 42
Location: Hyderabad

PostPosted: Thu Jun 16, 2016 2:47 pm
Reply with quote

Thanks for your reply and time.

Nic- you say NP should be inserted into the 4th field when the third field is not blank but you show NS
Kiran- Yes you are correct it should be NS

Nic- that you have a dataset not a file and you did not specify LRECL or RECFM (either, or both, of which could affect the solution)
Kiran- I have mentioned in the first message ( cleint filed is 8 char, date is 10 char, client_ty is 3 charaters and file is sorted on client, date ( asec)), in addition to that, it is 80 length FB PS file.

Nic- you say that the next client_ty has to be updated when I suspect that that should say that if the client_ty is blank it should be updated with the client_ty of the next client record. But what if there is no 'next' client_ty?
Kiran- I have mentioned in my first message In case we have spaces and there is only one record for that client, we have to update HMO and 4th field as SP
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jun 16, 2016 2:59 pm
Reply with quote

If You want to be considered in a more professional way
You should update your profile with professional data
not childish info like
Quote:
Mainframe Skills: Reading


if Your skills are only Reading
who wrote the post on Your behalf ?
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Thu Jun 16, 2016 8:59 pm
Reply with quote

Kiran,
See if this works for you.

Code:
//STEP0001 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTJNF1 DD *                                                     
CLIENT-1   2016-01-01   HMO                                         
CLIENT-2   2016-01-01   090                                         
CLIENT-2   2016-02-01   520                                         
CLIENT-2   2016-02-03   HMO                                         
CLIENT-2   2016-03-01                                               
CLIENT-2   2016-04-01   520                                         
CLIENT-2   2016-05-01   090                                         
//SORTJNF2 DD *                                                     
CLIENT-1   2016-01-01   HMO                                         
CLIENT-2   2016-01-01   090                                         
CLIENT-2   2016-02-01   520                                         
CLIENT-2   2016-02-03   HMO                                         
CLIENT-2   2016-03-01                                               
CLIENT-2   2016-04-01   520                                         
CLIENT-2   2016-05-01   090                                         
//SORTOUT  DD SYSOUT=*                                             
//SYSIN DD *                                                       
 JOINKEYS FILE=F1,FIELDS=(01,08,A,81,8,A),SORTED,NOSEQCK           
 JOINKEYS FILE=F2,FIELDS=(01,08,A,81,8,A),SORTED,NOSEQCK           
 JOIN UNPAIRED,F1                                                   
 REFORMAT FIELDS=(F1:1,80,F2:25,3)                                 
 INREC IFOUTLEN=80,                                                 
       IFTHEN=(WHEN=INIT,OVERLAY=(31:C'NS')),                       
       IFTHEN=(WHEN=(25,3,CH,EQ,C' '),OVERLAY=(25:81,3,31:C'SP'))   
 SORT FIELDS=COPY                                                   
/*                                                                 
//JNF1CNTL DD *                                                     
 INREC OVERLAY=(81:SEQNUM,8,ZD,START=2,INCR=1,RESTART=(1,8))       
/*                                                                 
//JNF2CNTL DD *                                                     
 INREC OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,8))                       
/*                                                                 


OUTPUT
Code:
CLIENT-1   2016-01-01   HMO   NS
CLIENT-2   2016-01-01   090   NS
CLIENT-2   2016-02-01   520   NS
CLIENT-2   2016-02-03   HMO   NS
CLIENT-2   2016-03-01   520   SP
CLIENT-2   2016-04-01   520   NS
CLIENT-2   2016-05-01   090   NS


Thanks,
Back to top
View user's profile Send private message
kgumraj2

New User


Joined: 01 Aug 2007
Posts: 42
Location: Hyderabad

PostPosted: Thu Jun 16, 2016 11:16 pm
Reply with quote

Thanks I will give a try. Thanks very much for your time.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Thu Jun 16, 2016 11:21 pm
Reply with quote

Please test, little modification on what TS wants about HMO.
Code:
IFTHEN=(WHEN=INIT,OVERLAY=(31:C'NS')),                   
IFTHEN=(WHEN=(25,3,CH,EQ,C' ',AND,81,3,CH,NE,C' '),     
                          OVERLAY=(25:81,3,31:C'SP')),   
IFTHEN=(WHEN=(25,3,CH,EQ,C' ',AND,81,3,CH,EQ,C' '),     
                          OVERLAY=(25:C'HMO',31:C'SP')) 

I hope TS don't have the same client appearing twice with blank client_ty.
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 Jun 17, 2016 2:30 am
Reply with quote

Full knowledge of the data is important. Consecutive blanks would be a problem, as well as blanks in the final record of a key.

Still, assuming those don't exist, WHEN=GROUP for the blank, with PUSH of the entire record, RECORDS=2, OUTFIL to omit the blanks, and a BUILD with the slash-operator (get the basic data, (81,80,/,1,80), a little breakdown to copy the required bytes and the literal) subordinate to a WHEN= confirming that the keys are equal should be about there.

So, can there be consecutive blanks, and if so, is there a maximum? And what would you want done? If the final record of a group is blank, what would you want done?

I can't see that the JOINKEYS needs the RESTART, just a plain sequence should do. A test for equal keys could replace the primary key and just use the sequence for the match.

But the important thing first is the data.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Fri Jun 17, 2016 2:58 am
Reply with quote

RESTART is there so that rules don't cross client boundaries. GROUP/PUSH vs JOINKEY is a preference thing

Thanks,
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 Jun 17, 2016 3:06 am
Reply with quote

You've got the client in the for the key. What bounds would you cross?

Maybe it's preference, but I go for reading the file once unless it is needed to read it twice. Mostly.
Back to top
View user's profile Send private message
kgumraj2

New User


Joined: 01 Aug 2007
Posts: 42
Location: Hyderabad

PostPosted: Sat Jun 18, 2016 2:01 pm
Reply with quote

Thanks everyone.
It has only one space record, that needs to be updated.

Special thanks to sqlcode1.
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

 


Search our Forums:

Back to Top