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

Skipping secondary record when primary is skiiped


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

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Fri Dec 06, 2013 7:33 pm
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
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: 213
Location: Chennai

PostPosted: Fri Dec 06, 2013 11:52 pm
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
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: 213
Location: Chennai

PostPosted: Sat Dec 07, 2013 12:49 am
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
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: 213
Location: Chennai

PostPosted: Sat Dec 07, 2013 2:08 am
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
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

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: 213
Location: Chennai

PostPosted: Mon Dec 09, 2013 9:42 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top