HOW TO GET REQUIRED FIELDS INTO O/P FILE



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: HOW TO GET REQUIRED FIELDS INTO O/P FILE

Postby BillyBoyo » Wed Mar 09, 2011 3:25 pm

So, you have to tell us what you've done to process the spanned records... because we don't know where the data is or how it is arranged otherwise. Hopefully you've not done anything to make it more difficult.

Try this.
01   RECORD-TO-BE-SEARCHED REDEFINES INPUT-RECORD.
       05  FILLER OCCURS x TIMES DEPENDING ON BYTES-BEFORE-ITEM-IDENTIFIER.
             10  FILLER PIC X.
       05  ITEM-ITSELF.
            10   ITEM-LENGTH COMP PIC S9(9) (maybe, doesn't specify).
            10   FILLER OCCURS x TIMES DEPENDING ON LENGTH-OF-ITEM-LESS-ITS-LENGTH. (note, not ITEM-LENGTH)
                   15  FILLER PIC X.
        05  DATA-TO-SEARCH-FOR PIC XX.

To start processing a new record,
     Set BYTES-BEFORE-ITEM-IDENTIFIER to the fixed number of bytes before it could be item data
     Set LENGHT-OF-ITEM to zero (yes, zero)
     Then you can test ITEM-ITSELF against your table of requests. If it matches, put your key into your ouput record, calculate lenght-of-item-less... and move ITEM-ITSELF to output record. Write. Add ITEM-LENGTH to
BYTES-BEFORE-ITEM-IDENTIFIER and then you'll basically be there.

Of course, you'll need to be checking the length of your input record itself, or number of items on it, whatever you have and have not mentioned (or not obviously enough).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Re: HOW TO GET REQUIRED FIELDS INTO O/P FILE

 

Re: HOW TO GET REQUIRED FIELDS INTO O/P FILE

Postby enrico-sorichetti » Wed Mar 09, 2011 3:26 pm

but I do not have any application doc as of now


amazing, so the dataset You are supposed to process springs out from nothing!

to reword the question...
we have two <applications/programs>
the one that You are trying to write, and the documentation is .... missing, being created while writing the program
the one that creates the dataset You want to process ...

that was the thing I was talking about... the documentation related to the second one ..
if also that one is missing...
good luck! we are all wasting time.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: HOW TO GET REQUIRED FIELDS INTO O/P FILE

Postby BillyBoyo » Wed Mar 09, 2011 3:43 pm

BillyBoyo wrote:So, you have to tell us what you've done to process the spanned records... because we don't know where the data is or how it is arranged otherwise. Hopefully you've not done anything to make it more difficult.

Try this.
01   RECORD-TO-BE-SEARCHED REDEFINES INPUT-RECORD.
       05  FILLER OCCURS x TIMES DEPENDING ON BYTES-BEFORE-ITEM-IDENTIFIER.
             10  FILLER PIC X.
       05  ITEM-ITSELF.
            10   ITEM-LENGTH COMP PIC S9(9) (maybe, doesn't specify).
            10   FILLER OCCURS x TIMES DEPENDING ON LENGTH-OF-ITEM-LESS-ITS-LENGTH. (note, not ITEM-LENGTH)
                   15  FILLER PIC X.
        05  DATA-TO-SEARCH-FOR PIC XX.

To start processing a new record,
     Set BYTES-BEFORE-ITEM-IDENTIFIER to the fixed number of bytes before it could be item data
     Set LENGHT-OF-ITEM to zero (yes, zero)
     Then you can test ITEM-ITSELF against your table of requests. If it matches, put your key into your ouput record, calculate lenght-of-item-less... and move ITEM-ITSELF to output record. Write. Add ITEM-LENGTH to
BYTES-BEFORE-ITEM-IDENTIFIER and then you'll basically be there.

Of course, you'll need to be checking the length of your input record itself, or number of items on it, whatever you have and have not mentioned (or not obviously enough).


Forgot an important bit. After adding ITEM-LENGTH to BYTES-BEFORE... important to set LENGTH-OF-ITEM to zero again, othewise the whole thing goes to pot.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: HOW TO GET REQUIRED FIELDS INTO O/P FILE

Postby Zio69 » Wed Mar 09, 2011 6:08 pm

Mann_B wrote:Thanks all for ur replies ..but I do not have any application doc as of now.

So..... what? Were you testing our responsiveness and willingness to help??
Zio69
 
Posts: 31
Joined: Wed Feb 16, 2011 7:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: HOW TO GET REQUIRED FIELDS INTO O/P FILE

Postby BillyBoyo » Thu Mar 10, 2011 3:35 am

Is this approximately how your file looks?

01 A--FUNNY-RECORD.
05 LENGTH-BEFORE-FIRST-ITEM COMP PIC S(9).
05 SPAN-RECORD-NUMBER PIC X.
05 OF-THIS-MANY-SPANNED-RECORDS PIC X.
05 MAYBE-SOME-OTHER-STUFF PIC X(X).

Where, 4+1+1+X are the value in LENGTH-BEFORE-FIRST-ITEM.

05 ITEM-ITSELF.
10 ITEM-LENGTH COMP PIC S9(4).
10 ITEM-CODE-AND-FIELDS.
15 FILLER PIC X
OCCURS 1 TIMES DEPENDING ON (ITEM-LENGTH - 2) (note, this is not real code).
Then there can be additional ITEMS in the same sort of manner, until a physical record is "full", when the spanning occurs (I hope the file doesn't split items).

Your output file:


01 THE-OUTPUT.
05 THE-REQUEST-WHICH-WAS-SATISFIED PIC X(X) (copy of the request causing the extract).
05 THE-ITEM-EXTRACTED.
10 EXTRACT-ITEM-LENGTH COMP PIC S9(4).
10 EXTRACT-ITEM-CODE-AND-FIELDS.
15 FILLER PIC X
OCCURS 1 TIMES DEPENDING ON (EXTRACT-ITEM-LENGTH - 2) (note, this is not real code).

Obviously, you may want other fields from the input record before the item data in the output as well. I can't guess about that. Assuming the data before the items is replicated (or non-existent) on the spanned records, get all of this from the "1" record.

Then, I don't think you'd need to bother any more about the spanning.

Step along each record as suggested.

I would always put a header on the output file, containing some sort of meaningful file name and the business date, if nothing else.

I would always put a trailer on the output file, containing at least a record count (in your case, might be difficult to "hash total" major numeric fields).

You will need a seperate program to extract the required field. Assuming the fields are delimited by something (that is not possible in the data itself) then I don't think you'd need the length of the field. You could UNSTRING, or modify the stepping method above to look for the delimiters and pick out the Nth field. If not so delimited, then you'd somehow need start position and length of each field.

Still looks like a home-grown (or external supplier) database. I hope I'm not helping you bust a proprietary system. Why don't you already have a program reading the file that you can modify?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: HOW TO GET REQUIRED FIELDS INTO O/P FILE

Postby Mann_B » Thu Mar 10, 2011 11:32 am

Zio69 wrote:
Mann_B wrote:Thanks all for ur replies ..but I do not have any application doc as of now.

So..... what? Were you testing our responsiveness and willingness to help??


I am thanking you all for such quick responses.
I think ,it noway means am testing your responsiveness or your willingness to help.
Mann_B
 
Posts: 79
Joined: Wed Mar 31, 2010 11:48 am
Has thanked: 0 time
Been thanked: 0 time

Re: HOW TO GET REQUIRED FIELDS INTO O/P FILE

Postby Mann_B » Thu Mar 10, 2011 11:51 am

Thanks a lot ....BIlliBoyo

Am working on it ..I will try with the way that you have suggusted
Mann_B
 
Posts: 79
Joined: Wed Mar 31, 2010 11:48 am
Has thanked: 0 time
Been thanked: 0 time

Previous

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post