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
 

 

Skipping secondary record when primary is skiiped

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

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Fri Dec 06, 2013 7:33 pm    Post subject: Reply to: Compare flat with vsam file using DFSORT
Reply with quote

Hi,

Could some one advice me on below.

We have two records in the VSAM file one is primary and secondary
S0100DDAAAAA ==Secondary
P0100DDAAAAA ==Primary
Always primary key has FLAG at 450 postition 'N'.

If primary flag has 'N' in 450th position then i should also skip the secondary record. But secondary record will not have the flag to skip or omit.

Currently the program just check the matching record for FLAG 'N', If matched it just skip the record from the copy. Due to this only primary record is skipped, But secondary record is written.

Code:

* CONTROL STATEMENTS FOR JOINKEYS APPLICATION                 
  JOINKEYS FILE=F1,FIELDS=(3,1,A,5,2,A,8,4,A,13,5,A)         
  JOINKEYS FILE=F2,FIELDS=(1,1,A,2,2,A,4,4,A,8,5,A),SORTED,   
           TYPE=F,NOSEQCK                                     
  REFORMAT FIELDS=(F1:1,1354)                                 
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)           
  SORT FIELDS=COPY                                           
//JNF2CNTL DD *                                               
 INCLUDE COND=(450,1,CH,NE,C'N')                             
 INREC BUILD=(1,12)                                           
/*     


example

Input file 1 Flat file

Code:
   
KEY                       
C~S~01~00DD~AAAAA     
C~P~01~00DD~AAAAA           


Input file 2 VSAM
Code:
 
Key                      FLAG                     
S0100DDAAAAA             
P0100DDAAAAA             N


Output shoud be None.

But getting the record
Code:
                     
C~S~01~00DD~AAAAA 


Please advice
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Dec 06, 2013 11:07 pm    Post subject: Reply to: Compare flat with vsam file using DFSORT
Reply with quote

How do you determine the primary key and the secondary key? The char 's' or 'p' in the first byte? If so since it is VSAM file and is already sorted on the key field how did you have "S" record before a "P" record?

Either way remove the include cond in JNF2CNTL and use INREC WHEN=GROUP to push the "N" Indicator to the secondary record. Build the record with Key and indicator

Change the reformat to include the indicator on the main task and code an OMIT condition to remove the joined records with "N" indicator on the main task.
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Fri Dec 06, 2013 11:52 pm    Post subject: Reply to: Compare flat with vsam file using DFSORT
Reply with quote

thank you for the kind advice.
Sorry Kolusu, I couldn't get you, doesn't have much knowledge, IF you could share me a sample code will be great.

Here is what I did to fix this issue, Please advice.

Code:

//STEP01 EXEC PGM=SORT                                               
//SYSOUT DD SYSOUT=*                                                 
//SORTIN DD DSN=VSAM1,DISP=SHR                 
//SORTOUT DD DSN=TEMPFILE,DISP=(NEW,CATLG,DELETE),             
//           DCB=(LRECL=11,BLKSIZE=0,RECFM=FB),                     
//           SPACE=(CYL,(1,1),RLSE)                                 
//SYSIN DD *                                                         
  SORT FIELDS=COPY                                                   
  INCLUDE COND=(450,1,CH,EQ,C'N')                                   
  OUTREC FIELDS=(1:2,11)                                             
/*                                                                   
//STEP02 EXEC PGM=SORT                                               
//SYSOUT DD SYSOUT=*                                                 
//SORTJNF1 DD DSN=FLATFILE,DISP=SHR
//SORTJNF2 DD DSN=TEMPFILE,DISP=SHR                             
//SORTOUT DD DSN=OUTPUTFILE,             
//             DISP=(NEW,CATLG,DELETE),                             
//             UNIT=SAVDA,                                           
//             SPACE=(CYL,(100,50),RLSE),                           
//             DCB=(DSORG=PS,RECFM=FB,LRECL=1354,BLKSIZE=0)         
//SYSIN DD *                                       
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION       
   JOINKEYS FILE=F1,FIELDS=(5,2,A,8,4,A,13,5,A)     
   JOINKEYS FILE=F2,FIELDS=(1,2,A,3,4,A,7,5,A)     
   REFORMAT FIELDS=(F1:1,1354)                     
   JOIN UNPAIRED,F1,ONLY                           
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)
   SORT FIELDS=COPY                                 
/*               
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Dec 07, 2013 12:10 am    Post subject: Re: Reply to: Compare flat with vsam file using DFSORT
Reply with quote

magesh23586 wrote:
thank you for the kind advice.
Sorry Kolusu, I couldn't get you, doesn't have much knowledge, IF you could share me a sample code will be great.

Here is what I did to fix this issue, Please advice.


You did NOT answer any of questions but you want a sample code? Quite demanding eh? Remember that I can neither read your brain or look over your shoulder to understand the requirement. You need to explain in detail about the requirement.

Secondly Why would you split the job into 2 steps? when a single pass of Joinkeys was doing the job earlier? Why couldn't you code the same control cards you used in step01 as JNF2CNTL?
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Sat Dec 07, 2013 12:49 am    Post subject: Reply to: Compare flat with vsam file using DFSORT
Reply with quote

Sorry, that's my mistake

The key records start with various values.
E
F
S
T
1
2
3
4
Till 9

When '1' has 'N' flag, I need to skip all records start with E,F,S,T,1,2,3,4,Till 9 records.

Tried this way but no joy, none of records are filtered, all the records came into the output file icon_sad.gif
I think I am missing something

Code:

//SYSIN DD *                                                       
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION                     
   JOINKEYS FILE=F1,FIELDS=(5,2,A,8,4,A,13,5,A)                   
   JOINKEYS FILE=F2,FIELDS=(1,2,A,3,4,A,7,5,A)                     
   REFORMAT FIELDS=(F1:1,1354)                                     
   JOIN UNPAIRED,F1,ONLY                                           
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)               
   SORT FIELDS=COPY                                               
/*                                                                 
//JNF2CNTL DD *                                                   
   INCLUDE COND=(450,1,CH,EQ,C'N')                                 
/*                                                                 
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Dec 07, 2013 1:07 am    Post subject: Re: Reply to: Compare flat with vsam file using DFSORT
Reply with quote

magesh23586 wrote:

Tried this way but no joy, none of records are filtered, all the records came into the output file icon_sad.gif I think I am missing something

Code:

   JOINKEYS FILE=F2,FIELDS=(1,2,A,3,4,A,7,5,A)                     
//JNF2CNTL DD *                                                   
   INCLUDE COND=(450,1,CH,EQ,C'N')                                 
/*                                                                 


Looks like we are going in circles. I guess I should give up. Did you even compare the step01 control cards with your JNF2CNTL control cards?

Code:

//SYSIN DD *                                                         
  SORT FIELDS=COPY                                                   
  INCLUDE COND=(450,1,CH,EQ,C'N')                                   
  OUTREC FIELDS=(1:2,11)                                             
/*


You are moving the key value using OUTREC from position 2 to position 1 and you don't that in your JNF2. If you haven't done then you at least need to change the Joinkey FIELDS and you haven't done that and you are wondering why you got wrong results?

I have no clue as to why you removed the SORTED,NOSEQCK from your joinkey statements or why your key fields changed from 4 fields to 3 fields.

Anyway good luck. I can't be spending time on an infinite loop of requirements.
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Sat Dec 07, 2013 2:08 am    Post subject: Reply to: Compare flat with vsam file using DFSORT
Reply with quote

Thank you very much, Your advice/solution worked.

The reason why removed OUTREC, it is not supporting, But yes over sight error missed to look at Joinkey of F2.

Because I missed to look at joinkey, on a trail error I removed it which is my mistake

The reason why I changed 4 to 3 fields is because, 1st colum in vsam file is of Record type S OR P OR 1 OR 9 etc. If I compare it will full key then, only 1 record will be skipped

For example
IF we have three records in the Flat file 1
C~S~01~00DD~AAAAA ==Secondary
C~1~01~00DD~AAAAA ==Primary
C~2~01~00DD~AAAAA ==Secondary

Three records in the VSAM File

S0100DDAAAAA
10100DDAAAAA N
20100DDAAAAA

Output file will have following records, where these record also needs to skipped, because all three belongs to same group.

C~S~01~00DD~AAAAA
C~2~01~00DD~AAAAA

So if I remove the first field then it will compare only the below values
File1 VSAM1
0100DDAAAAA ==> 0100DDAAAAA

All the three records will be skipped, which is what required.

Here is the updated code which worked.


Code:

//SYSIN DD *                                                 
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION               
   JOINKEYS FILE=F1,FIELDS=(3,1,A,5,2,A,8,4,A,13,5,A)       
   JOINKEYS FILE=F2,FIELDS=(1,1,A,2,2,A,4,4,A,8,5,A),SORTED,
            NOSEQCK,TYPE=F                                   
   REFORMAT FIELDS=(F1:1,1354)                               
   JOIN UNPAIRED,F1,ONLY                                     
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)         
   SORT FIELDS=(3,15,CH,A) ==> added this to make the output file in the same seq of the source,                                   
/*                                                           
//JNF2CNTL DD *                                             
   INCLUDE COND=(450,1,CH,EQ,C'N')                           
/*                                                           


Only one question, is there a way to retain the same sequence of source file in the output file, Currently I am doing via sort fields.

Thanks for all your valuable inputs.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Dec 07, 2013 3:21 am    Post subject: Re: Reply to: Compare flat with vsam file using DFSORT
Reply with quote

magesh23586 wrote:
Thank you very much, Your advice/solution worked.

The reason why removed OUTREC, it is not supporting, But yes over sight error missed to look at Joinkey of F2.


I gather from this you did NOT read upon Joinkeys or look at your previous working solution where an INREC was used. When a solution is posted , just don't copy a working solution and forget about it. Understand what the job does and in future any changes((like the one you had) will be an easy task. Don't rely on someone to help you round the clock. As is learning is not a bad thing, so you should give it a try.

Here is the link to Joinkeys documentation and read upon the section 4.1.1 JOINKEYS Application Processing

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA60/4.0?


magesh23586 wrote:

Here is the updated code which worked.


Code:

//SYSIN DD *                                                 
   JOINKEYS FILE=F2,FIELDS=(1,1,A,2,2,A,4,4,A,8,5,A),SORTED,
            NOSEQCK,TYPE=F                                   
   REFORMAT FIELDS=(F1:1,1354)                               


I really doubt if the code worked for you as you still show that you are comparing the 1 first byte of VSAM key which you are supposed to ignore. But if you say it works then whom I to complain.

magesh23586 wrote:

Only one question, is there a way to retain the same sequence of source file in the output file, Currently I am doing via sort fields.

Thanks for all your valuable inputs.


Code a JNF1CNTL with an INREC Overlay an 8 byte sequence number at the end (pos 1395) and sort on that sequence number in the main task and remove it using OUTREC.
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Mon Dec 09, 2013 9:42 pm    Post subject: Reply to: Skipping secondary record when primary is skiiped
Reply with quote

Sorry copied the other code which i did for my testing. Please find the below code, which worked.

Code:

//SYSIN DD *                                                 
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION               
   JOINKEYS FILE=F1,FIELDS=(5,2,A,8,4,A,13,5,A)       
   JOINKEYS FILE=F2,FIELDS=(2,2,A,4,4,A,8,5,A),SORTED,
            NOSEQCK,TYPE=F                                   
   REFORMAT FIELDS=(F1:1,1354)                               
   JOIN UNPAIRED,F1,ONLY                                     
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)         
   SORT FIELDS=(3,15,CH,A) ==> added this to make the output file in the same seq of the source,                                   
/*                                                           
//JNF2CNTL DD *                                             
   INCLUDE COND=(450,1,CH,EQ,C'N')                           
   INREC BUILD=(2,11)
/*   
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 How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts Using 'parm' to vary SORTOUT record v... Sysaron DFSORT/ICETOOL 13 Wed Sep 07, 2016 9:24 pm


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