Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Keep/discard unmodified records based on a PARSE variable?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
David Sde

New User


Joined: 24 Apr 2011
Posts: 23
Location: USA

PostPosted: Thu Apr 17, 2014 10:22 pm    Post subject: Keep/discard unmodified records based on a PARSE variable?
Reply with quote

Hi,

I hope someone can offer me some advice.

I have a pipe-delimited input file of VB records. The file contains several different "record types" as defined by a unique 5-character string in the first position of each record (i.e., in column 5). Some of the "record types" (but not all) must be filtered on a constant 3-character "data code" (call it "XYZ") whose location in the record depends upon the 5-character record type.

Presumably, I need to use IFTHEN with PARSE to find the "data code" field in each record. That's where I get confused; do I do this in INREC? OUTREC? OUTFIL? If the parsed variable containing the data code is equal to "XYZ" (or blanks) then I want to keep the input record exactly as it was given to me originally (i.e., in its original pipe-delimited format). Otherwise, I want to discard the record entirely. Additionally, there are some 5-character "record types" which do not contain the "code" field at all, in which case I want to keep those records unconditionally.

I guess what I'm saying is: I need the IFTHEN PARSE to determine whether or not I want to keep the record or discard it, but I do not want to modify the original record if I'm going to keep it. I didn't want to have to BUILD a new record in fixed-column format after the PARSE, and then reconstruct the original pipe-delimited version of the record. I couldn't figure out if that was possible (and how it could be done).

I hope this makes sense. I can certainly do this using ICETOOL if multiple operators are needed. Can anyone offer an approach?

Thanks so much,

David
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Thu Apr 17, 2014 11:40 pm    Post subject: Reply to: Keep/discard unmodified records based on a PARSE v
Reply with quote

Does this re-state what you want?

1. You want to keep all records which are not of particular types

2. Of those of particular types, you need to keep XYX or space at a different particular position determined by the different record type

If so, yes, you'd need PARSE to locate the data for the different record types in 2, one PARSE per different column required.

The thing would be to extend your record, temporarily, so that you can store the PARSEd field to select it later on OUTFIL INCLUDE=/OMIT=.

That helps with your question "where", as it lets out OUTFIL.

Since there is no reason not to do it in INREC (the results do not depend on the order of the file), I think it best to do it in INREC.

To extend a V record:

Code:
BUILD=(1,4,nX,5)


This copies the RDW (1,4), which is obligatory for V records, then inserts n blanks, then puts your variable data from 5 to the end of the record at the location following the n blanks.

You then have somewhere to store your PARSEd field.

In OUTFIL, you will have something like

BUILD=(1,4,<5+n as a literal value>)

to get you back to your original records.

The nX mentioned is a generally convenient way, it does not have to be blanks inserted, it can be any value. But since you want blanks to be included as a value from your PARSEd field, and you need to have some way to readily get the records which are not being filtered, the blanks are probably going to be what you want.

If you still need assistance beyond that, please give some representative sample input and expected output for that sample.
Back to top
View user's profile Send private message
David Sde

New User


Joined: 24 Apr 2011
Posts: 23
Location: USA

PostPosted: Fri Apr 18, 2014 1:41 am    Post subject: Reply to: Keep/discard unmodified records based on a PARSE v
Reply with quote

Quote:
The thing would be to extend your record, temporarily, so that you can store the PARSEd field to select it later on OUTFIL INCLUDE=/OMIT=.

Bill,

That is precisely the insight I was looking for. It works perfectly. Thank you so much!

David
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Fri Apr 18, 2014 1:54 am    Post subject: Reply to: Keep/discard unmodified records based on a PARSE v
Reply with quote

No problem. Thanks for letting us know. Kudos for not just sitting around and waiting for a full answer, and blindly copy/pasting that.

If you can post what you have come up with, it can help someone in the future.
Back to top
View user's profile Send private message
David Sde

New User


Joined: 24 Apr 2011
Posts: 23
Location: USA

PostPosted: Fri Apr 18, 2014 6:07 pm    Post subject: Reply to: Keep/discard unmodified records based on a PARSE v
Reply with quote

Quote:
If you can post what you have come up with, it can help someone in the future.

Sure. Here's the general idea:

Code:

 INREC IFTHEN=(WHEN=(5,5,CH,EQ,C'AAAAA'),           
                PARSE=(%=(ENDBEFR=C'|'),             
                       %=(ENDBEFR=C'|'),             
                       %=(ENDBEFR=C'|'),             
                       %01=(ENDBEFR=C'|',FIXLEN=3)),
       BUILD=(1,4,%01,5)),                           
       IFTHEN=(WHEN=(5,5,CH,EQ,C'BBBBB'),           
                PARSE=(%=(ENDBEFR=C'|'),             
                       %=(ENDBEFR=C'|'),             
                       %=(ENDBEFR=C'|'),             
                       %=(ENDBEFR=C'|'),             
                       %02=(ENDBEFR=C'|',FIXLEN=3)),
       BUILD=(1,4,%02,5)),                           
       IFTHEN=(WHEN=NONE,                           
       BUILD=(1,4,3X,5))                             
*                                                   
 OUTFIL FNAMES=TEMP1,                               
  INCLUDE=(5,3,CH,EQ,C'XYZ',OR,5,3,CH,EQ,C'   '),     
  BUILD=(1,4,8)         
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Hi,Iam trying to unwrap the data base... bhavana yalavarthi DFSORT/ICETOOL 0 Fri Dec 09, 2016 10:25 am
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 1 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us