View previous topic :: View next topic
|
Author |
Message |
itjagadesh
New User
Joined: 05 Dec 2006 Posts: 89 Location: chennai
|
|
|
|
All,
I have requirement to get userid from FILE1 and replace on FILE2 second line ,4th Position
Both FILE1 and FILE2 having 80 bytes.
File 1 - 80 Bytes
Userid - First 6 bytes
File2 - 80 bytes
########################## - Record 1
$$$USERID$$$$$$$$$$$$$$$$$ - Record 2
%%%%%%%%%%%%%%%%%%%%%%%%%% - Record 3
************************** - Record 4
Example
FILE1
AAAAAA (First 6 characters - Userid)
FILE2
BBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEE
I need to get userid from first file and override on second file ,2 record ,4the position.
OUTPUT -
FILE3
BBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCC
DDDAAAAAADDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
Above shows userid replaced on FILE2
ie) always i need to copy paste userid from FILE1 to FILE2 (2nd record ,4the position)
Thanks
Jagadesh |
|
Back to top |
|
|
itjagadesh
New User
Joined: 05 Dec 2006 Posts: 89 Location: chennai
|
|
|
|
Correstion in output file
Example
FILE1
AAAAAA
FILE2
BBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
I need to get userid from first file and override on second file ,2 record ,4th position.
OUTPUT -
FILE3
BBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCAAAAAACCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
ie) always i need to copy paste userid from FILE1 to FILE2 (2nd record ,4th position) |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
what is the join key in FILE1 & FILE2? |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
I would suggest to create the sort card dynamically to achieve the same
Edit : Does your input contains only four records ?
Or your input contains records in group of four ?
Or your input contains many but you wanted to consider only second record? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10879 Location: italy
|
|
|
|
the description seemed clear to me ...
file 1 ==> 1 record
file 2 ==> n records
whatever the content of file 2 only the second record should be considered
and the content of the only record of file1 should overlay part of it.
hint ...
apply a sequence number to file1 starting from 2 ( at column 81 )
apply a sequence number to file2 ( at column 81 )
joinkeys on the sequence number and process accordingly
no need for dynamic sort cards. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Arg I get that Enrico my shop doesn't have the latest product Thanks guess got to take a break |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10879 Location: italy
|
|
|
|
up to a certain extent You can get the same result using icetool splice |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Yes I was trying to work it on splice then realised it may not be needed. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Enrico:
Here goes my splice version of code
Considering 25 as LRECL
Code: |
//S010 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
AAAA
//IN2 DD *
AAAAAAAAAAAAAAAAAAAA
CCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDD
//OUT DD SYSOUT=*
//T1 DD DSN=&&T1,SPACE=(TRK,(5,5)),
// DISP=(MOD,PASS)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(30,2,ZD) WITH(1,3) WITH(8,22)-
USING(CTL3) KEEPNODUPS
//*
//CTL1CNTL DD *
OUTREC FIELDS=(4:1,4,30:C'02')
//CTL2CNTL DD *
OUTREC FIELDS=(1:1,25,30:SEQNUM,2,ZD)
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,OUTREC=(1,25)
//*
|
OUTPUT
Code: |
AAAAAAAAAAAAAAAAAAAA
CCCAAAACCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDD
|
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10879 Location: italy
|
|
|
|
nice shot! |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Thanks |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
itjagadesh wrote: |
I need to get userid from first file and override on second file ,2 record ,4th position. |
itjagadesh,
The following DFSORT JCL will give you the desired results. Since both files are having same DCB properties just concatenate them together to SORTIN and pick the value from 1st file and overlay on to the 3rd record.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your FB 80 byte 1 record USERid file,DISP=SHR
// DD DSN=Your FB 80 byte file to have 2nd record replaced,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=GROUP,BEGIN=(81,8,ZD,EQ,1),PUSH=(89:1,6),RECORDS=3),
IFTHEN=(WHEN=(81,8,ZD,EQ,3),OVERLAY=(4:89,6))
OUTFIL BUILD=(1,80),OMIT=(81,8,ZD,EQ,1)
//* |
PS: Enrico and prem , it is a very simple requirement , lets keep it that way |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Just in case if your shop doesn't support when=group, then you can use the symbol generation method shown here as we are only dealing with just 1 record from file 1.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAAAAA
//SORTOUT DD DSN=&&S1,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
OPTION COPY,STOPAFT=1
OUTFIL REMOVECC,NODETAIL,HEADER1=('USERID,C''',1,6,C'''',80:X)
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=SHR
//SORTIN DD *
BBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(81,8,ZD,EQ,2),OVERLAY=(4:USERID))
//* |
|
|
Back to top |
|
|
itjagadesh
New User
Joined: 05 Dec 2006 Posts: 89 Location: chennai
|
|
|
|
Sorry for delayed response.Post given by 'Pandora-Box' worked fine.
Thank you all for your help |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
With due respect to Pandora-Box, a strange choice, but there we go. Did you even try Kolusu's two solutions? |
|
Back to top |
|
|
|