View previous topic :: View next topic
|
Author |
Message |
Shweta12j
New User
Joined: 10 May 2010 Posts: 32 Location: Mumbai
|
|
|
|
Hello All,
I have a query regarding an array. Below mentioned is my requirement..
I have an array which is defined like this:
Code: |
07 SPECIAL-CODES OCCURS 7.
09 CODE PIC X(1).
09 CODE-DATE PIC X(8). |
if suppose there are values in the above array as in:
7 SPECIAL-CODES(1) OCCURS 7 TIMES
9 CODE (1) 1/AN A
9 CODE-DATE(1) 8/AN 20071128
7 SPECIAL-CODES(2)
9 CODE(2) 1/AN 3
9 CODE-DATE(2) 8/AN 20081225
7 SPECIAL-CODES(3)
9 CODE(3) 1/AN 2
9 CODE-DATE(3) 8/AN 20081224
i need to move the code with the most recent code- date in one variable say A
and other two codes with their respective code-dates in other variables say B and C.
Kindly let me know how can i do this with the help of an array or if there is an alternative way to do it!
Thanks & regards,
Shweta. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
i need to move the code with the most recent code- date in one variable say A
and other two codes with their respective code-dates in other variables say B and C.
Kindly let me know how can i do this with the help of an array or if there is an alternative way to do it! |
You are not clear here. Move the data where? Move the latest or all of them -- you stated latest but you also talk about the other two values?
Also, please learn to use the Code button in submitting posts -- I edited your post to do this.
Did you not learn how to process an array in your classwork? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
there are host-arrays for db2 and there are cobol internal tables
what you have is a cobol internal table.
so the largest code-date(n) should go to A
Code: |
move spaces to A, B, C
perform varying subscript from 1 by 1 until subscript > 7
evaluate true
when code-date(subscript) > A
move B to C
move A to B
move code-date(subscript) to A
when code-date(subscript) > B
move B to C
move code-date(subscript) to B
when code-date(subscript) > C
move code-date(subscript) to C
when other
continue
end-evaluate
end-perform
|
|
|
Back to top |
|
|
Shweta12j
New User
Joined: 10 May 2010 Posts: 32 Location: Mumbai
|
|
|
|
Hi Robert,
Thanks for reminding of code button. Will take care of it next time onwards.
Yes i did learn to use an array but in above secnario was not able to make it out.
Dick thanks for your promt response.
I will try the above code at my end.
Kind Regards,
Shweta |
|
Back to top |
|
|
|