cp_ur530 wrote:I have read the record in the file into a table , but the recrods are not in sequence on the key
Is there any reason you can't sort the input file into this order (with your system SORT as a seperate STEP/JOB), then store in your table?
If there is a reason, you might still be lucky.
You have branch-number and salerep-number. You have defined them as numeric, I don't know why since you are never going to do a calculation with them - so better as PIC XX.
Irrespective of that, if they genuninely are numeric:
Define a table of 10,000 items, let's do 10,000 flags, you'll know if you need to include more data.
Set all the flags off at before you read any records.
Make a number out of your branch/salesperson. Start off as usage Display. Then move the resulting number to a COMP PIC S9(4), because you are going to use it as a subscript.
Add one to the value of this subscript - this is to deal with the case 0000 if it can exist. If it can't logically exist, test for it in your program and behave appropriately.
Then, using the subscript you have created, set the appropriate flag in the table "on".
You can then interrogate the table as you need, by using the same technicque.