Thursday, April 24, 2014

SAP Smartforms + KYOCERA printer = DMC, QR codes work

Once I had to solve following task, print DMC square codes on Kyocera printers without any third party software. It is a reasonable step to replace all line bar codes with one square code containing all needed.

Because SAP does not support internally these codes, it is a bit challenge. The task did not allow usage of any software due to CPU time consumption during code rendering on server side.
Kyocera printers comes with interesting "option". You can print QR, DMC and really long list of various codes on their printers IF, If you buy small additional piece of hardware so called flash module. It allows you to trigger printer internal PCL commands producing bar codes as you wish. OK, it seems to be a solution. And you can suspect here, if there is some article concerning the topic, the way is not blind. Yes, it works! :)

So, what's needed?


At first we need plug a flash module into the printer. Kyocera produces various types of compact flash cards, types A, B, C... Here be careful, there is a list of supported cards for every printer. It means, you need to have proper card for your Kyocera printer. Note: flash card can be possibly flashed to upper version.

You need device driver supporting used printer language. You can choose standard PCL or Kyocera proprietary language called PRESCRIBE. This article is focused on usage of Prescribe.

In my case I used KYOAAA1C driver for my Kyocera FS-2020D.

List of suitable drivers:

  •       KYOAAA1C   KYO FS2000/3900/4000 PCL POSS
  •       KYOAAB1C   KYO FS95XX PCL POSS
  •       KYOAAC1C   KYO KMX050 PCL POSS
  •       KYOAAD1C   KYO FSC5400/FSC5300 PCL POSS
  •       KYOAAE1C   KYO FS1028/1128MFP PCL POSS
  •       KYOAAF1C   KYO TASKalfa XXXci PCL POSS  


For full list look at: http://www.stechno.net/sap-notes.html?view=sapnote&id=1135057#sthash.EMTwTPm8.dpuf

Now we can move on


Thing is not too complex. Some base explanation of DMC parameters is given just here. I recommend to download PDF from Kyocera website to understand usage of wanted code in depth. By the same way you can use QRs, DMCs and so on...

In general we need just some text element with proper font style. Style is very important, because SAP text element automatic line breaks destroy Prescribe command. So keep in mind you need to have:

  1. Window with enough space, usually simply MAIN window is a good option.
  2. Whole command must be in preview visible on ONE line. No breaks are possible. That's why we use for text element special very small font size as protection against automatic line breaks. 

Setup style


Style is setup in transaction Smartforms. Use font size 1 pt to save a space.


Setup global variables for DMC code


We can include whole DMC code string into one variable. But SAP limits length of text string used in SF up to 255 characters. That's why is better choice to separate prefix and suffix of the code to gain more space for the content itself.


Preparation of DMC content in initialization part


You can call some custom routines placed directly in SF to make a content of the code. Here we are preparing also Prescribe command itself, I mean prefix and suffix.



Whole code of init can looks like:


* DMC code properties (printed via Prescribe)
DATAlv_code_type       TYPE string" type of square code
      lv_dmc_symbol_from TYPE string,
      lv_dmc_symbol_to   TYPE string,
      lv_dmc_position_x  TYPE string,
      lv_dmc_position_y  TYPE string,
      lv_dmc_module_size TYPE string.

* DMC dimensions
lv_code_type        '100'" 100 means DMC
lv_dmc_module_size  '13'.  " size of the small squares with dimension of 13 dots (pixels)
lv_dmc_symbol_from  '11'.  " min. size
lv_dmc_symbol_to    '19'.  " max size
lv_dmc_position_x   '738'" horizontal in px
lv_dmc_position_y   '960'" vertical in px

PERFORM get_dmccode_content
  USING    label_data2
  CHANGING gv_dmc_content.

" Prescribe DMC prefix + suffix definition
CONCATENATE '!R! UNIT D; MAP ' " Note: UNIT D = pixels, MAP = position
            lv_dmc_position_x ','
            lv_dmc_position_y
            '; BARC ' lv_code_type " BARC = print barcode
            ',' lv_dmc_module_size
            ',' lv_dmc_symbol_from
            ',' lv_dmc_symbol_to
            ',0,0,"'
INTO gv_dmc_prefix RESPECTING BLANKS.
gv_dmc_suffix   '";EXIT;'.


DMC size on paper


The "module size" is the size of the small squares from which the bar code is built. If you use the command "UNIT D;" the unit is set to dots (pixels), e.g. the value 15 here means 52 x 52 rows. Final size of the DMC code depends on the length of content. If you set up min - max range for symbol attribute of DMC, system  tries to use the smallest possible one according to content length.

Display DMC code


Display gained global variables in text element via proper style. Prescribe command should be the very first thing sent to the printer, see hierarchy below.


Remember the used style above is too small to understand the idea. If I would enlarged version of picture above and view it by bigger font style, it would look something like below. In real we are inserting three different lines in order prefix, next row of content and finally suffix row.



How to overcome the limits


With system bar code (SE73) you can encode max. 255 characters in Smart Forms and max. 70 characters in SAPScript. With bar code formatted as text, the case of here described solution,  you can encode as much as you can place in one line. Maximum length of a field in Smart Forms is 255 characters.
Therefore you have to split the barcode data into several fields, if you want to encode more than 255 characters. 

Text element content

&DMC_PREFIX&
&DMC_DATA_FIELD_1&&DMC_DATA_FIELD_2&&DMC_DATA_FIELD_3&
&DMC_SUFFIX& 

Addition
See the SAP note Sap note 497380 - Maximum bar code length

Troubleshooting part 


You can test the setting of printer including the message  "codes not loaded" by following Prescribe command: "!R! CALL BSTP; EXIT;" Simply place the command into new text element and try to print out. By this command you would able to see any printer start up error. It would be nice to see if module is working properly.

The proper print driver could be tested by following commands. If print out would be successful, you know, driver works. But it is not telling you anything about bar code module yet.

Example 1

!R! UNIT C; MRP 3, 3;
SFNT "Univers-MdCd", 12;
MRP 3, 3;
CIR .35;

Example 2

!R! RES; PSRC 1;
SFNT "Helvetica", 10;
MZP 3, 3;
RTTX 15, " ----- Text1...";
RTTX 45, " ----- Text2...";
RTTX 75, " ----- Text3...";
PAGE; EXIT;

Finally many thanks to Mr. Norbert Volk-Klee for his precious Prescribe support.

Wish you happy printing cool codes!

3 comments:

  1. Amazing site! I have got lots of useful information about SAP Smartforms and KYOCERA printers through this post. I am very excited to see your next posts for getting useful knowledge.

    ReplyDelete
    Replies
    1. Thanks a lot for ecouraging words without any advertisement :)

      Delete
  2. Kyocera printer work is amazing and too clean.Where we think about kyocera then it has great quality or make business success.

    ReplyDelete