Need a logic for the Natural program

I am reading the input as Adabas file which contain follwoing attrubutes.
Transaction-ID Option-ID User-Id Log-date.

I want a logic to find the how many users used the same option during the month at transaction level.

Please provide the logic for the above problem.

It would help, of course, to know something about the file. Which field(s) are descriptors? What is the format of Log-date?

That said, in the absence of other information, you probably want something like:

              READ FILE-VIEW IN LOGICAL SEQUENCE BY LOG-DATE
                              STARTING FROM #START TO #END
              END-ALL
              SORT BY USER-ID USING KEYS
              AT BREAK OF USER-ID
                   ADD 1 TO #COUNT 
                   END-BREAK
              END-SORT

If you also need other fields for something, replace “KEYS” with appropriate field names.

steve

Thanks steve for a quick response.
Actually i have super descriptor like this transaction-option-log-date-user.
And log-date is in this format yyyymmdd.

can you provide the logic using this super.

Thanks steve for a quick response.
Actually i have super descriptor like this transaction-option-log-date-user.
And log-date is in this format yyyymmdd.

can you provide the logic using this super.

The super descriptor does not look like it will be helpful at all since it starts with Transaction ID, which plays no role in your report requirement.

Assuming there are no other descriptors or supers that are relevant; you will probably have to do something like:

READ FILE-VIEW IN PHYSICAL SEQUENCE
ACCEPT IF LOG-DATE GE #START AND LE #END
END-ALL
SORT BY OPTION-ID USER-ID USING KEYS
AT BREAK OF USER-ID
ADD 1 TO #COUNT
END-BREAK
AT BREAK OF OPTION-ID
WRITE 'NO. OF USERS FOR THIS OPTION ID IS: ’ #COUNT
RESET #COUNT
END-BREAK
END-SORT

Earlier code was incorrect; i misread the requirement. this code should get you the number of different users for each option id.

steve

Steve,

Thanks.

Let me explain the exact requirement of report.I have a input adabas file contains the current month (say example October) data and previous monts (say example Aug and Sep) data as well. If User used the same option in the current month and previous month then he is a existing user. If user used the option in the current month only then he is new user. Now I want a report how many existing user and new users used the corresponding option in the current month. The input adabas file look like this.

Transaction-ID Option-ID User-ID Log-Date
ACUA C A345 20060815
ACUA C A345 20061005
ACUA C A789 20061005
ACUA D A789 20061005
ACUA D A123 20061005
According to this input file the report should be like this

Transaction-ID Option-ID User Count
ACUA C E(Existing user) 1
ACUA C N(New user) 1
ACUA D N 2.

That means every option contains only 2 records, one with existing user and one with new user.

Hope you understand the requirement.If you provide logic for this report it would be great help for me.

I am trying this logic using the super which explained earlier.If this super helps, then provide logic using this super.

Regards
Ramesh

Steve,

I tired with your program which you have given on Mon Oct 09, 2006 1:44 pm, but the problem is AT BREAK OF OPTION-ID, the first record missing, since it founds the at break.How to come out with this type of proble.
Please help in this regard.

Thanks
Ramesh

I spent several hours agonizing about how to respond to the last post in this thread. At the risk of starting a controversy, I decided to respond as follows.

First, I am a Natural teacher, have been ever since Natural was developed. If I had a student come to me after a one week introductory class and admit they could not write the code for the report above, I would wonder if I had done a poor job teaching or if the student was awake. I have workshops in my introductory class that are just like the report above, some are even harder.

Ramesh, if I, or someone else, were to simply write the code for you, it would not, as in your quote, be a “great help” to you. You would learn nothing about Natural. Worse, your manager/supervisor would assume you know far more Natural than you do, and your next assignment would be a lot tougher.

If this were a class workshop, I would suggest that you write a HISTOGRAM loop (assuming we have the entire report description in your last post, which indicates that the only required fields are in the superdescriptor) and write out the values of the super.

Then, REDEFINE the super to access the individual component parts, and write some code (try AT BREAK) to isolate the appropriate records (transaction/option pair). As evident by your posting, which just came in while I am writing this, that is similar to what you were doing. However, my suggestion was based on your very meager original description of the problem. I suggested using READ and SORT, which it would appear is not necessary at all.

Play with the HISTOGRAM loop. You should be able to figure out (especially since you are familiar with AT BREAK) how to write the report.

steve

Steve

Thanks for good suggestion.