Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Query regarding array

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Shweta12j

New User


Joined: 10 May 2010
Posts: 32
Location: Mumbai

PostPosted: Wed Aug 11, 2010 7:22 pm    Post subject: Query regarding array
Reply with quote

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
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8280
Location: Dubuque, Iowa, USA

PostPosted: Wed Aug 11, 2010 8:10 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Wed Aug 11, 2010 8:13 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Shweta12j

New User


Joined: 10 May 2010
Posts: 32
Location: Mumbai

PostPosted: Wed Aug 11, 2010 8:48 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am
No new posts How to replace the below query? pkmurali DB2 12 Tue Feb 27, 2018 9:51 pm
No new posts Need Guidance regarding UPDATE query Poha Eater DB2 3 Mon Feb 12, 2018 11:35 pm
No new posts Query to skip Max time-stamp and fetc... vickey_dw DB2 8 Sun Jan 28, 2018 1:09 am
No new posts reg query on DYNALLOC feature raghuraman123 SYNCSORT 12 Wed Jan 10, 2018 2:42 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us