19 Replies Latest reply: Feb 1, 2016 5:59 AM by Uday P RSS

    Match function issue

    Uday P

      Hi All,

       

      I am using Match function to retrieve a certain result which is working fine in the UI, but when I use the same in script, I am not getting the same result. I have used the following expression.

       

      If(Match(DISMM,'VR','V1','ZA','ZD')=0,'Not_Stocked','Not_ClosestPlant')

       

      DISMM is a field that contains the values,VR,V1,ZA,ZD,ND,PD,X0,Z1. When I used the expression in a list box under Expression. When I  select  Stocked or Not_ClosestPlant,the resultant DISMM values are getting selected, but with script, that is not happening.Can anyone please help.

        • Re: Match function issue
          Sunny Talwar

          Would you be able to share a sample where it isn't working?

          • Re: Match function issue
            Sunny Talwar

            Seems to be working here using this script:

             

            Table:

            LOAD *,

              If(Match(DISMM,'VR','V1','ZA','ZD')=0,'Not_Stocked','Not_ClosestPlant') as New_Dim;

            LOAD * Inline [

            DISMM

            VR

            V1

            ZA

            ZD

            ND

            PD

            X0

            Z1

            ];

             

            Capture.PNG

              • Re: Match function issue
                Uday P

                Hi Sunny,

                Here is the complete script that I have been using. The bold part is where I am having the issue.

                 

                RCode:

                Load %VBELNPOSNR,

                if(PSTYV='TAB' OR PSTYV='TABN','0 – CrossDock',If(LIPS_WERKS=[WH Code 1],'1 – Cust_Geo_Prime',if(LIPS_WERKS='8041' or

                LIPS_WERKS='8042'or LIPS_WERKS='8043'or LIPS_WERKS='8044' or LIPS_WERKS='8615','2 – Sci_Ed',

                if(LIPS_WERKS='8031' or LIPS_WERKS='8032','3 – Furniture',

                if(LIPS_WERKS='8033' or LIPS_WERKS='8035','4 – Export',

                if(LIPS_WERKS='8036' or LIPS_WERKS='8037','5 – Seradigm',if(LIPS_WERKS <> [WH Code 1] AND LIPS_WERKS <> [WH Code 2] AND

                LIPS_WERKS <> [WH Code 3] and LIPS_WERKS <> [WH Code 4] and LIPS_WERKS <> [WH Code 5] and

                LIPS_WERKS <> [WH Code 6] and

                LIPS_WERKS <> '8031' and LIPS_WERKS <> '8032' and LIPS_WERKS <> '8033' and LIPS_WERKS <> '8036' and LIPS_WERKS <> '8037'

                and LIPS_WERKS <> '8041' and LIPS_WERKS <> '8042' and LIPS_WERKS <> '8043' and LIPS_WERKS <> '8044'

                  and LIPS_WERKS <> '8615' ,'6 – AWS_Override',if(%KNMTWERKS=LIPS_WERKS,'7 – Per_InfoRec',if(CLSTK_PLANT=LIPS_WERKS,'8 – Closest_StkPlnt',

                if(Match(DISMM,'VR','V1','ZA','ZD')=0, '9-Not_Stocked',

                  '10 – Not_Closest_StkPlnt'

                )))))))))) AS ReasonCode

                Resident Delivery;

                 

                 

                I have attached the selections screenshots of the Reason codes and their possible selections of DISMM when the above'IF' statement expression is used in UI and script. It shows that the script loaded expression is not selecting the relevant DISMM values.

              • Re: Match function issue
                Dominic Mander

                But the script is executing without failure and the field produced contains both Not_Stoked and Not_ClosestPlant?

                 

                If that is the case I suspect that wherever you're calculating this new field it is not correctly associated to DISMM in the data model. You could verify this in the table viewer.

                • Re: Match function issue
                  Uday P

                  Hello Everyone,

                  Thanks for your help. I have used the following code and checked it in a straight table using what Dominic has suggested and now it seems to be working fine.

                   

                  Load %VBELNPOSNR,

                  if(PSTYV='TAB' OR PSTYV='TABN','0 – CrossDock',If(LIPS_WERKS=[WH Code 1],'1 – Cust_Geo_Prime',if(LIPS_WERKS='8041' or

                  LIPS_WERKS='8042'or LIPS_WERKS='8043'or LIPS_WERKS='8044' or LIPS_WERKS='8615','2 – Sci_Ed',

                  if(LIPS_WERKS='8031' or LIPS_WERKS='8032','3 – Furniture',

                  if(LIPS_WERKS='8033' or LIPS_WERKS='8035','4 – Export',

                  if(LIPS_WERKS='8036' or LIPS_WERKS='8037','5 – Seradigm',if(LIPS_WERKS <> [WH Code 1] AND LIPS_WERKS <> [WH Code 2] AND

                  LIPS_WERKS <> [WH Code 3] and LIPS_WERKS <> [WH Code 4] and LIPS_WERKS <> [WH Code 5] and

                  LIPS_WERKS <> [WH Code 6] and

                  LIPS_WERKS <> '8031' and LIPS_WERKS <> '8032' and LIPS_WERKS <> '8033' and LIPS_WERKS <> '8036' and LIPS_WERKS <> '8037'

                  and LIPS_WERKS <> '8041' and LIPS_WERKS <> '8042' and LIPS_WERKS <> '8043' and LIPS_WERKS <> '8044'

                    and LIPS_WERKS <> '8615' ,'6 – AWS_Override',if(%KNMTWERKS=LIPS_WERKS,'7 – Per_InfoRec',if(CLSTK_PLANT=LIPS_WERKS,'8 – Closest_StkPlnt',

                  IF(DISMM<>'VR' AND DISMM<>'V1' AND DISMM<>'ZA' AND DISMM<>'ZD','9 - NOT_STOCKED',

                  '10 – Not_Closest_StkPlnt'

                  )))))))))) AS ReasonCode

                  Resident Delivery;

                   

                   

                  Although I have tried the same script earlier, it seems to be working this time. Anyways thank you for all your help. The OR and AND operators are creating a problem for other developers as well in our team. They don't seem to do the operations correctly sometime and later they work fine. I'm not able to figure out why.