Using a + operator in SSRS join syntax for Epicor SSRS report

Hello,

I have modified an SSRS report to include a new table (ERP.JobOper).

The standard join syntax works fine in SSRS:

LEFT OUTER JOIN JobOper_" + Parameters!TableGuid.Value + " T7 ON T1.Company = T7.Company AND T1.JobNum = T7.JobNum AND T1.AssemblySeq = T7.AssemblySeq AND T1.JobSeq = T7.OprSeq "

However, I’m looking to get a bit fancier with my last join condition.

Instead of T1.JobSeq = T7.OprSeq, I’d like to use T1.JobSeq + 10 = T7.OprSeq

If I write this query in SSMS, it executes fine and returns the result I want. But I can’t seem to get the syntax to work in an Epicor SSRS report.

T1.JobSeq = T7.OprSeq works in SSMS
T1.JobSeq + 10 = T7.OprSeq works in SSMS

T1.JobSeq = T7.OprSeq works in SSRS
T1.JobSeq + 10 = T7.OprSeq does NOT work in SSRS

1 Like

I haven’t tried this before, so I don’t know if this is doable. Can you copy the query from SSRS into SSMS and fix the quotes / Parameters!TableGuid.Value portions and see if your query works?

Have you tried (T1.JobSeq + 10) in SSRS?

Hi Randy,

Yup, so far I’ve tried:

T1.JobSeq + 10 = T7.OprSeq
(T1.JobSeq + 10) = T7.OprSeq
(T1.JobSeq + 10 = T7.OprSeq)
T1.JobSeq = T7.OprSeq - 10

Seems like it’s not seeing JobSeq as a integer, perhaps try: (CInt(T1.JobSeq) + 10)

2 Likes

Try making a calculated field in the RDD and then linking with that in SSRS data definitions

1 Like

No luck so far, but I’ll play around with that a bit and see if I can get it to work. Thanks for the feedback!

1 Like

Try and move the selection to the where clause:

WHERE (T1.JobSeq + 10) = T7.OprSeq

or maybe a case

T7.OprSeq = (CASE WHEN T1.JobSeq IS NOT NULL THEN T1.JobSeq + 10 ELSE NULL END)

1 Like

I would put a CTE at the beginning of the query and do the calculation in there. Then join on the field from the CTE.

1 Like

lol.. was just thinking the same thing…

Here is working example. Your CTE would be a bit different.

="
with NotePad as
(
select key2, key3, key4, key5,Company ,STRING_AGG(character01, CHAR(13) + CHAR(10)) as Key5Notes 
from KineticPilot.ice.ud01 where CHECKBOX02 = 1 
group by key2, key3, key4, key5,Company
)

SELECT 
PartNotes.key5notes as PartNotes,
OrderDtlNotes.Key5Notes as OrderDtlNote,
custNoteNotes.key5notes as CustNote,
 OrderHdrNotes.key5Notes as OrderHdrNote,

T1.Company,T1.LegalNumber,T1.PackNum,CAST( T1.CustNum as nvarchar ) as CustNum,T1.ShipComment,T1.ShipDate,T1.Calc_BilContct,T1.Calc_BillToAddress,T1.Calc_SoldToAddress,T1.Calc_Contct,T1.Calc_CustPartOpts,T1.Calc_FOBDescription,T1.Calc_LegalNum,T1.Calc_NumRecordPerPage,T1.Calc_NumTotalParts,T1.Calc_SalesRepName,T1.Calc_ShipToAddress,T1.Calc_ShipViaDescription,T1.Calc_stPhone,T1.Calc_CusPhone,T1.Calc_stFax,T1.Calc_EMailAddress,T1.Calc_FaxNum,T1.Calc_SEmailAddr,T1.Calc_CarrierDesc,T1.Calc_ShipViaSCAC,T1.Calc_CarrierSCAC, T2.PackLine,T2.Discount,T2.ExtPrice,T2.HeaderShipComment,T2.LineDesc,T2.OrderLine,T2.OrderNum,T2.OrderRelNum,T2.PartNum,T2.RevisionNum,T2.ShipComment as ShipDtl_ShipComment,T2.UnitPrice,T2.XPartNum,T2.XRevisionNum,T2.Calc_DspBackOrdQty,T2.Calc_DspBackOrdQtyUom,T2.Calc_DspLabDur,T2.Calc_DspLabMod,T2.Calc_DspLineDesc,T2.Calc_DspLineShpQty,T2.Calc_DspLineShpQtyUom,T2.Calc_DspMatDur,T2.Calc_DspMatMod,T2.Calc_DspMiscDur,T2.Calc_DspMiscMod,T2.Calc_DspPlannedQty,T2.Calc_DspPlannedQtyUom,T2.Calc_DspSerialNumber,T2.Calc_DspShipRouting,T2.Calc_DspSubShipTo,T2.Calc_GetNextLegalNum,T2.Calc_LegalText,T2.Calc_LinChangd,T2.Calc_NextLegalNumID,T2.Calc_NumLineByInv,T2.Calc_OrdRelRef,T2.Calc_POLine,T2.Calc_SalesRepName as ShipDtl_Calc_SalesRepName,T2.Calc_SerialNumLabl,T2.Calc_TotalLineCost,T2.Calc_TotalTax,T2.Calc_HidePackLine,T2.OrderLine_KitFlag,T2.OrderLine_KitParentLine,T2.OrderLine_KitPrintCompsPS,T2.OrderLine_DisplaySeq,T2.OrderLine_KitShipComplete,T2.Calc_MarkForAddress,T2.OrderNum_PONum,T2.PartNum_PartDescription,T2.PCID,T2.Calc_CommodityCode, T2.OrderRelNum_ReqDate ReleaseShipDate, T2.OrderRelNum_NeedByDate ReleaseNeedByDate,
FROM ShipHead_" + Parameters!TableGuid.Value + " T1
 LEFT OUTER JOIN ShipDtl_" + Parameters!TableGuid.Value + " T2
 ON T1.Company = T2.Company AND T1.PackNum = T2.PackNum 
Join NotePad as PartNotes on T2.PartNum  = PartNotes.Key2 and PartNotes.Key5 = 'Part'  
Left Join NotePad as OrderDtlNotes on T2.OrderNum  = OrderDtlNotes.Key2 and T2.OrderLine  = OrderDtlNotes.Key3 and T2.Company  = OrderDtlNotes.Company and OrderDtlNotes.Key5 = 'OrderDtl'  
left join Notepad as OrderHdrNotes on T2.OrderNum = OrderHdrNotes.Key2   and  T2.Company = OrderHdrNotes.Company and OrderHdrNotes.Key5 = 'OrderHed'  
left join Notepad as CustNoteNotes on T2.CustNum = CustNoteNotes.Key2 and T2.Company = CustNoteNotes.Company and CustNoteNotes.Key5 = 'Customer'
"   
2 Likes

It’s all just SQL. If it works differently in your rdl, it’s a SSRS thing not SQL.

Random thought - if the query spans multiple lines, do all of the lines after the first one have a whitespace at the start of the line? That’s a VB.Net thing which tends to be an annoying surprise.

can you expand on what “does Not work” means here? Does the whole report fail? Or are you getting something different then you would expect?

Hi Brandon,

If I use standard join syntax, I can execute the report and see an operation in my newly added column. In the screenshot below, it is the value “OS-2DLaser” But it is the current operation and my end user wants to see the next operation, which is why I am doing the + 10 on my join condition. I get the correct results in SSMS.

If I adjust my join condition to use the + 10 in SSRS, the report still generates but my new field is blank. But if I execute in SSMS instead, it displays the correct operation, not an empty string.

@Ihavequestions , if you post your RDL query, either @knash or I could change it into a CTE for you. That would be the easiest way to get around your issue.

2 Likes

Thank you @jkane and everyone else.

Ultimately, I had one too many join conditions on my RDD. It was only pulling in one row of data, so my + 10 was never going to work. I removed one of the join conditions and now the join logic works fine in both SSRS and SSMS.

Thanks to everyone for their suggestions along the way.

1 Like