4 Replies Latest reply on Aug 6, 2020 12:35 AM by Ben Daelemans

    Simulate "contains" function in export format templates

    Ben Daelemans Seasoned Veteran

      Hi All,

       

      We have a specific requirement to update one of our many export templates to solve a certain problem.

      However after searching, we can't seem to find exactly what we need to do in order to solve our specific problem.

       

      This is the problem:

      We have a multiple assignment structure called 'promotion' which is divided into active countries as our 2nd structure group level, and the promotion type per country is our 3rd level structure group.

       

      The structure looks like this:

       

      Promotion

           - Germany

                - New

                - Discount

                - Highlight

                - ...

           - France

                - New

                - Discount

                - Highlight

                - ...

       

      Items can be/are assigned to multiple promotion types in multiple countries.

       

      So we're looking for some sort of a "contains" function to see of the assignment string we work with in the export template,
      contains a specific country in order to display it in the right section of the template.

       

      for example:

      an item is assigned to the promotion type 'new' in both DE (Germany) and FR (France), when we get that assignment variable in the export template it looks like this: "DE_New;FR_New" (the identifiers of the 3rd level structure groups).

       

      We need a way to determine in the export template itself, if that string contains "DE", then we can display the item information on our 'German section' in the export.

       

      A very simple premise, but difficult to achieve since there is no such thing as a "contains" function..

       

      I've tried to combine the functions 'Compare', 'Substring' and 'SplitKeywords', with this philosophy:

      If i can compare the first 2 characters of every entry in the assignment string, and one of them is a match with 'DE', we can display the data, otherwise we can't.

      However that didn't work. it only compares the 1st entry of the assignment string, despite splitting it up, since in this coding language i can't work inside the function itself. (like I would be able to do in most languages for example loop through an array and handle data in that loop)

       

      Any ideas are very welcome, or if you have a found a function (or combination of functions) similar to "contains";

      please let me know

       

      Thanks in advance for the responses!

        • 1. Re: Simulate "contains" function in export format templates
          Ryan Jenson Seasoned Veteran

          Hi Ben,

           

          Can you try using {?StringIndexOfIgnoreCase} to search for DE_ and FR_? This function should return the location of those strings as an integer, this integer (more or less used as a boolean) could be interpreted by {?CompareIgnoreCase} as an if/then statement.

           

          For example:

           

          {?CompareIgnoreCase "{?StringIndexOfIgnoreCase "{&Item.Item Num}","ENG",1}", "1", "Your output data here", ""}

           

          StringIndexOfIgnoreCase will search the Item Num, starting from the first character, and search for the string "ENG". If "ENG" is found it will return a "1" into the CompareIgnoreCase which will then compare against my anticipated value and either return the output data or do nothing.

           

           

          I think your solution may look something like this:

           

          {?CompareIgnoreCase "{?StringIndexOfIgnoreCase "{&Structure assignments.Structure groups.Structure group identifier}","DE_",1}", "1", "This is a German promotion", ""}

          1 of 1 people found this helpful
          • 2. Re: Simulate "contains" function in export format templates
            Alex _ Guru

            Hi Ben,

             

            the OOTB scenario (in PIM 8.1) is to use the solution described by Ryan but I suggest you to build a custom export function in java (SDK) that check if a string is contained into a word.

             

            {?StringContains word, stringtobesearched, caseSensitive} --> true, false

             

            it's a very fast java code implementation and he give you best performance. (1 function vs 3)

             

            in PIM 10 Informatica have build OOTB this function.

             

            A

            1 of 1 people found this helpful
            • 3. Re: Simulate "contains" function in export format templates
              Ben Daelemans Seasoned Veteran

              Hi Ryan,

               

              Thanks for the suggestion, will definitely try this one out !

              • 4. Re: Simulate "contains" function in export format templates
                Ben Daelemans Seasoned Veteran

                Hi Alex,

                 

                Thanks for expanding upon Ryan's answer!

                 

                We will install PIM Informatica 10 this year, so I'll definitely keep this comment in mind.