Chapter Contents |
Previous |
Next |
SAS Companion for the OS/390 Environment |
Using this interface, you can implement interactive applications that can be used even by novice users. Users need only know how to log on to a 3270 or 3290 terminal. All other information can be supplied as part of the application itself.
For SAS programmers, using this interface is often preferable to using other languages to implement interactive ISPF applications because existing SAS data files and applications can be exploited. The interface also reduces the need for the SAS programmer to learn another language.
For detailed information about ISPF, see the IBM documents ISPF Dialog Developer's Guide and Reference and ISPF Reference Summary.
Software Requirements |
The following table summarizes the software requirements for using the interface.
Software | Version Required | |
---|---|---|
Base SAS Software | SAS System Release 6.08 or later | |
Operating Environment | OS/390/SP Version 2 or later TSO/E Version 2 or later | |
ISPF | ISPF Version 2 or later |
Enabling the Interface |
Invoking ISPF Services |
The IBM documents ISPF Dialog Developer's Guide and Reference and ISPF Reference Summary describe the ISPF services and their syntax conventions. To invoke these services, you can use either the ISPLINK CALL routine or the ISPEXEC CALL routine. However, ISPEXEC has the following limitations:
GRERROR |
GRINIT |
GRTERM |
VCOPY |
VDEFINE |
VDELETE |
VREPLACE |
VRESET |
Remember that ISPF restricts a name list to 254 names.
To invoke ISPEXEC from a SAS DATA step, use a CALL statement with one of these formats:
call ispexec(value1,value2 );
call ispexec(,value2 );
call ispexec(value2 );where value1 and value2 are variables, literals, or expressions to be passed as parameters to ISPF. Use the same parameters that you would use with an ISPF ISPEXEC. Value1, if specified, is the length of value2. If you use the second or third form of the call, the ISPF interface provides this value. Value2 is a character string that contains the service name and parameters, specified as they would be in a CLIST. Parameters can be specified as symbolic ISPF variables that will be replaced with the ISPF variable values at run time. Only one scan for symbolic variables is done, and the resulting service request must not exceed 512 bytes in length.
Note: If you use symbolic ISPF
variables, remember that both SAS and ISPF use ampersands to define symbolic
variables. Enclose the ISPF symbolic variable specifications in single quotes
to prevent them from being replaced by SAS.
To invoke ISPLINK from a SAS DATA step, use a CALL statement with this format:
call isplink(value1,...,value15 );where value1,...,value15 are variables, literals, or expressions to be passed as parameters to ISPF. You use the same parameters that you would use with an ISPF ISPLINK. See Using Special Facilities for Passing Parameters to ISPF for a description of special parameter considerations.
Trailing blanks are sometimes used by ISPF to determine
the end of a parameter; they are optional because the interface supplies them.
If more than 15 positional parameters are required (for example, TBSTATS can
have up to 17 parameters), parameters 15 through 20 can be specified in value15. The values must be separated by commas. The interface will
parse value15 into parameters 15 through 20.
Each ISPEXEC or ISPLINK CALL subroutine results in a return
code that is described in IBM's ISPF Dialog Developer's Guide and Reference manual. You can test the return code with the SAS numeric variable
ISP_RC. Because this variable is set by ISPEXEC or ISPLINK, the SAS compiler
produces a
Note: Variable
varname
is uninitialized
message. To avoid receiving this message, specify
the following SAS statement in your program:
retain isp_rc 0;
A standard ISPF function called Dialog Development Models uses the ISPF EDIT facility to simplify the development of programs. (See the chapter on "Using Edit Models" in the IBM manual ISPF Edit and Edit Macros. See also Using the ISPF Editor from Your SAS Session and Copying ISPF EDIT Models to Your SAS Session.)
If you specify PL/I as the model class, the statements
that the model facility produces will be in the proper SAS form. To simplify
the use of the Dialog Development Models, the PL/I return code variable, PLIRETV,
is recognized and used by the interface in the same way as ISP_RC. The following
examples could have been created using the
SELECT
Edit model:
data _null_; call ispexec('SELECT PANEL(ISR@PRIM)'); if pliretv ¬ = 0 then put pliretv=; run;
data _null_; call isplink('SELECT',' ','PANEL(ISR@PRIM)'); if pliretv ¬ = 0 then put pliretv=; run;
Using Special SAS System Options with the Interface |
The SAS interface to ISPF includes the following SAS system options. These options are useful in developing and debugging ISPF applications. Most of them are used in conjunction with the ISPF VDEFINE service, which is described in VDEFINE, VDELETE, and VRESET Services.
ISPCAPS | |
ISPCHARF | |
ISPCSR= | |
ISPEXECV= | |
ISPMISS= | |
ISPMSG= | |
ISPNOTES | |
ISPNZTRC | |
ISPPT | |
ISPTRACE | |
ISPVDEFA | |
ISPVDLT | |
ISPVDTRC | |
ISPVIMSG= | |
ISPVRMSG= | |
ISPVTMSG= | |
ISPVTNAM= | |
ISPVTPNL= | |
ISPVTRAP | |
ISPVTVARS= |
To determine which of these options are in effect for your SAS session, submit the following statements from the PROGRAM EDITOR window and view the output in the LOG window.
proc options group=isp; run;
You specify these options as you would specify any other
SAS system option. See Specifying or Changing System Option Settings.
For detailed information about these options, see System Options in the OS/390 Environment.
call isplink ('SAS','ISPNZTRC');
The system options whose status can be changed in this manner are listed in SAS Services and Their SAS/DMI Equivalents. See System Options in the OS/390 Environment for detailed descriptions of these options.
Note: For
compatibility with SAS/DMI, you can use the DMI service to change the status
of the corresponding system option.
SAS Service | Equivalent DMI Service | |
---|---|---|
('SAS','ISPCAPS') | ('DMI','CAPS') | |
('SAS','NOISPCAPS') | ('DMI','NOCAPS') | |
('SAS','ISPCHARF') | ('DMI','CHARFORMATTED') | |
('SAS','NOISPCHARF') | ('DMI','NOCHARFORMATTED') | |
('SAS','ISPNOTES') | ('DMI','NOTES') | |
('SAS','NOISPNOTES') | ('DMI','NONOTES') | |
('SAS','ISPNZTRC') | ('DMI','NZRCTRACE') | |
('SAS','NOISPNZTRC') | ('DMI','NONZRCTRACE') | |
('SAS','ISPPT') | ('DMI','PT') | |
('SAS','NOISPPT') | ('DMI','NOPT') | |
('SAS','ISPTRACE') | ('DMI','TRACE') | |
('SAS','NOISPTRACE') | ('DMI','NOTRACE') | |
('SAS','ISPVDTRC') | ('DMI','VDEFTRACE') | |
('SAS','NOISPVDTRC') | ('DMI','NOVDEFTRACE') | |
('SAS','ISPVDLT') | ('DMI','VDELVDEF') | |
('SAS','NOISPVDLT') | ('DMI','NOVDELVDEF') | |
('SAS','ISPVTRAP') | ('DMI','VTRAP') | |
('SAS','NOISPVTRAP') | ('DMI','NOVTRAP') |
Using the ISPF Editor from Your SAS Session |
If you
prefer to use the ISPF editor rather than the SAS editor, or if you need
to use the ISPF editor in order to use edit models (see the next section, Copying ISPF EDIT Models to Your SAS Session),
you can use the SAS HOSTEDIT command. Under OS/390, the HOSTEDIT command
temporarily suspends the current SAS session and initiates a session of the
ISPF editor or browser. See HOSTEDIT for details.
A major advantage of being able to access the ISPF editor with the HOSTEDIT command is that it enables you to access ISPF EDIT models, modify them as necessary, and then copy them to your SAS PROGRAM EDITOR window.
To access an ISPF EDIT model, do the following:
MODEL CLASS PLI
on the
ISPF editor command line.
MODEL
plus the model name
to include a particular model (for example,
MODEL TBDISPL
), or enter
MODEL
alone and specify a model from the list of EDIT models that appears.
You can then modify the model as necessary and use the END command to save it back to your PROGRAM EDITOR window.
For more information about the ISPF EDIT facility and EDIT models, refer to the IBM manual ISPF Edit and Edit Macros.
Using Special Facilities for Passing Parameters to ISPF |
You can also use other types of SAS variable lists, including numbered range lists (for example, x1-xn) and name range lists (x-numeric-a), as described in the chapter on "Rules of the SAS Language" in SAS Language Reference: Dictionary.
When a variable list is passed to the VDEFINE service (see VDEFINE, VDELETE, and VRESET Services), the special naming conventions refer to all variables in the current DATA step that are legal ISPF variable names. (Note: A name that contains an underscore is not a legal ISPF variable name.) SAS arrays, temporary DATA step variables such as FIRST.variable and LAST.variable, and the variable PLIRETV are not considered candidates for VDEFINE. The special naming conventions for services other than VDEFINE refer only to the list of currently defined variables and not to all of the variables in the DATA step.
Specifically, the special variable-naming conventions can be used in the following places:
length fixed10 $4; retain fixed10; if _n_=1 then fixed10=put(10,pib4.);
or
retain fixed10 '0000000a'x;
In addition, you can specify a hexadecimal value as a literal parameter by enclosing the value in single or double quotes and entering the letter X after the closing quote.
Some of the services that have numeric parameters are CONTROL, TBDISPL, TBCREATE, TBQUERY, TBSKIP, VDEFINE, and VCOPY.
Note: Never use a blank or null value for a numeric parameter.
The ISPF SELECT service has a special parameter list because it requires a full-word fixed binary parameter that specifies the length of the buffer. The SAS interface to ISPF provides this length parameter, but if you use the ISPLINK CALL routine to invoke the SELECT service, then you must reserve the parameter's place in the parameter list. Use either a comma or two single quotes with a blank between them (' ') to represent the parameter, as in the following example:
isplink('SELECT', ,'CMD(%MYDIALOG)');
If you use the ISPEXEC CALL routine to invoke the SELECT service, then you do not need to reserve the parameter's place:
ispexec('SELECT CMD(%MYDIALOG)');
When a parameter longer than 200 bytes is required, use the following form in place of the parameter:
=varname=length |
Using this parameter form does not change ISPF parameter
restrictions. For example, ISPEXEC allows a maximum of 512 bytes in its second
parameter regardless of how you specify the parameter.
Accessing SAS Variables from ISPF |
The ISPF VDEFINE service allows you to specify seven parameters. The form is
'VDEFINE', namelist, variable, format, length, optionlist, userdata
The interface provides the values for variable, format, length, and userdata. You need only specify namelist.
The optionlist parameter is optional and can be used when you are defining either SAS character variables or SAS numeric variables. The two VDEFINE options that you can specify are COPY and NOBSCAN. The LIST option is not supported. COPY allows the value of the variable that is being defined to be initialized to the value of a dialog variable that has the same name in the function pool, shared pool, or profile pool. The NOBSCAN option prevents ISPF from stripping trailing blanks from variables.
To define all SAS variables in the current DATA step, use the following statement:
call isplink('VDEFINE','_ALL_');
For more information about specifying variables, see Variable-Naming Conventions.
The VDELETE service ends ISPF access to specified variables in the SAS DATA step, and the interface drops the variables from the list of defined variables that it maintains. The interface recognizes the end of a SAS DATA step and deletes any variables that remain on its list of defined variables.
The VRESET service ends ISPF access to all
variables that have been passed to the VDEFINE service. However, in addition
to removing all variables that the user has passed to VDEFINE,
VRESET also removes variables that the interface has passed to VDEFINE. To
prevent variables that it is using from being removed, the interface changes
VRESET to ('VDELETE','_ALL_').
SAS provides unique services that you can use when defining
numeric and character variables to ISPF with the VDEFINE service.
Numeric SAS variables are in double-word floating-point format. You may pass them to the VDEFINE service with either the FLOAT format or the USER format. If you use the FLOAT format, you should specify (or let the interface provide) a length of 8, because all SAS numeric variables have a length of 8 during the execution of the SAS DATA step. (footnote 1)
Note: When the FLOAT format is used, certain
features of the SAS interface to ISPF are unavailable: SAS formats and informats
that are associated with the variable are not used, null values are not changed
to the special missing value "._" (period underscore), and accessing of variables
cannot be traced with the ISPVTRAP option.
Because earlier releases of ISPF did not support the
FLOAT format, SAS (and previously SAS/DMI) supports the use of the USER format.
If you specify the USER format, or if you let SAS default to it, then SAS
provides a user exit that uses any format and/or informat associated with
the variable. If no format or informat is associated with the variable, then
the default SAS format or informat is used.
If an application requires an ISPF dialog variable that is longer than the maximum SAS character variable length of 32,767, then the length parameter of VDEFINE can be specified and associated with the variables that are being defined to ISPF. In order to prevent the data from being overwritten, you must do the following:
It is good practice to code the SAS ARRAY and RETAIN statements for these extra-long variables immediately following the SAS DATA statement.
The following example shows how ISPF dialog variables named LONG1 and LONG2, each 32,000 bytes long, would be defined.
data _null_; array anyname1 $32000 long1 long1_c; array anyname2 $32000 long2 long2_c; retain long1 long1_c long2 long2_c ' '; call isplink('VDEFINE','(LONG1 LONG2)',,,64000);
The following statement defines to ISPF all variables in the current DATA step that begin with the letters PPR:
call isplink('VDEFINE','PPR:');
The next statement defines the variables SASAPPLN, ZCMD, and ZPREFIX to ISPF. The variables are to be initialized with the values from variables of the same name that already exist in the variable pools.
call isplink('VDEFINE', '(SASAPPLN ZCMD ZPREFIX)',,,,'COPY');
This next statement removes all previously defined variables from the variable pool, making them inaccessible to ISPF:
call isplink('VDELETE','_ALL_');
Tips and Common Problems |
When a variable is
neither specified with an initial value in
a RETAIN statement nor appears on the left side of the equal sign in an assignment
statement, the SAS log shows the
Note: Variable
varname
is uninitialized
message. For example,
the following statements would result in the message
NOTE: Variable
ZCMD is uninitialized
.
data _null_; length zcmd $200; call isplink('VDEFINE','ZCMD'); call isplink('DISPLAY','ISRTSO'); put zcmd=; run;
However, in this example the message is misleading because the call to ISPF actually assigns a value to ZCMD. To prevent the message from being generated, put the variable in a RETAIN statement with an initial value, or use the variable in an assignment statement. For example, the following RETAIN statement assigns an initial value (a blank) to the variable ZCMD:
retain zcmd ' ';
Under SAS/DMI (the Version 5 predecessor to the SAS interface to ISPF), it was not possible to pass numeric values directly to ISPF services for which numeric values are required. Instead, an alternate method was provided (see Specifying Fixed Binary Parameters). The alternate method is still supported but is not required. Therefore, if you used SAS/DMI to develop ISPF applications, you may prefer to modify those applications so that numeric values are passed directly to these ISPF services instead.
Testing ISPF Applications |
In addition, the SAS provides the MPRINT system option to help you find coding errors. If you want to see the SAS statements that are generated by SAS macros, specify MPRINT in a SAS OPTIONS statement. (The MPRINT system option is documented in SAS Language Reference: Dictionary).
The ISPF parameters are written to the SAS log when the ISPTRACE option is specified. The tracing can also be turned on and off with the ISPLINK CALL subroutine, as in the following example, which stops the tracing of ISPF parameters.
call isplink('SAS','NOISPTRACE');
Sample Application |
This section shows how one of those applications would
be written in the SAS language.
DATA _NULL_; LENGTH EMPSER $6 FNAME LNAME $16 ADDR1 ADDR2 ADDR3 ADDR4 $40 PHA $3 PHNUM MSG TYPECHG CHKTYPE $8 I STATE $1; RETAIN EMPSER FNAME LNAME I ADDR1 ADDR2 ADDR3 ADDR4 PHA PHNUM MSG TYPECHG CHKTYPE ' ' STATE '1' PLIRETV 0; CALL ISPLINK('VDEFINE', /* DEFINE VARIABLES */ '(EMPSER FNAME LNAME I ADDR: PHA PHNUM TYPECHG CHKTYPE)'); MSG=' '; /* INITIALIZE MESSAGE */ CALL ISPLINK('TBCREATE', /* IF TABLE DOESN'T EXIST*/ 'SASEMPTB','(EMPSER)', /* CREATE IT */ '(LNAME FNAME I ADDR: PHA PHNUM)', 'NOWRITE'); /* DON'T SAVE THE TABLE */ DO WHILE (STATE^='4'); /* LOOP UNTIL TERM SET */ CALL ISPLINK('DISPLAY','SASEMPLA',MSG); /* SELECT EMPLOYEE */ IF PLIRETV=8 THEN STATE='4'; /* END KEY THEN TERMINATE*/ ELSE DO; /* ENTER KEY PRESSED */ MSG=' '; /* RESET MESSAGE */ STATE='2'; /* PROCESS EMPLOYEE PANEL*/ CALL ISPLINK('TBGET','SASEMPTB'); /* OBTAIN EMPLOYEE DATA */ IF PLIRETV=0 THEN /* IF RECORD EXISTS THEN */ TYPECHG='U'; /* SET UPDATE FLAG */ ELSE DO; /* RECORD DOES NOT EXIST */ TYPECHG='N'; /* SET TYPE=NEW */ LNAME=' ';FNAME=' ';I=' '; /* INITIALIZE PANEL VARS */ ADDR1=' ';ADDR2=' ';ADDR3=' '; ADDR4=' ';PHA=' ';PHNUM=' '; END; CHKTYPE=TYPECHG; /* SAVE TYPE OF CHANGE */ CALL ISPLINK('DISPLAY','SASEMPLB',MSG); /* DISPLAY EMPLOYEE DATA */ IF PLIRETV^=8 THEN DO; /* END KEY NOT PRESSED */ IF TYPECHG='N' THEN DO; /* IF NEW EMPLOYEE */ CALL ISPLINK('TBADD','SASEMPTB'); /* ADD TO TABLE */ MSG='SASX217'; /* */ END; /* */ ELSE DO; /* */ IF TYPECHG='U' THEN DO; /* IF UPDATE REQUESTED */ CALL ISPLINK('TBPUT','SASEMPTB'); /* UPDATE TABLE */ MSG='SASX218'; /* */ END; /* */ ELSE DO; /* */ CALL ISPLINK('TBDELETE','SASEMPTB'); /* DELETED MESSAGE */ MSG='SASX219'; /* */ END; /* */ END; /* END TABLE MODS */ END; /* END 2ND PANEL PROCESS */ END; /* END 1ST PANEL PROCESS */ IF MSG^=' ' THEN CALL ISPLINK('LOG',MSG); /* LOG MESSAGE */ END; /* END DO LOOP */ CALL ISPLINK('TBCLOSE','SASEMPTB'); /* CLOSE TABLE */ CALL ISPLINK('VDELETE','_ALL_'); /* DELETE ALL VARIABLES */ RUN;
%------------------------------ EMPLOYEE SERIAL -------------------------------- %COMMAND ====>_ZCMD + + EMPLOYEE SERIAL: &EMPSER + + EMPLOYEE NAME:%===>_TYPECHG + (NEW, UPDATE, OR DELETE) + LAST %===>_LNAME + + FIRST %===>_FNAME + + INITIAL%===>_I+ + + HOME ADDRESS: + LINE 1%===>_ADDR1 + + LINE 2%===>_ADDR2 + + LINE 3%===>_ADDR3 + + LINE 4%===>_ADDR4 + + + HOME PHONE: + AREA CODE %===>_PHA+ + LOCAL NUMBER%===>_PHNUM + + )INIT .CURSOR = TYPECHG IF (&PHA = ' ') &PHA = 914 &TYPECHG = TRANS(&TYPECHG N,NEW U,UPDATE D,DELETE) )PROC &TYPECHG = TRUNC (&TYPECHG,1) IF (&TYPECHG = N) IF (&CHKTYPE ^= N) .MSG = SASX211 IF (&TYPECHG ^= N) IF (&CHKTYPE = N) .MSG = SASX212 VER (&LNAME,ALPHA) VER (&FNAME,ALPHA) VER (&I,ALPHA) VER (&PHA,NUM) VER (&PHNUM,PICT,'NNN-NNNN') IF (&TYPECHG = N,U) VER (&LNAME,NONBLANK,MSG=SASX214) VER (&FNAME,NONBLANK,MSG=SASX213) VER (&ADDR1,NONBLANK,MSG=SASX215) VER (&ADDR2,NONBLANK,MSG=SASX215) VER (&ADDR3,NONBLANK,MSG=SASX215) )END
First Employee Record Application Panel
%------------------------------ EMPLOYEE RECORDS ------------------------------- %COMMAND ====>_ZCMD + + EMPLOYEE SERIAL: &EMPSER + + EMPLOYEE NAME:%===>_TYPECHG + (NEW, UPDATE, OR DELETE) + LAST %===>_LNAME + + FIRST %===>_FNAME + + INITIAL%===>_I+ + + HOME ADDRESS: + LINE 1%===>_ADDR1 + + LINE 2%===>_ADDR2 + + LINE 3%===>_ADDR3 + + LINE 4%===>_ADDR4 + + + HOME PHONE: + AREA CODE %===>_PHA+ + LOCAL NUMBER%===>_PHNUM + + )INIT .CURSOR = TYPECHG IF (&PHA = ' ')PHA = 914TYPECHG = TRANS(&TYPECHG N,NEW U,UPDATE D,DELETE) )PROCTYPECHG = TRUNC (&TYPECHG,1) IF (&TYPECHG = N) IF (&CHKTYPE ¬= N) .MSG = SASX211 IF (&TYPECHG ¬= N) IF (&CHKTYPE = N) .MSG = SASX212 VER (&LNAME,ALPHA) VER (&FNAME,ALPHA) VER (&I,ALPHA) VER (&PHA,NUM) VER (&PHNUM,PICT,'NNN-NNNN') IF (&TYPECHG = N,U) VER (&LNAME,NONBLANK,MSG=SASX214) VER (&FNAME,NONBLANK,MSG=SASX213) VER (&ADDR1,NONBLANK,MSG=SASX215) VER (&ADDR2,NONBLANK,MSG=SASX215) VER (&ADDR3,NONBLANK,MSG=SASX215) )END
Second Employee Record Application Panel
SASX210 'INVALID TYPE OF CHANGE' .ALARM=YES 'TYPE OF CHANGE MUST BE NEW, UPDATE, OR DELETE.' SASX211 'TYPE ''NEW'' INVALID' .ALARM=YES 'EMPLOYEE SERIAL &EMPSER ALREADY EXISTS. CANNOT BE SPECIFIED AS NEW.' SASX212 'UPDATE OR DELETE INVALID' .ALARM=YES 'EMPLOYEE SERIAL &EMPSER IS NEW. CANNOT SPECIFY UPDATE OR DELETE.' SASX213 'ENTER FIRST NAME' .ALARM=YES 'EMPLOYEE NAME MUST BE ENTERED FOR TYPE OF CHANGE = NEW OR UPDATE.' SASX214 'ENTER LAST NAME' .ALARM=YES 'EMPLOYEE NAME MUST BE ENTERED FOR TYPE OF CHANGE = NEW OR UPDATE.' SASX215 'ENTER HOME ADDRESS' .ALARM=YES 'HOME ADDRESS MUST BE ENTERED FOR TYPE OF CHANGE = NEW OR UPDATE.' SASX217 '&EMPSER ADDED' 'EMPLOYEE &LNAME, &FNAME &I ADDED TO FILE.' SASX218 '&EMPSER UPDATED' 'EMPLOYEE &LNAME, &FNAME &I UPDATED.' SASX219 '&EMPSER DELETED' 'EMPLOYEE &LNAME, &FNAME &I DELETED.'
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.