The main advantage of using scripting in Adobe forms is that we can improve functionality and usability of forms.
With scripting we can get full control over forms at run time.
Benefits of Scripting:
(Examples: Hide /Display Table or Page in generated PDF Form, Adding Back ground colours based on conditions )
(Examples: Sum,Avg,Percentage, etc.. )
(Check existence of Data using flag conditions..).
All the Actions written in Script editor will be executed at the run time.
Where should we have to write our Script in Adobe Forms:
We can create our forms using Transaction Code SFP (Form Builder).
Go to Transaction Code SFP.
Enter the Form Name
Click on Layout.
Menu Bar --> Pallets --> Script Editor
Select the Script Editor.
Select an Object in the Layout.
The Script editor will be displayed as shown below.
Objects:
Objects are used to display the data in PDF Forms . Based on the data type we have to select Object from object library and add it to layout.
Examples: Amounts ----> Numeric Field / Decimal Field.
Date/Time ----> Date/Time Field.
Image ----> Image Field
We can divide the objects into two categories.
SAP Adobe forms Supports two scripting Languages.
A Form can use both languages in the form at the same time but we can't use both scripting languages for single Object.
FormCalc:
FormCalc is the default scripting language in Designer. It is an easy-to-use calculation language.
FormCalc is the best choice to work on functions like (date and time, financial, arithmetic , logical etc.)
Advantages:
FormCalc has many built in Functions that covers a range of Areas including Finance, logic, dates/times and mathematics.
FormCalc usually provides better performance than JavaScript because it executes calculations and validations more quickly.
FormCalc can be the best choice in many situations, regardless of programming experience.
This scripting language is very useful for Non Programmers who need to add calculations for their forms.
It is very similar to the Language that we use in Microsoft Office like Excel, Most FormCalc scripts are one line long.
Disadvantages:
Examples:
Go to SFP. Enter the Name of the Form and click on Create.
A pop will be displayed as shown below.Assign Interface for your form.
Interface is the place where we add code to fetch data from Data base tables.We can display the database
tables data by binding the Variables used in Interface with the Objects in the Form(layout).
Context is the place where the connection is established between Interface and Form.
Click on Save.To design the layout(Form) click on Layout.
Example 1:
FomCalc: Sum of Multiple Numbers (Sum)
Drag and Drop a Numeric Field from Object Library into the layout as shown below.. Select the Field. Go to Script Editor.
In Script editor select the event (form ready). We can see the Header line which represents the path of the form.
Headerline
data.#subform[0].NumericField1::ready:form - (FormCalc, client)
After adding FormCalc Script,Click on Save,Activate,Execute.
Output:
Example 2:
FormCalc: Annual Percentage of Loan(Apr)
Output:
Example 3:
FormCalc : To display the Number in Word Format ( WordNum )
Output:
Java Script:
Although FormCalc is default scripting language in designer, Java script is more ideal for creating sophisticated interactive and dynamic forms.
Advantages of Java script:
JavaScript is a scripting standard that many programmers and designers already know.
We can create JavaScript objects and custom functions, and use them through out Form.
This function is not available in FormCalc.It has been scripting standard we can find sample scripts for almost we need to do.
We can use JavaScript for both PDF Forms and HTML Forms.
Disadvantages:
Performance is lower than Formcalc.
Examples:
JavaScript: Hide/Display entire column in a table if the total sum of the column is '0'.
In debugging we can see the Entire column with zero values
If the entire column doesn't have zero values set a flag as shown below. The last column SI_AMT1 doesn't have values.
This flag value will be passed to variable lv_si1 which is in our Java script.
Now the added java script under the event ( Form ready) will be executed and the entire column with zero' will be removed from the table in PDF Form display.
Output: We can see no entire column with zero's in table in Output PDF Form.
Example 2 :
JavaScript: Adding Back ground colors for the Table Fields and field content should be displayed in Bold
191,191,191
217,217,217.
data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA.POSID::initialize - (JavaScript, client)
var numrows = xfa.resolveNodes("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA[*]").length;
var rowFillColor;
for (var i=0; i<numrows; i++)
{
posid = xfa.resolveNode("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA["+i+"].POSID").rawValue;
if (posid == "Outcome")
{
rowFillColor = "191,191,191";
xfa.resolveNode("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA["+i+"]").border.fill.color.value = rowFillColor;
xfa.resolveNode("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA["+i+"]").POSID.font.weight = "bold";
xfa.resolveNode("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA["+i+"]").POST1.font.weight = "bold";
xfa.resolveNode("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA["+i+"]").T_AMT1.font.weight = "bold";
xfa.resolveNode("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA["+i+"]").F_AMT1.font.weight = "bold";
xfa.resolveNode("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA["+i+"]").S_AMT1.font.weight = "bold";
xfa.resolveNode("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA["+i+"]").TH_AMT1.font.weight = "bold";
xfa.resolveNode("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA["+i+"]").FO_AMT1.font.weight = "bold";
xfa.resolveNode("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA["+i+"]").FI_AMT1.font.weight = "bold";
xfa.resolveNode("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA["+i+"]").SI_AMT1.font.weight = "bold";
}
else if (posid == "Output")
{
rowFillColor = "217,217,217";
xfa.resolveNode("data.Overal_Budget_Same_Currency.GT_TOT_BUD_SAMECUR.DATA["+i+"]").border.fill.color.value = rowFillColor;
}
delete outcome;
}
Output:
All the Rows which has Outcome in first cell are displayed in Bold with the assigned Back Ground Color.
All the Rows which has Output in first cell are displayed with assigned Back ground Color.
We have to decide the script language to be used in Adobe Forms, based on the Scenario/Functionality we need to achieve.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
10 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |