View previous topic :: View next topic |
Author |
Message |
sheelu Beginner
Joined: 07 Apr 2014 Posts: 26 Topics: 6
|
Posted: Mon May 19, 2014 1:44 am Post subject: Replace a particular record in PS file |
|
|
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 |
|
 |
William Collins Supermod
Joined: 03 Jun 2012 Posts: 437 Topics: 0
|
Posted: Mon May 19, 2014 4:34 am Post subject: |
|
|
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 |
|
 |
sheelu Beginner
Joined: 07 Apr 2014 Posts: 26 Topics: 6
|
Posted: Mon May 19, 2014 4:47 am Post subject: |
|
|
Thanks William
But I did not understand the symbol/constant part.Can you please elaborate??? |
|
Back to top |
|
 |
William Collins Supermod
Joined: 03 Jun 2012 Posts: 437 Topics: 0
|
Posted: Mon May 19, 2014 6:26 am Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
sheelu Beginner
Joined: 07 Apr 2014 Posts: 26 Topics: 6
|
Posted: Tue May 20, 2014 4:02 am Post subject: |
|
|
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 |
|
 |
William Collins Supermod
Joined: 03 Jun 2012 Posts: 437 Topics: 0
|
Posted: Tue May 20, 2014 4:18 am Post subject: |
|
|
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 |
|
 |
sheelu Beginner
Joined: 07 Apr 2014 Posts: 26 Topics: 6
|
Posted: Tue May 20, 2014 4:35 am Post subject: |
|
|
Sorry William |
|
Back to top |
|
 |
sheelu Beginner
Joined: 07 Apr 2014 Posts: 26 Topics: 6
|
Posted: Tue May 20, 2014 4:36 am Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
|
Posted: Tue May 20, 2014 11:56 am Post subject: |
|
|
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 |
|
 |
sheelu Beginner
Joined: 07 Apr 2014 Posts: 26 Topics: 6
|
Posted: Tue Jun 03, 2014 4:05 am Post subject: |
|
|
Thanks Kolusu and William
It is working perfect now.!!!!..
 |
|
Back to top |
|
 |
|
|