I’m new using Natural/ADABAS and I tried to make one question for another language without
unsuccessfully (sad day).
I’ve seen many topics talking about READ and FIND but in this specifc case I thought READ wouldn’t be faster than FIND. I will describe the question below and I will be really happy if anyone can help me today! See ya!
Develop a routine that returns the products launched in a given period that are of a certain type.
It must be read the product file, with the input parameter type of product (see list) and the desired release period - beginning and end date of the first record (confirmed).
The result should be sorted by launch date and the end of each date found will be presented a totalizing. At the end of the report should be the general totalizer.
It is extremely important to note that there is a super-descriptor field formed by the REG-TYPE + REG-DTCONFIRMADO descriptors and may be determined that any other fields may become descriptors if necessary.
The focus and priority of this issue is the query efficiency trying to use the lowest cost to the bank (ADABAS), justify your answer.
TABLE OF PRODUCTS = DB096552-YRE-AS
*FIELDS THAT WILL BE USED
REG-TYPE
REG-DTCONFIRMADO
REG-NAME
REG-IDENT
How the layout should be!
MAP
PROGRAM: * PROGRAM
PAGES: (NUMBER OF PAGES)
DATE:
PRODUCT REPORT LAUNCHED BETWEEN THE PERIOD The
IDENT PRODUCT NAME
TOTAL PRODUCT LAUNCHED IN THE DAY FOUND =>
I was thinking about something like that:
DEFINE DATA LOCAL
1 PRODUCTS VIEW OF DB096552-YRE-A
2 REG-TYPE(N02) => ONLY TO LET YOU KNOW THE SIZE
2 REG-DTCONFIRMADO (N08)
2 CAD-NAME (A30)
2 CAD-IDENT (A07)
1 #TYPE (A8)
1 #DT-INT (N08)
1 #DT-END (N08)
END-DEFINE
#PROGRAM := *PROGRAM
INPUT USING MAP 'M01'
READ PRODUCTS BY SUPER-REG-TYPE-REG-IDENT
STARTING FROM <super-descriptor> <- ( I don't know how to insert the value of super-descriptor here, but maybe is like that 'SUPER-REG-TYPE-REG-IDENT')
IF REG-DTCONFIRMADO GE #DT-INIT AND REG-DTCONFIRMADO LE #DT-END
. . .
ESCAPE TOP
END-READ
END
Am I correct that the super SUPER-REG-TYPE-REG-IDENT concatenates the reg-type and the reg-ident? If so, how many records might satisfy a given reg-type-reg-ident?
If the number is small, it is probably the case that the difference between FIND and READ will be insignificant (doesn’t matter very much).
If the number is large, how many records will satisfy the specified date range? If the answer is most of the records for a given type-ident will be in the specified date range, there will be little difference between FIND and READ.
A super descriptor type-ident and dtconfirmado “might” be useful, depending on the answer to my last question (immediately above). Then you could do a READ by reg-type-reg-ident-reg-confirmado.
Any information you have on the answers to the above questions would help the discussion.
Yes you are right! That’s one big problems for me, as I’m new in the language, I don’t even know how to do it. =/ sorry about that.
I don’t know how many records I will have to find out, but I want to know how is the best way to make this search with many records, so I think would be great if someone could show me how to do it right. Another important point is that I will need to have the recods organized, but I think as I’m using a super it will already be organized.
I don’t know how to paginate using the language, in other languages I’ve been working around normally I get 50 per page, but in this case I think that’s ok to show all of them, feel free to show me the best way to do it.
If you prefer you could change the vars to make easier to understand.
The point is, I want to see the best results I can get using READ and FIND, the results must be ordenated, so I think it is an important point, specially if we use READ (so far I don’t know how to use it right).
The program has to check the products by type and range of dates informed by the user, them the data has to be ordenated by CAD-IDENT and at the end of each one it has to display a counter with how many has per date. At the end of report it will display how many products we have, but only that has the same type informed and how many per date.
Well… I will try to change to see if makes the job eassier.
See bellow:
Develop a routine that returns all vehicles emplacados in a certain period, a particular type of vehicle.
For each one, you need to read the vehicle file, the input parameter type of the vehicle and the desired period of time: dt-init and dt-end (license plate).
The result should be sorted by the date of the license plate. At the end of each date found, it must be presented a totalizing and the end of the report should be a general totalizer.
I would like to know which fields I should become a super-descriptor and why this is the best option to perform an optimized search, thus increasing the performance of ADABAS.
The program should look like that:
PROGRAM: *PROGRAM
PAGE: (DON’T KNOW HOW TO DO IT)
RELATION OF THE PERIOD vehicles licensed during 99/99/9999 A 99/99/9999 BY THE TYPE?: “XXXXXXXX”
FIND versus READ, as I indicated in my earlier post, is a function of many things. There is no simple answer which says one is better than the other. To answer such a question you need to know quite a bit about Adabas, Natural, and, more than a little about the characteristics of the data (which you might be able to get from a business analyst).
Most importantly, you cannot answer your FIND versus READ question without knowing more about Adabas and Natural.
Explain to the company you work for that you require education in both Adabas and Natural.
This one is a no-brainer. You need to retrieve a set of records based on a range of key values, in key sequence. FIND can’t (efficiently) sort records.
You need to READ with a superdescriptor composed of vehicle type + license date + plate number. The basic code would look like this.