Jump to content

Label Function Syntax

From Commander4j

There are a number of functions which you can embed in your barcode label template to help format the data before sending to a labeller.

Referencing field names uses this syntax.

<*fieldname*>

for example

<*SSCC*>  <*QUANTITY*>  <*DESCRIPTION*>

Functions are resolved innermost-first, so they can be nested. The result of an inner function is passed as the input to the function which encloses it.

<PADLEFT(<SUBSTRING(<*BATCH*>,1,3)>,5,0)>

If a function is given the wrong number of parameters it returns the function name followed by [Incorrect number of parameters], and a function given an invalid date/time format returns the function name followed by [Incorrect date/time format]. This makes mistakes visible on the printed label rather than failing silently.

DATE_CREATED

This function returns the date & time when the pallet record was created in the database and allows you to specify the format that you want it formatted in the label.

Example usage

<DATE_CREATED(ddMMyy)>
<DATE_CREATED(dd/MM/yyyy)>

If the value of the DATE_CREATED field is null or blank it will return spaces instead of date.

DATETIME

The function allows you to format a datetime/timestamp field value from the database and display it in the label using the format specified.

<DATETIME(fieldname,dd/MM/yyyy  HH:mm:ss)>

EXPIRYDATE

When a label is printed Commander4j will automatically calculate the expiry date of the product. It is important to realise however that the application has 2 modes for recording the expiry date. It can be associated with the individual pallet number (SSCC) or it can be associated with the batch number. The mode that the system is using is defined in System Keys using the setting called EXPIRY DATE MODE

This function will retrieve the value from the appropriate table based on the setting above.

<EXPIRYDATE(MM yyyy)>
<EXPIRYDATE(MM)>
<EXPIRYDATE(yy)>
<EXPIRYDATE(dd)> <EXPIRYDATE(MM)> <EXPIRYDATE(yyyy)>

IIF

<IIF(param1,param2,param3,param4)>
IF param1 = param2 then
  return param3
else
  return param4

JULIAN_YJJJ

This function returns the production / manufacturing data in the format {last digit of year}{Julian day number}

<JULIAN_YJJJ()>

LEFT

<LEFT(fieldname,5)>

LOWERCASE

<LOWERCASE(fieldname)>

LTRIM

<LTRIM(fieldname)>

PADLEFT

 <PADLEFT(fieldname,14,0)>

This function pads out the size of a string to the length specified using the character specified.

It adds any additional characters to the left size of the string.

PADRIGHT

 <PADRIGHT(fieldname,14,0)>

This function pads out the size of a string to the length specified using the character specified.

It adds any additional characters to the right size of the string.

PALLET_WEIGHT_BARCODE

<PALLET_WEIGHT_BARCODE(KG,3)>

This function returns the total weight of the pallet (looked up from the pallet's SSCC) formatted to the number of decimal places specified, but with the decimal point removed so that the value can be embedded directly in a barcode.

The first parameter is the unit of measure for the weight; if it is left blank it defaults to KG. The second parameter is the number of decimal places.

For example a weight of 123.456 KG would produce 123456

<PALLET_WEIGHT_BARCODE(KG,3)>

See also PALLET_WEIGHT_TEXT, which is identical but keeps the decimal point for human-readable display.

PALLET_WEIGHT_TEXT

<PALLET_WEIGHT_TEXT(KG,3)>

This function returns the total weight of the pallet (looked up from the pallet's SSCC) formatted to the number of decimal places specified, for display as human-readable text on the label.

The first parameter is the unit of measure for the weight; if it is left blank it defaults to KG. The second parameter is the number of decimal places.

For example a weight of 123.456 KG would produce 123.456

<PALLET_WEIGHT_TEXT(KG,3)>

This is the same as PALLET_WEIGHT_BARCODE except that the decimal point is retained.

PRODDATE

This function returns the production / date of manufacture of the pallet and allows you to specify the format that you want it displayed in on the label.

<PRODDATE(dd/MM/yyyy)>
<PRODDATE(ddMMyy)>

If the format is left blank it defaults to dd/MM/yyyy. If the date of manufacture is null it returns spaces of the same length as the format specified instead of a date.

<RIGHT(fieldname,5)>

RTRIM

<RTRIM(fieldname)>

SUBSTRING

<SUBSTRING(fieldname,start,length)>

This function returns part of a string. start is the position of the first character to extract (the first character is position 1) and length is the number of characters to return.

<SUBSTRING(fieldname,1,3)>

would return the first 3 characters of the field. The function is bounds-safe; if the input is shorter than requested it returns as many characters as are available rather than producing an error.

SUBTR_LPAD

<SUBTR_LPAD(fieldname,start,length,size,padchar)>

This function first left-pads the input value out to size characters using padchar, and then returns a substring of the padded value starting at position start (the first character is position 1) for length characters.

For example, if a field contains 12:

<SUBTR_LPAD(fieldname,1,4,4,0)>

would first pad the value to 0012 and then return the first 4 characters 0012.

TIMESTAMP

This function returns the current system date & time at the moment the label is printed, formatted using the format specified.

<TIMESTAMP(dd/MM/yyyy HH:mm:ss)>
<TIMESTAMP(ddMMyy)>

If the format is left blank it defaults to dd/MM/yyyy HH:mm:ss.

TRIM

<TRIM(fieldname)>

UPPERCASE

<UPPERCASE(fieldname)>

USERNAME

This function returns the name of the user currently logged on to Commander4j, in upper case.

<USERNAME()>

VERSION

This function returns the version number of the Commander4j application.

<VERSION()>