Skip to Content
Technical Articles
Author's profile photo Atulkumar Jain

Display QR Code for GST INDIA E-Invoicing on Script and Smartform

Hi Community,

This blog post has been drafted together with my colleague Rabindra Prasad regarding QR code display for GST INDIA E-Invoicing on Script and Smart Forms as many developers are facing problems to display proper QR code.

Please follow below steps to display it as expected.

In most of the cases, existing form will be altered to accommodate the QR code and other IRN details. This blog post is to fulfill the above requirement.

STEP 1:

Implement following SAP note with the help of basis:

  • 2880604 – GST India: IRN Data Dictionary Activities for Non-Integrated Solution

STEP 2:

After successful implementation of note and updating IRN details in J_1IG_INVREFNUM table from NIC portal, Please create smart style in SE73 for QR Code.

a. Select System Bar Code and Click on Change button.

b. Click on Create button.

Click on ‘NEW’ and follow below steps.

here we can adjust module size based on requirement.

click ‘OK’ and save in your TR.
It looks like as shown below:

Style for QR code is created.

Note: QR Code created in SE73 will be client independent.

STEP 3:

Challenges:

Signed QR code provided by NIC portal is usually more than 900 characters and Smart form or Script would not accommodate the entire QR code string in a single text variable in forms as it has a capacity to hold 255 characters.

Solution:

Smart Form:

1. Segregate your QR code string into multiple variables of type string.

Example:

qr_code1 type String,
qr_code2 type String,
qr_code3 type String,
qr_code4 type String,
lv_iteration type i,
lv_count type i,
lv_remainder_char type i.

lv_iteration = lv_count DIV 255.
lv_iteration = lv_iteration + 1.
lv_remainder_char = lv_count MOD 255.
DO lv_iteration TIMES.
CASE sy-index.
WHEN 1.
IF lv_iteration EQ 1.
qr_code1 = ls_irn_data-signed_qrcode+0(LV_REMAINDER_CHAR).
ELSE.
qr_code1 = ls_irn_data-signed_qrcode+0(255).
ENDIF.
WHEN 2.
IF lv_iteration EQ 2.
qr_code2 = ls_irn_data-signed_qrcode+255(LV_REMAINDER_CHAR).
ELSE.
qr_code2 = ls_irn_data-signed_qrcode+255(255).
ENDIF.
WHEN 3.
IF lv_iteration EQ 3.
qr_code3 = ls_irn_data-signed_qrcode+510(LV_REMAINDER_CHAR).
ELSE.
qr_code3 = ls_irn_data-signed_qrcode+510(255).
ENDIF.
WHEN 4.
IF lv_iteration EQ 4.
qr_code4 = ls_irn_data-signed_qrcode+765(LV_REMAINDER_CHAR).
ENDIF.
ENDCASE.ENDDO.

Pass these variables to your Smart form through your driver program or fetch the QR code and apply above logic in your Smart form.

  1. Create a “Paragraph Format” and “Character Format” using Tcode: ‘Smartforms’ , Select radio button ‘Style’ and create as below:

Name: ZQRCODE

   3. Create Standard Text using Tcode: SO10

Note: SO10 texts are Client Dependent.

4.Create Window of size 2X2 CM in smart form layout and provide created SO10 text in general attribute tab as below:

Text Name: ZQRCODE

5. In output options tab, maintain your style.

Style: ZQRCODE

Activate your logic, QR code will be printed as expected.

*———————————————————————————————————————————–*

Scripts

1. Write the same segregation logic mentioned as above and adjust your driver program.

2. Create Window of size 2X2 CM as per your requirement.

3. Create paragraph format for QR code:

4. Create character format for QR code and provide the system barcode which is created in Tcode: SE73

5. Write script logic as shown below:

Activate your logic, QR code will be printed as expected.

 

Conclusion:-

By this post we have provided procedure to segregate big string into smaller strings and actions to be taken appropriately on existing SAP Scripts and SAP Smart forms to display readable QR code.

Also make sure that QR code is client independent, hence it will reflect the same in connected testing client as well and SO10 texts are client dependent, hence you need to create separately in testing client.

 

Please feel free to comment if this solves your problem and let us know if any help is required.

Please do not forget to reward points if you feel this blog post is useful.

Assigned tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Schwing India
      Schwing India

      Dear Athul,

      Very Nice Blog.Its Helpful for me.Thanks for the Article...

      Regards,

      Madhan M

      Author's profile photo Atulkumar Jain
      Atulkumar Jain
      Blog Post Author

      Thank you.

      Author's profile photo Abhishek Shukla 
      Abhishek Shukla 

      Hi Atul,

      Once we have the JSON file structure from the IRP portal and we have uploaded the same on SAP in table J* then print will be issued from that table itself OR we have to read details from J* table and use that on our smartform to print the IRN / QR Code.

      Thanks

       

      Author's profile photo Edward Niedfeldt
      Edward Niedfeldt

      Thanks for the nice blog!  One comment about the cursor positioning in the ABAP.  I found that in SAP ABAP the last character of each variable QR_CODE1, QR_CODE2, QR_CODE3 was getting cut off because while it showed in the debugger, it was treated as 256 instead of 255 (because internally SAP treats the first position as 1, not 0.)

      To fix this, I had to adjust everything to 254 in the code and it worked perfectly:

          lv_iteration lv_count DIV 254.
      lv_iteration lv_iteration + 1.
      lv_remainder_char lv_count MOD 254.

      DO lv_iteration TIMES.
      CASE sy-index.
      WHEN 1.
      IF lv_iteration EQ 1.
      qr_code1 ls_irn_data-signed_qrcode+0(lv_remainder_char).
      ELSE.
      qr_code1 ls_irn_data-signed_qrcode+0(254).
      ENDIF.
      WHEN 2.
      IF lv_iteration EQ 2.
      qr_code2 ls_irn_data-signed_qrcode+254(lv_remainder_char).
      ELSE.
      qr_code2 ls_irn_data-signed_qrcode+254(254).
      ENDIF.
      WHEN 3.
      IF lv_iteration EQ 3.
      qr_code3 ls_irn_data-signed_qrcode+508(lv_remainder_char).
      ELSE.
      qr_code3 ls_irn_data-signed_qrcode+508(254).
      ENDIF.
      WHEN 4.
      IF lv_iteration EQ 4.
      qr_code4 ls_irn_data-signed_qrcode+762(lv_remainder_char).
      ENDIF.
      ENDCASE.
      ENDDO.