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

Replacing records using key in the o/p file from an i/p file


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

New User


Joined: 10 Nov 2006
Posts: 7
Location: india

PostPosted: Tue Nov 11, 2008 8:53 pm
Reply with quote

Please let me know how to replace the records using key value (full or partial) in an output file from an input file. Size of both input and output has same.

For Example,

Note : Empno and Deptcode are the full key
Input file:
Empno Deptcode EmpName
10101 1 aa
10103 1 cc
10104 1 as
10105 1 ee
10201 1 dd
10202 1 ee

Output file before execution:
Empno Deptcode EmpName
10101 1 cc
10101 2 bb
10102 1 cc
10104 1 as
10105 1 ee
10201 1 dd
10202 1 ee

Now I have to remove extra records and also have to replace the existing records for the key(Empno) = 10101 which is the part key. I need the below result.

After Execution
Output file:
Empno Deptcode EmpName
10101 1 aa
10102 1 cc
10104 1 as
10105 1 ee
10201 1 dd
10202 1 ee

Thanks,
Arun
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Nov 12, 2008 12:01 am
Reply with quote

It's not clear what you want to do. It appears you want all of the non-duplicate records from the original "output" file. And you want to replace something in those records with something from the input file. But you haven't explained exactly what it is you want to replace. Do you want to replace the deptcode and empname, or just the deptcode, or just the empname? Only the records with 10101 have a different value for empname in the two files, so it's difficult to figure out what you're trying to do.

Please show a better example of the input files (for clarity, call them "input file1" and "input file2") and the expected output file (call it "output file") with all possible variations you have to handle. Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input files. Give the starting position, length and formt of all relevant fields.
Back to top
View user's profile Send private message
arunta

New User


Joined: 10 Nov 2006
Posts: 7
Location: india

PostPosted: Wed Nov 12, 2008 12:57 pm
Reply with quote

Hi,

THE kEY VALUE WE ARE SPECIFYING IS MAY BE PARTIAL OR FULL KEY.

Requirement:

1. Replace the existing records in the output file from the input using the key value.
2. Also insert the extra records in the output file from the input using the same key value.
3. Delete extra records in the output file for the same key which is not in input file.

Please note another example.

For Example,

Input file1:
Empno Deptcode EmpName
10101 0 xx
10101 1 aa
10101 2 bb
10103 1 cc

Input file2:
Empno Deptcode EmpName
10101 1 cc
10101 2 bb
10101 3 ss
10102 1 cc
10104 1 as

Note : Empno and Deptcode are the full key
Here I want to process with this key (Empno) = 10101 which is the part key. I need the below result.

In output file(which is the input file2),
10101 0 xx -> this record should be add as a new one.
10101 1 cc ->this one to be replace to-> 10101 1 aa
10101 3 ss -> this record should be removed
and if any new


After Execution
Input file2:
Empno Deptcode EmpName
10101 0 xx
10101 1 aa
10101 2 bb
10102 1 cc
10104 1 as

Please help me.

Thanks,
Arun
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Nov 12, 2008 11:41 pm
Reply with quote

To clarify, I believe the rules can be stated like this.

If an Empno in input file2 is found in input file1 (e.g. 10101) just keep the records with that Empno from input file1. If an Empno in input file2 is not found in input file1 (e.g. 10102), keep the records with that Empno from input file2.

If that's the case, then the following DFSORT/ICETOOL job will do what you asked for. I added a few more example records for completeness in testing. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD *
10101     0    xx
10101     1    aa
10101     2    bb
10103     1    cc
10105     1    cc
10105     2    ee
10107     1    ff
/*
//IN2 DD *
10101     1    cc
10101     2    bb
10101     3    ss
10102     1    cc
10104     1    as
10104     2    qq
10107     1    rr
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(T2) ON(1,5,CH) -
  WITHALL WITH(1,81) WITH(83,8) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:C'BB',83:8X)
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'VV',83:SEQNUM,8,ZD,RESTART=(1,5))
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=T2,
    INCLUDE=(81,2,CH,EQ,C'VB',AND,83,8,ZD,EQ,1),
    OVERLAY=(81:C'DD')
/*
//S2   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//CON DD DSN=&&T2,DISP=(OLD,PASS)
//    DD DSN=&&T1,DISP=(OLD,PASS)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN DD *
SPLICE FROM(CON) TO(OUT) ON(1,5,CH) KEEPBASE KEEPNODUPS -
  WITHALL WITH(1,81) USING(CTL1)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(81,2,SS,EQ,C'BD,VV'),
    BUILD=(1,80)
/*


OUT would have:

Code:

10101     0    xx       
10101     1    aa       
10101     2    bb       
10102     1    cc       
10104     1    as       
10104     2    qq       
10107     1    ff       
Back to top
View user's profile Send private message
arunta

New User


Joined: 10 Nov 2006
Posts: 7
Location: india

PostPosted: Thu Nov 13, 2008 11:46 am
Reply with quote

Hi Frank,

Thank you very much...

One thing i forgot to tell you that.. We are using VSAM files and not the sequential one. Sorry Man icon_sad.gif

As we expect, the above output is same, but I don't want the results in a separate output file and i need the results into Inputfile 2 itself (just like an updating this file and it should not affect the other key value records). Here I need to process only for the particular Key value and not for all the other keys.

Note: It has to be restoring the file using a key value from the backup (say Inputfile1,its a VSAM file).

Thanks,
Arun
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Nov 13, 2008 10:53 pm
Reply with quote

Quote:
Here I need to process only for the particular Key value and not for all the other keys.

Note: It has to be restoring the file using a key value from the backup (say Inputfile1,its a VSAM file).


Sorry, but I have no idea what you mean by this.

Assuming the records are fixed length, you could change the job to use VSAM input files like this:

Code:

...
//IN1 DD DSN=... input file1 (VSAM)
//IN2 DD DSN=... input file2 (VSAM)
...
COPY FROM(IN1) TO(T1) USING(CTL1) VSAMTYPE(F)
COPY FROM(IN2) TO(T1) USING(CTL2) VSAMTYPE(F)
...
//OUT DD DSN=...  input file2 (VSAM)
...
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 FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top