Enterprise Resource Planning Blog Posts by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member198406
Contributor
98,928

Hi Gurus,

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 Kernel if Required

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 Create(F5).

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)

Mode:

A - AUTOMATIC

N - NUMERIC

L - ALPHANUMERIC

B - BYTE_LATIN1

K - KANJI

U - BYTE_UTF8

1 - FNC1_POS1 (FNC1 in first position)

2 - FNC1_POS2 (FNC1 in second position)

Module Size: Numeric User Entry

Error Correction Level:

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.

*YOTQR starts

*&---------------------------------------------------------------------*

*& Report  YOTQR2 this program dirctly print BMP file of any barcode

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT YOTQR.

PARAMETERS: barcode like tfo05-tdbarcode default 'ZQRCODE',

            barcdata(50) type c lower case default '1234567890',

            filename type string LOWER CASE default 'd:\1.bmp'.

DATA:errmsg(80)   TYPE c,

      bc_cmd       LIKE itcoo,

      bp_cmd       LIKE itcoo,

      bitmapsize   TYPE i,

      bitmap2_size TYPE i,

      w            TYPE i,

      h            TYPE i,

      bitmap       LIKE rspolpbi OCCURS 10 WITH HEADER LINE,

      bitmap2      LIKE rspolpbi OCCURS 10 WITH HEADER LINE,

      l_bitmap     TYPE xstring,

      otf          LIKE itcoo OCCURS 10 WITH HEADER LINE.

PERFORM get_otf_bc_cmd  IN PROGRAM sapmssco

                       USING barcode

                             barcdata

                             bc_cmd.

CHECK sy-subrc = 0.

bp_cmd-tdprintcom = 'BP'.

PERFORM get_otf_bp_cmd  IN PROGRAM sapmssco

                       USING barcode

                             bp_cmd-tdprintpar.

CHECK sy-subrc = 0.

PERFORM renderbarcode IN PROGRAM sapmssco

                     TABLES bitmap

                      USING bc_cmd

                            bp_cmd

                            barcdata

                            bitmapsize

                            w

                            h

                            errmsg.

CHECK sy-subrc = 0.

perform bitmap2otf IN PROGRAM sapmssco

                   tables bitmap

                          otf

                    using bitmapsize

                          w

                          h.

data length type i.

data hex type xstring.

data bitmap3 type xstring.

FIELD-SYMBOLS  <fs>   type x.

clear: hex, bitmap3.

loop at otf.

  length = otf-tdprintpar+2(2).

  assign otf-tdprintpar+4(length) to <fs> casting.

  hex = <fs>(length).

  concatenate bitmap3 hex into bitmap3 in BYTE MODE.

endloop.

* convert from old format to new format

hex = 'FFFFFFFF01010000'.

CONCATENATE bitmap3(8) hex bitmap3+8 into bitmap3 in BYTE MODE.

clear hex.

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.

  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

    EXPORTING

      buffer                = bitmap3 " xstring

    TABLES

      binary_tab            = bitmap4.

data bitmap4_size type i.

bitmap4_size = xstrlen( bitmap3 ).

CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP'

EXPORTING

   OLD_FORMAT                     = 'BDS'

   NEW_FORMAT                     = 'BMP'

   BITMAP_FILE_BYTECOUNT_IN       = bitmap4_size

IMPORTING

   BITMAP_FILE_BYTECOUNT          = bitmap2_size

  TABLES

    bitmap_file                    = bitmap2

   BDS_BITMAP_FILE                = BITMAP4

EXCEPTIONS

   NO_BITMAP_FILE                 = 1

   FORMAT_NOT_SUPPORTED           = 2

   BITMAP_FILE_NOT_TYPE_X         = 3

   NO_BMP_FILE                    = 4

   BMPERR_INVALID_FORMAT          = 5

   BMPERR_NO_COLORTABLE           = 6

   BMPERR_UNSUP_COMPRESSION       = 7

   BMPERR_CORRUPT_RLE_DATA        = 8

   BMPERR_EOF                     = 9

   BDSERR_INVALID_FORMAT          = 10

   BDSERR_EOF                     = 11.

  CALL METHOD cl_gui_frontend_services=>gui_download

    EXPORTING

      bin_filesize = bitmap2_size

      filename     = filename

      filetype     = 'BIN'

    CHANGING

      data_tab     = bitmap2[]

    EXCEPTIONS

      OTHERS       = 3.

*YOTQR Ends


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. Caution: keep the <c1> (small letters) not <C1> (capital Letters) otherwise QR code will not get Printed)

in this example, I've used material Number to be encoded in QR Code.

Test The SmartForm


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.

22 Comments
busyaban7
Active Contributor
0 Kudos

Thanks for posting this useful document. Keep posting such great stuffs!!

former_member198406
Contributor
0 Kudos

Hi, Thanks Arijit.

0 Kudos
Thank you very much!

And could you tell me how control the size of QR Code showed on SmartForms?

Its size is too large, even set Font Size = 1pt in SmartStyles.

Thanks again!
former_member256391
Participant
0 Kudos

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP' is giving me an error sy-subrc = '2'.

 

What is the cause. i am having ECC6.0 EHP7 SAP system

 
former_member198406
Contributor
0 Kudos
You can control the size of the QR Code using Module size field while configuration.

 

Thanks.
Former Member
0 Kudos
Im building a html email and would like to know how I can add the bitmap image of QRcode in the  body of the email
Mithran
Participant
0 Kudos
Dear Dipesh,

 

Thanks a lot.

When we try to create a new bar code and assign to QR Code, QR code is not displayed in the Supported Bar Code Symbologies Tab. Please do the needful.



Regards,

Mithran
usiefert
Explorer
Hi Mithran,

please have a look to OSS Note 2340474 - SE73: QR code cannot be selected.

Regards

Uwe
Mithran
Participant
0 Kudos
Hi Uwe Stefart,

Thanks a lot for replying and as you said Post Implementing the given SNote 2340474 issue got resolved.

Thanks again

Regards,

Mithran

 
former_member525396
Discoverer
I slightly modified this in order to use the FM IMPORT_BITMAP_BDS to store the result as a graphic (SE78).   When I use SE78 to review the result the QR barcode appears immense, the properties also suggest the standard result will be 4.47 x 4.34 CM at 600 DPI.  What would I need to do in order to produce a smaller QR barcode ? The former version which I coded used a link to chart.apis.google.com this link allowed me to specify dimensions eg. 50x50mm or 100x100mm depending on the length of the content, is here a way to code this example to produce similar results?

 
0 Kudos
Which API or any standard form is available for generating dynamic QR code based on invoice amount and invoice date as this is my current requirement? Thanks in advance!
benamor_bentebba
Participant
0 Kudos
Thank you so much 😉
0 Kudos
Hi benamor, looks you have achieved your requirement? Can able to help me how to call API to generate QR code using abap smrt or Adobe form?

 
0 Kudos
dipeshkumar.bhavsar

Thanks for providing codes with screenshot. can use your FM in Adobe instead of smartform as usual calling from driver program?
benamor_bentebba
Participant
0 Kudos
Hi swami100, I'm sorry I don't know , I'm using Smartform in my developpement.
former_member572496
Participant
0 Kudos

Hello Experts,

I am able to get the QR 2005 code in the smartform. The print preview was perfect.

But I am not able to Print in the zebra printer.

With out QR code i am able to print. When i include the QR code i am not able the print it.

 

Thanks,

Sainath.

0 Kudos
Hello Experts,

Why the size of QR code is not constant?

Why the long string QR code size bigger than the short string QR code size?

 

Thanks.

Michal.
linwang502
Member
0 Kudos

I have the same problem as you. Have you found a good solution?

 

Thanks.

amolnamjoshi_1
Participant
0 Kudos
Thanks for the nice documents and presentation.

 
0 Kudos

Dear Dipesh,

We are experiencing the problem related to 2D Bar code in our system. As we have to implement the E Invoicing solution in our system and it has the requirement of this bar code. We are on ECC 6.0. So please suggest how can we implement this into our landscape.

 

Regards,

Ravinder Singh

mynynachau
Community Advocate
Community Advocate
0 Kudos

Hi there,


You have a question and need help by the community? Instead of posting a blog post comment, it is more helpful for you, if you post a new question in Q&A. Here is how to get started:




  1. Learn about asking and answering questions in SAP Community with this tutorial: https://developers.sap.com/tutorials/community-qa.html

  2. Ask your detailed question here: https://answers.sap.com/questions/ask.html

  3. Wait for a response.


That's it.


Best regards


Your SAP Community moderator

mynynachau
Community Advocate
Community Advocate
0 Kudos

Hi there,


You have a question and need help by the community? Instead of posting a blog post comment, it is more helpful for you, if you post a new question in Q&A. Here is how to get started:




  1. Learn about asking and answering questions in SAP Community with this tutorial: https://developers.sap.com/tutorials/community-qa.html

  2. Ask your detailed question here: https://answers.sap.com/questions/ask.html

  3. Wait for a response.


That’s it.


Best regards


Your SAP Community moderator

Labels in this area