Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

USER-SWITCH( ) Evaluate user switch

&pagelevel(3)&pagelevel

Domain: Job information

The USER-SWITCH( ) function checks the value of the specified user switch.

User switches are used, for example, to synchronize batch jobs, i.e. in background procedures. Each user ID has available to it 32 user switches, which apply for all the jobs running under the user ID. That is, user switches which are set in one job can be evaluated by a different job which is running under the same user ID. User switches are set by means of the MODIFY-USER-SWITCHES command.

Format

USER-SWITCH( )

NUMBER = number

,USER-ID = *OWN / <string 1..8>

Result type

BOOLEAN

Input parameters

NUMBER = number
0 ≤ number ≤ 31; designates the user switch to be evaluated.

USER-ID = *OWN
The caller’s own user identification.

USER-ID = <string 1..8>
Designates the user identification to which the user switch to be requested belongs.

Result

TRUE
The specified user switch is assigned the value ’ON’ and is therefore “switched on”.

FALSE
The specified user switch is assigned the value ’OFF’ and is therefore “switched off”.

Error message

SDP0304     OVERFLOW, NUMBER OUT OF RANGE

Example

In dialog:

/MODIFY-USER-SWITCHES ON = 1
/B = USER-SWITCH(1, USER-ID = 'US123')
/SHOW-VARIABLE B
B = TRUE

Within a procedure, user switches 1, 3, 5 and 8 are on, while user switches 2 and 4 are off:

/MODIFY-USER-SWITCHES ON = (1,3,5,8), OFF = (2,4)

User switches are requested later on:

/A = USER-IDENTIFICATION()
/IF (USER-SWITCH(2, USER-ID = A))
/   CALL-PROCEDURE C.PROC1.2
/END-IF
/...
/IF (USER-SWITCH(1, USER-ID = A))
/   CALL-PROCEDURE C.PROC1.1
/ELSE-IF USER-SWITCH(4, USER-ID = A)
/   CALL-PROCEDURE C.PROC1.4
/ELSE
/   CALL-PROCEDURE C.PROC2
/END-IF

User switch 2 is not set (OFF), which means that the condition in the first IF command is not met. PROC1.2 is therefore not called; instead, the command following END-IF is executed immediately.

In the second IF command, user switch 1 is checked; this switch is set (ON), which means that the condition is met. The procedure C.PROC1.1 is called.