Page 1 of 2

File Manager - Passing info between records.

PostPosted: Fri Mar 15, 2013 10:05 pm
by jkusb
Hi... I am trying to write a Batch File Manager that looks at a value in the header record, then changes all other records based on that value. I would normally do this with a COBOL program or something, but I am trying to incorporate this into an existing Batch File Manager that is already written and does other things too. I am perfectly happy to look through manuals or google search to work through the details, but it would be very helpful if you could help me get started in the right direction. Thank you Very much for taking the time to help... Jeff.

I tried to use FCH to look at the header record then make a global change, but couldn't get it working...
the trouble was limitations of the Find command in Batch (no PREV or NX etc) and couldn't figure out how
to check the return code after the Find to see if the find was successful...
$$FILEM FCH INPUT=DD01
F ' ' 100 790
F 'ENV31' 22
C '0' '1' 1 122

I also tried this (not full code, but the important REXX varialbe and variable passing)
[Set Variable after reading the first record]
$$FILEM DSC INPUT=DD01,
$$FILEM OUTPUT=DD01O,
$$FILEM PROC=*
/* FASTREXX */
/* ?do something to interrigate a value in the first record? */
JKTYP = 7
ADDRESS ISPEXEC
'VPUT JKTYP SHARED'
EXIT;
[Then on all subsequent records... do something different for TYPE7 records]
[I also tried with ADDRESS ISPEXEC 'VGET JKTYP' but that caused the JOB to abend]
* FASTREXX */
IF JKTYP = 7 THEN DO
OUTREC = CHANGE(OUTREC,FLD(5,6),'777777',1,5,6)
END
EXIT;

Re: File Manager - Passing info between records.

PostPosted: Sat Mar 16, 2013 1:21 am
by Ed Goodman
You've got me interested...

What else does the existing rexx do? It it already handling the i/o?

Re: File Manager - Passing info between records.

PostPosted: Sat Mar 16, 2013 1:35 am
by Ed Goodman
Oh, the reason for the abend is that the rexx environment you are running is NOT ispf, it's just the FileManager rexx environment. This ispf services are not available. The good news is that you can just use a variable.

My other question was: which command is the existing rexx running under? Like FCH or DSC?

If it's DSC, you can probably do something like:
If Substr(INREC,1,1) == '7' Then
mask_value = Substr(INREC,5,6)

then
OVLY_OUT(mask_value,5,6)

Re: File Manager - Passing info between records.

PostPosted: Sat Mar 16, 2013 1:44 am
by jkusb
There is no existing REXX... I was just playing with adding the REXX to try and set a variable based on the header rec so I could check it when doing the later recs.

--> THE INPUT AND OUTPUT FILES ARE TAKEN CARE
--> ABOVE THIS, BUT HERE IS WHAT THE PROC PART LOOKS
--> LIKE, WHAT I NEED TO BE ABLE TO DO IS, WITHIN
--> THE IF I NEED TO SET SOMETHING SO THAT WHEN I
--> GET TO THE OVLY_OUT STATEMENT I CAN CHECK IT AND
--> SAY: IF HEADER-TYPE-7... DO THIS OVLY_OUT,
--> OTHERWISE... DO THIS OVLY_OUT
//SYSIN DD *
*+* FMC2FM: BEGINNING OF FILE MANAGER STATEMENT OUTPUT *+*
$$FILEM DSC INPUT=DD01,
$$FILEM OUTPUT=DD01O,
$$FILEM PROC=*
IF FLD(1,2) = 'FH' THEN DO
RETURN
END
OVLY_OUT('*',025,026,C,' ')
RETURN
/+

Re: File Manager - Passing info between records.

PostPosted: Sat Mar 16, 2013 2:36 am
by Ed Goodman
Then what I just posted should work fine. Just don't use 'FLD' because that implies a formatted view. If you use Instr instead, you can just view the input record unformatted.

You could even just make it one if-then-else.

You are overlaying an existing segment of the record right, not making it longer?

Re: File Manager - Passing info between records.

PostPosted: Mon Mar 18, 2013 6:47 pm
by jkusb
WOW WOW WOW... YOU are the BEST!!! That was exactly the perfect solution... if there was any way to give you a "Thank You Brownie" I would :-)!

Re: File Manager - Passing info between records.

PostPosted: Mon Mar 18, 2013 7:17 pm
by Ed Goodman
What a great way to start the week!

Re: File Manager - Passing info between records.

PostPosted: Mon Mar 18, 2013 8:43 pm
by Ed Goodman
Also, post your code if you can so that others can benefit from your effort.

Re: File Manager - Passing info between records.

PostPosted: Mon Mar 18, 2013 11:32 pm
by jkusb
Glad to... you know, its amazing how something so 'little' can be the key to something quite big falling right into place :-)...

$$FILEM DSC  INPUT=DD01,                     
$$FILEM      OUTPUT=DD01O,                   
$$FILEM      PROC=*                           
 IF FLD(1,1) = 'F' THEN DO                   
  MASK_VALUE=SUBSTR(INREC,32,1)               
  RETURN                                     
 END                                         
 IF MASK_VALUE='7' THEN DO                   
   OVLY_OUT('7',120,001,C,' ')               
 END                                         
 ELSE DO                                     
   OVLY_OUT('9',120,001,C,' ')               
 END                                         
 RETURN                                       
/+


Code'd

Re: File Manager - Passing info between records.

PostPosted: Tue Apr 01, 2014 4:33 am
by Ed Goodman
Well, I got stuck tonight trying to figure out a process with FileManager. I came here and did a search, and GUESS WHO knew the answer! That's right..Ed Goodman. Ed Goodman knew how to do what I was trying to do with FileManager. It's a good thing I looked here, or I might NEVER have figured it out!

(I give myself a break because it's been more than a year)