Show TOC

Background documentationWriting Formula Scripts Locate this document in the navigation structure

 

Formula scripts for data collection use interpreted JavaScript as the scripting language.

Note Note

Scripting is disabled for security reasons by default. For more information, see   Authorizations   Standard Roles   SAP NetWeaver UME Security Roles and Actions   in SAP ME Security Guide at   http://service.sap.com/instguides   SAP Business Suite Applications   SAP Manufacturing   SAP Manufacturing Execution 6.0  .

End of the note.
Methods Available for Formula Scripts

SAP ME supports the following methods in DC formulas:

  • exit()

  • findSingleParameter()

  • print()

  • printAll()

exit ()

This method stops the script execution.

Example Example

exit(A)

Stops the script execution and returns the value of script variable A as the result of the formula calculation. This is the value that will be used for the data collection parameter to which the formula belongs.

End of the example.
findSingleParameter ()

You can use the findSingleParameter method with arguments as defined below:

findSingleParameter("parameter_name", "this" | "subassy", "item_name", "item_revision", "operation_name", "operation_revision", "resource_name", "last")

Note that you must enclose each argument in either double or single quotation marks.

Argument

Description

parameter_name

The name of the parameter as it appears in the Parameter Name field in Data Collection Maintenance

this | subassy

Use one of these literals: this returns the current SFC number subassy returns the SFC number of a subassembly consumed by the current SFC number

item_name

The name of the material associated with the SFC number

item_revision

The version of the material associated with the SFC number

operation_name

The name of the operation where data was collected for the SFC number

operation_revision

The version of the operation where data was collected for the SFC number

resource_name

The name of the resource where data was collected for the SFC number

last

Required literal to end the argument

Note that you cannot use mathematical symbols (+, -, *, /) in parameter names that are used in calculations.

Example Example

The DC group DC1/A has one parameter, P1, of the Numeric type. DC1/A is attached to the operation OP1.

The DC group DC2/A has three parameters defined as follows:

Parameter Name

Type

P2

Numeric

P3

Numeric

PFORM

Formula

DC2/A is attached to the operation OP2.

The operator collects data at OP1 through the DC Entry plug-in. Using the following formula for PFORM, when the operator at OP2 enters data for P2 and P3, and saves the entries, the DC Entry plug-in calculates the sum of these two values plus the saved value entered for P1 at OP1. The calculated value is saved for the parameter PFORM.

End of the example.

Caution Caution

When creating formulas, make sure that user input does not cause divide-by-zero errors.

End of the caution.
print () and printAll ()

The print(value,…) methods prints one or more values to the application server console/log file. This method should be used only for debugging and testing purposes.

The printAll() methods prints all of the variables available to the script. This method should be used for only debugging and testing purposes.

You can view results of the print() and printAll() methods in Log Viewer (Developer Traces view) in SAP NetWeaver Administrator.

To do that, configure Tracing as follows:

  1. In SAP NetWeaver Administrator, choose Log Configuration.

  2. On the Log Configuration: Java screen, select Tracing Locations in the Show field, enter com.sap.me.script.ScriptBOBean in the Location field and choose Go to find the location

  3. Change Severity from Error to Debug.

  4. On the SAP Manufacturing Execution Logging Configuration screen (  http://<SAP ME server>:<port>/manufacturing-admin   Logging Configuration  ), verify that the Debugging Information checkbox is selected.