Check out these blogs for further information and background to printing QRcodes/barcodes in SAP.
SDN Blog Barcode in SAP with the Barcode in Pure Postscript
Overview of BWIPP in SAP
Two general issues have come up in printing QRcodes in smartforms. Both relate to the text intended for the barcode being shown on the page and the QRcode/barcode generated but blank (and unreadable). So I will cover the fix for both issues below.
1) Smartform Print contol missing.
As covered in the comments section of the SDN blog
Check the raw format of the spool request. (send the print to the spool and not print immediately)
In SP01 when viewing your output requests, select on the menu screen, 'Goto' --> 'Display Requests' --> 'Settings', and select RAW format. and search for ZBW01 and ZBW02 then print control ZBW01 may not show up. For testing purposes swap out the device type and print controls for SAP standard and see if they appear.
The work around/fix was as follows.
In the smartform the setup was as below and did not create a proper barcode.
LOOP
..
.CELL
..PRINT CONTROL ZBW01
..TEXT FOR BARCODE
..PRINT CONTROL ZBW02
Turns out the missing print control occurs even with SAP standard print controls so is a smartform issue/feature and not related to the device type.
So the fix
Change to
LOOP
..
.CELL
..TEXT - empty / or blank lines to make room for the barcode
..PRINT CONTROL ZBW01
..TEXT FOR BARCODE
..PRINT CONTROL ZBW02
The above issue is normally only related to text boxes in a loop as standalone text boxes work as standard.
2) Format used in the text box for the barcode
There is a section in the SDN blog about "Identify the Text for the Barcode" so if I print the relevant section below.
"Standard formatted text can appear with the "s" command however sometimes especially if small text formatting is used other postscript procedures such as "w1" and "w2" appear. So any new form or output that requires a barcode should be output to a flat file. This is to check the file for the postscript formatting and commands used by SAP. This can be useful to note where to insert postscript commands via print controls (also for any trouble shooting). A tip for smartforms and sapscript is to search for lines with "<~" and "~>" as this signals ASCII85 encoded text. "
As the smartform will be converted to postscript then the way the smartforms text format is converted is vital to allow the barcode to be printed.
a) So lets start by creating a Windows frontend printer that prints purely text.
This will be used to create a text file of the SAP generated postscript.
Follow this note but use the QRcode/barcode device type
Note 576973 - Creating a file printer on a Windows PC
b) send the smartform to the new frontend printer.
You will be prompted for a file location so enter c:\smart.ps for example (the full path must be entered).
c) open smart.ps and search for /s {bct exch ctxt which is the start of print control ZBW01.
In your smartform there is some formatting to do with the width/size of the text so the normal postscript s command is not used and therefore the qrcode is not displayed correctly.
*NOTE, in the following example I will use postscript w1 and w2 as an example, the exact formatting may be different in your smartform, leave a comment and I will get back to you.
Here is an extract of some formatting I tested with a copy of the SF_EXAMPLE_01 smartform.
Screenshot of Smartform Formats used in a Text Box
Screenshot of the Postscript code generated by SAP for the smartform
*Note I have added the ASCII85 decoded text myself to show in this example.
Note the only line not using the postscript s command is the "small key word" text which uses the w1 and w2 postscript commands
The postscript commands w1 and w2 are used instead of the S command. Therefore to keep the formatting in the smartform we can add two new print controls.
Add print controls
ADD TWO new print CONTROLS
ZBW90 = /w1 {bct} def \n/w2 {ctxt /bct exch def} def\n
ZBW91 = /w1 {SW 0 8#040} def \n/w2 {widthshow} def \n
e) Change the smartform to include the new print controls
..TEXT - empty / or blank lines to make room for the barcode
..PRINT CONTROL ZBW90
..TEXT FOR BARCODE
..PRINT CONTROL ZBW02
..PRINT CONTROL ZBW91
Basically the ZBW90 changes the W1 and W2 commands to allow the concatenation of the text.
ZBW02 is the same command to generate the QR code.
ZBW91 resets the W1 and W2 to SAP standard postscript.
f) Print the smartform to the original QRcode(barcode) printer.
Any comments let me know happy to help.
6 comments:
Dear sir.
I'm able to print the QRcode through my system.
the problem im facing is that I'm unable to seperate the fields.
Like i have two fields. A B having 1 2 when i scan the code data shown to me is on the same line i want to separate them into new line like A 1
B 2
please help me what should i do..
I'm using this code.
LOOP AT gs_it_gen.
PRINT-CONTROL FUNCTION 'ZBW01'.
WRITE: 'Dispatch Note Number:', gs_it_gen-deliv_numb.
WRITE: 'Item Number:', gs_it_gen-itm_number .
WRITE: 'Material:', gs_it_gen-material .
WRITE: 'Batch:', gs_it_gen-batch .
WRITE: 'DLV.Qty',gs_it_gen-dlv_qty .
PRINT-CONTROL FUNCTION 'ZBW02'.
SKIP 10.
ENDLOOP.
Hi,
Good to hear you can print qrcodes on your system.
If I understand your requirements correctly, to achieve the separate lines in the scanned qrcode, then try the following.
Use the barcode writer in pure postscript "parse" option to add a line feed and carriage return as shown in the example below.
data: simpletest1 type string,
simpletest2 type string.
simpletest1 = 'hello'.
simpletest2 = 'qrcode'.
write: 'simple test adding line feed and carriage return'.
*leave gap for qr code
skip 6.
PRINT-CONTROL FUNCTION 'ZBW01'.
*print control ZOP01 sets the parse option for the barcode *writer in pure postscript
PRINT-CONTROL FUNCTION 'ZOP01'.
*NO-GAP required to remove the gap ^010^013 is the ascii *code for line feed & carriage return
WRITE: '1st line', simpletest1, '^010^013' NO-GAP.
WRITE: '2nd line', simpletest2, '^010^013' NO-GAP.
PRINT-CONTROL FUNCTION 'ZBW02'.
Let me know how you get on.
Cheers
Robert
Hi Robert,
Thank you for the detailed blog.
I need your help in printing the QR Code. We have configured the device type and all other settings. We are able to see the QRCODE generated through SMARTFORMS in the PDF Generated through CutePDF printer. But the problem is if we print using the Frontend printer, we are getting errors (Error in printing). We are using TEC SA4T TOSHIBA Model to print the QR Code.
Kindly help us in finding the root cause.
Thanks in advance for your support.
Best Regards,
Ranjan
Hi Ranjan,
I have never heard of the printer you are using, so after a quick Google search it appears to be a dedicated barcode printer. It appears to support QRcodes itself so I would check with Toshiba manual to see if it supports SAP directly.
As for Barcode Writer in Pure Postscript method in this blog then the printer needs to support postscript. If you check the manual it may state which level of postscript it supports (if any).
Cheers
Robert
Hi Robert
Thanks a lot for your useful tutorial!
It sadly doesn't work on my system. I would like to output a DataMatrix in SmartForms. Topically the DataMatrix will be putted out but the value is always the same (value=À). The structure in my SmartForms as same as you posted in the troubleshooting post. It never consider my value between the commands with the printer controls ZBW01 and ZBW02.
Are you aware with this problem and have a solution for that?
Best Regards,
Peter
Hi Peter,
Thanks for taking time to comment and ask the question, I am happy to help where I can. Having said that you have caught me on holiday for the next 2 weeks, so no real access to test or confirm things.
However I would suggest checking out the BWIPP wiki page for DataMatrix,
https://github.com/bwipp/postscriptbarcode/wiki/Data-Matrix
Here you can find that the BWIPP supports the extended ASCII characters.
Therefore you can use the parse option to confirm with the ASCII value to confirm that the character can be generated.
You can try the online BWIPP here
http://www.terryburton.co.uk/barcodewriter/generator/
although not the exact same version used in the SAP device type should give you a quicker indication that the character can be encoded before trying with SAP.
Drop me a reply via email if you want further information. My email address can be found here.
http://scn.sap.com/people/robert.russell2
Like I say happy to help but may be delayed in replying right now.
Cheers
Robert
Post a Comment