Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
********************************************************************************************

Update 1: 6th of May  - Latest updates  post release of solution for all customers

*********************************************************************************************

Update 2 : 16th of June - Update on overcoming the fixed size QR Code restriction with SAPscript/Smartform technology

********************************************************************************************

Update 3: 15th of November 2021 - In case of any issues with Note implementation, kindly raise a support ticket in the corresponding note component area.

********************************************************************************************

Starting June 2020, it would be legally required in Switzerland to generate a QR Bill payment part for all outgoing invoices. The SAP solution for printing QR Bills of SD invoices has been released in the collective note 2910269. The solution will enable you to generate a legally compliant print out adhering to the style guide published in the Swiss payment standard website

https://www.paymentstandards.ch/en/shared/news/2019/qrr-style.html

 

This blog post would be helpful if you are not directly using the SAP standard solution and doing a custom implementation for QR Bill Invoice printing.

 

As a part of the standard solution SAP has delivered certain templates and routines and I will explain the end to end process for handling the QR Bill invoice printing.  Based on your requirement, you can decide to simplify the custom implementation activities based on the recommendations below.

 

Step 1 : Creation of the Form Template

 

Form Data Providers Interface/SEGW Service:

Pre-requisite for developing a  Output Form template is defining and developing a Data provider. SAP has delivered a reference XFA Form interface as well as  XFA2 OData  based Gateway Service as Form Data Providers (details in Note 2910269), which could be copied/reused/referred to when creating your own Form Data Provider. The SAP design was to split the data provider into 2 parts to give a direction for customers when developing custom forms to only adjust the deltas while transitioning  from ESR regime to QR Bill regime.

  • Invoice Information: This is the basic Billing Document header/Item information along with the associated Material and Customer Master Data information and certain pricing information. With QR Bill there wouldn't be a change to this part compared to the prior ISR invoice and mechanism  to fetch the information from the Billing document could be reused from ISR invoice for  QR Invoice printing.


 

  • QR Bill Payment part: This consists of following components

    • Account / Payable to: In this section the account of the payee and its address is shown.

    • Reference: Here we can see either a 27 digit QR-Reference or a 25 digit ISO 11649 Creditor reference.

    •  Additional Information: Consists of unstructured information and structured information, the so-called SWICO tags.

    • Payable by: Contains the address of the payer

    • Swiss QR Code with  the embedded Swiss Cross at the center.

    • Control Data parameters from T049Q for dynamic layout adjustments

    • SAP has delivered routines to fetch the QR Bill payment information corresponding to the SD invoice. The ABAP structure defining the skeleton of the QR Bill payment part as well as coding logic routines to fetch the data could be directly reused in print programs/gateway service classes




 

The skeleton of XFA interface/ XFA2 gateway service is as shown in the images below





The XFA2 gateway based service can be delivered by release/support pack only. If you are not planning to upgrade to the latest support pack, via SAP notes only the interface based SAP standard form would be available.

 

QR Bill Style guide explains different ways/formats/languages in which the QR Bill could be printed.

  • Languages :SAP supports the printing of QR Bill Invoice in German/French/English/Italian, and mandatory headings in different languages are automatically adapted in the language you want to print the form. To achieve this, the headings in the layout should be made dynamic and SAP has delivered interface with legal headings in different languages "IF_CL_QRBILL_UTIL_XX" where XX is the language key and could be DE/FR/IT/EN


 

  • Formats :  In the SAP delivered configuration for QR Bill Control you can choose the following

    • PDF output form with scissors/separated lines: means that the payment part of the invoice is separated with the scissors icon or with a separation line from the actual invoice data in the PDF output.

    • Integrated QR-Bill A4: means that the QR-bill is part of the invoice.

    • Separated QR-Bill A5: means that the QR-bill is generated separately and is not part of the invoice.

    • Amount formatting is dynamically done based on the control data configuration




 

To achieve this, certain control parameters needs to be added in the Form Data Provider to dynamically adjust the layout. This logic for such dynamic layout adjustment based on configuration T049Q should be done at the layout script level. Reference can be taken from SAP delivered standard forms

 

Form Template

 

SAP form strategy is to deliver only Adobe forms as standard solutions. For QR Bill, SAP has delivered a reference QR Bill invoice adobe form template as described in note 2910269.

SAP’s approach for achieving the fixed size QR Code with the Swiss Cross, was using an Image Element in the form rather than a Barcode Element.

  • With the Bar Code element, there are 2 challenges we faced





    • Adobe  Forms does not support fixed size QR code element and the sizing of the QR code is dynamic based on the Data used for encoding. This means, in the form if a Swiss QR is an Barcode Element, then the style guide rules cannot be adhered to







    • Generating a QR code with a Cross in the middle (“Swiss QR Code Standard”) isn’t supported by Adobe yet




 

  •  To overcome this, in the reference Adobe Form template which SAP has designed, SAP used an image based approach





    • The SAP BASIS Class routine (CL_RSTX_BARCODE_RENDERER => QR_CODE), delivered via note 2790500, is used to fetch the QR Code Image in BITmap format.







    •  In the Form Data Provider( Interface/Gateway)  an Image Element variable is created  (Graphic/Image String)





 



    • In the Form Layout, there would be 2 elements of Image Type. One Mapped to the QR Code Image. Second one would be the static Swiss cross Image




 


 



    • There wouldn’t be any data loss, due to superimposition of the Swiss cross over the QR Code image.




 

There are limitation in SAPscripts and Smartform technology to achieve a the Swiss QR code, either by the image approach or the barcode element approach

  • Only static images which are uploaded in the application server can be used in the form. The design for Adobe forms explained above uses a dynamic QR Code generation as an image which is not feasible in SAPscript/Smartform technology. Additionally superimposition of Swiss cross over the bar code too isn't possible with the dynamic image approach, as it needs to be uploaded to the application server

  • Even though QR Code Barcode element is supported in SAPscript/Smartform technology, the sizing is dynamic based on the text input.  Similar to adobe forms, achieving fixed size QR Code with Barcode element is not possible.


 

Update : To overcome these restrictions in SAPscript and Smartform, SAP has provided design/implementation recommendations in the consulting note 2937591.  The following steps would be helpful only if you are using Smart forms or SAPscript for the QR Bill invoice. The High level design block for achieving the style guide specifications are as follows

1. Creating the QR Code

Create the QR Code in BITMAP format passing the invoice data and certain fixed QR Code generation control data as shown in the code block below. This would be the same routine as explained for Adobe forms in the prior sections
        cl_rstx_barcode_renderer=>qr_code(
exporting
i_module_size = l_module_size "Module Size should 10
i_mode = co_mode "Mode should be U
i_error_correction = co_err_corr "Error Correction should be M
i_rotation = 0
i_barcode_text = i_qrcode_data "String for QR code generation as per the Data Structure
importing
e_bitmap = e_bitmap "QR Code Output in BITMAP format

2. Re-Scaling the QR Code Image

The QR Code Output should be re-scaled based on the Print resolution. If the print resolution is 600 DPI, to achieve a 46*46 mm QR Code, it should be scaled to 1087*1087 pixel. This needs to performed every time as the data input to the QR code generator might vary in character size. Based on the character size, the bar code rendering utility would return an image of variable size.

 

Following is the sequence to adjust the dimension

  • Calculate the current Image size
    * create FXS-object and add bitmap
    data(lr_ip) = new cl_fxs_image_processor( ).
    data(lv_hndl) = lr_ip->add_image( lv_bitmap ). "Bitmap Output from Step1


    * Method to extract the Image size
    lr_ip->get_info( exporting
    iv_handle = lv_hndl
    importing
    ev_mimetype = lv_mimetype
    ev_xres = lv_xres "Contains the Width size
    ev_yres = lv_yres "Contains the Height size
    ev_xdpi = lv_xdpi
    ev_ydpi = lv_ydpi
    ev_bitdepth = lv_bitdepth ).


  • Recalculate the Module Size based on the extracted Image Height/Width Size


* we need a height of 1087 pixel to get the print-size of 46mm at 600dpi.
"c_module_size is 10 used in step 1 to generate the QR Code BITMAP
"lv_yres is width size extracted in the previous step

l_new_module_size = c_module_size * 1087 / lv_yres.


  • Once the required dimension is nearly achieved after looping the action in the previous steps, generate the QR Code again with the recalculated Module size, as explain in step 1 using "cl_rstx_barcode_renderer=>qr_code". Since module size can only be specified as an integer value, there could be rounding errors resulting in QR Code size difference of approx. +/-1mm.


3. Swiss Cross Logo

The Official logo downloaded using the link, available under https://www.paymentstandards.ch/de/shared/communication-grid/swiss-qr-code.html, has a white background. Smart form interprets this as transparent and doesn't completely cover the QR Code. In the note 2937591, you can find a .BMP image file attached, which overcomes the problem by performing the following

  • Convert Image of PNG to BMP

  • Increase Color Depth to 8Bit (256 Colors)

  • Replace white background color with a light gray background - for example, RGB: 240, 240, 240


This image needs to be uploaded in SE78 as explained in the note 2937591


 

4. Form Layout and Processing

With the restriction of using only Static images for form rendering, the QR Code image needs to be uploaded via program logic in the print program, each time the form is rendered. Separate SE78 image object space in the application layer for QR Code Image. Every time the QR Bill is printed, this space is used for uploaded, overwriting the QR Code image. Optimized coding example is explained in the note 2937591
"Further Processong of extracted BITMAP image in prior steps

data(lt_bin_data) = cl_bcs_convert=>xstring_to_solix( iv_xstring = i_bitmap ).

"Static Space for QR Code generation which is overwritten when rendering a new QR Bill
ls_stxbitmaps-tdname = 'ZZ_TESTQRCODE_SWISSQR'.


ls_stxbitmaps-tdobject = 'GRAPHICS'.
ls_stxbitmaps-tdid = 'BMAP'.
ls_stxbitmaps-tdbtype = 'BMON'.

l_bytecount = xstrlen( i_bitmap ). 

ls_stxbitmaps-resident = off.
ls_stxbitmaps-autoheight = on.


* enqueue bds graphic
call function 'ENQUEUE_ESSGRABDS'
exporting
tdobject = ls_stxbitmaps-tdobject
tdname = ls_stxbitmaps-tdname
tdid = ls_stxbitmaps-tdid
tdbtype = ls_stxbitmaps-tdbtype
exceptions
foreign_lock = 1
others = 2.

if sy-subrc <> 0.
exit.
endif.

call function 'SAPSCRIPT_CONVERT_BITMAP_BDS'
exporting
color = off
format = 'BMP'
resident = off
bitmap_bytecount = l_bytecount
compress_bitmap = off
importing
width_tw = ls_stxbitmaps-widthtw
height_tw = ls_stxbitmaps-heighttw
width_pix = ls_stxbitmaps-widthpix
height_pix = ls_stxbitmaps-heightpix
dpi = ls_stxbitmaps-resolution
bds_bytecount = l_bds_bytecount
tables
bitmap_file = lt_bin_data
bitmap_file_bds = lt_bds_content
exceptions
format_not_supported = 1
no_bmp_file = 2
bmperr_invalid_format = 3
bmperr_no_colortable = 4
bmperr_unsup_compression = 5
bmperr_corrupt_rle_data = 6
tifferr_invalid_format = 7
tifferr_no_colortable = 8
tifferr_unsup_compression = 9
bmperr_eof = 10
others = 11.

if sy-subrc <> 0.
* conversion error
* dequeue bds graphic
call function 'DEQUEUE_ESSGRABDS'
exporting
tdobject = ls_stxbitmaps-tdobject
tdname = ls_stxbitmaps-tdname
tdid = ls_stxbitmaps-tdid
tdbtype = ls_stxbitmaps-tdbtype.


exit.
endif.

And in the Smart form script,  at specific positions
"For QR Code Image which has a static SE78 space reserved

/: BITMAP &G_BDS_NAME1& OBJECT GRAPHICS ID BMAP TYPE BMON DPI 600


"In the same screen space the Swiss Cross static image is superimposed

/: BITMAP 'ISH_CH_SWISS_CROSS_COL' OBJECT GRAPHICS ID BMAP TYPE BCOL DPI 600

 

 

Step 2 : Configuration Of Output Management

  • NAST Output Management


 



    • Prerequisite is have the form template as explained in the Step 1 ready. Additionally a print driver program would be required. Print program should perform the following

      1. Get the Invoice information to be mapped to in the interface. As explained in Step 1, the existing solution for ISR invoice print program can be reused for the QR Bill print program, as the changes are only related with the payment part.

      2. Get The QR Bill payment part to be mapped in the Form interface. QR Bill payment part should be structured in the same way as SAP standard form interface, then the routines explained in the note  can be reused for getting the QR Bill Payment part data.

      3. Perform the standard print processing technical flow, where you open the print jobs and finally call the Function module corresponding to your Form template sending the information extracted in point 1 and 2.

      4. To better understand the SAP print program, the invoice/ payment part information fetching have separate "GET" routines and print processing is done in separate routine.






 



    • A sample Output management config via transaction code NACE is shown below

      • Create a new output type for Billing Area (V3)












      • Assign the newly created Form Template and the print driver program in the Processing routine section of the output type








  • Maintain condition record for the newly created output type, for a Specific Business Partner/BillingType/Sales Org combination based on your requirement.




 





      • When creating a invoice, an output item is created as with the specified medium/language and Form template in the NACE configuration









  • New Output Management in S/4 HANA On-Prem


 



    • Unlike the legacy NAST based output management,  APOC based output management wouldn't require a print program, if you have created a Gateway Service based form.

    • The Structure of your FDP (The skeleton) should be defined as Entity/Entity Sets in your gateway Service.

    • For the Invoice information, redefinition from the Core SD Service  "FDP_V3_BD_STANDARD" is recommended

    • For the QR Bill Payment part, you would need to create new Entity sets, as shown in the section above ( Highlighted part) and the logic to fetch the QR Bill payment part information should be written in the generated DPC extension class. Here you can reuse the SAP delivered routines explained in the note 2910269, to fetch the information

    • You would need to maintain the Output Control Configurations via IMG path "Cross-Application Components -> Output Control








    • You can create new Output Types under Application Object Type "Billing Document"









    • In the Business  Rule for Output Parameter determination (Tcode OPD) you can assign the newly created Form Template, to a Billing Type and also specify the language you want the form template to be printed.





 



    • In the configuration "Assign Form Templates", you would need to assign the Form template to your newly created Billing Type. Please note, with the new output management, you can also use a interface based form explained in the "NAST output Management Section" for which you would need a Print driver program. If you want to use a interface based form, then all the steps in the earlier section needs to be followed.









    • When creating a invoice, an output item is created as with the specified medium/language and Form template in the Output Control configurations






 

When the Output is triggered,( i.e, the created output item is completely processed) can also be configured. Generally, this should be done when the SD Billing Document is release to FI. In the NAST based output management, this is handled via procedures and routines and in the APOC output management it is handled via Output relevance setting as shown below


 

This is an overview of the end to end process and development cycle to generate a compliant QR Bill Invoice.

 

Additionally to cater to requirements pertaining to selection of separate printer tray for printing the payment part, SAP has a design approach and recommendation

  • The QR Bill payment part is always printed in a separate page (The last page)

  • The page format of the page containing the QR Bill payment part is  different compared to the other pages containing the invoice information.


For example SAP has delivered a reference form in A4 format. The pages in the form template layout  for the invoice information part, are specified as A4 format. The last page in the layout with the QR Bill payment part, is specified as A4 Plain format

  • The printer description file (the .XDC file associated with the printer) is modified by assigning different printer trays for specific page format. Details for modifying the XDC file using Eclipse IDE is described in the SAP note 766410

33 Comments