Showing results for 
Search instead for 
Did you mean: 

How to write an If statement to compare shiptocode to business partner master address?

0 Kudos

So I have my queries which narrows it down to a specific document number, the card code, and essentially everything else with it. Now all I need to do is to do the comparisons for the shiptocode and bp master addresswhich should be a really simple if statement but I feel like I got brain wiped

I am using sql server mangement studio as well to generate the query. I am doing this configuration in the sales order.

Here is what is in my SQL condition

DECLARE @documentnumber INT(MAX)<br>DECLARE @shiptocode NVARCHAR (MAX)<br>SET @cardcode = $[$4.0.0]<br>SET @documentnumber = $[$8.0.0]<br>SET @shiptocode = $[$40.0.0]

I am using SAP B1UP for b1 validation configuration. Here is the query

SELECT        dbo.ORDR.DocNum, dbo.CRD1.Street, dbo.CRD1.ZipCode, dbo.CRD1.Block, dbo.CRD1.City, dbo.CRD1.Country, dbo.CRD1.State, dbo.ORDR.DocStatus, dbo.CRD1.Address, dbo.CRD1.CardCode, dbo.ORDR.CardCode AS Expr1, <br>                         dbo.ORDR.ShipToCode<br>FROM            dbo.CRD1 INNER JOIN<br>                         dbo.ORDR ON dbo.CRD1.Address = dbo.ORDR.ShipToCode<br>WHERE        (dbo.ORDR.DocStatus = 'o') AND (dbo.CRD1.CardCode = @cardcode) AND (dbo.ORDR.DocNum = @documentnumber)

Here is my final if statement where to do the comparisons in the sql condition, unless you can do a comparison in the sql server management studio.

--IF(shiptocode != address) pseudocode<br>--execute function<br>SELECT 'error' FOR BROWSE<br>END

So i just need to somehow either modify the if statement in the sql condition for b1up or do it in the sql server management studio

Accepted Solutions (0)

Answers (1)

Answers (1)

Active Contributor

Hi Tommy,

in the Query-Picture you are joining CRD1 / OCRD / ORDR (including CardCode)

in the B1up-Statement just

dbo.ORDR ON dbo.CRD1.Address = dbo.ORDR.ShipToCode

You should use the CardCode there as well and also CRD1.AdresType = 'S'

regards Lothar