MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Replace a particular record in PS file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
sheelu
Beginner


Joined: 07 Apr 2014
Posts: 26
Topics: 6

PostPosted: Mon May 19, 2014 1:44 am    Post subject: Replace a particular record in PS file Reply with quote

Hi

Suppose I have two PS files such that the first file will have only 1 record at at a time.I want to copy the contents of the first file to the second file in such a way that it has to replace a particular record of the second file based on value of a particular column.

for eg:

If ps file2 has many records,Is it possible to replace a particular record of the file with data from file 1 where data between 10th-18th column (file2) is equal to a particular string???
Back to top
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Mon May 19, 2014 4:34 am    Post subject: Reply with quote

Yes, generate a symbol, a constant, in one step,

Use IFTHEN=(WHEN=(logical expresion) to identify your record, and replace the position with the value from the symbol.
Back to top
View user's profile Send private message
sheelu
Beginner


Joined: 07 Apr 2014
Posts: 26
Topics: 6

PostPosted: Mon May 19, 2014 4:47 am    Post subject: Reply with quote

Thanks William

But I did not understand the symbol/constant part.Can you please elaborate???
Back to top
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Mon May 19, 2014 6:26 am    Post subject: Reply with quote

Code:
//SYMNAMES DD *
  THIS-IS-A-CONSTANT,C'YES'
//SYMNOUT DD SYSOUT=*
//SYIN
  OPTION COPY
  INREC OVERLAY=(1:THIS-IS-A-CONSTANT)
//SORTIN
NOT HERE, CONSTANT


Symbols can be used to define fields on records, or contants.

By generating the symbol file, you can take data from one file (single-record, or more) and then use data from a file in another file through referencing the generated symbol.

You read the data from your single-record file, and format it as a symbol file (fixed-length, 80 bytes). Then just include the DSN in your second step, and reference the (meaningful) name that you've given to the constant in your control cards for that step.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Mon May 19, 2014 10:59 am    Post subject: Reply with quote

sheelu,

Please search before posting. Check this link http://www.mvsforums.com/helpboards/viewtopic.php?&t=7784&highlight=symnames
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sheelu
Beginner


Joined: 07 Apr 2014
Posts: 26
Topics: 6

PostPosted: Tue May 20, 2014 4:02 am    Post subject: Reply with quote

Hi all
I tried the following code to replace a record in a file with a record from another file.
Code:

//STEP011  EXEC PGM=SORT                                 
//SYSOUT DD SYSOUT=*                                     
//SORTIN  DD DSN=xxxxx.xxxxx.xxxxx.PS,DISP=SHR           
//SORTOUT DD DSN=&T2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE),
//         DCB=(RECFM=FB,LRECL=80)                       
//SYSIN     DD *                                         
  OPTION STOPAFT=1                                       
  SORT FIELDS=COPY                                       
  OUTREC FIELDS=(C'FILE1VAL,''',1,77,C'''')               
/*   

//STEP0200 EXEC PGM=SORT                               
//SYMNAMES DD DSN=&T2,DISP=SHR                         
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD DSN=yyyyyy.yyyyyy.yyyyyy.PS,DISP=SHR   
//SORTOUT   DD SYSOUT=*                               
//SYSIN     DD *                                       
   OPTION COPY                                         
   INREC IFTHEN=(WHEN=(10,4,CH,EQ,C'VSPS'),           
   OVERLAY=(1:FILE1VAL))                               
//*     

My requirement is to replace the record in the second PS file(yyy.ps) with contents from the first PS file (xxx.ps)where the 10th column contains the string "VSPS". But on execution I am getting error in SYMNAMES processing.
Back to top
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Tue May 20, 2014 4:18 am    Post subject: Reply with quote

Do you want us to just guess what error it gave you?

You need a 77-byte value? You didn't mention that. You'll need to do that it two pieces.

SYMNAMES must be fixed-length 80-byte records, with data between 1 and 71.

Either split your input it two, or use OUTFIL BUILD with the slash operator (/).
Back to top
View user's profile Send private message
sheelu
Beginner


Joined: 07 Apr 2014
Posts: 26
Topics: 6

PostPosted: Tue May 20, 2014 4:35 am    Post subject: Reply with quote

Sorry William
Back to top
View user's profile Send private message
sheelu
Beginner


Joined: 07 Apr 2014
Posts: 26
Topics: 6

PostPosted: Tue May 20, 2014 4:36 am    Post subject: Reply with quote

I was getting the error message :symbol,value or syntax is invalid.
I think it might be because of the SYMNAME limitation of data length (between 1 and 71 )as you told.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Tue May 20, 2014 11:56 am    Post subject: Reply with quote

sheelu wrote:
I was getting the error message :symbol,value or syntax is invalid.
I think it might be because of the SYMNAME limitation of data length (between 1 and 71 )as you told.


sheelu,

Please try to understand and follow what William said. You need to split the string into 2 constants using slash "/" operator. something like this

Code:

//SYSIN    DD *                                             
  OPTION COPY,STOPAFT=1                                     
  OUTFIL BUILD=(C'FILE1VAL1,C''',01,38,C'''',/,             
                C'FILE1VAL2,C''',39,39,C'''',80:X)           
//*



and then use them in your step2 as follows

Code:

//SYSIN    DD *                               
  OPTION COPY                                 
  INREC IFTHEN=(WHEN=(10,4,CH,EQ,C'VSPS'),   
  OVERLAY=(FILE1VAL1,FILE1VAL2))             
//*                                           

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sheelu
Beginner


Joined: 07 Apr 2014
Posts: 26
Topics: 6

PostPosted: Tue Jun 03, 2014 4:05 am    Post subject: Reply with quote

Thanks Kolusu and William


It is working perfect now.!!!!..



Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group