Objectives: The result of an MBean call should be transferred for further use.
Objects used: Job, Workflow and Variable
Script elements used: :ENDPROCESS, GET_PROCESS_LINE, GET_VAR, JMX_INVOKE, PREP_PROCESS_REPORT, :PROCESS, :PUT_VAR, R3_ACTIVATE_REPORT and R3_MODIFY_VARIANT
The JMX agent and the functions made available in AE can be used to establish a connection to MBean Servers and access their MBeans. This example illustrates how an MBean can be called. The result will then be transferred to an SAP variant which is finally used to process a report.
Variable
First a variable is required which stores the result of the MBean call. Create a static Variable object with the following attributes in a first step:
Enter a key which will later contain the value of the MBean.
Jobs
Now create a JMX job. Select the connection to the MBean Server in the Host tab and use the Form tab in order to enter the script function for calling the MBean. The example below shows the content of the Process tab which contains the same information as the Form tab:
JMX_INVOKE OPERATIONNAME=conversionRate, MBEAN=UC4:type=CurrencyConverter, SIGNATURE="java.lang.String,java.lang.String", PARAMS="USD,EUR"
The MBean "UC4:type=CurrencyConverter" of the above example calculates the currency exchange rate Dollar vs. Euro and writes it to the job report. The value can be read using the script function PREP_PROCESS_REPORT. Use this script element in the Post Process tab of the JMX job. Example:
:SET &HND# = PREP_PROCESS_REPORT("JOBS",, "REP",,"COL=DELIMITER", "DELIMITER=*:*")
:PROCESS &HND#
: SET &RET# = GET_PROCESS_LINE(&HND#,2)
: PUT_VAR VARA.CURRENCY_RATE,"RATE",&RET#
:ENDPROCESS
In the next step, create a SAP job that reads the currency exchange rate from the Variable object, modifies a variant and starts a report. Create a SAP job and enter the processing statements either using the Form tab or directly in the Process tab. Example:
:SET &RATE# = GET_VAR(VARA.CURRENCY_RATE,"RATE")
R3_MODIFY_VARIANT REPORT='Z_CURRENCY_ABAP',VARIANT='VARIANT1',SELNAME='RATE',KIND='P',LOW='&RATE#'
R3_ACTIVATE_REPORT REPORT='Z_CURRENCY_ABAP',VARIANT='VARIANT1'
Note that the value for the parameter LOW is read from the Variable object.
Workflow
In a last step, create a workflow and add the two jobs above to it.
To execute the workflow, you must ensure that the MBean that you use has been registered for the MBean Server. Register it once using the script function JMX_CREATE_MBEAN. Vice versa, JMX_UNREGISTER_MBEAN removes an MBean that has already been registered.