BAQ Concatenate - Syntax OK, but Test Error

Hello,
I am very new to Epicor, BAQ and Calculations.
I created a Calculated Field to show PartNum_PONum_PO$ in one field. I checked the Syntax within the Calculated Filed SQL Editor and Analyze and the Syntax is OK. However, when I run Test, I get the following error:
Severity: Error, Text: Bad SQL statement.
Review the server event logs for details.
Query returned 0 row(s).
Query has no more records to return.
Query execution total time: 7866.6191 ms.

My calculation looks like this: (Part.PartNum+β€˜β€˜+OrderHed.PONum+’’+OrderHed.DocTotalCharges)
My data type is: nvarchar

Any thoughts on why this is happening?

CONCAT(Part.PartNum, ' ', OrderHed.PONum, ' ', OrderHed.DocTotalCharges)

Your syntax might work, but that’s not how I do mine in a BAQ. For example, jobs created from our orders use the naming convention of β€˜00’+ OrderNum + β€˜-’ + OrderLine + β€˜-’ + OrderRel

In trying to connect, I’m looking for something that starts with 00 then has an order number followed by - and then I don’t care what comes next:

Using LIKE instead or =
CONCAT (β€˜00’,OrderHed.OrderNum,β€˜-’,β€˜%’)
single quotes around the strings, no quotes around the field name, and then quotes around the % wildcard character.

Hopefully you can pull something useful from that.

edit Looks like Aaron beat me to it.

Your suggestion worked: Concat(Part.PartNum,β€˜','PO β€˜,OrderHed.PONum,’’,β€˜$’,OrderHed.DocTotalCharges)
The only small issue is with the currency. Instead of seeing $37,112.00, I see $37112.000.

Thank you for your input!

Give this a blast.

CONCAT(Part.PartNum, ', PO ', OrderHed.PONum, ', $', FORMAT(OrderHed.DocTotalCharges, 2))

I get: β€œArgument data type int is invalid for argument 2 of format function.”

My apologies

CONCAT(Part.PartNum, ', PO ', OrderHed.PONum, ', $', CAST(OrderHed.DocTotalCharges AS DECIMAL(18, 2)))

Works! Only thing missing is the commas. I have some six figure+ orders, so the commas are important.

I would use FORMAT:

FORMAT(OrderHed.DocTotalCharges, 'C', 'en-us')

It produces this: $37,112.00


CONCAT(Part.PartNum, ', PO ', OrderHed.PONum, ', ', FORMAT(OrderHed.DocTotalCharges, 'C', 'en-us'))
2 Likes

Brilliant!
I ended up with two $$. but corrected it by deleting the dollar sign only. Here’s the final code:

CONCAT(Part.PartNum, ', PO ', OrderHed.PONum, ', ', FORMAT(OrderHed.DocTotalCharges,β€˜C’,β€˜en-us’))

Thank you Anthony!