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

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


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

New User


Joined: 15 May 2006
Posts: 92

PostPosted: Mon May 05, 2014 11:21 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 05, 2014 2:00 pm
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: 92

PostPosted: Mon May 05, 2014 3:39 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 05, 2014 4:42 pm
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: 92

PostPosted: Mon May 05, 2014 5:08 pm
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 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 8
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts How I Found a Bug in a FORTRAN Compiler All Other Mainframe Topics 4
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top