|
View previous topic :: View next topic
|
| Author |
Message |
kgumraj2
New User
.jpg)
Joined: 01 Aug 2007 Posts: 42 Location: Hyderabad
|
|
|
|
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 |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| 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 |
|
 |
kgumraj2
New User
.jpg)
Joined: 01 Aug 2007 Posts: 42 Location: Hyderabad
|
|
|
|
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 |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
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 |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
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 |
|
 |
kgumraj2
New User
.jpg)
Joined: 01 Aug 2007 Posts: 42 Location: Hyderabad
|
|
|
|
| Thanks I will give a try. Thanks very much for your time. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
RESTART is there so that rules don't cross client boundaries. GROUP/PUSH vs JOINKEY is a preference thing
Thanks, |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
kgumraj2
New User
.jpg)
Joined: 01 Aug 2007 Posts: 42 Location: Hyderabad
|
|
|
|
Thanks everyone.
It has only one space record, that needs to be updated.
Special thanks to sqlcode1. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|