4 Replies Latest reply on Aug 4, 2017 2:15 PM by Jason Humberstone

    Using ^SF command when populating a field defined in a recalled stored format

    Jason Humberstone

      Hello,

       

      I'm using a ZT420 printer with ZPLII.

       

      Can anyone please tell me why my serialised field is incrementing fine with this code:

       

      ^XA

      ^XFE:PRODUCT.GRF

      ^FS^FT296,1056

      ^FDBL0000

      ^SFAAdddd,1

      ^FS

      ^PQ2

      ^XZ

       

      However, when I use this similar code that uses a field defined in the PRODUCT.GRF stored format, the serialised field isn't incremented.

       

      ^XA

      ^XFE:PRODUCT.GRF

      ^FS

      ^FN1

      ^FDBL0000

      ^SFAAdddd,1

      ^FS

      ^PQ2

      ^XZ

       

      The field definition in the PRODUCT.GRF stored format is:

       

      ^FT296,1056

      ^FN1

      ^FS

       

      Is this expected behaviour? If not, can you tell me what I need to do to get the approach in the second piece of code working, please?

       

      Thanks,

      Jason.

        • Re: Using ^SF command when populating a field defined in a recalled stored format
          Samantha Corn

          Hi Jason,

           

          The issue is that when you are calling the format, the ^FN1 command is only looking at the ^FD command directly after it, completely ignoring the ^SFAAdddd. If the field data format is always the same (two letters, four numbers), you can move the ^SFAAdddd,1 inside the stored format after the ^FN1. I did it with this basic format:

           

          ^XA

          ^DFR:PRODUCT.GRF^FS

          ^FO25,25^A0N,50,50^FDZebra Printer^FS

          ^FO25,75^A0N,50,50^FDSerial Number^FS

          ^FO25,150^A0N,50,50^FN1^SFAAdddd,1^FS

          ^XZ

           

          Which I was able to print the correct serial numbers using:

           

          ^XA

          ^XFR:PRODUCT.GRF

          ^FS

          ^FN1

          ^FDBL0000

          ^FS

          ^PQ2

          ^XZ

            • Re: Using ^SF command when populating a field defined in a recalled stored format
              Jason Humberstone

              Hi Samantha,

               

              Thank you for the fast response. I can't try it at the moment but I think that will work fine.

               

              Just to satisfy my curiosity, is there therefore no way to define the position (and other similar visual attributes) of a serial number field in the stored format, whilst defining the mask and the data the mask applies to in the code that recalls the format?

               

              Thanks again,

              Jason.

                • Re: Using ^SF command when populating a field defined in a recalled stored format
                  Samantha Corn

                  Hi Jason,

                   

                  Apologies, I figured out another way to do it without defining the string in the format. You can use the ^SN command, which more or less combines the ^FD and ^SF commands. Full documentation can be found on page 312 of the ZPL Programming Guide. I did it by removing the ^SF from the format above and changing the second ZPL part to:

                   

                  ^XA

                  ^XFR:PRODUCT.GRF

                  ^FS

                  ^FN1

                  ^SNBL0000,1,Y

                  ^FS

                  ^PQ2

                  ^XZ

                    • Re: Using ^SF command when populating a field defined in a recalled stored format
                      Jason Humberstone

                      Thanks Samantha. That leaves me with one more question, please.

                       

                      The code I posted was simplified to demonstrate the original problem I had more clearly. The actual code I have is constructing a GS1 DataMatrix barcode containing application identifier 21; a serial number.

                       

                      I apologise but I haven't got the exact code to hand at the moment, but it is basically defining a stored format with a numbered DataMatrix barcode field. The code is then recalling that format and populating the field with the character sequence required to construct valid GS1 element strings, using ^FD.

                       

                      If the character sequence is. _110_12100, I then need to increment the digits after the 21 by one for each label printed.

                       

                      The calling code is something like this:

                       

                      ^XA

                      ^XFR:PRODUCT2.GRF

                      ^FS

                      ^FN1

                      ^FD_110_12100

                      ^FS

                      ^PQ2

                      ^XZ

                       

                      , with FN1 being the DataMatrix field defined in the stored format.

                       

                      Am I right in saying that specific task can only be done with the ^SF command and in order to define the field's visual characteristics (like position) in the stored format, the mask will need to also be defined in the stored format? Or is there some way ^SN could work in this case too?

                       

                      Thanks again for your help,

                      Jason.