SHARE

Scans the LOCAL pool for matching variable names.

Every match is recorded. At the end of the EXEC the values for all these matches are gathered and transferred back to the calling EXEC using an AOEXEC command. The use of this command is only meaningful in an EXEC that is driven by AOAnywhere.

BBSAMP member QAOBCMD3 contains an example of how you can use IMFEXEC SHARE to transfer variables back to an EXEC driven by AOAnywhere.

Command

Parameters

SHARE

Variable name | (var1 var2...varn)

The following table describes the parameters:

Parameter

Function

Notes

Variable

name of a variable or variables that will be searched for in the LOCAL variable pool and transferred back to the calling EXEC (AOEXEC command)

You can list one variable or a list of variable names. Multiple variable names must be enclosed in parentheses.

You can list either fully qualified variable names or variable name patterns. Patterns must follow coding conventions such as

  • A*B+

  • A*

  • *

At the time of the IMFEXEC SHARE command, the LOCAL pool is scanned for matching variable names. Every match is recorded and at the end of the EXEC, the values for all these matches are gathered and transferred back to the calling EXEC (AOEXEC SELECT EXEC command). For IMFEXEC SHARE to work, at least one variable has to be specified in the SHARE() keyword of the AOEXEC SELECT EXEC statement.

For example 'IMFEXEC SHARE (A B C)' causes the EXEC to determine whether variables A, B, or C currently exist in the LOCAL pool. If these variables do not exist, no data is transferred back to the EXEC. If they exist at the time of the command, they are recorded.

After the EXEC terminates, the values of the variables are gathered and set in the function pool of the invoking AOEXEC EXEC, which means that an 'IMFEXEC SHARE(*)' causes all current variables in the LOCAL pool to be recorded and at EXEC termination, transferred back to the invoking EXEC.

Condition codes are listed in the following table:

Value

Description

12

This EXEC is not running under AOEXEC control. Therefore the IMFEXEC SHARE statement is inapplicable.

16

Syntax error occurred.

Example

The pattern match happens at the time of the IMFEXEC SHARE statement. If at the time the statement executes and no matches are found in the LOCAL pool but subsequently new variables are created that would have matched these variables, nothing is transferred back. For example:

/* REXX */
A=1
B=2
'IMFEXEC VPUT (A B) LOCAL'
'IMFEXEC SHARE (C)'
C=3
'IMFEXEC VPUT (C) LOCAL'

CLIST example:

PROC 0
SET A=1
SET B=2
IMFEXEC VPUT (A B) LOCAL
IMFEXEC SHARE (C)
SET C=3
IMFEXEC VPUT (C) LOCAL

In this example, the variable C is not returned to the invoking EXEC.

The following sample code shows how the variable C is returned to the invoking EXEC.

REXX EXEC example:

/* REXX */
A=1
B=C
C=3
'IMFEXEC VPUT (A B C) LOCAL'
'IMFEXEC SHARE (C)'

CLIST example:

PROC 0
SET A=1
SET B=C
SET C=3
IMFEXEC VPUT (A B C) LOCAL
IMFEXEC SHARE (C)

The following figure shows a three-part example in which a batch job named AOA10 calls two EXECs, CMD5 and CMD6. The CMD5 EXEC uses the AOAnywhere AOEXEC SELECT EXEC command to invoke the CMD6 EXEC. The CMD6 EXEC runs in the MainView AutoOPERATOR PAS, issues an MVS command, and returns the command responses to the CMD5 EXEC.

Example of one EXEC calling a second EXEC and receiving the responses

//AOA10    EXEC PGM=IKJEFT01,DYNAMNBR=20,REGION=2M
//*
//* sample: %CMD5 your IMFEXEC CMD statement here
//*
//STEPLIB  DD DISP=SHR,DSN=hlq.BBLINK
//SYSPROC  DD DISP=SHR,DSN=hlq.EXEC
//*
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
%CMD5 IMFEXEC CMD 'D IPLINFO' TYPE(MVS)
/*
/* REXX CMD5 This example shows an AOAnywhere EXEC invoking another EXEC, CMD6, that issues an IMFEXEC CMD and receives the responses back. The CMD6 EXEC returns the command responses as LINE* variables and the total number of responses in the IMFNOL variable */
trace n
arg p1       /* get EXEC parameter, if any  */
/* set the target PAS  */
ss1 = 'EK6X'
/*
   EXEC parameter is a valid IMFEXEC CMD statement
   if no parameter was passed to this EXEC (ie. length of p1 = 0)
   then set a default command
*/
if length(p1) > 0 then
command1 = p1
else
/*
 COMMAND1 should contain a valid IMFEXEC CMD statement
*/
COMMAND1 = 'IMFEXEC CMD 'D PROG,EXIT'' ,
           'TYPE(MVS) COUNT(1)'
/* surround COMMAND1 with double quotes to make it
   a literal for INTERPRET
*/
command1 = ''' || command1 || '''
/* display COMMAND1 for debug, verify the IMFEXEC CMD is within
   double quotes
*/
say 'command1='command1
imfnol = -1
'AOEXEC SELECT EXEC(CMD6 ) SHARE(COMMAND1)' ,
 'WAIT(YES) SSID('ss1')'
/* print the variables for debug  */
say 'imfnol='imfnol 'rc='rc 'imfrc='imfrc 'imfcc='imfcc ,
    'imfexrc='imfexrc
/* print the command responses  */
do i = 1 to imfnol
say 'line'i'='value('line'i)
end i
say 'EXEC ended'
= = =
/* REXX CMD6
   an AOAnywhere EXEC calls us, and passes the command
   in Local variable command1
*/
parse arg exname p1 p2 .
'IMFEXEC MSG '.'EXNAME 'EID='IMFEID 'STARTED''
'IMFEXEC VGET COMMAND1 LOCAL'
if imfcc /= 0 then do
'IMFEXEC MSG '.cmd6 you did not SHARE variable command1''
'IMFEXEC EXIT CODE(8)'
exit
end
/* execute the command the caller sent us  */
interpret command1
/* save IMFCC from the IMFEXEC CMD */
cmdCC = imfcc
'IMFEXEC MSG '.'EXNAME 'IMFEXEC CMD IMFRC='IMFRC 'IMFCC='IMFCC
/* VPUT IMFNOL into the LOCAL pool for for IMFEXEC SHARE later
   the LINE* variables are already in the LOCAL pool
*/                                                            
'IMFEXEC VPUT  (IMFNOL) LOCAL'
'IMFEXEC SHARE (IMFNOL LINE*)'
'IMFEXEC MSG '.'EXNAME 'EID='IMFEID 'ENDED''
/* set an unusual return code just to test passing the RC  */
'IMFEXEC EXIT CODE(987)'



This version of the documentation is no longer supported. However, the documentation is available for your convenience. You will not be able to leave comments.

Comments