How to: |
Use the CALL command when you need one procedure to call another. When you use CALL, both the calling and called procedures communicate using variables: local variables that you pass between them and the global transaction variables FocError, FocErrorRow, and FocCurrent. CALL allows you to link modular procedures, so each procedure can perform its own set of discrete operations within the context of your application. Since called procedures can reside on different servers, you can physically partition applications across different platforms.
For additional information about requirements for passing variables, see the Developing WebFOCUS Maintain Applications manual.
The syntax of the CALL command is:
CALL procedure [AT server ] [KEEP|DROP] [PATH {VAR|LIST}] [FROM var_list] [INTO var_list] [;] var_list: {variable} [{variable} ...]
where:
Is the name of the Maintain procedure to run.
Identifies the server of the called procedure if the called procedure and calling procedure are on different servers.
In most situations the Maintain Development Environment supplies this phrase during the deployment phase and you should refrain from coding it yourself. If you do code the AT server clause in your procedure, it will not change during deployment. You can use a variable to supply the server name.
The DROP parameter terminates the server session that the AT server phrase creates. The KEEP parameter leaves the server session active for reuse by subsequent calls. KEEP is the default value.
Is used to specify additional locations (search paths) the system should use when searching for dependent resources (Master Files, imported modules, and others). The path location names are application names existing within the APPROOT directory structure or application names that have been introduced with the APP MAP command. The search path value can be in the form of a Maintain variable or a list of literal values enclosed in quotes, as follows:
CALL Procedure AT server PATH "AppDir1 AppDir2 AppDir3" ; CALL Procedure AT server PATH MyVariable ;
Is included if this Maintain procedure passes one or more variables to the called procedure.
Is included if the called Maintain procedure passes one or more variables back to this procedure.
Are the scalar variables and stacks that are passed to or from this procedure. Multiple variables are separated by blank spaces.
Is the name of a scalar variable or stack. You can pass any variable except for those defined as variable-length character (that is, those defined as A0 or TX) and those defined using STACK OF.
Terminates the command. Although the semicolon is optional, it is recommended that you include it to allow for flexible syntax and better processing. For more information about the benefits of including the semicolon, see Terminating Command Syntax.
The following example shows three Maintain procedures. The first displays a form to collect employee IDs and salaries. It then calls Validate to make sure that the salaries are in a range. If they are all valid, it calls PutData and includes them in the data source. If not, it sets FocError to the invalid row and redisplays the data.
MAINTAIN FILE EMPLOYEE INFER EMP_ID CURR_SAL INTO EMPSTACK; Winform Show EMPL; CASE VALIDATE_DATA CALL VALIDATE FROM EMPSTACK; IF FOCERROR EQ 0 THEN BEGIN CALL PUTDATA FROM EMPSTACK; TYPE "DATA ACCEPTED"; ENDBEGIN ELSE BEGIN TYPE "THERE WAS AN ERROR IN ROW <FOCERROR"; TYPE "TRY AGAIN"; ENDBEGIN ENDCASE END
The Validate procedure contains:
MAINTAIN FILE EMPLOYEE FROM EMPSTACK INFER EMP_ID INTO EMPSTACK; COMPUTE CNT/I4=1; REPEAT EMPSTACK.FOCCOUNT; IF EMPSTACK(CNT).CURR_SAL GT 100000 THEN BEGIN COMPUTE FOCERROR=CNT; GOTO EXITREPEAT; ENDBEGIN ELSE COMPUTE CNT=CNT+1; ENDREPEAT END
The PutData procedure, residing on a remote WebFOCUS Server, contains:
MAINTAIN FILE EMPLOYEE FROM EMPSTACK INFER EMP_ID INTO EMPSTACK; FOR ALL INCLUDE EMP_ID CURR_SAL FROM EMPSTACK; END
The following syntax demonstrates the use of the variable MYSERVE passing the server name EDASERVE in the CALL (or EXEC) statement.
COMPUTE MYSERVE/A8='EDASERVE'; .... CALL CALLPROC AT MYSERVE (...path ....)
To disable this feature, see the server profile command MNTCON REMOTESTYLE.
The following example shows all of the models and body types for the displayed country and car. The first calls GETCARS to populate the stack containing Country and Car. Maintain then calls GETMODEL to populate the other stack with the proper information. Each time a new Country and Car combination is introduced, Maintain calls GETMODEL to repopulate the stack.
MAINTAIN FILE CAR INFER COUNTRY CAR INTO CARSTK; INFER COUNTRY CAR MODEL BODYTYPE INTO DETSTK; CALL GETCARS INTO CARSTK; PERFORM GET_DETAIL; Winform Show CARFORM; CASE GET_DETAIL CALL GETMODEL FROM CARSTK INTO DETSTK; ENDCASE CASE NEXTCAR IF CARSTK.FOCINDEX LT CARSTK.FOCCOUNT THEN COMPUTE CARSTK.FOCINDEX= CARSTK.FOCINDEX +1; ELSE COMPUTE CARSTK.FOCINDEX = 1; PERFORM GET_DETAIL; ENDCASE CASE PREVCAR IF CARSTK.FOCINDEX GT 1 THEN COMPUTE CARSTK.FOCINDEX= CARSTK.FOCINDEX -1; ELSE COMPUTE CARSTK.FOCINDEX = CARSTK.FOCCOUNT; PERFORM GET_DETAIL; ENDCASE
The procedure GETCARS loads all Country and Car combinations into CARSTK.
MAINTAIN FILE CAR INTO CARSTK FOR ALL NEXT COUNTRY CAR INTO CARSTK; END
The procedure GETMODEL loads all model and body type combinations into CARSTK for displayed Country and Car combinations.
MAINTAIN FILE CAR FROM CARSTK INTO DETSTK INFER COUNTRY CAR INTO CARSTK; STACK CLEAR DETSTK; REPOSITION COUNTRY; FOR ALL NEXT COUNTRY CAR MODEL BODYTYPE INTO DETSTK WHERE COUNTRY EQ CARSTK(CARSTK.FOCINDEX).COUNTRY AND CAR EQ CARSTK(CARSTK.FOCINDEX).CAR; END
WebFOCUS |