原文地址 https://blogs.sap.com/2016/05/12/qr-code-or-2d-bar-code-in-sap/
I have came across requirement of Printing QR Code (Quick Response Code) or 2D Bar Code on Smartforms or Download it as an Image file.
Here, I am going to explain "How it can be done?"
Step 1: Upgrade the
Log in to the SAP >> SAP Easy Access Screen >> System Menu >> Status
Now, Click on the component to check the SAP_BASIS release 731
Close the pop-up dialog and click on the arrow button. The Kernel Version Should be 321 or superior. If it is not then ask your Basis Team to upgrade it.
Step 2: Implement SAP Note 2029824
Ask the Developer to implement the note
2029824 – Support for QR code and data matrix bar code
Step 3: SAP Script Font Maintenance
After successful implementation of the SAP Note. Go to Transaction SE73.
Click on System Bar Code option and Click on Change.
Click on New (new Barcode Technology)
Define the Name and Description of the Bar code.
Select Bar Code Symbology as "QR Code 2005" and Click OK. Select Alignment as "Normal"
Choose Mode, Module Size, Error Correction Level (Refer the SAP note 2030263 for further information)
1 – FNC1_POS1 (FNC1 in first position)
2 – FNC1_POS2 (FNC1 in second position)
Module Size: Numeric User Entry
L – 7 % Error Correction capability
M – 15% Error Correction capability
Q – 25% Error Correction capability
H – 30% Error Correction capability
Save the Bar Code Definition. Select the same and Test.
Step 4: Create Program to Download the QR Code as BMP (image File)
Write the below code in the SE38 Program. This Program can download the QR Code as image (.bmp format) on your presentation system.
*& Report
PARAMETERS: barcode like tfo05-tdbarcode default 'ZQRCODE',
PERFORM get_otf_bc_cmd
PERFORM get_otf_bp_cmd
PERFORM renderbarcode IN PROGRAM sapmssco
perform bitmap2otf IN PROGRAM sapmssco
* convert from old format to new format
CONCATENATE bitmap3(8) hex bitmap3+8 into bitmap3 in BYTE MODE.
shift hex right by 90 places in BYTE MODE.
CONCATENATE bitmap3(42) hex bitmap3+42 into bitmap3 in BYTE MODE.
data bitmap4 type SBDST_CONTENT.
bitmap4_size = xstrlen( bitmap3 ).
CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP'
Step 5: Create Smartstyle for QR Code
Define your Smartstyle as below screenshots
Define the QR Code in Character Format as below Screenshot
Step 6: Use SmartStyle in SmartForm
Define the smartstyle in the form attributes as per the below screenshot
Define Text as below screenshots.
in this example, I've used material Number to be encoded in QR Code.
We can use the same procedure to include the QR code on your SmartForms.
This Bar Code can encode up to 255 characters (it is the limit).But, I think, 255 characters enough.
Using this you can shrink the size of your label. You can encode the address information as QR Code and save the space on the form for more details and many more.
END
本人测试结果
最后,感谢群内同行