Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

As of SP14 of SAP GRC NFE 1.0, this functionality is included in the standard solution.
For that, apply SAP Note 1451768 on GRC NFE and SAP Note 1441403 on ERP.

Follow a code sample to read the authorization date and time directly from XML.

The routine start reading the DOCID from table /xnfe/xml using 44 access key, after than use this value the read XML from KPro.

Using string routines to identify the position of tag dhRecbto, read their content and split their value into two variables EV_AUTHDATE and EV_AUTHTIME.

Remark: There's a constant value on this code (gc_sdok-class) that can be found on the include /XNFE/DB_CONSTANTS, you can insert the include line on the TOP include of group function, or directly on the code.

FUNCTION zfdr_test_get_datetime_auth.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IV_ID) TYPE /XNFE/ID
*" EXPORTING
*" VALUE(EV_AUTHDATE) TYPE SYDATUM
*" VALUE(EV_AUTHTIME) TYPE SYUZEIT
*"----------------------------------------------------------------------

  DATA:
    lv_docid         TYPE /xnfe/xml-docid,
    ls_dokobject     TYPE sdokobject,
    lv_string        TYPE string,
    lv_dhrecbto      TYPE /xnfe/dhrecbto,
    lt_occur        TYPE match_result_tab,
    lv_inipos       TYPE i,
    lv_length       TYPE i.
  FIELD-SYMBOLS:
    <fs_occur> LIKE LINE OF lt_occur.
 
  SELECT SINGLE docid INTO lv_docid
  FROM /xnfe/xml
  WHERE id   = iv_id
    AND type = '1'.
 
  CHECK sy-subrc EQ 0.
  CHECK lv_docid IS NOT INITIAL.
 
  ls_dokobject-class = gc_sdok-class.
  ls_dokobject-objid = lv_docid.
 
  CALL FUNCTION '/XNFE/CORE_KPRO_XML_READ'
    EXPORTING
      is_dokobject     = ls_dokobject
    IMPORTING
      ev_content       = lv_string
    EXCEPTIONS
      no_existing      = 1
      no_authorization = 2
      no_content       = 3
      read_failure     = 4
      convert_failure  = 5
      OTHERS           = 6.
 
  CHECK sy-subrc EQ 0.
 
  REFRESH lt_occur.
  FIND FIRST OCCURRENCE OF REGEX '<dhRecbto>' IN lv_string RESULTS lt_occur.
  CHECK lt_occur[] IS NOT INITIAL.
  READ TABLE lt_occur ASSIGNING <fs_occur> INDEX 1.
  CHECK sy-subrc EQ 0.
  lv_inipos  = <fs_occur>-offset + <fs_occur>-length.
  REFRESH lt_occur.
  FIND FIRST OCCURRENCE OF REGEX '</dhRecbto>' IN lv_string RESULTS lt_occur.
  CHECK lt_occur[] IS NOT INITIAL.
  READ TABLE lt_occur ASSIGNING <fs_occur> INDEX 1.
  CHECK sy-subrc EQ 0.
  lv_length = <fs_occur>-offset - lv_inipos.
  lv_dhrecbto = lv_string+lv_inipos(lv_length).
 
  CHECK lv_dhrecbto IS NOT INITIAL.
  CALL FUNCTION '/XNFE/FORMAT_DATE'
    EXPORTING
      iv_sefaz_date = lv_dhrecbto
    IMPORTING
      ev_date       = ev_authdate
      ev_time       = ev_authtime.
 
ENDFUNCTION.