View previous topic :: View next topic
|
Author |
Message |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Hello
I have two input files.
File-1 --> FB,LRECL=80
File-2 --> FB,LRECL=80
Code: |
111
222
333
444
555
NNN
|
Expected output
Code: |
111
222
333
444
555
NNN ABCDEFGHIJKLMNO
|
File-1 will always have one single record of the length 15 bytes.
and want this single record to be copied to file-2 whenever first three bytes in file-2 is 'NNN'. File tow will always have only one single occurence of 'NNN' at position 1.
Thanks |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
i can think of two ways to do this:
1. use two sort steps.
a. sort step one: create a SYMNAME out of file 1.
b. sort step two: COPY file 2 to file 3 with IFTHEN nnn then overlay with SYMNAME constant created in step one.
2. use JOINKEYS with a J1CNTL that creates NNN........
in the future, use the PREVIEW button, and 'desk check' your post
before SUBMIT.
one place, file 1 is 80, and in another you say file 1 is 15. |
|
Back to top |
|
|
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
@dbzTHEdinosauer
Thanks for the reply
File-1 has LRECL = 80, but the only record in the file is of 15 bytes. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
techslam wrote: |
@dbzTHEdinosauer
Thanks for the reply
File-1 has LRECL = 80, but the only record in the file is of 15 bytes. |
That makes absolutely no sense........................................... |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Hello,
Assuming the record has constant value as NNN
Code: |
//STEP1 EXEC PGM=ICETOOL
//IN1 DD *
ABCDNNNNN
//IN2 DD *
111
222
333
444
555
NNN
//OUT1 DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN2) TO(OUT1) USING(CTL2)
COPY FROM(IN1) TO(OUT1) USING(CTL1)
/*
//CTL1CNTL DD *
INREC OVERLAY=(5:1,15,4:X,1:C'NNN')
/*
//CTL2CNTL DD *
SORT FIELDS=(1,3,CH,A)
OMIT COND=(1,5,CH,EQ,C'NNN ')
/* |
Try and let us know
Note: This is not a perfect solution, if the value 'NNN' is not constant maybe Joins could help you as DBz post (if it is dynamic) this is just handy to met the criteria. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
dbzTHEdinosauer wrote: |
techslam wrote: |
@dbzTHEdinosauer
Thanks for the reply
File-1 has LRECL = 80, but the only record in the file is of 15 bytes. |
That makes absolutely no sense........................................... |
To a sotfware engineer, it does; the 65 trailing spaces are somehow "not really" part of the record. |
|
Back to top |
|
|
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
@xknight
My file-2 does not have any key field.
Actually my file 2 has an email text as below :
Code: |
Hi Team,
Todays key value is xxxxxxxxxxxxxxx
|
Here the XXXXXXXXXXXXXXX is to be replaced with the 15 bytes data from file-1 |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Hello,
Can you post the e-mail text with the position layout, so we wouldn't need to assume the position for 15 digit data.
If you need to try on your own, using (INREC) you shall validate and extract the values (OUTREC FIELDS) from desired position and send it to the file as we needed.
Need help in assistance, please post the layout and content. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Another possibility. As dbz has said, you can put in a step to generate the symnames, this time from your outline text file. Lots of ways to crack an egg, if we know it is an egg.
Code: |
//EMAILREF EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
TEXT-LINE-1,'HI TEAM'
TEXT-LINE-2,'TODAYS KEY VALUE IS '
//SORTIN DD *
123456789012345
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL BUILD=(1:TEXT-LINE-1,/,TEXT-LINE-2,1,15)
|
|
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
techslam,
use the following DFSORT JCL which will give you the desired results
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
HI TEAM,
----+----1----+----2----+----3----+----4----+----5----+----6----+
TODAYS KEY VALUE IS ABCDEFGHIJKLMNO
//SORTOUT DD DSN=&&SYM,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//SYSIN DD *
OPTION COPY,SKIPREC=1,STOPAFT=1
INREC BUILD=(C'KEYVAL,C',C'''',22,15,C'''',80:X)
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&SYM,DISP=SHR
//SORTIN DD *
111
222
333
444
555
NNN
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'NNN'),OVERLAY=(5:KEYVAL))
//* |
Bill,
IMHO using Joinkeys for this job would be an overkill |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Readily conceded. You certainly don't need the H, in my opinion :-) |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Kolusu wrote: |
Bill,
IMHO using Joinkeys for this job would be an overkill
|
i think i am going to duck under this one. |
|
Back to top |
|
|
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
@Skolusu
Thanks a lot. This is exactly what I wanted. Appreciate it. |
|
Back to top |
|
|
|