Epicor - SQL query Part

We have some parts that are as follows:
13935
13935CO

The Job/WorkOrder will be for the 13935 part but I need a label (Barcode) for 13935CO

So needing a little help with the if - case statement:
Select a.PartNum, Part Description
Case When a.partnum =%CO% then a.PartNum Else B.partnum
??

@RPLEGRAND Where are you trying to produce this label?

If you are doing a baq it will be an outer join with a check for the partNum+‘CO’ existing.

select top 10
Coalesce(p.partnum,jh.partnum) As [Label Part]
,p.partnum,jh.partnum
from JobHead jh
left outer join Part p on p.partnum = concat(jh.partnum ,'CO')
where jh.partnum  like '13935%' 

you could try.

CASE WHEN a.partnum LIKE ‘%CO%’ THEN a.PartNum Else B.partnum END

or you can just append the CO to the part as well.

Hard to see what you really want though based on half the SQL Query.

We are pre-printing labels from Bartender for production line as parts come off the machines.

We Job / Workorder would be created for part # 12345.
The challenge is not all parts have the CO at the end 12345CO.

So was thinking about the if else or if contains to return the correct part to use for printing the barcode.

So in Bartender they can select the Job # and print x qty of labels.
Job # is tied to 12345 and need label for 12345CO if the CO is a valid part number in part master.

The sql I posted will do that, but where are you triggering the bartender file from? I have never made bartender labels, so I am not familiar with the process.

If it is a bpm then you could use a .Any() statement to check for the CO part number existing.

Bartender will pull from a SQL query.

1 Like