Column Expression Syntax issue

Hi Team,
New to Knime, Trying to use Column Expression node to set the barcode based on UOM
If UOM =“PCS” barcode code to start with “100000”+ Product Code (6 Digits), and then workout a checksum digit to make the barcode 13 digits long
If UOM =“PACK” barcode code to start with “200000”+ Product Code (6 Digits), and then workout a checksum digit to make the barcode 13 digits long
If UOM =“CARTON” barcode code to start with “300000”+ Product Code (6 Digits), and then workout a checksum digit to make the barcode 13 digits long
What is the best way to script it in Column expression node.
Appreciate your help. Thanks

Hi @Suniljc ,

I am just giving you a screenshot on how to use it. Hope it suffices your requirement.

If Product Code is coming from another column, you can use column(“Product”) and similarly for Checksum value.

4 Likes

Hi Kamtaot,
Thank you for the script. I will try the solution in the workflow.
Kind Regards,
Sunil

Hi Kamtaot,
Worked nicely. Just now need to implement GTN13 check digit calcs for the barcodes as shown below:

Check Digit formula
Thanks

1 Like

Hi @Suniljc , welcome to the KNIME community forum!

As @kamtaot has answered the question related to syntax, please mark @kamtaot’s answer as the solution. :slight_smile:

With regards the secondary part of your question, I looked at the description of the GTIN13 algorithm and have uploaded this component to the hub.

I tested it against an online GTIN13 generator, but as it is new, please test it for yourself to your satisfaction and let me know if you discover any errors.

Here is my test workflow.

The “expected” results were calculated using an online generator, so that I could compare the output from the component.

GTIN 13 Generator.knwf (18.0 KB)

(implemented using java snippet. Java method for GTIN13 algorithm written by chatGPT )

5 Likes

Thank you @takbb for all the effort
Getting this error
URL can’t be dropped to the workbench! Corresponding hub not mounted. Unknow URL https://knime.hub.com/takbb/… when i try to drag & drop.
I am on Knime version 4.7 .

Hi @takbb
Downloaded manually from your page and linked it to the workflow and works perfectly. While downloading it had a warning Knime Ver 4.7.7 is required. I forced it onto my workbench.
Have you hidden the Java snippet ? There is a space in the field GTN13 between 12 & 13 digit. I could clean it up using column expression node.
Thank you for the awesome work you have done for me.
Kind Regards,
Sunil

Hi @Suniljc , not sure why it didn’t download from the hub directly. May have been a glitch.

With regard the space, I was under the impression that the check digit was separated by a space in the GTIN13 codes, but if that’s not the case I can amend it. Also does it go at the start or at the end, lol…

What format works for you. I’ll fix it.

If there are possible variations, I can add some config options later.

No the java snippet isn’t hidden. That’s not possible. It’s there inside the component if you open it

@Suniljc , I’ve updated the component. It has additional config options, so you can remove the space by not including a space in the “delimiter” box, and also adjust the position of the check digit. If you update the component on the workflow, you should get the new changes.

1 Like

Thank you Brian. Awesome job

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.