Previous Topic: @IF Status CodesNext Topic: @KEEP—places an explicit shared or exclusive lock on a record


@IF Example

The following examples illustrate two uses of the @IF statement.

In the first example, the @IF statement tests the DEPT-EMPLOYEE set for existing EMPLOYEE members and, if no occurrences of the EMPLOYEE record are found (that is, ERRSTAT is 0000), moves a message to that effect to location EMPLSWS.

If the current occurrence of the DEPT-EMPLOYEE set contains one or more occurrences of the EMPLOYEE record (that is, ERRSTAT is 1601), the GOTO clause is ignored and the next statement in the program is executed.

	@IF SET='DEPT-EMPLOYEE',EMPTY=YES, _
	GOTO=NOEMPL
	.
	.
  NOEMPL EQU _
	MVC EMPLSWS,=CL2_'NO EMPLOYEES IN SET'

In this next example, the @IF statement is used to verify that the EMPLOYEE record that is current of run unit is not a member of the current occurrence of the OFFICE-EMPLOYEE set before code is executed to connect the EMPLOYEE record to that set.

If the EMPLOYEE record is not a member of OFFICE-EMPLOYEE (that is, ERRSTAT is 1601), the program branches to the LINKSET paragraph. If the EMPLOYEE record is already a member of the OFFICE-EMPLOYEE set (that is, ERRSTAT is 0000), the GOTO clause is ignored and the next statement in the program is executed.

@IF SET='OFFICE-EMPLOYEE',MEMBER=NO,GOTO=LINKSET