GET input file more than once?



Unicenter CA-Easytrieve Plus Report Generator: CA's information retrieval and data management tool

GET input file more than once?

Postby Claude3rd » Fri Oct 22, 2010 4:08 am

HI all,
I have just a smattering of experience with Easytrieve, and all of it gleaned from my co-workers. I do have the "Easytrieve Plus student guide" though! My coworkers are willing to help when I hit a bump, but I can't seem to get a satisfactory answer from them on this one. I've been reading through the forums here and elsewhere trying to find an answer for my problem, but haven't come across a working solution.

Basically, We have a CICS screen where a user keys in a number of transaction codes for the night. That screen can only accommodate 54 codes though, so when we have more than that, I have to hold a batch job and manually add the missing codes to a file. These codes are listed three times within the file though, each time with different info after the code number.

Input File1 example, just transaction codes:
ABC1003
ABC1004


Input File2 example
ABC1001  PULL EVEN WHEN NO MATCH
ABC1002  PULL EVEN WHEN NO MATCH
000.000  PULL % OPEN % CLOSE     
ABC1001  DROP-ACTION                     
ABC1002  DROP-ACTION                     
100.100  DROP % OPEN % CLOSE     
ABC1001  DROP-BUCK                     
ABC1002  DROP-BUCK                     
AAA0000  ZZZZZZZZ                     


Expected Output
ABC1001  PULL EVEN WHEN NO MATCH
ABC1002  PULL EVEN WHEN NO MATCH
ABC1003  PULL EVEN WHEN NO MATCH
ABC1004  PULL EVEN WHEN NO MATCH
000.000  PULL % OPEN % CLOSE     
ABC1001  DROP-ACTION                     
ABC1002  DROP-ACTION       
ABC1003  DROP-ACTION
ABC1004  DROP-ACTION
100.100  DROP % OPEN % CLOSE     
ABC1001  DROP-BUCK                     
ABC1002  DROP-BUCK             
ABC1003  DROP-BUCK
ABC1004  DROP-BUCK
AAA0000  ZZZZZZZZ                     


The program reads FILE2 and writes it out with no changes until it finds the end-of-section markers (The two line with % and the line with ZZZZZZZZ), It then reads FILE1 with a get until EOF loop. It then formats the transaction codes into the style for the section it is adding it to (Pull, Drop) before adding it to the output.
This works great for the first marker, the output contains all the old & new transactions, but it fails on a A010 INVALID FILE REFERENCE since FILE1 is now at EOF. Is there a way to close the file, or start the read from the top of FILE1 again?

IF DESCRIPT NE W-MARKER-1 W-MARKER-2 W-MARKER-3         
** IF NO MATCH TO MARKER FLAGS, THEN SEND IT TO O/P FILE
   BUFF-OUTDD = BUFF-FILE2                           
   PUT OUTDD                                           
   W-RETAIN-DESC = DESCRIPT                             
ELSE                                                   
*   IF ONE OF THE MARKERS IS FOUND...                   
*   SAVE THE DESCRIPTION AREA                           
   W-LINE1-DESCRIPT = W-RETAIN-DESC                     
                                                       
   PERFORM READ-FILE1
* DONE ADDING DATA, PUT MARKER ON OUTPUT FILE           
   BUFF-OUTDD = BUFF-FILE2
   PUT OUTDD                                           
END-IF

READ-FILE1. PROC
*   READ FILE1 TO ADD THE DATA     
   GET FILE1
   DO WHILE NOT EOF FILE1               
      W-LINE1-TRN-CODE = BUFF-TRN
      BUFF-OUTDD = W-LINE1                 
      PUT OUTDD                           
      GET FILE1
   END-DO                           
END-PROC     


I've tried multiple JOB statements, but that resets the output too. I eventually got it to work using three separate DD's for FILE1, all pointing to the same DSN, and each having a separate PROC, but that looks sloppy.
Claude3rd
 
Posts: 2
Joined: Fri Oct 22, 2010 2:26 am
Has thanked: 0 time
Been thanked: 0 time

Re: GET input file more than once?

Postby dick scherrer » Fri Oct 22, 2010 6:11 am

Hello and welcome to the forum,

It may help if you post the jcl for this step.

If you use vsam for file one, you can re-read the data and not use multiple dd statements. I'm not aware of a way to close and re-open a file with Easytrieve.

You might also consider reading file1 into an array within the program.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: GET input file more than once?

Postby Claude3rd » Tue Oct 26, 2010 2:24 am

Thanks for the reply, dick scherrer.

An Array seems to be exactly what I needed. I had been looking at using one, but thought it wouldn't work out based on the examples in the Easytrieve Student Guide. The examples I saw had an array as one line, for example "JanFebMarAprMayJunJulAugSepOctNovDec" I couldn't figure out how to make that idea work for me. After showing your answer to a co-worker, he showed me the way to use an array as I needed, one record at a time. I swear, they'll fight tooth and nail to resist imparting more knowledge on others.

Interestingly enough, I had been asking if Easytrieve supported just such a feature, from my barely remembered days of BASIC coding on the old C64 computer, but I couldn't recall the name for it. And I guess my poor communication of "You would load a variable with a counter for a reference" didn't quite explain what I barely remembered. The easytrieve implementation seems nearly identical from what I recall of tables in Basic. Below is my testing of the code. It is not full featured yet, but it does display the loaded array.

So now I have this code to load the array

LOAD-TBL. PROC                                           
**  READ FILE1 TO LOAD THE TABLE                   
   DISPLAY 'LOADING TABLE'                               
   W-COUNT-TBL = W-COUNT-TBL + 1                         
   GET FILE1
   DO WHILE NOT EOF FILE1
      W-EXTRACT(W-COUNT-TBL) = BUFF-MGT                 
      DISPLAY 'CURRENT BUFF-MGT : ' BUFF-MGT             
      W-COUNT-TBL = W-COUNT-TBL + 1                     
      GET FILE1
   END-DO                                               
   DISPLAY 'TOTAL TABLE RECORDS     : ' W-COUNT-TBL   
END-PROC                                                 


And for testing purposes, this display of the values:

UNLOAD-TBL. PROC                                           
   W-COUNT-OUT = W-COUNT-OUT + 1                           
   DO WHILE W-COUNT-OUT LT W-COUNT-TBL                     
      DISPLAY 'CURRENT RECORD   : ' W-EXTRACT(W-COUNT-OUT)
      W-COUNT-OUT = W-COUNT-OUT + 1                       
   END-DO                                                 
END-PROC                                                   
Claude3rd
 
Posts: 2
Joined: Fri Oct 22, 2010 2:26 am
Has thanked: 0 time
Been thanked: 0 time

Re: GET input file more than once?

Postby dick scherrer » Tue Oct 26, 2010 2:37 am

Good to hear you have it working - thank you for letting us know :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to CA-Easytrieve

 


  • Related topics
    Replies
    Views
    Last post