View previous topic :: View next topic
|
Author |
Message |
dp33770
New User
Joined: 04 Jul 2007 Posts: 91 Location: Hyderabad
|
|
|
|
Hi all,
can anyone help me for below requirement in Easytrieve
I have one VSAM FILE V1 as below
subdealer-code
dealer-code
address-1
address-2
recored ex:
AAA BBB mumbai north-central
BBB BBB mumbai west-central
CCC BBB mumbai east-central
DDD BBB mumbai south-central
my requiremnet is I want to do a random search to find out the address-2 where dealer and subdealer are same.
in my example it will be BBB and address-2 which will be displayed is west-central |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
and the question is...?
O. |
|
Back to top |
|
|
dp33770
New User
Joined: 04 Jul 2007 Posts: 91 Location: Hyderabad
|
|
|
|
Quote: |
my requiremnet is I want to do a random search to find out the address-2 where dealer and subdealer are same |
|
|
Back to top |
|
|
aluru_m
New User
Joined: 22 May 2008 Posts: 5 Location: New Jersey
|
|
|
|
Deep,
You need another sequential file or user input to read the subdealer-code. Next read the VASM file with the key, if sub-dealer code equal to dealer code get the address.
Define the Vsam file and Read with the key
FILE V1 VS
subdealer-code
dealer-code
address-1
address-2
READ V1 KEY subdealer-code STATUS
IF FILE-STATUS EQ 0
IF subdealer-code = dealer-code
get the address
END-IF
END-IF |
|
Back to top |
|
|
dp33770
New User
Joined: 04 Jul 2007 Posts: 91 Location: Hyderabad
|
|
|
|
My Key is of 10 charcter length
can I check for only few character of the key.
For eg.
WS-VAR =' AAAA '
READ V1 KEY WS-VAR STATUS
I want to fetch the records which has AAAA at 4 position |
|
Back to top |
|
|
aluru_m
New User
Joined: 22 May 2008 Posts: 5 Location: New Jersey
|
|
|
|
Create two fields in the input file layout - 1-4 and 5-10 then read with the first field subdealer-code1.
FILE V1 VS
subdealer-code1
subdealer-code2
dealer-code
address-1
address-2 |
|
Back to top |
|
|
dp33770
New User
Joined: 04 Jul 2007 Posts: 91 Location: Hyderabad
|
|
|
|
I can not change the Input File structure as its being used in multiple places.
The KEY in input file is of 10 char long . Where as I need to check only from 4th to 8th pos(4char) as the key ...
Can we have something like % as we have in DB2...
Or do we have any other option where in I can just use part of the key to retrive the record randomly... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I can not change the Input File structure as its being used in multiple places. |
You can use an alternate definition in your program without changing the "global" definition. You would define the bytes you want to reference as another field. The access would be sequential rather than random. |
|
Back to top |
|
|
dp33770
New User
Joined: 04 Jul 2007 Posts: 91 Location: Hyderabad
|
|
|
|
Here is a small ex:
My Key is of 10 charcter length in input file
which is a combination of two fileds
Field1-6
field2-4
records for the input file(V1):
---------
111111BBBB
222222CCCC
333333DDDD
111111EEEE
222222AAAA
now if i give the below read stmt
For eg.
WS-VAR ='AAAA'
READ V1 KEY WS-VAR STATUS
then will it retrieve the record 222222AAAA.
For me I gets File Status code as 16 . I think its for record not found.
Please let me know If my requirement is not clear... |
|
Back to top |
|
|
aluru_m
New User
Joined: 22 May 2008 Posts: 5 Location: New Jersey
|
|
|
|
You cannot read a file with variable. You need to use the field name that is defined as file layout. There is NO harm in defining the fields as in order of layout it will not change the file structure.
Define as
FILE V1 VS
subdealer-code1 1 6 N
subdealer-code2 7 4 N
dealer-code
address-1
address-2
READ V1 KEY subdealer-code2 STATUS |
|
Back to top |
|
|
|