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

Keep/discard unmodified records based on a PARSE variable?


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 17, 2014 11:40 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Apr 18, 2014 1:54 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 5
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top