Page 1 of 1

Replace two files using sort

PostPosted: Fri Jan 20, 2012 8:55 pm
by sai_stc
I have two files file 1 (LRECL 325) and file 2(LRECL 177)

I have to replace the 1st record starting from postion 2 to 10 in file 1 with file 2 data only from postion 9 to 16 i.e the date part from file 2 has to be taken and replace the date part in file 1 without any change in the remaining data .I will be doing it manually when ever it is required .can some one suggest me how to solve this

File1:

201201035438
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000

File :2

C5035A0120120118R726701000000000000000000000000000000000005035503550350000000000


EXPECTED OUT PUT :


2012011895438
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000

Re: Replace two files using sort

PostPosted: Fri Jan 20, 2012 8:59 pm
by sai_stc
small change their is no key value in the file 1 to identify it as a unique record .

File1:

201201035438
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000

File :2

C5035A0120120118R726701000000000000000000000000000000000005035503550350000000000


EXPECTED OUT PUT :


2012011895438
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000

Re: Replace two files using sort

PostPosted: Fri Jan 20, 2012 11:05 pm
by skolusu
sai_stc,

use the following DFSORT JCL which will give you the desired results
//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=Your input FB 177 byte file,DISP=SHR
//SORTOUT  DD DSN=&&S1,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)         
//SYSIN    DD *                                                   
  OPTION COPY,STOPAFT=1                                           
  OUTFIL REMOVECC,NODETAIL,HEADER1=('FDATE,C''',9,8,C'''',80:X)   
//*                                                               
//STEP0200 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SYMNAMES DD DSN=&&S1,DISP=SHR                                   
//SORTIN   DD DSN=Your input FB 325 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  OPTION COPY                                                 
  INREC IFOUTLEN=325,IFTHEN=(WHEN=INIT,OVERLAY=(326:SEQNUM,8,ZD)),
  IFTHEN=(WHEN=(326,8,ZD,EQ,1),OVERLAY=(FDATE))                   
//*

Re: Replace two files using sort

PostPosted: Sat Jan 21, 2012 1:04 pm
by sai_stc
HI SKOLUSU,

i have tried with the code which you have provided but could not get the desired output. it is displaying the Pcomm details in sysout.it will be helpful if u suggest me on this.

Thanks in advance.

Re: Replace two files using sort

PostPosted: Sat Jan 21, 2012 1:39 pm
by sai_stc
Let me clearly explain you what my requirement is
i just want to replace the charecters from file 2 (LRECL 177)
from positions 9-16 in to file 1(LRECL 325) only first record positions 2 to 9.
In general charecters will be in date format but it is not nessesary to be exactly the current day.so it will be help ful if u can suggest me how to copy the 8 positions from file 2 (9-16) and replace the 8 poitions which needs to be changed in file 1(2-9) without change in the remaining data.


File1:
201201035438
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000

File :2
C5035A0120120118R726701000000000000000000000000000000000005035503550350000000000


EXPECTED OUT PUT :

2012011895438
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000

Re: Replace two files using sort

PostPosted: Sat Jan 21, 2012 1:44 pm
by NicC
Where does the 9 in the first record of your output come from? it is not in either of your input files.

what do you mean by 'pcomm' output. Please show your SYSOUT in full using the code tags available via the 'Full Editor' or POSTREPLY buttons.

Re: Replace two files using sort

PostPosted: Sat Jan 21, 2012 4:55 pm
by BillyBoyo
The SORTOUT DD in the code provided to you usese SYSOUT=*. If you want it to go to a dataset, or somewhere else, change it.

The code provided to you

  1. takes your date record and forms a DFSORT Symbol for a constant with the value of the date from your date file
  2. takes your second file, appends a sequence number to each record, tests for sequence number being one, and if so, puts the constant created as a symbol in the previous step into the first eight bytes of what has been identified as being the first record on the file
  3. there are always three things

If you still have problems, in addition to what NicC has already requested, show the JCL and sort cards you are using and the messages from that step. In the Code tags, please.

Re: Replace two files using sort

PostPosted: Mon Jan 23, 2012 11:49 am
by sai_stc
NicC wrote:Where does the 9 in the first record of your output come from? it is not in either of your input files.

what do you mean by 'pcomm' output. Please show your SYSOUT in full using the code tags available via the 'Full Editor' or POSTREPLY buttons.


Sorry that was a typo.

file 1 (LRECL 325) and file 2(LRECL 177)

File1:
201201035438
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000

File :2
C5035A0120120118R726701000000000000000000000000000000000005035503550350000000000


EXPECTED OUT PUT :

201201185438
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000
AHDHKADH46465AHHIHAKH445500000000000000000000000000

Re: Replace two files using sort

PostPosted: Mon Jan 23, 2012 9:40 pm
by skolusu
sai_stc wrote:HI SKOLUSU,

i have tried with the code which you have provided but could not get the desired output. it is displaying the Pcomm details in sysout.it will be helpful if u suggest me on this.

Thanks in advance.


*sigh* I Just showed you an example so that the output would be displayed in the sysout. change the following statement in step0200 and re-run your job.
//SORTOUT  DD SYSOUT=*

to
//SORTOUT  DD DSN=Your output file,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)

sai_stc wrote:from positions 9-16 in to file 1(LRECL 325) only first record positions 2 to 9.


My job assumes that the date should be overlaid on to position 1. If you want it in position 2 then change the following statement
IFTHEN=(WHEN=(326,8,ZD,EQ,1),OVERLAY=(FDATE))


to
IFTHEN=(WHEN=(326,8,ZD,EQ,1),OVERLAY=(2:FDATE))

Re: Replace two files using sort

PostPosted: Fri Feb 03, 2012 5:07 pm
by sai_stc
Thank you so much :)