The GROUP attribute can be used to cross-reference Adabas files if the file you want to search does not contain a descriptor. This cross-referencing can be done only if fields within the file you want to search correspond to descriptors in the file you are cross-referencing.
Consider this situation: You have a SALES file which contains salesman information. It also has account information, such as COMPANY_CODE, ITEM_NUMBER, and ITEM_NAME.
Suppose you also have an ACCOUNT file containing information about each company in the territory of a salesman. The ACCOUNT file has a superdescriptor consisting of COMP_CODE, IT_NUMBER, and IT_NAME. These fields correspond to the fields specified in the SALES file.
You can create a link between the matching fields in the SALES and ACCOUNT files. To do this, describe the matching fields from the SALES file as a group. Then you can join the group field to the superdescriptor in the ACCOUNTS file. The host file is the file, without a descriptor, containing the held values which must be grouped in order to retrieve related records in the second file. For example:
FILE=SALES ,SUFFIX=ADBSINX ,$ SEGNAME=ACCT_SEG ,SEGTYPE=S ,$ GROUP=LINKFLDS ,ALIAS= ,USAGE=A20 ,ACTUAL=A20 ,$ FIELD=COMPANY_CODE ,ALIAS=BA ,USAGE=A3 ,ACTUAL=A3 ,$ FIELD=ITEM_NUMBER ,ALIAS=BB ,USAGE=A5 ,ACTUAL=A5 ,$ FIELD-ITEM_NAME ,ALIAS=BC ,USAGE=A12 ,ACTUAL=A12 ,$
SALES is the host file which uses the superdescriptor (COMPANY) in the ACCOUNT file for the company-related data. The superdescriptor in the ACCOUNT file, easily recognized by TYPE=SPR in the Access File, is composed of fields that correspond to the dummy group in the host. Looking at the GROUP attribute used to cross-reference files, above, and the GROUP attribute used to cross-reference files, below, you see how the fields in the LINKFLDS group in the SALES file relate to the superdescriptor COMPANY in the ACCOUNT file:
FILE=ACCOUNT ,SUFFIX=ADBSINX ,$ SEGNAME=PROD_SEG ,SEGTYPE=S ,PARENT=ACCTS ,$ GROUP=COMPANY ,ALIAS=S1 ,USAGE=A20 ,ACTUAL=A20, INDEX=I,$ FIELD=COMP_CODE ,ALIAS=AA ,USAGE=A3 ,ACTUAL=A3 ,$ FIELD=IT_NUMBER ,ALIAS=AB ,USAGE=A5 ,ACTUAL=A5 ,$ FIELD-IT_NAME ,ALIAS=AC ,USAGE=A12 ,ACTUAL=A12 ,$
Use the GROUP superdescriptor COMPANY to retrieve data for those values using the JOIN command within a procedure. The JOIN command or embedded cross-reference completes the link. In this example, you would join LINKFLDS in SALES to COMPANY in ACCOUNT using the following syntax:
JOIN LINKFLDS IN SALES TO ALL COMPANY IN ACCOUNT AS J1
iWay Software |