Page 1 of 1

CFF master record

Posted: Tue Dec 15, 2009 10:02 am
by NSIT-DVP-01
Hi,

Can anybody give me an explanation to the "master record" in CFF? In Parallel Job Developer Guide, it says that you can toggle a master record when you define multiple record types but doesn't mention the usage of master record. I wonder what is the master record supposed to do? What can we do with it. And what's the difference with or without master record toggled.

Thanks in advance!

Regards

Posted: Tue Dec 15, 2009 3:23 pm
by ray.wurlod
I'm guessing that the master record is the level 01 item.

Posted: Wed Dec 16, 2009 3:54 am
by NSIT-DVP-01
Posted: Tue Dec 15, 2009 10:23 pm
I'm guessing that the master record is the level 01 item.
Hi ray,

Thanks for your reply. I have checked the CFF stage "Layout" tab with COBOL format, I found that for every record definition (master record toggled or not), its level 01 item is always the name of the record. And this name is defined by myself in the tab "Records". I think that "master record" toggled or not doesn't influence the level 01 item. [/quote]

Posted: Wed Dec 16, 2009 2:01 pm
by ray.wurlod
OK that was a guess. But it still works - the level 01 item "contains" (in some sense) all the higher-numbered-level items. I'd be happy to learn, if anyone knows the real answer, especially if they can back it up with a reference.

Posted: Fri Jan 29, 2010 3:49 pm
by bpsprecher
Yeah -- the Parallel CFF is very powerful, but it's so different from the Server CFF and it isn't documented very well. For that reason I cannot supply a reference; only hard-learned experience.

The CFF processes one record at a time, but you've probably figured out by now that the CFF can "buffer" data from previous rows. You are only allowed to select one Master record type per CFF. Set a record type as Master, and when it is read, the output buffer will be emptied.

So how about a simple example? Suppose we have a file with a Header (H record type), Detail (D), Transaction (X) and Trailer (T). Each Detail can have multiple Transactions.

The COBOL copybook will look like the following (by the way, I find it much easier to create each record type as its own 01-level in the same *.cfd file, and import all at the same time!):

Code: Select all

       01  CFF_HEADER.
           05  RECORD_TYPE                        PIC X(1).
           05  FILLER                             PIC X(1).
           05  FILENAME                           PIC X(10).
       01  CFF_DETAIL.
           05  RECORD_TYPE                        PIC X(1).
           05  FILLER                             PIC X(1).
           05  CUST_NAME                          PIC X(4).
       01  CFF_TRANSACTION.
           05  RECORD_TYPE                        PIC X(1).
           05  FILLER                             PIC X(1).
           05  TXN_AMT                            PIC 9(3).
       01  CFF_TRAILER.
           05  RECORD_TYPE                        PIC X(1).
           05  FILLER                             PIC X(1).
           05  NAME_CNT                           PIC 9(1).
The data in the input file:

Code: Select all

H File1.dat 
D Ray  
X 750
X 999
D Bob 
X 500
X 499
T 2
We are going to build 1 output stream that will have Detail and Transaction information (RECORD_TYPE, CFF_DETAIL-FILLER, CFF_DETAIL-CUST_NAME, CFF_TRANSACTION-TXN_AMT). We will NOT select any record types as Master, and our constraint will be for record types = "D" and "X":

Code: Select all

D Ray    
X Ray 750
X Ray 999
D Bob 999
X Bob 500
X Bob 499
Notice how the first Detail row's CFF_TRANSACTION-TXN_AMT value is empty -- we expect that since we hadn't read in a Transaction row yet. But look at Bob's first Detail row -- he inherited the value from Ray's last Transaction Amount!

So now if we select the CFF_DETAIL as Master, the CFF_TRANSACTION-TXN_AMT will be emptied every time a CFF_DETAIL row is read:

Code: Select all

D Ray    
X Ray 750
X Ray 999
D Bob    
X Bob 500
X Bob 499
Of course, the situation could be avoided by setting the constraint just for record types = "X" (i.e. just spit out Transaction rows). I would guess you would code your CFF like I did above if you were going to run a single stream through a Transformer to split the output by constraints on the record type. However, you could just as easily have 2 output streams from the CFF; one for each record type (Detail and Transaction).

It just depends on what type of output you need. The CFF is very flexible, and I wish more people were using it so I can get more information from DSXchange!

Posted: Fri Feb 05, 2010 10:20 am
by NSIT-DVP-01
To dt12946:

Thanks a lot for your so detailed information!

Cordialment
NSIT

Posted: Fri Feb 05, 2010 10:32 am
by bpsprecher
You're very welcome NSIT.

I stumbled on your post while searching for CFF array handling. I actually found very good information in IBM's Parallel Job Developer's Guide in Chapter 10. Also, Appendix C does a great job explaining FILLER creation.

Now I'm just wondering why I subconsciously gave Ray more money than Bob in my example...

Posted: Fri Feb 05, 2010 5:30 pm
by ray.wurlod
Currency fluctuation... :wink: