Introduction

Smart value help allows to see the 5 last entries or a list of suggestion based on what you have entered.

You can see the application help for more details on the functionnalities :

Smart Input Help – Generic User Interface Functions – SAP Library

Smart value help script

First let’s have a look in the BSP application THTMLB_SCRIPTS, page scripts_.oo_smart_value_help.js

Here is the javascript that handles this functionality :

<%–
  Smart Value Help(SVH) – Handles the last five values and suggested values for a F4 Inputfield.

  There are two main types of F4
  1) Simple F4 – Values are ready on the popup
  2) Complex F4 – Values are not ready on the popup until user clicks search button Ex: F4 opens an Advanced Search view

  In the first case(simple F4) both last entries and f4 suggested values are provided, in the complex F4 only the last
  entries will be provided.
  –%>


var thtmlbCSVHMangerSingleton = thtmlbClass.create();
thtmlbCSVHMangerSingleton.prototype = {
   alertTimerId:                 0,
   inputField:                   “”,
   sicfPath:                     “/webcuif/uif_callback”,
   lastFiveHandler:              “CL_THTMLB_SMART_VALUE_HELP”,
   svhHandler:                   “CL_THTMLB_F4HELP”,
   displayBackgroundSearch:      “backgroundSearch”,
   displayLastFive:              “lastFive”,
   displaySmartValueHelp:        “smartValueHelp”,
   saveInputFieldId:             “saveId”,
   timeDelayMS:                  200,
   helpId:                       “”,
   helpInputMapping:             “”, <%– value retrived by the backend –%>
   helpInputMappingParser:       “”, <%– value passed to the backend for F4 –%>
   helpOutputMapping:            “”,
   pageId:                       “”,
   helpType:                     “”,
   popupF4InputField:            “”, <%– inputfieldF4 used in a comples F4 popup –%>
   controller:                   “”,
   view:                         “”,
   svhType:                      “”, <%– backgroundSearch ,lastFive or both –%>
   numberOfCharacters:           1,
   tooManyRecords:               “(Too Many Records…)”,

Here we can see the handling classes for last five entries : CL_THTMLB_SMART_VALUE_HELP and for the suggested values : CL_THTMLB_F4HELP.


The attribute “numberOfCharacters” define the number of characters that need to be entered before the function is activated.


Below in the page we see the code that handles behaviour on key entered :

       <%– enter, shift or escape (hide the context menu if its opened)–%>
       <%– hide the context menu for function keys, capslock and other keys –%>
       contextMenu = document.getElementById(“thtmlb_contextMenu__items”);
       if ((charCode < 47 && !(charCode == 8 || charCode == 46 || charCode == 38 || charCode == 40 )) || ( charCode >= 112 && charCode <= 123))
             thtmlb_hideContextMenu();
             <%– backspace –%>
           else if (charCode == 8 ){

         …



If you want suggested values to appear every time (and not only when you hit backspace) you have to change the code like this (code added in green) :

<%– any other character –%>
                                    } else if (thtmlbCSVHManger.inputField.value.length >= thtmlbCSVHManger.numberOfCharacters ){
                                           <%–       thtmlbCSVHManger.alertTimerId = window.setTimeout(‘thtmlbCSVHManger.svhFrontEndSearch();’,thtmlbCSVHManger.timeDelayMS);   –%>
                                           thtmlbCSVHManger.alertTimerId = window.setTimeout(‘thtmlbCSVHManger.ajaxCallRequest(thtmlbCSVHManger.displaySmartValueHelp);’,thtmlbCSVHManger.timeDelayMS);
                                             }



Handling class for Smart value help


So the class  CL_THTMLB_F4HELP is called to handle the request :


/wp-content/uploads/2014/03/2014_03_28_16_14_14_420949.png

In this class we can see that the suggested values actually come from a search help (defined in SE11).


The search help has to use dialog type “Display value immediately”.


So basically, every field can be assigned a search help in order to get suggested values, in order to do that you need to assign a search help to the data element of the field.

Example : Address check/completion using an external Web Service.


I have defined a search help based on an exit :

/wp-content/uploads/2014/03/2014_03_28_16_47_22_420995.png


In the function module ZDQE_SHLP_LIBRE I call the web service that will search for address.


I create a data element to enter a free text, with reference to this search help :

/wp-content/uploads/2014/03/2014_03_28_16_26_25_420996.png


Important : for my need the class CL_THTMLB_F4HELP, METHOD HANDLE_REQUEST has to be modified by removing the * in prefiltering value, else values are filtered according to value entered in the field by the user, so you only see them if they contain the pattern defined with the *.


Now I can use my field to enter free address and get suggested values (example with french address) :

/wp-content/uploads/2014/03/2014_03_28_17_08_46_420997.png


The web service I used return only one value (the closest to what the user entered), you can see here what happened after entering “rue jacques paris”, but of course you can have a list of results to choose from.









To report this post you need to login first.

9 Comments

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

    1. Benoît Sabys Post author

      Hello,

      I mean I removed the below standard coding :

      * concatenate the gv_prefiltering_value with ‘*’ to be used in prefiltering
         CONCATENATE gv_prefiltering_value ‘*’ INTO gv_prefiltering_value.


      If you leave the * added in this code, then the values are filtered according to the pattern, for instance when I enter “rue jacques” it will never get me “rue Jean Jacques Rousseau” because then it wouldn’t fit the pattern ‘rue jacques*’.


      So it is why I add to remove it.


      But it depends on your needs, you can also leave it of course.


      Regards


      (0) 
  1. Roman Koblents

    Hello Benoit!


    Very usefull blog! Thank you!

    But could you help me, i can’t understand how could you change standard class CL_THTMLB_F4HELP, METHOD HANDLE_REQUEST and standard view scripts_.oo_smart_value_help.js?


    Did you make enhance or what? Maybe you changed standard class with your z-class? But how then make you z-class been call?


    I need in my case change the logic of CL_THTMLB_F4HELP, METHOD HANDLE_REQUEST but i don’t whant to enhance it? Is There way to change the handler in SICF? Could you please explain this to me?


    I also tried to make a copy of BSP THTMLB_SCRIPTS with my ZTHTMLB_SCRIPTS and the insert a row in Table bsp_applc. But it didn’t help. My Z-BSP didn’t been called and everuthing was the same!


    Please provide me explanations!

    Regards, Roman

    (0) 
    1. Benoît Sabys Post author

      Hello,

      Well I directly modified the standard code.

      But I guess eventually you can modify only the page scripts_.oo_smart_value_help.js to change the svh handler and put a z subclass of CL_THTMLB_F4HELP.


      Regards

      (0) 
        1. Benoît Sabys Post author

          Well, like every standard object, with an access key.

          SE80, Application BSP THTMLB_SCRIPTS then you go to the page and click on the modify icon.

          (0) 

Leave a Reply