Skip to Content
Author's profile photo Suneel uggina

Overview on Scripting languages for Adobe Form Beginners

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:

  • Display/Hide form objects based on Conditions while generating the PDF Form

        (Examples: Hide /Display Table or Page in generated PDF Form, Adding Back ground colours based on conditions )

  • Automatic calculation in Forms.

        (Examples: Sum,Avg,Percentage, etc.. )

  • Data validations.

        (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

Script Editor.png

   Select the Script Editor.

   Select an Object in the Layout.

   The Script editor will be displayed as shown below.

2015-07-15 16_17_01-Form Builder_ Change Form ZAF_FORM_CALC.png


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.

  • Objects supported by Scripting Languages.
  • Objects not Supported by Scripting languages.

Objects in Adobe Forms.png

SAP Adobe forms Supports two scripting Languages.

  • FormCalc.
  • JavaScript.

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 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.)


  • Built-in-Functions

        FormCalc has many built in Functions that covers a range of Areas including Finance, logic, dates/times and mathematics.

  • Performance

        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.

  • Easier to maintain

        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.


  • FormCalc is not as powerful or as ubiquitous as Java Script.
  • It will not work for HTML Forms ..
  • Not very useful for creating sophisticated interactive and dynamic forms.


      Go to SFP. Enter the Name of the Form and click on Create.

2015-07-15 17_24_00-Form Builder_ Entry Point.png

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.

2015-07-15 17_27_53-.png

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.



data.#subform[0].NumericField1::ready:form – (FormCalc, client)

  • #subform[0]                     ——>   Name of the Subform
  • NumericField1                 ——>   Name of the Field on the Layout
  • ready:form                       ——>  Event under which the script added will be executed.
  • FormCalc, client               ——>  ( Scripting language,Run at ) 

   After adding FormCalc Script,Click on Save,Activate,Execute.




Example 2:

    FormCalc: Annual Percentage of Loan(Apr)




     Example 3:

     FormCalc : To display the Number in Word Format ( WordNum )





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 ubiquitous.

        JavaScript is a scripting standard that many programmers and designers already know.

  • Object -oriented.

         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.

  • Works for HTML and PDF Forms:

        We can use JavaScript for both PDF Forms and HTML Forms.


  • Performance

        Performance is lower than Formcalc.


  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

  • In my table I have a Field POSID it the value of the field is Outcome then it should display all the data in  bold and back ground colors with following          properties.


  • Else if POSID field value is Output then it should display background color with following properties .


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;



    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.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Nicely explained...really helpful....:)

      Author's profile photo Former Member
      Former Member

      Very helpful information - Thank you.

      One comment on what you wrote:

      SAP Adobe forms Supports two scripting Languages.

      • FormCalc.
      • JavaScript.

      A Form can use both languages in the form at the same time but we can't use both scripting languages for single Object.

      You can use both languages on a single object but not for the same event..

      Author's profile photo Suneel uggina
      Suneel uggina
      Blog Post Author

      Thank you very much Shai

      Author's profile photo Former Member
      Former Member

      Hi Suneel,

        Is it possible to use Javascript or FormCalc with offline or Non Interactive Adode forms ?

      We are generating PDF file by sending XSTRING data to ADS.

        I wanted to include some Javascript  before sending to ADS. So that ADS can give manipulated PDF with Javascript.



      Satya Lingolu

      Author's profile photo Suneel uggina
      Suneel uggina
      Blog Post Author

      Hi Satya,

      Yes, it is possible to use javascript or Formcalc in offline or Non Interactive Forms.

      Step1:  Design the Form and place the Java script as per your requirement.          

      Step2 : Create the Report to call the Form.

      Please refer the code to call the Form through a Report.

      * Data declaration

      DATA: fm_name TYPE char30,                        " Name of the Function Module

                 fp_docparams   TYPE    sfpdocparams,     " Strcuture SFPDOCEPARAMS

                 fp_outparams   TYPE    sfpoutputparams.  " Structure SFPOUTPUTPARAMS

      * Sets the Output parameters and opens the Spool Job

      CALL FUNCTION 'FP_JOB_OPEN'             " Form Processing: Call Form


          ie_outputparams = fp_outparams


          cancel          = 1

          usage_error     = 2

          system_error    = 3

          internal_error  = 4

          OTHERS          = 5.

      IF sy-subrc <> 0.

      * Implement suitable error handling here


      *Get the name of the generated function module



          i_name                     = 'ZAF_FORM_CALC'


         E_FUNCNAME                 = fm_name

      *   E_INTERFACE_TYPE           =

      *   EV_FUNCNAME_INBOUND        =


      * Initiliase the language and Country values

      fp_docparams-langu   = 'E'.

      fp_docparams-country = 'US'.

      * Call generated Function Module

      CALL FUNCTION fm_name


          /1bcdwb/docparams = fp_docparams

      *    *    IMPORTING

      *     /1BCDWB/FORMOUTPUT       =


          usage_error       = 1

          system_error      = 2

          internal_error    = 3.

      IF sy-subrc <> 0.

      *  <error handling>


      * Close the Spool Job.


      *    IMPORTING

      *     E_RESULT             =


          usage_error           = 1

          system_error          = 2

          internal_error        = 3

          OTHERS               = 4.

      IF sy-subrc <> 0.

      * <error handling>


      Step 2: Execute the Report:

      Step3:  Select the Printer .Click on Print Preview.

      Step4: A pdf form will be displayed with manipulated Javascript/Form Calc as required.

      Generated PDF through a Report:


      Author's profile photo Former Member
      Former Member

      Hi Suneel ,

      Thanks for the reply.

      I do not have form created in SFP transaction . I have xstring data which I will send it to ADS .

        ADS will process my data and give back PDF..

      Created using example programs FP_PDF_TEST_* from SAP.

      Now I would like to send Javascript to ADS along with XString, so that ADS process Javascript and gives new PDF.

      Thanking you,



      Author's profile photo Suneel uggina
      Suneel uggina
      Blog Post Author

      Hi Satya,

      I don't have idea on passing Java script to Xstring. if u got solution for your requirement could you please share it.

      Thanks & Regards,


      Author's profile photo Former Member
      Former Member

      For me the term “Objects not Supported by Scripting languages” is a bit confusing. It is possible to change the Color of a circle or to hide an image. These objects just don’t’ have events like "form ready" or "initialize".

      Author's profile photo Suneel uggina
      Suneel uggina
      Blog Post Author

      Hi Meier

      Thanks for reading the blog. For the objects which i mentioned as 'Objects not support Scripting',I couldn't found any  event to add script directly to that objects in the JavaScript Editor.We can add script to sub forms in which those objects are wrapped. Could you please elaborate how can we add script directly to Circle to get color dynamically.


      Suneel Uggina.

      Author's profile photo Former Member
      Former Member

      You are absolutely right. It is not possible to access a circle directly. But when I read the blog I got the impression that it is not possible at all to change the properties of a circle. And maybe other reader got the same wrong impression.

      What I meant is when we've got a Circle with the name CIRCLE1 inside a subform, then we can apply Coding to that subform like

      this.CIRCLE1.value.arc.fill.color.value = "255,0,0";"

      to change the color to red.

      Author's profile photo Raul Daimiel
      Raul Daimiel

      Dear Suneel,

      Thank you very much for this valuable entry you shared!!. Quite useful!!!. I will pick it up as the backbone of my 'how-to' work with JavaScript in Adobe forms!.

      May I ask a question in here?.

      Let's say I do have Two Text Fields on my form.

      Is there any way - via Java Script - to get the position of the first one and place the second one exactly right after that one?.


      Field 1 has 5 characters long, Field 2 would need to be printed from position 6.

      I'm wondering if that'd be a good way of coding:

      • Define the variables to get the values calculated

                  var Field1_length = Text1.length;

      var Field2_length = Text1.length + Text2.length;

      -  Assign the value to the position:

      Field2.x = Field2_length;


      This is the approach I want to achieve but unfortunately it does not work...

      Any idea would be deeply appreaciated!.

      Kind Regards




      Author's profile photo Rathish Rajagopal
      Rathish Rajagopal

      In adobe forms, some scripting is added for "bold" the letters the field format is - Rich Text in the a place, at that place the symbol '&' is maintained, it is not printing in the report.

      any scripting is there to convert "&" symbol into word "AND" in Adobe forms