Friday 30 October 2020

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

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 fulfil 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.

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

b. Click on Create button.

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

Click on ‘NEW’ and follow below steps.

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

here we can adjust module size based on requirement.

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

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

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

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.

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

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

Name: ZQRCODE

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

3. Create Standard Text using Tcode: SO10

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

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

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

5. In output options tab, maintain your style.

Style: ZQRCODE

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

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:

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

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

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

5. Write script logic as shown below:

SAP ABAP Tutorial and Material, SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Learning

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

No comments:

Post a Comment