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

Syncsort extracting a string from a file


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

New User


Joined: 03 Oct 2008
Posts: 14
Location: chennai

PostPosted: Mon Oct 06, 2008 7:46 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Mon Oct 06, 2008 7:56 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Oct 07, 2008 12:29 am
Reply with quote

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
View user's profile Send private message
arpita70003

New User


Joined: 03 Oct 2008
Posts: 14
Location: chennai

PostPosted: Tue Oct 07, 2008 8:19 am
Reply with quote

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
View user's profile Send private message
arpita70003

New User


Joined: 03 Oct 2008
Posts: 14
Location: chennai

PostPosted: Tue Oct 07, 2008 11:06 am
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Tue Oct 07, 2008 11:15 am
Reply with quote

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
View user's profile Send private message
arpita70003

New User


Joined: 03 Oct 2008
Posts: 14
Location: chennai

PostPosted: Tue Oct 07, 2008 11:43 am
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Oct 07, 2008 11:48 am
Reply with quote

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
View user's profile Send private message
arpita70003

New User


Joined: 03 Oct 2008
Posts: 14
Location: chennai

PostPosted: Tue Oct 07, 2008 12:09 pm
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Oct 07, 2008 2:49 pm
Reply with quote

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
View user's profile Send private message
arpita70003

New User


Joined: 03 Oct 2008
Posts: 14
Location: chennai

PostPosted: Tue Oct 07, 2008 6:21 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Tue Oct 07, 2008 8:21 pm
Reply with quote

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
View user's profile Send private message
arpita70003

New User


Joined: 03 Oct 2008
Posts: 14
Location: chennai

PostPosted: Wed Oct 08, 2008 4:21 pm
Reply with quote

Wow.... :)thanks a lottttt.........
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 FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
Search our Forums:

Back to Top