• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Mod to vvUtility_suggest

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mod to vvUtility_suggest

    Please consider making a mod to vvUtility_suggest to allow it to do 'Contains' searches as well as the current 'Starts with' searches.

    I have a customer information string that contains the customer's number, name, address, city, state, zip, country.

    I made changes to the vvUtility_suggest to allow it to do 'Contains' searches so I can key in whatever information I know about the customer, like name, number, city, etc and it suggests customers.

    I realize the ramifications of changing code in the Valencexx library. I backed out my changes and thought I'd suggest the change via the forum.

    Feel free to use my code if you wish.

    Code:
    p vvUtility_suggest...                                                  
    p                 b                   export                            
    d                 pi                                                    
    d  inValue                     150a   const varying options(*varsize)   
    d  inFieldName                  10a   const varying options(*varsize)   
    d  inFileName                   10a   const varying options(*varsize)   
    d  inNumToReturn                 3  0 const                             
    d  inWhereCond                 512a   const varying                     
    d                                     options(*varsize:*nopass)         
    d  SearchType...                                                        
    d                                1a   Const Options(*NoPass)            
    
                                                                            
    D SearchTypeString...                                                   
    D                              200a                                     
    
      // Build search type.                                                 
      SearchTypeString = *Blank;                                            
      If %Parms >= 6 And %Addr(SearchType) <> *Null And                     
        SearchType = 'C';                                                   
        SearchTypeString = 'Like ' + SQ + '%' + %Trim(Compare) + '%' + SQ;  
      Else;                                                                 
        SearchTypeString = 'Like ' + SQ + %Trim(Compare) + '%' + SQ;        
      EndIf;                                                                
                                                                            
      // Build the sql statement...                                         
      Stmt = 'Select ' + %Trim(inFieldName) +                               
        ' From ' + %Trim(inFileName) +                                      
        ' Where Upper(' + %Trim(inFieldName) + ') ' +                       
        %Trim(SearchTypeString);  

  • #2
    Thanks for the suggestion Mike. We'll likely add this searchtype option to vvUtility_suggest in one of the upcoming maintenance releases, as it seems like a sensible addition for this function. That said, vvUtility_suggest is a very early (Valence 1.0) procedure and has become a bit obsolete since the introduction of various SQL-centric functions in later releases. In fact we'll probably be dropping the vvUtility_suggest procedure from the API documentation altogether in Valence 3.1 (though it will remain accessible in the service program for backward compatibility).

    Today we generally recommend using the vvOut_ExecSQLtoJSON with your own custom SQL statement instead, as it makes the process a little more straightforward from a debugging standpoint (i.e., no need to step into the service program to see what the select statement is). We'll be updating the EXCMBTA example in Valence 3.1 to show this technique.

    Rob

    Comment


    • #3
      Thanks for the reply Rob.

      I'll wait for 3.1.

      Later...

      Comment

      Working...
      X