Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
cpavel_garcia
Explorer

Si actualmente ya tienes instalado la solución de SAP para facturas electrónicas SD/FI e instalado el Certificado Digital, se puede generar el Sello Digital del Recibo de Nómina directamente desde SAP. Este evita el dar datos confidenciales de la firma electrónica a los PAC.

Para este propósito debemos de usar el BADI HRPAYMX_CFDI  liberado por SAP para la solución de Recibos de Nómina CFDI.

El Sello Digital se obtiene a partir de una cadena de caracteres con información definida por el SAT el cual se encripta con algoritmos definidos por el SAT y se genera un string de 172 posiciones denominado "Sello Digital".

La base para la generación del Sello Digital es la generación de los que se denomina cadena original usando la estructura liberada por SAP HRPAYMX_S_CFDI_ANNEX_20.

Adjunto un programa que permite generar la cadena original.

Módulo de Función ZPYMX_DI_CREATE_ORI_IN_MSG

INCLUDE LZPYMX_DI_SIGNATURETOP
CONSTANTS gc_pipeline TYPE c VALUE '|'.

FUNCTION ZPYMX_DI_CREATE_ORI_IN_MSG

FUNCTION zpymx_di_create_ori_in_msg.

*"----------------------------------------------------------------------

*"*"Interfase local

*"  IMPORTING

*"     REFERENCE(IS_CFDI_ANNEX_20) TYPE  HRPAYMX_S_CFDI_ANNEX_20

*"  EXPORTING

*"     REFERENCE(EV_ORI_INPUT_MSG) TYPE  STRING

*"  EXCEPTIONS

*"      OIM_BLOCK_ERROR

*"      DATA_BLOCK_ERROR

*"      BLOCK_CREATION_ERROR

*"      CUSTOM_ERROR

*"----------------------------------------------------------------------

   DATA:

     lo_annex20  TYPE REF TO cl_abap_structdescr,

     lt_comp_tab TYPE cl_abap_structdescr=>component_table,

     ls_comp     TYPE LINE OF cl_abap_structdescr=>component_table.

   "built up character string

   DATA lv_data_pos_chain         TYPE string.

   FIELD-SYMBOLS:

     <lv_value> TYPE ANY.

   lo_annex20 ?= cl_abap_typedescr=>describe_by_data( is_cfdi_annex_20 ).

   lt_comp_tab = lo_annex20->get_components( ).

*----------------------------------------------------------------------*

* Procesar Estructura

*----------------------------------------------------------------------*

   LOOP AT lt_comp_tab INTO ls_comp.

     ASSIGN COMPONENT ls_comp-name

     OF STRUCTURE is_cfdi_annex_20 TO <lv_value>.

     PERFORM f_create_chain USING <lv_value>

                                  ls_comp-type->kind

                           CHANGING lv_data_pos_chain.

   ENDLOOP.

   CONCATENATE gc_pipeline gc_pipeline

               lv_data_pos_chain

               gc_pipeline gc_pipeline INTO ev_ori_input_msg.

* Remove direct consecutive blanks, because SAT input message

* is created in this way

   CONDENSE ev_ori_input_msg.

ENDFUNCTION.

INCLUDE LZPYMX_DI_SIGNATUREF01

*----------------------------------------------------------------------*

***INCLUDE LZPYMX_DI_SIGNATUREF01 .

*----------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*&      Form  F_CREATE_CHAIN

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*      -->P_<LV_VALUE>  text

*      <--P_LV_DATA_POS_CHAIN  text

*----------------------------------------------------------------------*

FORM f_create_chain  USING      value(p_elemento) TYPE any

                                 p_kind TYPE c

                      CHANGING   data_pos_chain TYPE any.

   DATA:

     lo_elemento  TYPE REF TO cl_abap_structdescr,

     lt_comp_tab TYPE cl_abap_structdescr=>component_table,

     ls_comp     TYPE LINE OF cl_abap_structdescr=>component_table.

   FIELD-SYMBOLS:

     <lv_header> TYPE ANY,

     <dyn_table> TYPE STANDARD TABLE,

     <lv_value>  TYPE ANY.

   DATA concatenated_field(255) TYPE c.

   CASE p_kind.

     WHEN cl_abap_typedescr=>kind_table.

       ASSIGN p_elemento TO <dyn_table>.

       LOOP AT <dyn_table> ASSIGNING <lv_header>.

         lo_elemento ?= cl_abap_typedescr=>describe_by_data( <lv_header> ).

         lt_comp_tab = lo_elemento->get_components( ).

         LOOP AT lt_comp_tab INTO ls_comp.

           ASSIGN COMPONENT ls_comp-name

           OF STRUCTURE <lv_header> TO <lv_value>.

           PERFORM f_create_chain USING <lv_value>

                                        ls_comp-type->kind

                                 CHANGING data_pos_chain.

         ENDLOOP.

       ENDLOOP.

     WHEN cl_abap_typedescr=>kind_struct.

       lo_elemento ?= cl_abap_typedescr=>describe_by_data( p_elemento ).

       lt_comp_tab = lo_elemento->get_components( ).

       LOOP AT lt_comp_tab INTO ls_comp.

         ASSIGN COMPONENT ls_comp-name

         OF STRUCTURE p_elemento TO <lv_value>.

         PERFORM f_create_chain USING <lv_value>

                                      ls_comp-type->kind

                               CHANGING data_pos_chain.

       ENDLOOP.

     WHEN cl_abap_typedescr=>kind_elem.

       IF ( p_elemento IS NOT INITIAL ) AND

          ( p_elemento <> '' ).

         concatenated_field = p_elemento.

*         deleting of unnecessary white spaces

         "CONDENSE concatenated_field.

         SHIFT concatenated_field LEFT DELETING LEADING space.

         IF data_pos_chain <> ''.

           CONCATENATE data_pos_chain concatenated_field

           INTO data_pos_chain

           SEPARATED BY gc_pipeline.

         ELSE.

           data_pos_chain = concatenated_field.

         ENDIF.

       ENDIF.

     WHEN OTHERS.

       IF ( p_elemento IS NOT INITIAL ) AND

          ( p_elemento <> '' ).

         concatenated_field = p_elemento.

*         deleting of unnecessary white spaces

         "CONDENSE concatenated_field.

         SHIFT concatenated_field LEFT DELETING LEADING space.

         IF data_pos_chain <> ''.

           CONCATENATE data_pos_chain concatenated_field

           INTO data_pos_chain

           SEPARATED BY gc_pipeline.

         ELSE.

           data_pos_chain = concatenated_field.

         ENDIF.

       ENDIF.

   ENDCASE.

ENDFORM.                    " F_CREATE_CHAIN

Con los datos llenos en la estructura SAP HRPAYMX_S_CFDI_ANNEX_20, se genera de forma automática la cadena original.

Una vez que se ha generado la cadena original debemos de aplicar los módulos de función que tiene SAP de forma estándar para generar el Sello Digital tomando los certificados instalados en los servidores de aplicación.

Si necesitan más información estoy a sus órdenes por este medio.

Saludos,

32 Comments
Labels in this area