View previous topic :: View next topic
|
Author |
Message |
arpita70003
New User
Joined: 03 Oct 2008 Posts: 14 Location: chennai
|
|
|
|
Hi,
I need to get a particular sting from a record and omit the rest.
For instance, if i have a file containing many records like,
* START **************
**********************
*
* SYSOUT ID: XYZ
* GEN: 2742
* SEQ: 1
*
**********************
and i need to extract only the data that is present in 10th to 13th column from the dataset.
Thanks,
Arpita |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Hello,
You can do this using any of the SORT products in your shop.
For extracting pos- 10 to 13, you can use an INREC statement like this
Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN= Input file
//SORTOUT DD DSN= Output file
//SYSIN DD *
INREC FIELDS=(10,4)
SORT FIELDS=COPY |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello Arpita and welcome to the forum,
Quote: |
and i need to extract only the data that is present in 10th to 13th column from the dataset. |
Is there some reason to make a new file? If all that is needed is the data in pos 10-13, why not simply use the original file rather than making some very limited use copy? |
|
Back to top |
|
|
arpita70003
New User
Joined: 03 Oct 2008 Posts: 14 Location: chennai
|
|
|
|
Thanks D.Sch,
I am developing a tool ,so i need to go through various steps of extracting the data from the file. And the final output file will be be given to a Rexx code for further processing.
Thanks a lot..
Hi Arun,
Hope this will work out. Thanks..
Thanks,
Arpita |
|
Back to top |
|
|
arpita70003
New User
Joined: 03 Oct 2008 Posts: 14 Location: chennai
|
|
|
|
Hi D.Sch,
Let me give you my requirement.
Suppose i have a file:
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6--
***************************** Top of Data ********************
19.49.56 JOB012345---- FRIDAY, 26 SEP 2008 ----
IEF373I STEP/ABCDE /START 2008270.1949
IEF374I STEP/ABCXYZ /STOP 2008270.1949 CPU 0MIN 00.04SEC |
I need to check the (23:5) data of all the record. If that is same as '/STOP', i need to extract the data from (50:12) field of that matched record. And in the output file i need to add my comments and write the extracted field.
The output file should look like
Code: |
EXECUTION TIME: 0MIN 00.04SEC
(comment added) (field extracted from the input file)
|
Initially i thought i can process this in the REXX code. But it will be fine if i can achieve this by JCL itself. Please guide. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
I need to check the (23:5) data of all the record. If that is same as '/STOP', i need to extract the data from (50:12) field of that matched record. And in the output file i need to add my comments and write the extracted field. |
It is possible to extract fields as you mentioned above, but I dont have any idea about how you are planning to add 'comments' in the output. Will it be the same for all the extracted records? Also where do we get the first record from? - EXECUTION TIME: 0MIN 00.04SEC. |
|
Back to top |
|
|
arpita70003
New User
Joined: 03 Oct 2008 Posts: 14 Location: chennai
|
|
|
|
Hi Arun,
EXECUTION TIME: 0MIN 00.04SEC.
Here
EXECUTION TIME: -> comment
0MIN 00.04SEC -> extracted data from (50:12) field of the matched record
The comments of all the records of the output file will not be same, if the input record is with '/STOP' in the (23:5) position then only the above process should be performed..
I really have no idea if i can achieve this by JCL.. |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
this is what I think you need but it should be (50:13) so you don't truncate the C in SEC, although you will truncate anything greater than 9 commencing in 50
Code: |
SORT FIELDS=COPY
OUTFIL INCLUDE=(23,5,CH,EQ,C'/STOP'),
BUILD=(01:C'EXECUTION TIME: ',50,13)
|
Gerry |
|
Back to top |
|
|
arpita70003
New User
Joined: 03 Oct 2008 Posts: 14 Location: chennai
|
|
|
|
Hi Gerry,
I tried out with the SYSIN card. It gave an abend saying
Code: |
SORTIN : RECFM=FBA ; LRECL= 133; BLKSIZE= 1330
SORTOUT : RECFM=FBA ; LRECL= 133; BLKSIZE= 1330
SORTOUT HAS INCOMPATIBLE LRECL |
Is there anything specific with the LRECL field? |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
try
Code: |
SORT FIELDS=COPY
OUTFIL INCLUDE=(23,5,CH,EQ,C'/STOP'),
BUILD=(01:C'EXECUTION TIME: ',50,13,133:X)
|
Gerry |
|
Back to top |
|
|
arpita70003
New User
Joined: 03 Oct 2008 Posts: 14 Location: chennai
|
|
|
|
Thanks Gerry,
The code worked fine..
By using the same kind of SYSIN card, is it possible to extract more than one data based on more than one search conditions,
For example,
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6--
***************************** Top of Data ********************
19.49.56 JOB012345---- FRIDAY, 26 SEP 2008 ----
IEF373I STEP/ABCDE /START 2008270.1949
IEF374I STEP/ABCXYZ /STOP 2008270.1949 CPU 0MIN 00.04SEC |
If i want to validate two conditions on the above input file ,
Condition 1 - If the (23:6)data = '/START'
extract (30:12)data with 'START TIME : ' as comment.
Condition 2 - If the (23:5)data ='/STOP'
extract (30:12)data with 'STOP TIME:' and (50:13)data with 'EXECUTION TIME:' as comments.
The desired output looks like,
Code: |
START TIME: 2008270.1949 (extracted from the 1st record of i/p file)
STOP TIME: 2008270.1949(extracted from (30:12) data of 2nd input record)
EXECUTION TIME: 0MIN 00.04SEC (extracted from (50:13)data of 2nd record)
|
Please assist. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Hello,
The below Syncsort job works for your requirement. I have assumed FB, LRECL=80 for the output dataset. You can modify it as per your attributes.
Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN= Input File -----> FBA,LRECL=133
//SORTOUT DD DSN= Output File -----> FB,LRECL=80
//SYSIN DD *
INCLUDE COND=(23,6,CH,EQ,C'/START',OR,23,5,CH,EQ,C'/STOP')
SORT FIELDS=COPY
OUTFIL IFTHEN=(WHEN=(23,6,CH,EQ,C'/START'),
BUILD=(C'START TIME : ',30,12)),
IFTHEN=(WHEN=(23,5,CH,EQ,C'/STOP'),
BUILD=(C'STOP TIME : ',30,12,/,
C'EXECUTION TIME : ',50,13)),IFOUTLEN=80 |
SORTOUT
Code: |
START TIME : 2008270.1949
STOP TIME : 2008270.1949
EXECUTION TIME : 0MIN 00.04SEC |
|
|
Back to top |
|
|
arpita70003
New User
Joined: 03 Oct 2008 Posts: 14 Location: chennai
|
|
|
|
Wow.... :)thanks a lottttt......... |
|
Back to top |
|
|
|