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 

Extract a string from an unstructured input file.

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


Joined: 16 Jun 2005
Posts: 4
Topics: 1

PostPosted: Fri Jul 22, 2005 1:45 am    Post subject: Extract a string from an unstructured input file. Reply with quote

Hi ,
I have a requirement ,from an existing sort card ( this is present in a PDS), i need to extract a string of data.
The input file structure looks like this:
------------------------------------------------------------------
SORT FIELDS=COPY
OMIT COND=(089,007,CH,EQ,C'A00009D',
OR,089,007,CH,EQ,C'A20034F',
OR,089,007,CH,EQ,C'A20153B',
OR,089,007,CH,EQ,C'A20631B',
OR,089,007,CH,EQ,C'A22369A',
OR,089,007,CH,EQ,C'A23002J',
OR,089,007,CH,EQ,C'A23928I',
OR,089,007,CH,EQ,C'A25153G')

------------------------------------------------------------------

From the above rows of data the following output needs to be generated:
A00009D
A20034F
A20153B
A20631B
A22369A
A23002J
A23928I
A25153G

The problem here is, there is no fixed position where the data in input file will start.

In our shop we are using only sort and older version of Synctool.

Can any one help me to get the required output using sort.
Back to top
View user's profile Send private message
Brian
Beginner


Joined: 12 Aug 2003
Posts: 95
Topics: 6

PostPosted: Fri Jul 22, 2005 3:23 am    Post subject: Reply with quote

Darren,

Have you tried the substring option with sort.

Code:

INCLUDE COND=(1,80,ss,eq,C'A25153G')


Cheers
Brian
Back to top
View user's profile Send private message
Darren
Beginner


Joined: 16 Jun 2005
Posts: 4
Topics: 1

PostPosted: Fri Jul 22, 2005 6:53 am    Post subject: Reply with quote

Hi Brain,

The values in input file can change.
I need to take the value of Character string which starts with 'A'.

If I have a value something like this

(089,007,CH,EQ,C'A123456',
OR,089,007,CH,EQ,C'DDDDDDD',
OR,089,007,CH,EQ,C'EEEEEEE')

Then the output file should have A123456 only.
Back to top
View user's profile Send private message
bprasanna
Beginner


Joined: 05 Sep 2003
Posts: 119
Topics: 33
Location: Hyderabad

PostPosted: Fri Jul 22, 2005 12:54 pm    Post subject: Reply with quote

Hi Darren,
try the below INCLUDE condition.I modifed the Brien's solution a little bit.

Brian's solution:

INCLUDE COND=(1,80,ss,eq,C'A25153G')


change the above include condition to
INCLUDE COND=(1,80,ss,eq,x'123')

see the hex format of C and change the above 1 to hexvalue of C,
see the hex format of ' and change the above 2 to hexvalue of ',
see the hex format of A and change the above 3 to hexvalue of A.
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Sat Jul 23, 2005 12:41 am    Post subject: Reply with quote

I think Darren has a different requirement.

What I understand that the string is present in every record - so 'INCLUDE COND' is not required.

Now he wants to extract the string - i would write a program to do this.
Back to top
View user's profile Send private message Send e-mail
Darren
Beginner


Joined: 16 Jun 2005
Posts: 4
Topics: 1

PostPosted: Mon Jul 25, 2005 1:51 am    Post subject: Reply with quote

Thanks bprasanna and Dibakar

Using the 'INCLUDE COND' I can get the all records having "C'A" at any position in the string.

Where as my requirement is to get the output file in particular format:

A00009D
A20034F
A20153B
A20631B
A22369A
A23002J
A23928I
A25153G
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Mon Jul 25, 2005 3:58 am    Post subject: Reply with quote

Darren,

It would be helpful if you could provide us clear information. From your first post I understand that you know the values to Include/Omit.

Code:

SORT FIELDS=COPY
OMIT COND=(089,007,CH,EQ,C'A00009D',
OR,089,007,CH,EQ,C'A20034F',
OR,089,007,CH,EQ,C'A20153B',
OR,089,007,CH,EQ,C'A20631B',
OR,089,007,CH,EQ,C'A22369A',
OR,089,007,CH,EQ,C'A23002J',
OR,089,007,CH,EQ,C'A23928I',
OR,089,007,CH,EQ,C'A25153G')


First of all, you have given an OMIT condition but you also listed the value in your output.

Second, if you know the include Literals but if the problem is only their position you can use the SS operator provided by Brian and Bprasanna. Instead of "089,007" you specify "1,100" (i.e 1, LRECL - assuming that your LRECL is 100).

Code:

SORT FIELDS=COPY
OMIT COND=(1,100,CH,EQ,C'A00009D',
OR,1,100,SS,EQ,C'A20034F',
OR,1,100,SS,EQ,C'A20153B',
OR,1,100,SS,EQ,C'A20631B',
OR,1,100,SS,EQ,C'A22369A',
OR,1,100,SS,EQ,C'A23002J',
OR,1,100,SS,EQ,C'A23928I',
OR,1,100,SS,EQ,C'A25153G')


If the above solution does not satisfy your requirement, please post sample input and sample output. Also change OMIT to INCLUDE if you want to actually INCLUDE the records with the given values.

Thanks,
Phantom
Back to top
View user's profile Send private message
Darren
Beginner


Joined: 16 Jun 2005
Posts: 4
Topics: 1

PostPosted: Mon Jul 25, 2005 4:07 am    Post subject: Reply with quote

Hi Phantom,

The first post for this has the input and the expected output file.
For your reference I am posting the input and output again.
The input file is a sort card of another job.

Input file :
------------------------------------------------------------------
SORT FIELDS=COPY
OMIT COND=(089,007,CH,EQ,C'A00009D',
OR,089,007,CH,EQ,C'A20034F',
OR,089,007,CH,EQ,C'A20153B',
OR,089,007,CH,EQ,C'A20631B',
OR,089,007,CH,EQ,C'A22369A',
OR,089,007,CH,EQ,C'A23002J',
OR,089,007,CH,EQ,C'A23928I',
OR,089,007,CH,EQ,C'A25153G')

------------------------------------------------------------------

Required Output file :

A00009D
A20034F
A20153B
A20631B
A22369A
A23002J
A23928I
A25153G
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Tue Jul 26, 2005 2:39 am    Post subject: Reply with quote

Darren,

With Syncsort, I don't see any direct way to accomplish this. I'm thinking of using CHANGE operator in SORT but even that would be complex in this case. I'm not sure if there is a better way to solve this. Probably someone else can help you out.

Thanks,
Phantom
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