Page 1 of 1

Help in search instruction

PostPosted: Sun Aug 23, 2009 8:57 pm
by ruizito
Hi!
I need to make a validation in a program. For that, I put all the valids numbers in a table. After, I want to make a search instruction for each record of my input file to know if the record is valid.
I'm in home and I don't have a cobol compilator here.
Anyone can compile this code for my and tell me if it works?

The table is:


01 TAB-NIFS.
05 TABLE-NIF OCCURS 50
DEPENDING ON CONT-REG-NIF
INDEXED BY WS-INDEX-NIF.
10 TABLE-NIF-SIZE PIC 9(02) VALUE ZEROS.
10 TABLE-NIF-VALUE PIC X(09) VALUE SPACES.
01 CONT-REG-NIF PIC 9(02) USAGE COMP-3 VALUE ZEROS.


An example of the load table is.

TABLE-NIF-SIZE | TABLE-NIF-VALUE
2 | 21
1 | 1
4 | 1233
3 | 123
9 | 123456789

The search instruction is:

Set ws-index-NIF to 1.

SEARCH TABLE-NIF

At end
set SW-NOTFND to true

When TABLE-NIF-VALUE( 1: TABLE-NIF-SIZE(WS-INDEX-NIF) )(ws-index-NIF) = FILEIN-NIF(1: TABLE-NIF-SIZE(WS-INDEX-NIF) )
set sw-FND to true

End-Search.


Thanks

Re: Help in search instruction

PostPosted: Mon Aug 24, 2009 8:52 am
by dick scherrer
Hello,

Suggest you download one of the free cobol compilers and install on your pc. A web search for free cobol compiler gives many links. I believe MicroFocus also has a free version.

Re: Help in search instruction

PostPosted: Mon Aug 24, 2009 12:41 pm
by GuyC
I haven't tried it in a while, but I don't think you can use index in a reference. i.e. var(1:var2(ix)) won't compile (probably).

and there is an functional error as well with the code provided : any number in file starting with 1 will equal your second entry in the table. You should use the size of the filein-nif to test. : varA(1:sizeofvarA) = varB(1:sizeofvarB)

Re: Help in search instruction

PostPosted: Tue Aug 25, 2009 12:15 am
by dick scherrer
Hello,

One way to use reference modification on a field in an array is:
 01  HOLD-DTL-ARRAY VALUE SPACES.           
     03  HOLD-DTL OCCURS 900 TIMES.         
        05 CST-HD           PIC X(13).     
        05 RCD-TYP-HD       PIC XX.         
        05 ORD-TYPE-HD      PIC X.         
        05 DTL-NBR-HD       PIC XXX.       
        05 FILLER           PIC X(1200).   


         DISPLAY HOLD-DTL(1) (1:30)       
         DISPLAY HOLD-DTL(2) (1:30)       
         DISPLAY HOLD-DTL(3) (1:30)       
         DISPLAY HOLD-DTL(4) (1:30)       
         DISPLAY HOLD-DTL(5) (1:30)       
         DISPLAY HOLD-DTL(6) (1:30)       
         DISPLAY HOLD-DTL(7) (1:30)       
         DISPLAY HOLD-DTL(8) (1:30)       
         DISPLAY HOLD-DTL(9) (1:30)       


Re: Help in search instruction

PostPosted: Thu Aug 27, 2009 12:13 pm
by GuyC
display var(ix) (1:30)

is not the same as
display var (1:var2(ix)) 


can be coded as :
move var2(ix) to ws-len
display var(1:ws-len)

but not in a Search