Thursday, 4 July 2024

Delivery Sample code for PT (Portugal) QR codes

QR codes for Portual in SAP ABAP 

Below code will give QR code for the given delivery Docuemnt, before using this code SIPT_LIKP table should have entries for the delivery document.

once Delviery got PGI'ed then only SIPT tables will have entries.

---------------------------------------------------------------------------------------------------------------------------

DATAls_qr                   TYPE sipt_s_invqrcode,
      lv_obj                  TYPE REF TO cl_qrcode_pt_obd_utill,
      ls_qrc_get_param        TYPE cl_rdsv_qrcode=>qrcode_get_param,
      ls_qrc_additional_param TYPE cl_sipt_qrcode_pt=>additional_param,
      ls_qrc_object_pt        TYPE cl_qrcode_pt_obd_utill=>ty_obd_pt_s.

PARAMETERS p_vbeln TYPE vbeln_vl DEFAULT '0083252768'.

*delivery_no = p_vbeln.

CREATE OBJECT lv_obj.

CALL METHOD lv_obj->get_qrcode_obd_data
  EXPORTING
    iv_delivery     p_vbeln
  IMPORTING
    qrcode_obd_data ls_qrc_object_pt.

IF ls_qrc_object_pt-header-customer_vatreg IS INITIAL.
  ls_qrc_object_pt-header-customer_vatreg '999999990'.
ENDIF.

ls_qrc_get_param-intca       'PT'.
ls_qrc_get_param-source_type 'OUTBOUND_DELIVERY'.


TRY.
    BREAK-POINT.
    cl_rdsv_qrcode=>get_qrcode(
    EXPORTING get_param  ls_qrc_get_param
    source_object ls_qrc_object_pt
         additional_param ls_qrc_additional_param
    IMPORTING qrcode  DATA(qr_result).
  CATCH cx_rdsv_qrcode INTO DATA(exc_qrc).
    MESSAGE ID exc_qrc->if_t100_message~t100key-msgid
    TYPE 'E'
    NUMBER exc_qrc->if_t100_message~t100key-msgno
    WITH exc_qrc->if_t100_message~t100key-attr1.
ENDTRY.


*ls_qr-qrstring =  condense( qr_result-qrstring ).
ls_qr-qrstring =  qr_result-qrstring.

Saturday, 30 April 2022

Delivery code for PT(portugal) QR codes

 

Below code will give QR code for the given delivery Docuemnt, before using this code SIPT_LIKP table should have entries for the delivery document.

once Delviery got PGI'ed then only SIPT tables will have entries.

---------------------------------------------------------------------------------------------------------------------------

DATAls_qr                   TYPE sipt_s_invqrcode,
      lv_obj                  TYPE REF TO cl_qrcode_pt_obd_utill,
      ls_qrc_get_param        TYPE cl_rdsv_qrcode=>qrcode_get_param,
      ls_qrc_additional_param TYPE cl_sipt_qrcode_pt=>additional_param,
      ls_qrc_object_pt        TYPE cl_qrcode_pt_obd_utill=>ty_obd_pt_s.

PARAMETERS p_vbeln TYPE vbeln_vl DEFAULT '0083252768'.

*delivery_no = p_vbeln.

CREATE OBJECT lv_obj.

CALL METHOD lv_obj->get_qrcode_obd_data
  EXPORTING
    iv_delivery     p_vbeln
  IMPORTING
    qrcode_obd_data ls_qrc_object_pt.

IF ls_qrc_object_pt-header-customer_vatreg IS INITIAL.
  ls_qrc_object_pt-header-customer_vatreg '999999990'.
ENDIF.

ls_qrc_get_param-intca       'PT'.
ls_qrc_get_param-source_type 'OUTBOUND_DELIVERY'.


TRY.
    BREAK-POINT.
    cl_rdsv_qrcode=>get_qrcode(
    EXPORTING get_param  ls_qrc_get_param
    source_object ls_qrc_object_pt
         additional_param ls_qrc_additional_param
    IMPORTING qrcode  DATA(qr_result).
  CATCH cx_rdsv_qrcode INTO DATA(exc_qrc).
    MESSAGE ID exc_qrc->if_t100_message~t100key-msgid
    TYPE 'E'
    NUMBER exc_qrc->if_t100_message~t100key-msgno
    WITH exc_qrc->if_t100_message~t100key-attr1.
ENDTRY.


*ls_qr-qrstring =  condense( qr_result-qrstring ).
ls_qr-qrstring =  qr_result-qrstring.

Invoice sample code for PT QR codes

 

Below code will give QR code back in QRSTRING.

for this SIPT_VBRK should have entries for the given invoice docuemnt.

-------------------------------------------------------------------------------------------------------------

DATAsource_object_pt TYPE cl_sipt_qrcode_pt=>source_object_pt,

      qrc_get_param    TYPE cl_rdsv_qrcode=>qrcode_get_param,
      source_object    TYPE cl_rdsv_map_util_sd=>source_object_sd,
      key              TYPE cl_rdsv_map_util_sd=>keys_sd,
      ls_qr            TYPE sipt_s_invqrcode.
      

PARAMETERS p_vbeln TYPE vbeln_vf DEFAULT '1100200008'.

qrc_get_param-intca  'PT'.
qrc_get_param-source_type 'BILLING_DOCUMENT'.
key-vbeln  p_vbeln.  "'1100200007'.

DATA(lcl_dataNEW cl_sipt_map_qrc_pt_sd).

TRY.
    lcl_data->if_rdsv_map_get~read_source_object(
    EXPORTING key  key
    IMPORTING source_object  source_object ).

    lcl_data->if_rdsv_map_get~map(
    EXPORTING source_object  source_object
    IMPORTING target_object  source_object_pt ).

  CATCH cx_rdsv_map INTO DATA(exc_map).
    MESSAGE ID exc_map->if_t100_message~t100key-msgid
    TYPE 'E'
    NUMBER exc_map->if_t100_message~t100key-msgno
    WITH exc_map->if_t100_message~t100key-attr1.
ENDTRY.

TRY.
    BREAK-POINT.
    cl_rdsv_qrcode=>get_qrcode(
    EXPORTING get_param  qrc_get_param
    source_object source_object_pt
    IMPORTING qrcode  DATA(qr_result).

  CATCH cx_rdsv_qrcode INTO DATA(exc_qrc).
    MESSAGE ID exc_qrc->if_t100_message~t100key-msgid
    TYPE 'E'
    NUMBER exc_qrc->if_t100_message~t100key-msgno
    WITH exc_qrc->if_t100_message~t100key-attr1.
ENDTRY.

*ls_qr-qrstring =  condense( qr_result-qrstring ).
ls_qr-qrstring =  qr_result-qrstring.

PT QR code


There is a special legal requirements for Portual QR codes.

Printing Forms:

In order to ensure that our customers meet all legal requirements and that their system is properly up to date in accordance to these requirements, we would like to send a summary of the most important rules related to the printing forms of documents according to the rules defined by the Portuguese Tax Authority (AT).

Some of the rules described in this document are not recent, since they have been active in Portarias n.º 363/2010, 340/2013 and Ofício circulado N.º 50.001/2013.

We have also taken into consideration the most recent rules defined by the Despacho 8632/2014 and Decreto Lei n.º 28/2019.

The following list describes the most relevant aspects of the existing rules:

Digital Signature Footprint

In every fiscally relevant document (FI invoices, SD Billing and Outbound delivery documents) the following information must be presented, otherwise the document was not certified:

• <footprint> - Processado por programa certificado n.º <certificate id>/AT

As according to the note 2398759, it’s possible to use the method CL_SIPT_PR_INFO=>GET_SIGNATURE_INFO to retrieve the digital signature footprint (4 characters) and certificate ID.

The Digital Signature characters (footprint) to be printed in the layout are the following:

• Field SIPT_VBRK-PRINT_CHAR – For SD Billing documents

• Field SIPT_LIKP-PRINT_CHAR – For Outbound delivery documents

• Field SIPT_BKPF-PRINT_CHAR – For FI invoices

The certificate ID is CERT_ID, which can be retrieved in the same tables.

The final result of the print out would be something like the following: " yyxx -Processado por Programa Certificado Nº 631/AT"

QR Code

The Decree-Law no. 28/2019, of 15 February, has determined new Portuguese requirements for invoices and other fiscally relevant documents. According to the new requirements, these documents must contain a two-dimensional bar code (QR code).

The QR Code must respect the technical specifications indicated by the Tax Authorities and printed on the documents of digitally signed documents. In the case of documents with more than one page, the code can appear on the first or last page of the document.

The creation of the two-dimensional bar code (QR code) must comply with the following specifications:


• Error Correction Code (ECC): ‘M’;

• Type: Byte;

• Points per module (Size): 2;

• Version: V=9 (minimum value);

• Image dimensions: minimum 30x30 mm;

• Margin: 0,25 cm;

The system requirements for the printing of QR codes in general can be found in the following notes:

• 2029824 - Support for QR code and data matrix bar code (ABAP part)

• 2029589 - Support for QR code and data matrix bar code (kernel part)

• 2030263 - Support for QR Code 2005 Barcode in SAPscript and Smart Forms