View previous topic :: View next topic
|
Author |
Message |
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
what did You not understand in the pseudo code I posted ? |
|
Back to top |
|
|
nileshyp
New User
Joined: 22 Jun 2005 Posts: 65 Location: Mumbai
|
|
|
|
Layout of both files are as follows
Code: |
Accnt range file :
01 ACCT-RANG-REC.
05 FROM-ACCT-NO.
10 ACRG-FROM-OFFC PIC X(03).
10 ACRG-FROM-ACCT PIC X(05).
05 THRU-ACCT-NO.
10 ACRG-THRU-OFFC PIC X(03).
10 ACRG-THRU-ACCT PIC X(05).
05 ACRG-FILLER PIC X(64).
Data file Key part
01 DATALINE-REC.
05 ML-KEY.
10 ML-CLIENT PIC XX.
10 ML-OFFC-ACCT.
15 ML-OFFICE PIC XXX.
15 ML-ACCOUNT PIC X(5).
10 ML-CURRENCY-CODE PIC XX. |
Till now i have done as follows
Code: |
Perform READ-ACCT-RANGES
READ ACNT-RANGE-FILE
END
MOVE HIGH-VALUES TO FROM-ACCT-NO
NOT END
ADD 1 TO AR-CTR
END-READ.
PERFORM I-MAIN-LOGIC THRU PARA-EXIT
UNTIL FROM-ACCT-NO = HIGH-VALUES.
MOVE FROM-ACCT-NO TO ML-OFFC-ACCT.
START MONY-LINE-FILE KEY >= ML-KEY.
EVALUATE ML-STATUS
WHEN '00'
PERFORM 175-READ-DATALINE-FILE
WHEN '23'
MOVE HIGH-VALUES TO ML-OFFC-ACCT
WHEN OTHER
DISPLAY 'ABORT NUMBER: ' ABEND-NUM
DISPLAY 'FILE STATUS : ' ML-STATUS
PERFORM 999-ABORT-JOB
END-EVALUATE.
175-READ-DATALINE-FILE.
READ DATA-LINE-FILE NEXT.
EVALUATE ML-STATUS
WHEN '00'
ADD 1 TO ML-CTR
WHEN '10'
MOVE HIGH-VALUES TO ML-OFFC-ACCT
WHEN OTHER
DISPLAY 'ABORT NUMBER: ' ABEND-NUM
DISPLAY 'FILE STATUS : ' ML-STATUS
PERFORM 999-ABORT-JOB
END-EVALUATE.
PERFORM UNTIL ML-OFFC-ACCT > THRU-ACCT-NO
perform...
peform ... etc
etc..
PERFORM 175-READ-DATALINE-FILE
Perform READ-ACCT-RANGES |
Could you suggest more efficient and simple way of achieving above?
Regards,
N |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
yeah, use the rope that enrico mentioned earlier. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
Could you suggest more efficient and simple way of achieving above? |
It is not always possible to do this. Some problems just require a certain amount of logic (and hence code) to resolve -- and without completely changing the problem statement, you cannot get around this. Either learn to deal with the complexity, or get used to being utterly confused as an IT person, or find a career that doesn't require the complexity. Your choice. |
|
Back to top |
|
|
nileshyp
New User
Joined: 22 Jun 2005 Posts: 65 Location: Mumbai
|
|
|
|
Anyway.. can you please give me some examples of such programs so that i will take a look and try to buid it accordingly. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
I do not speak cobolese, but whatever the language chosen
I would follow strictly the pseudo code I suggested
effective, and very easy to follow
it did not take me very long to prototype the whole thing in REXX
file1 ( the range data )
file2 ( the data )
Code: |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
the prototype to check the logic
Code: |
#! /opt/oorexx/bin/rexx
/* read the first record from the range file */
file1buff = ""
file1buff = linein("file1.txt")
/* check for an empty range file */
if file1buff = "" then do
/* simulate end of file */
key1 = 9999
key2 = 9999
end
else do
key1 = strip(word(file1buff,1))
key2 = strip(word(file1buff,2))
end
/* read the first record from the data file */
file2buff = ""
file2buff = linein("file2.txt")
do forever
/* check for end-of-file on the data file */
if file2buff = "" then ,
leave
keyd = strip(file2buff)
/* check for the data key in the current range */
if key1 <= keyd & keyd <= key2 then do
file3buff = right(keyd,4) || " in range " right(key1,4) right(key2,4)
say file3buff
/* read the next record from the data file */
file2buff = ""
file2buff = linein("file2.txt")
iterate
end
/* check for the data key below the current range */
if keyd < key1 then do
file3buff = right(keyd,4) || " NOT in range"
say file3buff
/* read the next record from the data file */
file2buff = ""
file2buff = linein("file2.txt")
iterate
end
/* check for the data key above the current range */
/* not needed but prevents nasty situations */
if keyd > key2 then do
/* read the next record from the range file */
file1buff = ""
file1buff = linein("file1.txt")
/* check for end-of-file on the range file */
if file1buff = "" then do
key1 = 9999
key2 = 9999
end
else do
key1 = strip(word(file1buff,1))
key2 = strip(word(file1buff,2))
end
iterate
end
say "***** Logic Error, should not be here "
end
exit
|
the result
Code: |
1 NOT in range
2 NOT in range
3 in range 3 5
4 in range 3 5
5 in range 3 5
6 NOT in range
7 NOT in range
8 NOT in range
9 NOT in range
10 in range 10 12
11 in range 10 12
12 in range 10 12
13 NOT in range
14 in range 14 18
15 in range 14 18
16 in range 14 18
17 in range 14 18
18 in range 14 18
19 NOT in range
20 NOT in range
|
it did not take that long - check the posts timestamps
started doing since Your last post appeared
while waiting for a loong build to complete on my mac |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
Perhaps the code example provided in this link could get you started in the right direction. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Hi Ronald!
getting into a self reference loop
if the TS had read and understood the pseudo code we would not be here!
since I was having a coffee break I prototyped the sillyness in rexx |
|
Back to top |
|
|
|