× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I'm not sure if I good understood your task. 
My idea how to solve it, is to create the indexfile with Custommer name as 
index and then read only those records, which CUSTNAME match the given 
pattern:

I'will try to describe here very roughly the program :-)

1) Create index file (e.g. with SQL) on your MASTER-FILE, where index is 
the custommer name, e.g
   if your master file is CUST, then create index CUSTI, 
 
   Declaration in COBOL seems similar as shown here:

   SELECT MASTER-FILE
     ASSIGN TO DATABASE-CUSTI
     ORGANIZATION IS INDEXED
     ACCESS IS DYNAMIC
     RECORD KEY IS EXTERNALLY-DESCRIBED-KEY
     WITH DUPLICATES
     FILE STATUS IS MASTER-FILE-STATUS.
...
   FD  MASTER-FILE.
       01  MASTER-RECORD.
       COPY DD-CUST-REC OF CUSTI.


2) Then move input from 'Position to' (e.g. WS-CUSTNAME) to the key field 
and START at that position 
     MOVE WS-CUSTNAME TO CUSTNAME OF CUST-REC

     START MASTER-FILE
        KEY = CUSTNAME OF CUST-REC
        INVALID KEY
          SET CUSTOMMER-NOT-FOUND TO TRUE
              ...
        NOT INVALID KEY
          PERFORM 210-CLEAR-SUBFILE
          PERFORM 220-LOAD-SUBFILE
          PERFORM 230-DISPLAY-SUBFILE
     END-START.

3)In your 220-LOAD-SUBFILE paragraph you will read the records in the 
cycle from master file, e.g

   220-LOAD-SUBFILE.
       INITIALIZE WS-SUBFILE-RECORD-RRN.
       MOVE 'YES' TO ARE-THERE-MORE-RECORDS.
  ***  Read first record
       READ MASTER-FILE NEXT RECORD.
  ***  Store to subfile and read next
       PERFORM 225-READ-CUST-RECORD-RTN
          UNTIL NO-MORE-RECORDS-FOR-THIS-CUSTNAME.
       SET SUBFILE-END-YES TO TRUE. 

    In your 225-READ-CUST-RECORD-RTN paragraph you will move fields from 
the database to the subfile.
    Note that WS-SUBFILE-RECORD-RRN is declared as the relative key of the 
subfile.

    225-READ-OBEC-RECORD-RTN.
        ADD 1 TO WS-SUBFILE-RECORD-RRN.
        ...
   ***  Store fields from database to the subfile
        MOVE CUSTNAME OF CUSTREC TO SFL-CUSTNAME OF SFLRECORD-O.
        ....
   ***  write subfile at display
        WRITE SUBFILE DISPLAY-RECORD
           FORMAT IS 'SFLRECORD'.
        READ MASTER-FILE NEXT RECORD
           AT END
             SET NO-MORE-RECORDS-FOR-THIS-CUSTNAME TO TRUE
             MOVE ORD-NR TO MAX-NR
        END-READ
        IF WS-CUSTNAME = CUSTNAME OF CUST-REC
           SET NO-MORE-RECORDS-FOR-THIS-OBEC TO TRUE
           ...
        END-IF.

and so on...




"Bhat, Chandra" <Chandra.Bhat@xxxxxxxxxxxx> 
Sent by: cobol400-l-bounces@xxxxxxxxxxxx
07.04.2006 06:28
Please respond to
COBOL Programming on the iSeries/AS400 <cobol400-l@xxxxxxxxxxxx>


To
cobol400-l@xxxxxxxxxxxx
cc

Subject
[COBOL400-L] How to view data in alphabetical order in a subfile






Folks,
 
In the below subfile, The records are displayed in the alphabetical order.
Now, what I want to know is how can I view records from a particular
customer name starting with alphabet say 'P' if when I enter P or PXXXXX 
in
the 'Position' to field? 
 
 
                                                              Position to 
.
. . . . 
 

 Type options, press Enter.

  2=Edit       3=Add     4=Delete 
 
     Cust.Name     City                     A/c No

      A1                MUMBAI              10001

      A2                DELHI                  10002

      B1                HYDERABAD       20001

      B2                KOLKATA            20002

      C1                PUNE                  30001

      C2                CHENNAI             30002

      D1                BANGALORE       40001

      D2                NAGPUR              40002

      -                    - 
      -                    - 
 
Rgds
 
 
 
 
IMPORTANT NOTICE: 

The information in this email (and any attachments) is confidential. 
If you are not the intended recipient, you must not use or disseminate the
information.
If you have received this email in error, please immediately notify me by
"Reply" command 
and permanently delete the original and any copies or printouts thereof. 
Although this email and any attachments are believed to be free of any 
virus
or 
other defect that might affect any computer system into which it is 
received
and opened, 
it is the responsibility of the recipient to ensure that it is virus free
and no responsibility 
is accepted by American International Group, Inc. or its subsidiaries or
affiliates either 
jointly or severally, for any loss or damage arising in any way from its
use.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.