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: 7936
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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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