Dynamic Array Creation in Eazytrieve



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

Dynamic Array Creation in Eazytrieve

Postby satmaar » Fri Aug 20, 2010 3:36 pm

Hi,
Since i am new to Eazytrieve,Could any one tell me dynamic Array Creation in Eazytrieve?Is there any concept in Eazytrieve OCCURS DEPENDING ON?
satmaar
 
Posts: 4
Joined: Fri Aug 20, 2010 3:14 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Dynamic Array Creation in Eazytrieve

Postby NicC » Fri Aug 20, 2010 4:21 pm

OCCURS does not appear in the idex of either of the 2 manuals I have but I may not have the correct manual. What does your manual say?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Dynamic Array Creation in Eazytrieve

Postby dick scherrer » Sat Aug 21, 2010 3:11 am

Hello,

Which release of Easytrieve are you using?

One way to do what you want is to generate the needed definition as part of the job stream, then execute it in that jobstream. . .
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: Dynamic Array Creation in Eazytrieve

Postby dick scherrer » Sat Aug 21, 2010 4:22 am

Add-on. . .

You do realize that ODO does not allocate the array dynamically in a COBOL program. . .

Why do you believe you need a dynamic array?
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: Dynamic Array Creation in Eazytrieve

Postby sjrcreation » Thu Mar 10, 2011 5:30 pm

Hi dick scherrer

I cant understand the approach. if there is an input file which i dont know how may recod there in it.
i want to put it in an array. how to do it.

I tried as below.
DO WHILE NOT EOF file1
GET file1
COUNT = file1:RECORD-COUNT
END-DO
DEFINE W-DATA W 80 A OCCURS COUNT

but it is not working ,, it need an intereger value after OCCURS

so how to solve it.
sjrcreation
 
Posts: 30
Joined: Sat Dec 11, 2010 9:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: Dynamic Array Creation in Eazytrieve

Postby Zio69 » Thu Mar 10, 2011 6:44 pm

I guess it depends on what you want to do with the data you put in the array.
If you want to search the array for a specific value (like a SEARCH in COBOL), then there's no need for an array.... EZT handles that by TABLE files. Unfortunately the array needs to be sorted by its key and no duplicates are allowed (like in a SEARCH ALL). However even in this case you've gotta give EZT an approximate amount of how many entries the table will contain.
If it's something else, then you have no choice but to shoot for the moon when coding occurences and hope for the best (and remember that you've only got so much memory avaiable.....).

If it's a SEARCH you're looking for, here's an example: let's say you need to decode ISO country. So US--> United States of America, FR --> France and so on. Let's also assume you've got this information in a sequential file, but not in the right order

FILE ISOCODES
ISO              1  3 A
COUNTRY          * 80 A
*
FILE DECODE TABLE 500 VIRTUAL F(83)
ARG              1  3 A
DESC             4 80 A
*
FILE OTHERFIL
ISO-COUNTRY     55  3 A
*
* PLEASE NOTE: WHEN USING TABLE FILES
* FIELDS MUST BE ARG AND DESC
*
WS-COUNTRY       W 80 A
*
SORT ISOCODES TO DECODE USING ISO
*
JOB INPUT OTHERFIL
* .... WHATEVER LOGIC YOU NEED
SEARCH DECODE WITH ISO-COUNTRY GIVING WS-COUNTRY
IF NOT DECODE
   DISPLAY 'UNKNOWN ISO CODE ' ISO-COUNTRY
END-IF
*....


"500" is a rough estimate of how many entries I'm going to load into the table; if I'll load less than 500 no problem; if I'll load 600, again no problem. I don't remember if there's a well defined tolerance, but I do remember that as the table gets bigger (in absolute size, not in # of elements) the tolerance gets smaller.
Another constrain for TABLEs is that you can only use ARG and DESC as fields; so if the key is composed of more than one field, you may need to build a WS variable to search. Same applies for what is returned from the search (DESC).
In case you don't want to use a VIRTUAL file, you need to allocate an adequate file in your JCL.

Edit:
I've just re-read your post.... there's one thing you need to understand: you coded

DEFINE W-DATA W 80 A OCCURS COUNT


Although EZT may look like it's interpreted (like the BASIC of old times), it is NOT. It doesn't matter where you code a variable: wherever it is, it will be as if it's coded at the top of your program. Therefore coding it right after COUNT has a meaningful value is irrelevant. Let alone that is not allowed!
Zio69
 
Posts: 31
Joined: Wed Feb 16, 2011 7:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Dynamic Array Creation in Eazytrieve

Postby BillyBoyo » Thu Mar 10, 2011 7:22 pm

Like Cobol, Easytrieve doesn't do dynamic allocation of storage.

If you let us know a little more about what you are trying to do, ie what you would use the data for if you could store it all, then we might be able to help. Otherwise, you need to set/find some reasonable limit for the the number of records on the file, and deal with it if it happens (user abend or chuck out the data, are easiest, but it all depends on your data). There is a similar question in the COBOL forum at the moment.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Dynamic Array Creation in Eazytrieve

Postby sjrcreation » Thu Mar 10, 2011 7:42 pm

Thanks Zio69 /BillyBoyo

Zi069 thanks for explaining the tabel concept.

BillyBoyo here is my req:

my requirement is like, the input have " customer name" and "Amount". like
xxxxx 2356
yyyyyy 8569
ttttttt 2312
xxxxx 1251

my expected output is like should have unique customer name ie no repeation and if they are more occurance of customer the amount should be added. so O/P
xxxx 3607
yyyyyy 8569
ttttttt 2312

so what i plan is to first sort and put in virtual file and then put them in array.
compair the array(1) = array(2)
if = in customer name then add the ammount
else put the same in output file.

so what will be the best approach for this ??
sjrcreation
 
Posts: 30
Joined: Sat Dec 11, 2010 9:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: Dynamic Array Creation in Eazytrieve

Postby sjrcreation » Thu Mar 10, 2011 7:45 pm

Zio69 wrote:Unfortunately the array needs to be sorted by its key and no duplicates are allowed

hi Zio69

are you sure about the above.. :?:
sjrcreation
 
Posts: 30
Joined: Sat Dec 11, 2010 9:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: Dynamic Array Creation in Eazytrieve

Postby BillyBoyo » Thu Mar 10, 2011 8:15 pm

sjrcreation wrote:so what will be the best approach for this ??


So, if you have two input files with the same key, then I'd suggest the matched file processing in Easytrieve.

Sort the files first. If there can be no "internal duplicates" on each of the files that is best, but can deal with duplicates.

On the JOB statement you put two files. The "main" file first, then the other file.

Look in the manual, for the exact details. It used to be badly documented there, but I think they've improved it.

With no internal dupes, you have at most three conditions to deal with. Keys equal (so you add and output), main key low (so just output the main), and other key low (maybe this cannot logically occur?) so output from the other file.

All other cases you should report an error, however your site standards say (including the other key low, if it shouldn't be that way).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Next

Return to CA-Easytrieve

 


  • Related topics
    Replies
    Views
    Last post