|
View previous topic :: View next topic
|
| Author |
Message |
frozenblood Warnings : 1 New User
Joined: 16 Oct 2012 Posts: 37 Location: INDIA
|
|
|
|
Hi,
I have a requirement where I need to find the records in which certain attributes have changed in the current file as compared to the prev day file ad write the delta records to a new file.
Details as below:
1) Both files have the same structure and a key in position 1:4
2) Key field cannot change in current version as compared to prev version only attributes field can change.
File Format:
| Code: |
Key PIC S9(09) COMP 1:4
Attribute1 PIC S9(08)V COMP-3 18:5
Attribute2 PIC X(30) 23:30
Attribute3 PIC X(01) 206:1
|
I have written the following code and its not working as desired:
| Code: |
//STEP1 EXEC PGM=SORT
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=CURR,DISP=SHR
//SORTJNF2 DD DSN=PREV,DISP=SHR
//SYSIN DD *
OPTION COPY
JOINKEYS FILES=F1,FIELDS=(1,4,A),SORTED
JOINKEYS FILES=F2,FIELDS=(1,4,A),SORTED
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,4,18,5,23,30,206,1,F2:1,4,18,5,23,30,206,1)
OUTFIL REMOVECC,OMIT=(1,40,CH,EQ,41,40,CH),
IFTHEN=(WHEN=(41,1,CH,EQ,C'1'),BUILD=(C' ',1,4)),
IFTHEN=(WHEN=(NONE),BUILD=(C' ',1,4))
/*
//*
|
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10900 Location: italy
|
|
|
|
| Quote: |
| I have written the following code and its not working as desired: |
You just posted a generic whining,
to get good help You should describe HOW it does not behave according to YOUR EXPECTATIONS |
|
| Back to top |
|
 |
frozenblood Warnings : 1 New User
Joined: 16 Oct 2012 Posts: 37 Location: INDIA
|
|
|
|
| I am getting blank output but deltas are present in current file. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Why would you need UNPAIRED?
Although you have two conditions, condition-1 and not-condition-1, you do the same build for each, a blank followed by the key.
Show sample input records which cover all your options, expected output, please. |
|
| Back to top |
|
 |
frozenblood Warnings : 1 New User
Joined: 16 Oct 2012 Posts: 37 Location: INDIA
|
|
|
|
| Code: |
CURRENT FILE:
AAAA 1234 BARBARA S
BBBB 5678 SYMPHONY K
CCCC 9012 AIRLOUNGE Y
DDDD 5555 DAVIDOFF T
PREV FILE:
AAAA 1111 BARBARA S
BBBB 5678 SYMPHONY K
CCCC 9012 AIR Y
OUTPUT
AAAA 1234 BARBARA S
CCCC 9012 AIRLOUNGE Y
DDDD 5555 DAVIDOFF T
|
|
|
| Back to top |
|
 |
frozenblood Warnings : 1 New User
Joined: 16 Oct 2012 Posts: 37 Location: INDIA
|
|
|
|
| any suggestions? |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Try:
| Code: |
//JS001 EXEC PGM=SORT
//*
//SYSOUT DD SYSOUT=*
//*
//SORTJNF1 DD *
AAAA 1234 BARBARA S
BBBB 5678 SYMPHONY K
CCCC 9012 AIRLOUNGE Y
DDDD 5555 DAVIDOFF T
//SORTJNF2 DD *
AAAA 1111 BARBARA S
BBBB 5678 SYMPHONY K
CCCC 9012 AIR Y
//*
//SORTOUT DD SYSOUT=*
//*
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(1,21,A)
JOINKEYS FILE=F2,FIELDS=(1,21,A)
REFORMAT FIELDS=(F1:1,21,F2:1,21),FILL=C'~'
JOIN UNPAIRED F1,F2
OUTFIL FNAMES=SORTOUT,
INCLUDE=(01,01,CH,NE,C'~',AND,22,01,CH,EQ,C'~'),
BUILD=(1,21)
/*
//* |
|
|
| Back to top |
|
 |
frozenblood Warnings : 1 New User
Joined: 16 Oct 2012 Posts: 37 Location: INDIA
|
|
|
|
Hi Anuj,
Thanks for your response.
The fields are not consecutive, below is the definition
| Code: |
Key PIC S9(09) COMP 1:4
Attribute1 PIC S9(08)V COMP-3 18:5
Attribute2 PIC X(30) 23:30
Attribute3 PIC X(01) 206:1
|
so do u want me to make a consecutive file of the above fields using outrec and then run the above ? |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
I've showed a solution for the inputs you've posted and that give this as output, which is same as you show as expected output:
| Code: |
AAAA 1234 BARBARA S
CCCC 9012 AIRLOUNGE Y
DDDD 5555 DAVIDOFF T |
I've used the inputs as in-stream data so the assumptions are that your input files are FB, LRECL=80. If they differ we'd need to tweak the sort statements. So if the keys to be compared are at multiple positions, mention those positions at JOINKEYS statement as shown here: ibmmainframes.com/about51839.html and see if it works for you. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Code: |
| JOIN UNPAIRED F1,F2 |
I think the F1,F2 is being treated as a comment.
UNPAIRED will get F1,F2 anyway.
Since mismatches are ignored in the INCLUDE, why not drop the JOIN altogether, so you only get matched records?
frozenblood, I at least am unclear about what you mean,
Please show representative inputs, and expected output. Don't expect people to keep providing solutions as you change your inputs - or, unless told it is not possible with what you have - expect people to imagine it a good idea for you to change your data to fit a solution. |
|
| Back to top |
|
 |
frozenblood Warnings : 1 New User
Joined: 16 Oct 2012 Posts: 37 Location: INDIA
|
|
|
|
Thanks everyone, I have achieved the above requirement in 2 steps :
| Code: |
1) Sort the curr and prev file on the basis of key field and write only the required fields(to be compared for delta) using OUTREC to temp datasets respectively. Hence making both datasets of LRECL 40
2)
//STEP3 EXEC PGM=SORT
//SORTOUT DD DSN=DELTA,
// DISP=(NEW,CATLG,DELETE),
// AVGREC=K,SPACE=(40,(1900,300),RLSE),
// RECFM=FB,LRECL=40
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=TEMP.CURR,DISP=SHR
//SORTJNF2 DD DSN=TEMP.PREV,DISP=SHR
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(1,40,A)
JOINKEYS FILE=F2,FIELDS=(1,40,A)
REFORMAT FIELDS=(F1:1,40,F2:1,40),FILL=C'~'
JOIN UNPAIRED
OUTFIL FNAMES=SORTOUT,
INCLUDE=(01,01,CH,NE,C'~',AND,41,01,CH,EQ,C'~'),
BUILD=(1,40)
//*
|
|
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
| Bill Woodger wrote: |
| frozenblood, I at least am unclear about what you mean, |
I think OP is/was looking for the unpaired F1 records but I'm not very sure.
However, the way it was explained here:
| Quote: |
| I have a requirement where I need to find the records in which certain attributes have changed in the current file as compared to the prev day file ad write the delta records to a new file. |
with site specif terminology it was tough to comprehend as what is needed. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You could try this then:
| Code: |
//STEP3 EXEC PGM=SORT
//SORTOUT DD DSN=DELTA,
// DISP=(NEW,CATLG,DELETE),
// AVGREC=K,SPACE=(40,(1900,300),RLSE),
// RECFM=FB,LRECL=40
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=TEMP.CURR,DISP=SHR
//SORTJNF2 DD DSN=TEMP.PREV,DISP=SHR
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,40,A),SORTED
JOINKEYS FILE=F2,FIELDS=(1,40,A),SORTED
JOIN UNPAIRED,F1,ONLY
REFORMAT FIELDS=(F1:1,40)
SORT FIELDS=COPY
//* |
|
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
| That's better Bill. OTOH, I just tried to show a generic aproach for the two file match. Hopefully, OP has got something to work upon now. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|