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
 

 

Search all to be sorted explicitly

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

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Tue Apr 23, 2013 12:09 am    Post subject: Search all to be sorted explicitly
Reply with quote

Hi

I am having a table of 2000 items and I am loading the table depending on the value of a key say count. Once the table is loaded I am searching for an entry in the table against a value in a file. If they match I have to write it in a file. The file has ten records. The issue that I am facing is that the ten records from the file is only being matched with the first record. I am using SEARCH ALL...I see that this as a case of index non-initialization. I even tried with initialization still no success. Kindly help.
Back to top
View user's profile Send private message

don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 650
Location: Whitby, ON, Canada

PostPosted: Tue Apr 23, 2013 12:13 am    Post subject:
Reply with quote

Is the table in the correct sort sequence?
Back to top
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Tue Apr 23, 2013 12:15 am    Post subject: Reply to: Search all issue
Reply with quote

I have defined the table using the ascending key. So when the table is loaded it is in ascending sequence
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Apr 23, 2013 12:23 am    Post subject: Re: Reply to: Search all issue
Reply with quote

suraaj wrote:
I have defined the table using the ascending key. So when the table is loaded it is in ascending sequence


No, did you load the table with the keys in the correct sequence, how the table is defined in COBOL does not mean the data is in the correct sequence, you have to ensure that when you load the data!
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Apr 23, 2013 12:24 am    Post subject: Reply to: Search all issue
Reply with quote

Is the table fixed-length or variable-length (OCCURS DEPENDING ON)?

The table-data must be in sorted-order before you load it. COBOL will NOT ensure it's sorted as this is the programmer's responsibility.

Move HIGH-VALUES to the table before you load the sorted table-entries. Then if the number of entries is less than 2000, you'll have HIGH-VALUES at the end of the table, ensuring the SEARCH ALL will work.

What will you do if the number of table-entries exceeds 2000 at O'Dark thirty in the morning? icon_eek.gif

Where are you getting the table-data?

You might be better off defining the table to LINKAGE, where you can create a Dynamic-Table (via CEEGTST), based upon knowing the number of entries beforehand.

When defined in LINKAGE, you can define the table as a true ODO, 1 to 1677721 TIMES and allow an additional PIC 9(09) COMP variable, which represents the actual number of table entries.

For example -

Code:

    03  WS-STG-LGTH        PIC 9(09) COMP.
LINKAGE SECTION.
01  LS-DYNAMIC-TBL.
    03  LS-DYNAMIC-OCCURS  PIC 9(09) COMP.
    03  LS-DYNAMIC-ENTRIES OCCURS 1 TO 1677721 TIMES
                           DEPENDING ON LS-DYNAMIC-OCCURS
                           INDEXED BY X-LS-DT, X-LS-DT-MAX
                           PIC X(10).
Back to top
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Tue Apr 23, 2013 1:34 am    Post subject: Reply to: Search all issue
Reply with quote

The issue is reolved. I had not taken into consideration that the table has to be sorted explicitly. The table is created using depending on so that the table remains just enough long to contain the number of elements present.
Thanks for the solution Craq Giegerich
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 Search a Load Module sreekanth1984 TSO/ISPF 8 Tue Jun 07, 2016 8:45 pm
No new posts SUM file with secondary sorted file cdelaf32 SYNCSORT 9 Mon Apr 25, 2016 10:20 pm
No new posts Copy one PDS to another PDS based on ... alluri12 JCL & VSAM 10 Tue Sep 29, 2015 8:10 pm
No new posts Record should be sorted as a group sushanth bobby DFSORT/ICETOOL 7 Thu Aug 06, 2015 2:38 pm
No new posts Search and replace the key in the report V S Amarendra Reddy SYNCSORT 1 Thu Jul 09, 2015 7:41 pm


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