Page 1 of 2

How to add information to the end of each record

PostPosted: Wed Apr 24, 2013 1:44 pm
by ottoelflaco
Hello,
sorry my english is not good, I m trying to improve it..

My problem:

I have two files:

One file has many records.
The other file only has one record.

I need add the information of the second file to the end of all records of the first file .

My english is poor. I ll try to explain with example:

input FILE1:
charles
james
peter


input FILE2:


output FILE
charles  12345
james   12345
peter    12345


EDIT: the record of file2 will be written in the last position of file 1

Re: How to add information to the end of each record

PostPosted: Wed Apr 24, 2013 2:02 pm
by ottoelflaco
I have done that solution:

  JOINKEYS FILE=F1,FIELDS=(2050,1,A)
  JOINKEYS FILE=F2,FIELDS=(27,1,A)   
  SORT FIELDS=COPY                   
  REFORMAT FIELDS=(F1:1,2049,F2:1,26)
/*                                   
//JNF1CNTL DD *                     
  INREC OVERLAY=(2050:C'1')         
//JNF2CNTL DD *                     
  INREC OVERLAY=(27:C'1')           
//*                                 


What do you think?....thanks :)

Re: How to add information to the end of each record

PostPosted: Wed Apr 24, 2013 2:18 pm
by enrico-sorichetti
for a one input record to be used as overlay Joinkeys might be a bit of overshooting
this approach might yield a better performance ... repeat MIGHT
from the data posted here what it could look like

****** ***************************** Top of Data ******************************
......
000004 //S1      EXEC PGM=SORT
000005 //SYSOUT    DD SYSOUT=*
000006 //SORTIN    DD *
000007 12345
000008 //SORTOUT   DD DISP=(NEW,PASS),
000009 //             DCB=(RECFM=FB,LRECL=80),
000010 //             UNIT=SYSDA,SPACE=(CYL,(1,1)),
000011 //             DSN=&&SYMBOLS
000012 //SYSIN     DD *
000013   SORT FIELDS=COPY
000014   OUTREC BUILD=(C'MYDATA,C''',1,5,C'''',80X)
000015 //*
000016 //S2      EXEC PGM=SORT
000017 //SYSOUT    DD SYSOUT=*
000018 //SYMNAMES  DD DISP=(OLD,PASS),
000019 //             DSN=&&SYMBOLS
000020 //          DD *
000021 SOURCE,1,10
000022 //SORTIN    DD *
000023 AAAAAAA
000024 BB
000025 CCCCCCC
000026 //SORTOUT   DD SYSOUT=*,
000027 //             DCB=(RECFM=FB,LRECL=80)
000028 //SYSIN     DD *
000029   SORT FIELDS=COPY
000030   OUTREC BUILD=(SOURCE,MYDATA,80X)
000031
****** **************************** Bottom of Data ****************************

Re: How to add information to the end of each record

PostPosted: Wed Apr 24, 2013 2:21 pm
by ottoelflaco
The finality of this join is I need compare timestamp field of file2 with timestamp field of each record of file1. So I thought in add to the end the information of field2 and now I can compare, I only want the records with greater timestamp of file 1. Maybe is more easy...If somebody know other solution... :)

Regards!

Re: How to add information to the end of each record

PostPosted: Wed Apr 24, 2013 2:25 pm
by enrico-sorichetti
The finality of this join is I need compare timestamp field of file2 with timestamp field of each record of file1. So I thought in add to the end the information of field2 and now I can compare, I only want the records with greater timestamp of file 1. Maybe is more easy...If somebody know other solution...

so why in hell You wasted people's time with a misleading description of the requirement :evil: :evil: :evil:
writing, testing and posting a snippet to find out that the TS changed his mind is really something that pisses off people

Re: How to add information to the end of each record

PostPosted: Wed Apr 24, 2013 2:33 pm
by ottoelflaco
Ey Enrico!

Thank you for post. be quiet man...

I am only learning, so the first post is my main question for you.

But I thought maybe other solution is posible, so maybe somebody could guide to me to other solution. All ways, I m very interested in know the solution of my first post...

If I haven´t described all I would want know is because of my poor level of english.

Right now I m seeing your solution, I m looking information of 'SOURCE'...Thank you very much for help to me. :)

Re: How to add information to the end of each record

PostPosted: Wed Apr 24, 2013 2:47 pm
by enrico-sorichetti
Ey Enrico!
Thank you for post. be quiet man...
I am only learning, so the first post is my main question for you.
But I thought maybe other solution is posible, so maybe somebody could guide to me to other solution. All ways, I m very interested in know the solution of my first post...
If I haven´t described all I would want know is because of my poor level of english.
Right now I m seeing your solution, I m looking information of 'SOURCE'...Thank you very much for help to me.


a relatively unclear description of the requirement MIGHT BE DUE to a language proficiency issue
( or to a poor understanding of the requirement )
but posting a compleley different requirement is just symptom of bad attitude, bad manners, laziness, incompetence ...
ant that applies to any question from any poster on any forum

to make the most out of the questions You ask it would be VERY WISE for You
to read and meditate on

How To Ask Questions The Smart Way
here
http://catb.org/~esr/faqs/smart-questions.html

You will learn what will be the tone of the answers You will receive as related to the way You asked

and ...
be quiet Yourself, sonny :evil: :evil: :evil:

Re: How to add information to the end of each record

PostPosted: Wed Apr 24, 2013 3:06 pm
by ottoelflaco
ok, thank you for the link :).

Re: How to add information to the end of each record

PostPosted: Wed Apr 24, 2013 9:27 pm
by ottoelflaco
I couldn´t find other solution by now..
I have done this for select records with greater timestamp:

 JOINKEYS FILE=F1,FIELDS=(93,1,A)   
  JOINKEYS FILE=F2,FIELDS=(27,1,A)   
  SORT FIELDS=COPY                   
  REFORMAT FIELDS=(F1:1,92,F2:1,26) 
  INCLUDE COND=(66,26,CH,GE,93,26,CH)
/*                                   
//JNF1CNTL DD *                     
  INREC OVERLAY=(93:C'1')           
//JNF2CNTL DD *                     
  INREC OVERLAY=(27:C'1')           

Re: How to add information to the end of each record

PostPosted: Wed Apr 24, 2013 10:07 pm
by skolusu
ottoelflaco,

Using Joinkeys for a such task is an overkill as you are performing an actual sort when it is not needed. And even though english is not your strong language, I suggest that you do not show this condescending attitude with the people who are trying to help.

Either way here is a job which will give you the desired results. I also added a few checks like setting an RC=4 when the timestamp file is empty and we wouldn't even execute the next step.

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DISP=SHR,DSN=Your Input FB 26 byte file
//SORTOUT  DD DSN=&&S,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//SYSIN    DD *                                           
  OPTION COPY,STOPAFT=1,NULLOUT=RC4                       
  INREC BUILD=(C'TSTMP,C''',1,26,C'''',80:X)             
//*                                                       
//STEP0200 EXEC PGM=SORT,COND=(4,EQ,STEP0100)             
//SYSOUT   DD SYSOUT=*                                   
//SYMNAMES DD DISP=SHR,DSN=&&S                           
//SORTIN   DD DISP=SHR,DSN=Your Input FB 92 byte file 
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                           
  OPTION COPY                                             
  INCLUDE COND=(66,26,CH,GE,TSTMP)                       
//*


If you insist on using Joinkeys , I would suggest that you use the following control cards which are far more efficient than what you have
//SYSIN    DD *                                     
  OPTION COPY                                       
  JOINKEYS FILES=F1,FIELDS=(93,1,A),SORTED,NOSEQCK 
  JOINKEYS FILES=F2,FIELDS=(27,1,A),SORTED,NOSEQCK 
  REFORMAT FIELDS=(F1:1,92,F2:1,26)                 
  INCLUDE COND=(66,26,CH,GE,93,26,CH)               
  INREC BUILD=(1,92)                               
//*                                                 
//JNF1CNTL DD *                                     
  INREC OVERLAY=(93:C'1')                           
//*                                                 
//JNF2CNTL DD *                                     
  INREC OVERLAY=(27:C'1')                           
//*