Skip to Content
Working on one of projects in Integrated Planning (IP) I met requirement to warn users before they run any important process.

In one of scenarios users plan any data in application developed by Integrated Planning via Web Application Designer (WAD) interface. This planned data should be approved by principals level.

User clicks button “Send for Approval” designed in WAD, but before sending for approval (by planning sequence execution) I want to be sure that button clicked not accidentally or I want to notice user with any notification before.

This blog demonstrates how to show alert message with YES/NO option before IP planning sequence run.

When a user clicks button “Send for Approval” alert message will appear with text “Do you really want …. ?”.

If YES clicked, planning sequence will be processed, otherwise no.

First add SCRIPT_ITEM in WAD to your template and in “Web Item Parameters” tab click on script (marked by red color in figure below).

image

In script editor choose “Create with Wizard” and select “Execute a Planning Sequence (Simple)” command.

image

Complete attaching of planning sequence and click OK.

Generated JavaScript code will appear in script editor window.

Edit this code: just after function definition add next javascript code:

var ok_var=confirm(“Are you sure you would like to …”)

if (ok_var){

Here will be all code generated by wizard except function definition

}

Be sure that at the end of function you added closing parentheses.

Goto button group/button properties and select in “Action” SCRIPT_FUNCTION.

Then in “Script Function” select function for planning sequence execution (usually the name generated javascript function for planning sequence execution will be function executeJS_EXEC_PLANNING_SEQUENCE_SIMPLE_R.

image

Press OK and save web template. 

Now, if user clicks this button, alert window will appear. Depending on user choice (YES/NO) planning sequence will be executed or no.

To report this post you need to login first.

13 Comments

You must be Logged on to comment or reply to a post.

  1. Ravi Reddy
    Andrey,
    This is a very useful feature.  Lot of my users ask this when they want to peform an action (deleting key figures or distribution) and confirmation message will be very useful.

    I have one more request that I often get, user inputs some values in the planning query.  They forgot to click save button and click on another page on the web or close the screen, how can I give them a message to display “Do you want to save your changes?”.  Basically there should be a dirty flag when changes were made that can be checked before moving away from the planning window.  It would be great if you can share your thoughts on this.

    Thanks
    Ravi

    (0) 
    1. Andrey Uryukin Post author
      Hi.
      Thank you for your comment.
      It is known issue that users forget to press “save” and follow to another page.
      I don’t think it is possible (at least I don’t know how) to avoid it completely, but you can reduce those cases by setting in your “save” button properties “Execute on Enter”.
      In this case each time user enter data and press enter save function will be executed.
      Regards.
      (0) 
      1. Dave Poorvi
        Hi Andrey

        I too have a same requirement of having a confirmation pop-up message to run a planning sequence.
        I have followed your instructutions.
        But when I execute the button which has action ‘function script’ nothing happened and then if I press any button it does not recognize the web page, it says the URL address is not correct.
        Do you have any idea why this would be happening.
        Please help.
        Thanks in advance.

        Poorvi

        (0) 
        1. Dave Poorvi
          Below is my code:

          /**
          * Javascript functions that are to be integrated into a web template and that
          * are to be used later in the web application ALWAYS have to have the same function
          * signature, i.e. the parameters that will be passed.
          *
          * @param currentState – a list of parameters that describe the state the web item
          * @param defaultCommandSequence – the initially used sequence of commands that
          *                       would have been used instead of the custom
          *                       script.
          **/
          function executeJS_EXEC_PLANNING_SEQUENCE_SIMPLE_R( currentState, defaultCommandSequence )
          var ok_var=confirm(“are you sure”)
          if (ok_var){
          {
               //Note: information can be extracted using the parameter ‘currentState’
               //     and ‘defaultCommandSequence’. In either case create your own object
               //     of type ‘sapbi_CommandSequence’ that will be sent to the server.
               //     To extract specific values of parameters refer to the following
               //     snippet:
               //          var key = currentState.getParameter( PARAM_KEY ).getValue();
               //          alert( “Selected key: ” + key );
               //
               //     (‘PARAM_KEY’ refers to any parameter’s name)
               //Create a new object of type sapbi_CommandSequence
               var commandSequence = new sapbi_CommandSequence();
               /*
                * Create a new object of type sapbi_Command with the command named “EXEC_PLANNING_SEQUENCE_SIMPLE”
               */
               var commandEXEC_PLANNING_SEQUENCE_SIMPLE_1 = new sapbi_Command( “EXEC_PLANNING_SEQUENCE_SIMPLE” );
               /* Create parameter PLANNING_SEQUENCE */
               var paramPLANNING_SEQUENCE = new sapbi_Parameter( “PLANNING_SEQUENCE”, “MAP_SP_PM_04” );
               commandEXEC_PLANNING_SEQUENCE_SIMPLE_1.addParameter( paramPLANNING_SEQUENCE );
                    
               /* End parameter PLANNING_SEQUENCE */
               
               // Add the command to the command sequence
               commandSequence.addCommand( commandEXEC_PLANNING_SEQUENCE_SIMPLE_1 );
               /*
                * End command commandEXEC_PLANNING_SEQUENCE_SIMPLE_1
               */
               //Send the command sequence to the server
              return sapbi_page.sendCommand( commandSequence );
          }
          }

          (0) 
  2. Viren P Devi
    Hi Andrey,

    Thanks for sharing very useful blog.I tried implementing it but it seems that it is not working as expected. Prompt is not being generated while executing the sequence.Below is the code. Kindly check it and let me know if I am doing anything wrong.
    ***********************************************

    /**
    * Javascript functions that are to be integrated into a web template and that
    * are to be used later in the web application ALWAYS have to have the same function
    * signature, i.e. the parameters that will be passed.
    *
    * @param currentState – a list of parameters that describe the state the web item
    * @param defaultCommandSequence – the initially used sequence of commands that
    *                       would have been used instead of the custom
    *                       script.
    **/
    function executeJS_EXEC_PLANNING_SEQUENCE_SIMPLE_R( currentState, defaultCommandSequence )

    var ok_var=confirm(“Are you sure “)

    if (ok_var){

    {
         //Note: information can be extracted using the parameter ‘currentState’
         //     and ‘defaultCommandSequence’. In either case create your own object
         //     of type ‘sapbi_CommandSequence’ that will be sent to the server.
         //     To extract specific values of parameters refer to the following
         //     snippet:
         //          var key = currentState.getParameter( PARAM_KEY ).getValue();
         //          alert( “Selected key: ” + key );
         //
         //     (‘PARAM_KEY’ refers to any parameter’s name)
         //Create a new object of type sapbi_CommandSequence
         var commandSequence = new sapbi_CommandSequence();
         /*
          * Create a new object of type sapbi_Command with the command named “EXEC_PLANNING_SEQUENCE_SIMPLE”
         */
         var commandEXEC_PLANNING_SEQUENCE_SIMPLE_1 = new sapbi_Command( “EXEC_PLANNING_SEQUENCE_SIMPLE” );
         /* Create parameter PLANNING_SEQUENCE */
         var paramPLANNING_SEQUENCE = new sapbi_Parameter( “PLANNING_SEQUENCE”, “ZIPFIS008” );
         commandEXEC_PLANNING_SEQUENCE_SIMPLE_1.addParameter( paramPLANNING_SEQUENCE );
              
         /* End parameter PLANNING_SEQUENCE */
         
         // Add the command to the command sequence
         commandSequence.addCommand( commandEXEC_PLANNING_SEQUENCE_SIMPLE_1 );
         /*
          * End command commandEXEC_PLANNING_SEQUENCE_SIMPLE_1
         */
         //Send the command sequence to the server
        return sapbi_page.sendCommand( commandSequence );
    }

    }

    ****************************************

    Thanks,
    Viren

    (0) 
    1. Andrey Uryukin Post author
      Hi.

      Plz correct your code to following (you ahve placed first parentheses in wrong place):
      /**
      * Javascript functions that are to be integrated into a web template and that
      * are to be used later in the web application ALWAYS have to have the same function
      * signature, i.e. the parameters that will be passed.
      *
      * @param currentState – a list of parameters that describe the state the web item
      * @param defaultCommandSequence – the initially used sequence of commands that
      * would have been used instead of the custom
      * script.
      **/
      function executeJS_EXEC_PLANNING_SEQUENCE_SIMPLE_R( currentState, defaultCommandSequence )

      {

      var ok_var=confirm(“Are you sure “)

      if (ok_var){

      /Note: information can be extracted using the parameter ‘currentState’
      // and ‘defaultCommandSequence’. In either case create your own object
      // of type ‘sapbi_CommandSequence’ that will be sent to the server.
      // To extract specific values of parameters refer to the following
      // snippet:
      // var key = currentState.getParameter( PARAM_KEY ).getValue();
      // alert( “Selected key: ” + key );
      //
      // (‘PARAM_KEY’ refers to any parameter’s name)
      //Create a new object of type sapbi_CommandSequence
      var commandSequence = new sapbi_CommandSequence();
      /*
      * Create a new object of type sapbi_Command with the command named “EXEC_PLANNING_SEQUENCE_SIMPLE”
      */
      var commandEXEC_PLANNING_SEQUENCE_SIMPLE_1 = new sapbi_Command( “EXEC_PLANNING_SEQUENCE_SIMPLE” );
      /* Create parameter PLANNING_SEQUENCE */
      var paramPLANNING_SEQUENCE = new sapbi_Parameter( “PLANNING_SEQUENCE”, “ZIPFIS008” );
      commandEXEC_PLANNING_SEQUENCE_SIMPLE_1.addParameter( paramPLANNING_SEQUENCE );

      /* End parameter PLANNING_SEQUENCE */

      // Add the command to the command sequence
      commandSequence.addCommand( commandEXEC_PLANNING_SEQUENCE_SIMPLE_1 );
      /*
      * End command commandEXEC_PLANNING_SEQUENCE_SIMPLE_1
      */
      //Send the command sequence to the server
      return sapbi_page.sendCommand( commandSequence );
      }

      }

      (0) 
  3. Dave Poorvi
    Hi

    I had same requirement and could solve it with the help of your blog, thanks.
    I have another requirement in futher to this one:
    In the java script, we have mentioned the name of the planning sequence, and we selected(for the button), action with java script, and gave the name of the java script.
    My requirement is to have a SAVE button also in the same button.we need to save the data when the user execute the planning sequence.Can you pleasehelp on how to have multiple commands in java script.
    Normally, with the action option ‘ command via assitant’ we can have multiple commands or sequences.

    (0) 
  4. Dave Poorvi
    Hi

    I had same requirement and could solve it with the help of your blog, thanks.
    I have another requirement in futher to this one:
    In the java script, we have mentioned the name of the planning sequence, and we selected(for the button), action with java script, and gave the name of the java script.
    My requirement is to have a SAVE button also in the same button.we need to save the data when the user execute the planning sequence.Can you pleasehelp on how to have multiple commands in java script.
    Normally, with the action option ‘ command via assitant’ we can have multiple commands or sequences.

    Thanks in advance.
    Poorvi

    (0) 
  5. Leonardo Terribile
    Imaging you have a group of buttons to trigger several chains. In order to reuse code, is it posible to identify with button was pushed from the Java function to avoid having to duplicate code?

    Thanks in advance!

    (0) 
    1. Andrey Uryukin Post author
      Hi.
      I’m not sure about identyfing the button, but you can try the next approach:
      1. create one general function with common code and ont of the parameters that this function gets will be a button meaning (lets say 1-save X, 2-save Y etc.) According to 1 or 2 you will execute the needed code in this function without duplicated code.
      2. for each button create somple function that calls general function and pass to it a button meaning (1,2 or whatever).
      This way you will maintiain only one general function and several simple functions that call this general function.

      Regards.

      (0) 

Leave a Reply