Skip to main content

Pop Up Message When No BOM exists

Answered

Comments

6 comments

  • Nadav Caridi

    Hi , 

    Maybe Just try 


    IF NOT EXISTS (SELECT TOP 1 o.code FROM dbo.OITT o WHERE o.code=$[$38.1.0])
    BEGIN
    SELECT 'STOP' [result]
    END

     

    Good Luck 

  • Rahul

    Hi Nadav

    Thanks for your reply

    It works and a message pops up when there is no BOM

    also, how do I add the below criteria so that it ignores anything that belongs to this item group code?

    OITM.[ItmsGrpCod] <> '288'

    Regards

    Rahul

     

     

  • Nadav Caridi

    Hi

    In that case you need an join from the oitm to oitt 

    or just create a 2nd condition with another select 

    IF (

    NOT EXISTS (SELECT TOP 1 o.code FROM dbo.OITT o WHERE o.code=$[$38.1.0])

    AND (put 2nd condition for group code here )

    )
    BEGIN
    SELECT 'STOP' [result]
    END

  • Rahul

    Hi Nadav

    Sorry i am still a beginer at this

    Tried the below, but it wont work

     

    IF (NOT EXISTS (SELECT TOP 1 O.CODE FROM dbo.OITT O WHERE O.CODE = $[$38.1.0])
    AND T0.[ItmsGrpCod] <> '288')

    FROM OITM T0 INNER JOIN OITT T1 ON T0.[ItemCode] = T1.[Code]
    BEGIN

    SELECT 'STOP' [RESULT]

    END

  • Nadav Caridi

    Hi Rahul,

    I think you better do it with two queries , would be easier for you to read and understand if you're new to this 

    so query 2 should look like this (to get the group code): 

    (select top 1 t1.ItmsGrpCod from OITM t1 where t1.ItemCode=$[$38.1.0])

     

    and then just combine the two conditions into the previous query for the validation :

    IF (

    NOT EXISTS (SELECT TOP 1 o.code FROM dbo.OITT o WHERE o.code=$[$38.1.0])

    AND ((select top 1 ItmsGrpCod from OITM t1 where t1.ItemCode=$[$38.1.0])<>'288')

    )
    BEGIN
    SELECT 'STOP' [result]
    END

     

    Good Luck.

  • Rahul

    Hi Nadav

    It works perfectly

    Thank you very much

    Much appreciated

    Regards

    Rahul

     

Please sign in to leave a comment.