Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 7989
Location: Bellevue, IA

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: 6966
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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts GETMAIN/FREEMAIN query Suja.Sai CICS 9 Tue Jan 31, 2017 12:01 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us