Replace two files using sort



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Replace two files using sort

Postby sai_stc » Fri Jan 20, 2012 8:55 pm

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
sai_stc
 
Posts: 6
Joined: Fri Jan 20, 2012 8:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Replace two files using sort

Postby sai_stc » Fri Jan 20, 2012 8:59 pm

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
sai_stc
 
Posts: 6
Joined: Fri Jan 20, 2012 8:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Replace two files using sort

Postby skolusu » Fri Jan 20, 2012 11:05 pm

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))                   
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Replace two files using sort

Postby sai_stc » Sat Jan 21, 2012 1:04 pm

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.
sai_stc
 
Posts: 6
Joined: Fri Jan 20, 2012 8:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Replace two files using sort

Postby sai_stc » Sat Jan 21, 2012 1:39 pm

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
sai_stc
 
Posts: 6
Joined: Fri Jan 20, 2012 8:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Replace two files using sort

Postby NicC » Sat Jan 21, 2012 1:44 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Replace two files using sort

Postby BillyBoyo » Sat Jan 21, 2012 4:55 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Replace two files using sort

Postby sai_stc » Mon Jan 23, 2012 11:49 am

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
You do not have the required permissions to view the files attached to this post.
sai_stc
 
Posts: 6
Joined: Fri Jan 20, 2012 8:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Replace two files using sort

Postby skolusu » Mon Jan 23, 2012 9:40 pm

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))
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Replace two files using sort

Postby sai_stc » Fri Feb 03, 2012 5:07 pm

Thank you so much :)
sai_stc
 
Posts: 6
Joined: Fri Jan 20, 2012 8:18 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post