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
 

 

To update sub record in one file when a match is found.

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

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Mon May 05, 2014 11:21 am    Post subject: To update sub record in one file when a match is found.
Reply with quote

I have two files:

File 1 - 250 Bytes - FB
File 2 - 80 Bytes - FB

File 1 contains a field at 99th position which is 16 bytes alphanumeric. When this field is equal to first 16 bytes of File 2 then two fields in File 1 (at position 18th and 71st) both of which are 6 bytes long should be replaced with 6-Bytes field in File 1 (6 bytes from position 18th). For this to happen I wrote the following JCL which is working fine.

Code:
//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD  SYSOUT=*                                         
//INA      DD  DSN=250 Byte File-FB,DISP=SHR     
//INB      DD  DSN=80 Byte File-FB,DISP=SHR                 
//SORTOUT  DD  SYSOUT=*                                         
//SYSIN    DD  *                                               
  OPTION COPY                                                   
  JOINKEYS F1=INA,FIELDS=(99,16,A)                             
  JOINKEYS F2=INB,FIELDS=(01,16,A)                             
  JOIN UNPAIRED,F1                                             
  REFORMAT FIELDS=(F1:1,250,?,F2:18,6)                         
  INREC IFOUTLEN=250,                                           
  IFTHEN=(WHEN=(251,1,CH,EQ,C'B'),OVERLAY=(18:252,6,71:252,6)) 


However, there is a sub record too associated with the main record in which there is a field at 34th byte that also needs to be updated with the
same field from File 1 (6 bytes from position 18th) when a match is found. The 16 bytes key field is only appearing in the main record and not in the sub record.
This sub record is recognized with values '04' at position 3. The main record is recognized with values '01' at position 3. This is explained as shown below:

Code:
DT01XXXXXXXXXXXXX155901XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX155901
DT04xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx155901xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


First record starting with DT01 - First occurrence of 155901 is at 18th position and second is at 71st position which was updated from File 2. And my above JCL is correctly updating this.
For the sub record I need help to update 6 bytes starting from 34th position when 16 bytes at pos 99th in the main record of File 1 match with the first 16 bytes in File 2.

I hope I have made my problem clear.

Any help will be really appreciated.

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

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Mon May 05, 2014 2:00 pm    Post subject: Reply to: To update sub record in one file when a match is f
Reply with quote

Why do you have JOIN UNPAIRED,F1?

You only want matches, so don't specify a JOIN.

You then don't need the ? or the test for its value being C'B'.

Put your main file on as F1, and in JNF1CNTL temporarily extend the records so that a new field, populated by IFTHEN=(WHEN=GROUP for your data header) contains the key (PUSH=(251:keystart,length).

In JNF2CNTL, cut down the record so it only contains what is needed.

If either of the files is already in key order, specify SORTED for it on the JOINKEYS.

In the Main Task, you will get two matches, one for the main record and one for the sub-record. Identify those by type and put data from F2 into the correct position.
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Mon May 05, 2014 3:39 pm    Post subject: Reply to: To update sub record in one file when a match is f
Reply with quote

Hi Bill,

The output file will have both matched as well as unmatched records. however, the change that I have mentioned will be applicable only for the matched ones and hence the unmatched ones will remain as is.

BTW I have got the thing working with the below two steps:

Code:
//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD  SYSOUT=*                                       
//SORTIN   DD  DSN=250 Bytes FB file,DISP=SHR   
//SORTOUT  DD  DSN=&&TEMP1,DISP=(,PASS)                       
//SYSIN    DD  *                                             
  OPTION COPY                                                 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,04,CH,EQ,                 
           C'DT01'),PUSH=(270:99,16))                         
  OUTREC OVERLAY=(290:SEQNUM,6,ZD)                           
/*                                                           
//STEP0101 EXEC PGM=SORT                                     
//SYSOUT   DD  SYSOUT=*                                       
//INA      DD  DSN=&&TEMP1,DISP=SHR                           
//INB      DD  DSN=80 Byte FB file,DISP=SHR               
//SORTOUT  DD  SYSOUT=*                                 
//SYSIN    DD  *                                         
  SORT FIELDS=(258,6,ZD,A)                               
  JOINKEYS F1=INA,FIELDS=(270,16,A)                     
  JOINKEYS F2=INB,FIELDS=(01,16,A)                       
  JOIN UNPAIRED,F1                                       
  REFORMAT FIELDS=(F1:1,250,?,F2:18,6,F1:290,6)         
  INREC IFOUTLEN=263,                                   
  IFTHEN=(WHEN=(251,1,CH,EQ,C'B',AND,1,4,SS,EQ,C'DT01'),
      OVERLAY=(18:252,6,71:252,6)),                     
  IFTHEN=(WHEN=(251,1,CH,EQ,C'B',AND,1,4,SS,EQ,C'DT04'),
      OVERLAY=(34:252,6))                               
  OUTREC BUILD=(1,250)   
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Mon May 05, 2014 4:42 pm    Post subject: Reply to: To update sub record in one file when a match is f
Reply with quote

I'm glad you have something working, but I think there are some confusions.

Firstly, you use SS for a field-type where CH would do. Look up SS in the manual, and samples of its use. Understand it. Change these SSs to CHs.

Next, your separate step can be coded in JNF1CNTL instead. Saving a step. It is fine to save a step when not needed.

The positions you have chosen for your extra fields are fine for developing the solution (makes it easier to see what is where) but for your final version you probably are better with the fields being contiguous.

You could use JNF2CNTL to cut down the F2 to only the data needed (key + value). This will use fewer resources, especially if you need to sort the field (which JOINKEYS does by default).

Are the files in order already?

The use of IFOUTLEN is to set your final record-length from a particular process. There should be no need to then have a BUILD in a following process just to change the length. Set IFOUTLEN=250 and drop the OUTREC altogether.
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Mon May 05, 2014 5:08 pm    Post subject: Reply to: To update sub record in one file when a match is f
Reply with quote

Quote:
Firstly, you use SS for a field-type where CH would do. Look up SS in the manual, and samples of its use. Understand it. Change these SSs to CHs.


Yes you're right I can do away with SS.

I am in middle of polishing my JCL and your points will definitely help in that. I will get back to you with my final version. thanks for your time.

Regards,
Mohit
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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