Mentor SAP
After you create your calculations or scripts and tested your form design, you may discover scripting errors or unexpected field values as a result of scripting syntax errors.

 

LCD includes some important methods for testing and debugging your calculations and scripts. One of them is shown here.

 

For example, the following script returns a message at runtime indicating the name of the event on which the script is placed.

This indicates that a particular event has fired:

 

Another example of using the host model and event model methods is to obtain the value of a field on an interactive form before a user manually changed it. This is useful for observing how the objects on your form design respond to user-entered data:

 

The host model and event model provide functionality that lets you interact with either the host application or the various form events. These models are useful for returning information that can assist you in debugging calculation and scripts.

This example shows the syntax of an conditional expression. The IF statement is similar to ABAP.

 

To become familiar with navigation inside the scripting documentation, try to find the LCD advices on the IF statement.

 

The figure above shows one of the most common mistakes in scripting. ABAP developers, especially, need some time adapt to the case sensitivity of field names.

 

 

You can hide objects using the PRESENCE attribute. There are four possible settings for this attribute:

 

You can switch off the interactivity of fields by using the ACCESS attribute:

 

 

In this example, there was a condition coded in the context for the SFPSY-TIME field. The condition was chosen in a way that it always failed (for example SFPSY-TIME = “666666”). The effect is a field in the layout that always remains empty, because there is no value assigned to it (nothing is transported from the ABAP stack to the ADS on the Java side).

 

The frame of the time field and its caption are always shown now.

 

To solve this problem, scripting can be coded with the following condition: “$ == null”. If this returns TRUE, the “presence” attribute can be used to suppress the appearance of the empty field.

 

Adobe recommends using subforms to suppress fields with no content.

 

To do this, the field has to be wrapped into a subform and the repeat subform flag must be set. Min count and Max count are left empty.

 

With this trick, empty fields in the layout can be suppressed without the need to code scripting. The result is that form processing will run faster.

 

There are situations where some nodes are not filled with data, they even do not exist.