infile empss01 idms func=func1 record=rec1
dbkey=key1 errstat=err sequence=seq1;
.
.
.
1 func1 = 'ACCEPT';
2 rec1 = 'DEPARTMENT';
3 seq1 = 'CURRENT';
input;
if err eq '0000' then do
4 put @1 'DBKEY OF RECORD = ' @19 key1;
.
.
.| 1 | FUNC1 is assigned the value of ACCEPT. |
| 2 | REC1 is assigned the record name DEPARTMENT because you want the db-key of this record. Before you can issue an ACCEPT function call for a specific record, you must first establish currency on the record. |
| 3 | SEQ1 is set to CURRENT to indicate that you want the db-key of the DEPARTMENT record that is current of the run unit. |
| 4 | After successful execution of the ACCEPT function call, KEY1 contains the db-key for the current DEPARTMENT record. The PUT statement prints the value of KEY1 on the SAS log. |
infile empss01 idms func=func1 set=set1
dbkey=key1 errstat=err sequence=seq1;
.
.
.
1 func1 = 'ACCEPT';
2 set1 = 'DEPT-EMPLOYEE';
3 seq1 = 'NEXT';
input;
if err eq '0000' then do
4 put @1 'DBKEY OF RECORD = ' @19 key1;
.
.
.| 1 | FUNC1 is assigned the function of ACCEPT. |
| 2 | SET1 is assigned the set name that is current of the run unit. For example, if you have currency on the EMPLOYEE record, the ACCEPT NEXT causes the db-key of the next record in the DEPT-EMPLOYEE set to be returned from the function call to CA-IDMS. The next record in the DEPT-EMPLOYEE set could be either an EMPLOYEE record or a DEPARTMENT record, depending on your location in the set when the ACCEPT NEXT function call is issued. |
| 3 | SEQ1 is set to NEXT to indicate that you want the db-key from the next record in the DEPT-EMPLOYEE set. |
| 4 | After successful execution of the ACCEPT function call, KEY1 contains the db-key for the NEXT record. The PUT statement prints the db-key on the SAS log. |
infile empss01 idms func=func1 record=recname . . . 1 func1 = 'BIND'; 2 recname = 'DEPARTMENT'; 3 input; . . .
| 1 | FUNC1 is assigned the function of BIND. |
| 2 | RECNAME is assigned the value of DEPARTMENT because this is the record on which you want to perform the BIND RECORD. |
| 3 | This INPUT statement generates and submits the BIND RECORD function call to CA-IDMS. |
infile empss01 idms func=funct record=recname
ikey=ckey keyoff=key0 errstat=stat
sequence=seq ikeylen=klen;
.
.
.
1 funct = 'FIND';
2 recname = 'EMPLOYEE';
3 ckey = '0101';
4 key0 = 0;
5 klen = 4;
6 input;
.
.
.
7 funct = 'OBTAIN';
8 seq = 'DUP';
if stat eq '0000' then do
9 input @1 employee_id 4.0
@5 firstname $char10.
@15 lastname $char15.
@30 street $char20.
@50 city $char15.
@65 state $char2.
@67 zip $char9.
@76 phone 10.0
@86 status $char2.
@88 ssnumber $char9.
@97 startdate 6.0
@103 termdate 6.0
@109 birthdate 6.0;
.
.
.| 1 | FUNCT is assigned the value of FIND. |
| 2 | RECNAME is assigned the name of the record that you want to access. In this example, the record is the EMPLOYEE record. |
| 3 | CKEY is assigned the character value of '0101', which is the value of the CALC key of the EMPLOYEE record that you want to access. Upon successful execution of the FIND CALC function call, currency is set to the EMPLOYEE record with the employee ID number of 0101. The CALC key for the employee record is the employee ID. |
| 4 | KEYO is set to zero because the employee ID or the CALC key is at offset zero in the employee record. In other words, the employee ID is the first element in the employee record. |
| 5 | KLEN is set to 4, which is the length of the CALC key, the employee ID. |
| 6 | This INPUT statement generates and submits the FIND CALC function call to CA-IDMS. No SAS variables are created. The FIND function establishes currency but does not retrieve data. |
| 7 | FUNCT is set to OBTAIN to generate an OBTAIN CALC function call to CA-IDMS. |
| 8 | SEQ is set to DUP so that the code generates an OBTAIN CALC DUP function call. RECNAME, CKEY, KLEN, and KEYO are still set from the previous FIND CALC function call and do not have to be set. |
| 9 | This
INPUT statement contains SAS variables because the OBTAIN function
call causes CA-IDMS to locate the specified record and move the data
associated with the record to the record buffer.
The INPUT keyword submits
the generated function call, which, if successful, returns a record
to the buffer. The remaining portion of the INPUT statement maps fields
from the buffer to the program data vector.
|
infile empss01 idms func=funct record=recname
errstat=stat sequence=seq;
.
.
.
1 funct = 'FIND';
2 seq = 'CURRENT';
3 recname = 'DEPARTMENT';
4 input;
.
.
.| 1 | FUNCT is assigned the value of FIND. |
| 2 | SEQ is assigned CURRENT so that the function call to CA-IDMS will locate the current record of the specified record type, set, or area. In this example, the code is looking for the current record of the record type DEPARTMENT. |
| 3 | RECNAME
specifies the name of the record type that is to be accessed. In this
example, the record is the DEPARTMENT record.
You can use the AREA
option or the SET option instead of the RECORD option with the FIND/OBTAIN
CURRENT function to locate the current record of the named area or
set, respectively.
|
| 4 | This INPUT statement generates and submits the FIND CURRENT function call to CA-IDMS. |
infile empss01 idms func=funct dbkey=dkey
errstat=stat sequence=seq;
.
.
.
1 funct = 'ACCEPT';
seq = 'NEXT';
2 dkey = ' ';
input;
.
.
.
funct = 'OBTAIN';
3 seq = ' ';
4 input @1 department_id 4.0
@5 department_name $char45.
@50 department_head 4.0;
.
.
.| 1 | FUNCT is assigned the value of ACCEPT to get the db-key for the next record, based on currency. |
| 2 | DKEY
is set to blanks to receive the new db-key.
After the ACCEPT function
call has successfully executed, the db-key is returned to the DATA
step in the DKEY variable. The db-key can be saved and used later
to access the record directly.
|
| 3 | The
SEQ option is set to blanks because it is not used with the OBTAIN
DBKEY function call.
If the RECORD option
is used with FIND/OBTAIN DBKEY, the db-key value must contain a db-key
of the named record type.
|
| 4 | The INPUT statement generates and submits the OBTAIN DBKEY function call. If successful, data returned to the buffer is mapped to the named variables. |
infile empss01 idms func=funct set=inset
errstat=stat sequence=seq;
.
.
.
1 funct = 'OBTAIN';
2 seq = 'OWNER';
3 inset = 'DEPT-EMPLOYEE';
4 input @1 department_id 4.0
@5 department_name $char45.
@50 department_head 4.0;
.
.
.| 1 | FUNCT is assigned the value of OBTAIN so that the data for the owner record is returned to the DATA step program. |
| 2 | SEQ is assigned OWNER to generate an OBTAIN OWNER function call. |
| 3 | INSET specifies the set whose owner record is to be retrieved. |
| 4 | The INPUT statement generates and submits the OBTAIN OWNER function call. If successful, data returned to the buffer are mapped to the named variables. |
infile empss01 idms func=funct record+recname
errstat=stat sequence=seq set=inset
sortfld=skey;
.
.
.
1 funct = 'OBTAIN';
2 seq = 'CURRENT';
3 skey = 'GARFIELD' || 'JENNIFER';
4 recname = 'EMPLOYEE';
5 inset = 'EMP-NAME-NDX';
6 input @1 employee_id 4.0
@5 firstname $char10.
@15 lastname $char15.
@30 street $char20.
@50 city $char15.
@65 state $char2.
@67 zip $char9.
@76 phone 10.0
@86 status $char2.
@88 ssnumber $char9.
@97 startdate 6.0
@103 termdate 6.0
@109 birthdate 6.0
@115 filler01 $char2. ;
.
.
.| 1 | FUNCT is assigned the value of OBTAIN to retrieve the data for the employee record with the sort key of JENNIFER GARFIELD. |
| 2 | SEQ is set to CURRENT to indicate that the search begins with the current record of the set specified in INSET. |
| 3 | SKEY contains the value of the sort control element to be used in searching the sorted set. In this example, SKEY is set to the last and first name value of the employee name sort control element in the EMP-NAME-NDX set where you want to begin the search. |
| 4 | RECNAME is set to the name of the record to retrieve. In this example, you are looking for the EMPLOYEE record. |
| 5 | INSET is assigned the name of a sorted set |
| 6 | The INPUT statement generates and submits the OBTAIN SORTFLD WITHIN CURRENT set function call. If successful, data is mapped from the buffer to the named variables. |
infile empss01 idms func=funct area=subarea record=recname errstat=stat
sequence=seq;
.
.
.
1 funct = 'OBTAIN';
2 seq = 'PRIOR';
3 subarea = 'EMP-DEMO-REGION';
recname = 'EMPLOYEE'
4 input @1 employee_id 4.0
@5 firstname $char10.
@15 lastname $char15.
@30 street $char20.
@50 city $char15.
@65 state $char2.
@67 zip $char9.
@76 phone 10.0
@86 status $char2.
@88 ssnumber $char9.
@97 startdate 6.0
@103 termdate 6.0
@109 birthdate 6.0
@115 filler01 $char2. ;
.
.
.| 1 | FUNCT is assigned the function of OBTAIN to retrieve the data for the EMPLOYEE record. |
| 2 | SEQ is set to PRIOR to indicate that the prior EMPLOYEE record is requested. |
| 3 | SUBAREA contains the name of the current area from which to retrieve the EMPLOYEE record. |
| 4 | The INPUT statement generates and submits the OBTAIN PRIOR function call. If successful, data is mapped from the buffer to the named variables. |
infile empss01 idms func=func1 record=rec1
errstat=err;
.
.
.
1 func1 = 'GET';
2 input @1 department_id 4.0
@5 department_name $char45.
@50 department_head 4.0;
.
.
.| 1 | FUNC1 is assigned the value of GET. |
| 2 | The record that is current of the run unit is moved into the input buffer. Currency must be established before issuing the GET function. |
infile empss01 idms func=func1 record=rec1
errstat=err;
.
.
.
func1 = 'GET';
1 rec1 = 'DEPARTMENT';
input @1 department_id 4.0
@5 department_name $char45.
@50 department_head 4.0;
.
.
.| 1 | The difference between this GET function call and the previous GET call is the use of the SAS variable REC1. This variable is set to the name of the specific record to move into the record buffer. In this example, the data associated with the DEPARTMENT record is moved. Currency must be established on the DEPARTMENT record before a GET call can be made for the record. |
infile empss01 idms func=funct record=recname
area=subarea errstat=stat sequence=seq
set=inset;
1 funct = 'FIND';
seq = 'FIRST';
recname = 'DEPARTMENT';
subarea = 'ORG-DEMO-REGION';
input;
if (stat ^= '0000') then go to staterr;
2 funct = 'IF';
3 seq = 'NEMPTY';
4 inset = 'DEPT-EMPLOYEE';
recname = ' ';
subarea = ' ';
input;
5 if (stat = '1601') then do;
put @1 'Set ' @5 inset @14 'is not empty';
stat = '0000';
_error_ = 0;
end;
6 else if (stat = '0000') then
put @1 'Set' @5 inset @14 'is empty';
else go to staterr;
stop;| 1 | Run-unit currency for the DML IF statement is established by the previous function call. A FIND function call establishes run-unit currency on the record DEPARTMENT for the DML IF statement, but does not retrieve the record. |
| 2 | FUNCT is assigned the value of IF to indicate that a test is performed. Set currency is determined by the owner of the current record in the set named in INSET. |
| 3 | SEQ is set to NEMPTY to indicate the type of test. |
| 4 | INSET names the set to test. |
| 5 | The first SAS IF statement directs the DATA step to write a message to the log if the value of STAT is 1601, which means that the set is not empty. |
| 6 | The second SAS IF statement directs the DATA step to stop if the value of STAT is 0000, which means the set is empty. |
infile empss01 idms func=func1 errstat=err
sequence=seq set=inset sortkey=skey dbkey=dkey;
.
.
1 func1 = 'RETURN';
2 seq = 'FIRST';
3 inset = 'EMP-NAME-NDX';
input;
4 put @1 'DBKEY OF RECORD = ' @19 dkey;
put @1 'SKEY OF RECORD = ' @19 skey;
.
.
.| 1 | FUNC1 is assigned the function of RETURN. |
| 2 | SEQ is assigned the value of FIRST. FIRST returns the db-key for the first index entry in the set EMP-NAME-NDX. You could also request the db-key from the PRIOR, NEXT, or LAST index entry in the set by assigning these values to the SEQUENCE= option. |
| 3 | SET is assigned the name of the index set (INSET) from which the specified db-key is to be returned. |
| 4 | DKEY contains the db-key for the first entry in EMP-NAME-NDX. SKEY contains the symbolic key for the entry. The PUT statements print the db-key and the symbolic key on the SAS log. |
infile empss01 idms func=func1 record=recname
ikeylen=keyl errstat=err sequence=seq
set=inset dbkey=dkey sortkey=skey;
.
.
.
1 func1 = 'RETURN';
2 seq = 'USING';
3 inset = 'EMP-NAME-NDX';
4 skey = 'GARFIELD JENNIFER';
5 keyl = 25;
6 dkey = ' ';
input;
.
.
.| 1 | FUNC1 is assigned the function of RETURN. |
| 2 | SEQ is set to USING to indicate that the index key entry in SKEY is used to locate the db-key. In this example, SKEY is set to the last name and first name GARFIELD JENNIFER. The call returns the db-key and symbolic key of the first record that it encounters that contains the name GARFIELD JENNIFER. |
| 3 | INSET is the name of the index set to be searched. |
| 4 | SKEY specifies the index key value to search for. |
| 5 | KEYL specifies the length of index key value. |
| 6 | DKEY
is set to blanks to receive the db-key.
After the RETURN function
call has successfully executed, the db-key is returned to the DATA
step in the DKEY variable.
|
|
COBOL DML Call1
|
|
|---|---|
| 1KEYOFF= INFILE statement option required for these calls | |