View previous topic :: View next topic
|
Author |
Message |
nmr
New User
Joined: 27 Sep 2007 Posts: 14 Location: hyderabad
|
|
|
|
my requirement is to read one file and send the key(policy number) to another file to read that file and check all transactions in the file effective dates are in assending order if the effective dates are not in acending order we need to send that records to one report file,can any body suggest me how give conditon to check all the dates are in acending order.
for example
eff date
---------
8/20/2007
8/22/2007
8/26/2007
9/12/2007
9/06/2007
9/28/2007
10/8/2007
10/6/2007
from the above effective dates
9/06/2007
10/6/2007
are not in order those records need to write in report file |
|
Back to top |
|
|
balakrishna reddy
Active User
Joined: 13 Jul 2007 Posts: 128 Location: Guntur
|
|
|
|
Hello,
I am giving you the logic for only date checking.put this in a separate para and call this para after reading the second file randomly.
Code: |
data division.
working-storage section.
01 date1.
05 mm1 pic 9(2).
05 dd1 pic 9(2).
05 yyyy1 pic 9(4).
01 tdate.
05 tmm1 pic 9(2).
05 tdd1 pic 9(2).
05 tyyyy1 pic 9(4).
01 rdate.
05 rmm pic 9(2).
05 rdd pic 9(2).
05 ryyyy pic 9(4).
procedure division.
................
............... (After reading the second file randomly move the date1 to tdate and dont perform the condition check para for first read)
...............
if(yyyy1 >= tyyyy1)
if(mm1 >= tmm1)
if(dd1 < tdd1)
move date1 to rdate
perform report-wrt-para
else
move date1 to tdate
end-if
end-if
end-if.
.............
.............
|
if you need any clarifications don't hesitate to ask. |
|
Back to top |
|
|
nmr
New User
Joined: 27 Sep 2007 Posts: 14 Location: hyderabad
|
|
|
|
hi balakrishnareddy,
the logic you send is good,how we implement this logic for second record
on words can you please ellaborate your code,it is very helpful to me,
i am new to cobol coding. |
|
Back to top |
|
|
balakrishna reddy
Active User
Joined: 13 Jul 2007 Posts: 128 Location: Guntur
|
|
|
|
Hi,
initialize i to '0'
Code: |
read-second-file-para.
read scnd-file at end move 'Y' to eof.
move date1 to tdate.
perform check-date-para varying i from 1 by 1 until 0 < i and eof = 'Y'.
move 1 to i.
read-secondfile-exit.
exit.
|
you have any confusion please let me know |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
What will happen if the year or month is out of sequence?
I'd suggest reformatting the dates to yyyymmdd and comparing the entire date rather than comparing the pieces separately. |
|
Back to top |
|
|
nmr
New User
Joined: 27 Sep 2007 Posts: 14 Location: hyderabad
|
|
|
|
Thanks balakrishnareddy and dick |
|
Back to top |
|
|
|