IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Inserting Date from input file to another file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Raj Ponnuchamy

New User


Joined: 09 Sep 2009
Posts: 9
Location: Chennai

PostPosted: Wed Sep 09, 2009 4:02 pm
Reply with quote

Hi,

I have two input files Input 1 and Input 2.Both are FB files.
Input 1 contains only date field. The length of the field is S9(07) COMP-3. The length of Input 1 file is 4.
Input 2 file contains many records. The length of the file is 857.

I need to insert the date field from Input 1 into the input 2 file at the position 32. The length of the target variable in the input 2 file is also S9(07) COMP-3.

Please let me know how i can achieve this through SORT.

Thanks
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Sep 09, 2009 4:26 pm
Reply with quote

Please specify which sort product is in use at your site as the solution may vary by product.

What happens to any data that already exists in the target position in file 2.

How many records are there in file 1. If more than one, what are the rules for insertion into file 2.
Back to top
View user's profile Send private message
Raj Ponnuchamy

New User


Joined: 09 Sep 2009
Posts: 9
Location: Chennai

PostPosted: Wed Sep 09, 2009 4:40 pm
Reply with quote

Hi,

The product used is SYNCSORT Z/OS UTIL V1R2.


The data already present in file2 should be replaced with the data from file 1.

There will be only one record in the file 1. This record needs to be inserted in the file 2 for all the records at the position 32. There is no rule for this insertion. All the record in file2 should be updated with the data from file 1

Thanks
Back to top
View user's profile Send private message
rockish

Active User


Joined: 05 Jun 2009
Posts: 185
Location: Planet Earth

PostPosted: Wed Sep 09, 2009 5:43 pm
Reply with quote

Couple of things..

I really wonder if anybody will give you a clarification on SYNCSORT int his board.. This is exclusive for DFSORT related products..

Next thing is, you still were not clear about what happens to the data that already exists at 32nd position !!! Should they be moved to the right or replaced with the four bytes from file1 ??

The following JCL's will work with DFSORT ICETOOL:

Case 1:
Moving the data after 32nd position to the right
Code:
//ICETOOL0 EXEC PGM=ICETOOL                                     
//TOOLMSG  DD SYSOUT=*                                         
//DFSMSG   DD SYSOUT=*                                         
//IN1      DD *                                                 
//IN2      DD *                                                 
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)   
//OUTPUT   DD SYSOUT=*                                         
//TOOLIN   DD *                                                 
  COPY FROM(IN1) USING(CTL1)                                   
  COPY FROM(IN2) USING(CTL2)                                   
  SPLICE FROM(T1) TO(OUTPUT) USING(CTL3) ON(862,1,CH) WITH(1,31) -
  WITH(36,826) WITHALL KEEPNODUPS                                 
//CTL1CNTL DD *                                                 
  OUTFIL FNAMES=T1,OUTREC=(32:1,4,862:C'0')                       
//CTL2CNTL DD *                               
  OUTFIL FNAMES=T1,OUTREC=(1:1,31,36:32,826,862:C'0')
//CTL3CNTL DD *                               
  OUTFIL FNAMES=OUTPUT,BUILD=(1,861)


Case 2:
Replacing the data in 32-35 position
Code:
//ICETOOL0 EXEC PGM=ICETOOL                                     
//TOOLMSG  DD SYSOUT=*                                         
//DFSMSG   DD SYSOUT=*                                         
//IN1      DD *                                                 
//IN2      DD *                                                 
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)   
//OUTPUT   DD SYSOUT=*                                         
//TOOLIN   DD *                                                 
  COPY FROM(IN1) USING(CTL1)                                   
  COPY FROM(IN2) USING(CTL2)                                   
  SPLICE FROM(T1) TO(OUTPUT) USING(CTL3) ON(862,1,CH) WITH(1,857) -
  WITHALL KEEPNODUPS                                 
//CTL1CNTL DD *                                                 
  OUTFIL FNAMES=T1,OUTREC=(32:1,4,858:C'0')                       
//CTL2CNTL DD *                               
  OUTFIL FNAMES=T1,OUTREC=(1:1,857,858:C'0')
//CTL3CNTL DD *                               
  OUTFIL FNAMES=OUTPUT,BUILD=(1,857)


Of course, Frank/Kolusu may suggest a better piece of code with DFSORT/ICETOOL..
Back to top
View user's profile Send private message
Raj Ponnuchamy

New User


Joined: 09 Sep 2009
Posts: 9
Location: Chennai

PostPosted: Wed Sep 09, 2009 6:04 pm
Reply with quote

Hi,

Thanks for the update.

As for the question

"Next thing is, you still were not clear about what happens to the data that already exists at 32nd position !!! Should they be moved to the right or replaced with the four bytes from file1 ?? "

The data already existing in 32 - 35 position in file 2 should be replaced with the four bytes data from file 1.

Is it possible to achieve this using SORT instead of ICETOOL ?

Thanks,
Back to top
View user's profile Send private message
rockish

Active User


Joined: 05 Jun 2009
Posts: 185
Location: Planet Earth

PostPosted: Wed Sep 09, 2009 6:08 pm
Reply with quote

I never handled two files using SORT so far !!!!! (Unless its a MERGE functionality)

If you are still particular about the usage of SORT, you might need to pass the four bytes as a symbolic variable rather than a separate file..

Somebody pls correct me if SORT can handle multiple input files !!
Back to top
View user's profile Send private message
rockish

Active User


Joined: 05 Jun 2009
Posts: 185
Location: Planet Earth

PostPosted: Wed Sep 09, 2009 6:20 pm
Reply with quote

If you are okay with using symbolic variables, following code will help,

Code:
//SORT000 EXEC PGM=SORT       
//SYSOUT   DD SYSOUT=*         
//SYMNAMES DD *               
MYPARM,X'F0F0F0F0'               
//SORTIN   DD DSN=<INPUT>,DISP=SHR
//SORTOUT  DD SYSOUT=*         
//SYSIN   DD *                 
  SORT FIELDS=COPY             
  OUTREC OVERLAY=(32:MYPARM)
Back to top
View user's profile Send private message
Raj Ponnuchamy

New User


Joined: 09 Sep 2009
Posts: 9
Location: Chennai

PostPosted: Thu Sep 10, 2009 1:07 pm
Reply with quote

Hi,

Actually this sort job will be running daily and the value in the file1 will be changing daily. So it would be better if the values are obtained from file1 instead of hard coding the value directly in the sort card.

Thanks
Back to top
View user's profile Send private message
rockish

Active User


Joined: 05 Jun 2009
Posts: 185
Location: Planet Earth

PostPosted: Thu Sep 10, 2009 2:04 pm
Reply with quote

I really wonder if you tried any of the JCL's I posted or simply raising questions..

Tell me why you want to use SORT and not XXXXTOOL. I have given you the JCL to get your requirement done using ICETOOL. SyncSort has its equivalent in the name of SYNCTOOL which I think also has an alias ICETOOL. I would suggest you to give atleast few minutes of YOUR effort in getting your requirement done.

I would like to quote the words of EXPAT from a different post,

Quote:
Please note DO NOT just ask for code without showing your own attempts. This is a HELP forum, not a do it for me forum.
Back to top
View user's profile Send private message
Raj Ponnuchamy

New User


Joined: 09 Sep 2009
Posts: 9
Location: Chennai

PostPosted: Thu Sep 10, 2009 3:45 pm
Reply with quote

Hi,

I was told that i should not use ICETOOL for this task in my concern. I dont know the reason for this.

Thanks for the help. I will try to achieve this by Sort.
Back to top
View user's profile Send private message
rockish

Active User


Joined: 05 Jun 2009
Posts: 185
Location: Planet Earth

PostPosted: Thu Sep 10, 2009 4:31 pm
Reply with quote

Cool, do share the JCL with me once you are done. As am really curious to know how SORT can handle two files !!
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Sep 10, 2009 4:32 pm
Reply with quote

rockish wrote:
I never handled two files using SORT so far !!!!! (Unless its a MERGE functionality)
rockish,

I am not sure which product you meant here by 'SORT'. But AFAIK a SyncSort JOIN application can have two input files.

Raj Ponnuchamy,

You can slightly modify the solution posted above like this to make it work for your requirement. This is untested. Give it a try. Good luck
Code:
//SORT001 EXEC PGM=SORT       
//SYSOUT   DD SYSOUT=*         
//SORTIN   DD DSN= Date-file (FB/LRECL=4)               
//SORTOUT  DD DSN=&&T1,DISP=(,PASS)         
//SYSIN    DD *                 
  SORT FIELDS=COPY             
  OUTREC BUILD=(C'DATE-X,''',1,4,C'''',80:X)
//SORT002 EXEC PGM=SORT       
//SYSOUT   DD SYSOUT=*         
//SYMNAMES DD DSN=&&T1,DISP=(OLD,PASS)             
//SORTIN   DD DSN= Input-file  (FB/LRECL=857)               
//SORTOUT  DD DSN= Output-file (FB/LRECL=857)           
//SYSIN   DD *                 
  INREC OVERLAY=(32:DATE-X)
  SORT FIELDS=COPY             
Back to top
View user's profile Send private message
rockish

Active User


Joined: 05 Jun 2009
Posts: 185
Location: Planet Earth

PostPosted: Thu Sep 10, 2009 7:31 pm
Reply with quote

Arun,
I think that may work with most of the SORT products icon_smile.gif

I have actually never used SYMNAMES that way !!!! Anyway, I learnt one more stuff today icon_smile.gif

Thanks for sharing..
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Sep 10, 2009 7:33 pm
Reply with quote

rockish wrote:
Arun,
I think that may work with most of the SORT products icon_smile.gif
What??? icon_rolleyes.gif
Back to top
View user's profile Send private message
rockish

Active User


Joined: 05 Jun 2009
Posts: 185
Location: Planet Earth

PostPosted: Thu Sep 10, 2009 8:31 pm
Reply with quote

OMG.. u mistook wat i said.. i stressed on something else

Quote:
I think that may work with most of the SORT products


All I meant to say was, your solution will work with other products too !!!!
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Sep 10, 2009 10:14 pm
Reply with quote

Sorry for the confusion. Actually I thought u were saying "SyncSort JOIN will work with most of the sort products"
Back to top
View user's profile Send private message
Raj Ponnuchamy

New User


Joined: 09 Sep 2009
Posts: 9
Location: Chennai

PostPosted: Fri Sep 11, 2009 12:44 pm
Reply with quote

Arun,

I have tested the sort code you provided and it worked as per my requirement. Thanks for the help.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Sep 11, 2009 7:47 pm
Reply with quote

You're welcome.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top