Skip to Content

Hola,

Ese documento tiene el código ABAP para generación del Código de Control de Servicio de Impuestos de Bolivia.

Yo hice una adaptación de un código PHP del sitio:

https://code.google.com/p/codigocontrol/

Crear Funcion ZSDBO_COD_CONTROL_GERA

Codigo de Funcion:

FUNCTION zsdbo_cod_control_gera.

*”———————————————————————-

*”*”Interfase local

*”  IMPORTING

*”     REFERENCE(I_FACTURA) TYPE  VBRK-XBLNR

*”     REFERENCE(I_NITCI) TYPE  KNA1-STCD1

*”     REFERENCE(I_FECHA) TYPE  VBRK-FKDAT

*”     REFERENCE(I_MONTO) TYPE  VBRP-KZWI1

*”     REFERENCE(I_BUKRS) TYPE  BUKRS

*”  EXPORTING

*”     REFERENCE(E_COD_CONTROL) TYPE  CHAR256

*”———————————————————————-

   PERFORM z_inicia_dados.

   PERFORM z_inicia_dados_verhoeff.

   v_factura = i_factura.

   v_nitci = i_nitci.

   v_fecha = i_fecha.

   IF v_nitci IS INITIAL.

     “Cliente no tiene NIT – Cód. de Control no generado

     MESSAGE i030(zsd).

     EXIT.

   ENDIF.

*Arredontamento do valor

   v_monto = round( val = i_monto dec = 0 mode = cl_abap_math=>round_half_up ).

   SHIFT v_monto LEFT DELETING LEADING space.

   SELECT SINGLE *

     FROM ztsd068 INTO str_ztsd068

     WHERE bukrs = i_bukrs

       AND datbi GE v_fecha

       AND datab LE v_fecha.

   WRITE str_ztsd068autoriza TO v_autorizacion LEFT-JUSTIFIED.

   WRITE str_ztsd068dosifica TO v_llave LEFT-JUSTIFIED.

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

**Testes

*  v_factura = ‘152’.

*  v_nitci = ‘1026469026’.

**ano / mes /dia

*  v_fecha = ‘20070728’.

*  v_monto = ‘135’.

*  v_llave = ‘A3Fs4s$)2cvD(eY667A5C4A2rsdf53kw9654E2B23s24df35F5’.

*  v_autorizacion = ‘79040011859’.

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

   PERFORM verhoeff_add_recursive USING v_factura ‘2’.

   PERFORM verhoeff_add_recursive USING v_nitci ‘2’.

   PERFORM verhoeff_add_recursive USING v_fecha ‘2’.

   PERFORM verhoeff_add_recursive USING v_monto ‘2’.

   v_factura_n = v_factura.

   v_nitci_n  = v_nitci.

   v_fecha_n  = v_fecha.

   v_monto_n  = v_monto.

   v_suma_n = v_factura_n + v_nitci_n + v_fecha_n + v_monto_n.

   WRITE v_suma_n TO v_suma NO-ZERO LEFT-JUSTIFIED .

   SHIFT v_suma LEFT DELETING LEADING space.

   PERFORM verhoeff_add_recursive USING v_suma ‘5’.

*   // paso2

   v_len = strlen( v_suma ) 5.

   v_digitos = substring( val = v_suma off = v_len len = 5 ).

   CLEAR: v_len, v_sub_llave.

   v_len = v_digitos(1) + 1.

   v_sub_llave = substring( val = v_llave off = 0 len = v_len ).

   v_len_a = v_len_a + v_len.

   CONCATENATE v_autorizacion

               v_sub_llave

          INTO v_autorizacion.

   CLEAR: v_len, v_sub_llave.

   v_len = v_digitos+1(1) + 1.

   v_sub_llave = substring( val = v_llave off = v_len_a len = v_len ).

   v_len_a = v_len_a + v_len.

   CONCATENATE v_factura

               v_sub_llave

          INTO v_factura.

   CLEAR: v_len, v_sub_llave.

   v_len = v_digitos+2(1) + 1.

   v_sub_llave = substring( val = v_llave off = v_len_a len = v_len ).

   v_len_a = v_len_a + v_len.

   CONCATENATE v_nitci

               v_sub_llave

          INTO v_nitci.

   CLEAR: v_len, v_sub_llave.

   v_len = v_digitos+3(1) + 1.

   v_sub_llave = substring( val = v_llave off = v_len_a len = v_len ).

   v_len_a = v_len_a + v_len.

   CONCATENATE v_fecha

               v_sub_llave

          INTO v_fecha.

*Alteracao DC – Inicio

*Verificar tamanho para nao dar out of bounds.

   CLEAR: v_len, v_sub_llave.

   v_len = v_digitos+4(1) + 1.

*–

   v_len_max = v_len_a + v_len.

   v_len_llave = strlen( v_llave ).

   v_len_aux = v_len_max v_len_llave.

   IF v_len_aux > 0.

     v_len = v_len v_len_aux.

   ENDIF.

*–

   v_sub_llave = substring( val = v_llave off = v_len_a len = v_len ).

   v_len_a = v_len_a + v_len.

*Alteracao DC – Fim

   CONCATENATE v_monto

               v_sub_llave

          INTO v_monto.

*   // paso3

   CONCATENATE v_autorizacion

               v_factura

               v_nitci

               v_fecha

               v_monto

          INTO v_mensaje.

   CONCATENATE v_llave

               v_digitos

          INTO v_llaverc4.

   PERFORM allegedrc4 USING v_mensaje

                            v_llaverc4

                            v_arc4.

*   // paso4

   v_suma_total = 0.

   v_sumas1 = 0.

   str_sumasline = 0. APPEND str_sumas TO tbl_sumas.

   str_sumasline = 0. APPEND str_sumas TO tbl_sumas.

   str_sumasline = 0. APPEND str_sumas TO tbl_sumas.

   str_sumasline = 0. APPEND str_sumas TO tbl_sumas.

   v_strlen_arc4 = strlen( v_arc4 ).

   v_i = 0.

   WHILE v_i < v_strlen_arc4.

     CALL METHOD cl_abap_conv_out_ce=>uccpi

       EXPORTING

         char = v_arc4+v_i(1)

       RECEIVING

         uccp = v_x.

     v_aux = v_i MOD 5.

     IF v_aux = 0.

       v_sumas1 = v_sumas1 + v_x.

     ELSE.

       READ TABLE tbl_sumas INTO str_sumas INDEX v_aux.

       str_sumasline = str_sumasline + v_x.

       MODIFY tbl_sumas FROM str_sumas INDEX v_aux.

     ENDIF.

     v_suma_total = v_suma_total + v_x.

     v_i = v_i + 1.

   ENDWHILE.

*   // paso5

   v_total = 0.

   v_stsp = v_sumas1 * v_suma_total.

   v_digitossum = v_digitos(1) + 1.

   v_dec2 = v_stsp / v_digitossum.

   v_stsp = trunc( v_dec2 ).

   v_total = v_total + v_stsp.

   v_i = 1.

   LOOP AT tbl_sumas INTO str_sumas.

     v_digitossum = v_digitos+v_i(1) + 1.

     v_stsp = str_sumasline * v_suma_total.

     v_dec2 = v_stsp / v_digitossum.

     v_stsp = trunc( v_dec2 ).

     v_total = v_total + v_stsp.

     v_i = v_i + 1.

   ENDLOOP.

   PERFORM big_base_convert USING v_total

                                  ’64’

                                  v_mensaje.

   PERFORM allegedrc4 USING v_mensaje

                            v_llaverc4

                            v_codcontrol_raw.

   v_len = strlen( v_codcontrol_raw ).

   IF v_len = 10.

     WRITE: v_codcontrol_raw TO v_codcontrol USING EDIT MASK ‘__-__-__-__-__’.

   ELSEIF v_len = 8.

     WRITE: v_codcontrol_raw TO v_codcontrol USING EDIT MASK ‘__-__-__-__’.

   ELSE.

     WRITE: v_codcontrol_raw TO v_codcontrol USING EDIT MASK ‘__-__-__’.

   ENDIF.

   e_cod_control = v_codcontrol.

ENDFUNCTION.

Forms Include (LZSDBO_COD_CONTROLF01):

*———————————————————————-*

***INCLUDE LZSDBO_COD_CONTROLF01 .

*———————————————————————-*

*&———————————————————————*

*&      Form  Z_INICIA_DADOS

*&———————————————————————*

*       text

*———————————————————————-*

FORM z_inicia_dados .

   CLEAR: tbl_table_d, tbl_table_p, tbl_state, tbl_sumas.

   CLEAR: str_table, str_ztsd068.

   CLEAR: str_state, str_state1, str_state2, str_sumas.

   CLEAR: v_autorizacion, v_factura, v_nitci, v_fecha, v_monto,

          v_llave, v_codigo, v_suma, v_suma_n, v_factura_n,

          v_nitci_n, v_fecha_n, v_monto_n, v_d, v_p, v_inv.

   CLEAR: v_digitos, v_len, v_len_a, v_sub_llave.

   CLEAR: v_mensaje, v_llaverc4, v_arc4, v_codcontrol_raw, v_codcontrol.

   CLEAR: v_suma_total, v_strlen_arc4, v_sumas1, v_i, v_x, v_aux,

          v_total, v_stsp, v_digitossum, v_dec2.

ENDFORM.                    ” Z_INICIA_DADOS

*&———————————————————————*

*&      Form  Z_INICIA_DADOS_VERHOEFF

*&———————————————————————*

* Tabelas p/ Verhoeff

*———————————————————————-*

FORM z_inicia_dados_verhoeff .

*Tabela D

   v_d  = ‘0123456789’.

   str_table = ‘1234067895’.

   APPEND str_table TO tbl_table_d.

   str_table = ‘2340178956’.

   APPEND str_table TO tbl_table_d.

   str_table = ‘3401289567’.

   APPEND str_table TO tbl_table_d.

   str_table = ‘4012395678’.

   APPEND str_table TO tbl_table_d.

   str_table = ‘5987604321’.

   APPEND str_table TO tbl_table_d.

   str_table = ‘6598710432’.

   APPEND str_table TO tbl_table_d.

   str_table = ‘7659821043’.

   APPEND str_table TO tbl_table_d.

   str_table = ‘8765932104’.

   APPEND str_table TO tbl_table_d.

   str_table = ‘9876543210’.

   APPEND str_table TO tbl_table_d.

*Tabela P

   v_p = ‘0123456789’.

   str_table = ‘1576283094’.

   APPEND str_table TO tbl_table_p.

   str_table = ‘5803796142’.

   APPEND str_table TO tbl_table_p.

   str_table = ‘8916043527’.

   APPEND str_table TO tbl_table_p.

   str_table = ‘9453126870’.

   APPEND str_table TO tbl_table_p.

   str_table = ‘4286573901’.

   APPEND str_table TO tbl_table_p.

   str_table = ‘2793806415’.

   APPEND str_table TO tbl_table_p.

   str_table = ‘7046913258’.

   APPEND str_table TO tbl_table_p.

*Inv

   v_inv = ‘0432156789’.

ENDFORM.                    ” Z_INICIA_DADOS_VERHOEFF

*&———————————————————————*

*&      Form  big_base_convert

*&———————————————————————*

*   * Conversion de numeros en base 10 a base 64 o 16

*———————————————————————-*

*   * @param string $numero: numero a convertir

*   * @param string $base: Opcional, convierte a la base indicada

*   * @return string: numero convertido

*———————————————————————-*

FORM big_base_convert USING u_numero

                             u_base

                             u_cifrado.

   DATA: lv_numero     TYPE i,

         lv_base       TYPE i,

         lv_cociente   TYPE i,

         lv_resto      TYPE i,

         lv_palabra    TYPE char256.

   DATA: tbl_dic TYPE TABLE OF char1,

         str_dic TYPE char1.

   lv_numero = u_numero.

   lv_base = u_base.

   str_dic = ‘1’. APPEND str_dic TO tbl_dic.

   str_dic = ‘2’. APPEND str_dic TO tbl_dic.

   str_dic ‘3’. APPEND str_dic TO tbl_dic.

   str_dic ‘4’. APPEND str_dic TO tbl_dic.

   str_dic ‘5’. APPEND str_dic TO tbl_dic.

   str_dic ‘6’.APPEND str_dic TO tbl_dic.

   str_dic ‘7’.APPEND str_dic TO tbl_dic.

   str_dic ‘8’.APPEND str_dic TO tbl_dic.

   str_dic ‘9’.APPEND str_dic TO tbl_dic.

   str_dic ‘A’.APPEND str_dic TO tbl_dic.

   str_dic ‘B’.APPEND str_dic TO tbl_dic.

   str_dic ‘C’.APPEND str_dic TO tbl_dic.

   str_dic ‘D’.APPEND str_dic TO tbl_dic.

   str_dic ‘E’.APPEND str_dic TO tbl_dic.

   str_dic ‘F’.APPEND str_dic TO tbl_dic.

   str_dic ‘G’.APPEND str_dic TO tbl_dic.

   str_dic ‘H’.APPEND str_dic TO tbl_dic.

   str_dic ‘I’.APPEND str_dic TO tbl_dic.

   str_dic ‘J’.APPEND str_dic TO tbl_dic.

   str_dic ‘K’.APPEND str_dic TO tbl_dic.

   str_dic ‘L’.APPEND str_dic TO tbl_dic.

   str_dic ‘M’.APPEND str_dic TO tbl_dic.

   str_dic ‘N’.APPEND str_dic TO tbl_dic.

   str_dic ‘O’.APPEND str_dic TO tbl_dic.

   str_dic ‘P’.APPEND str_dic TO tbl_dic.

   str_dic ‘Q’.APPEND str_dic TO tbl_dic.

   str_dic ‘R’.APPEND str_dic TO tbl_dic.

   str_dic ‘S’.APPEND str_dic TO tbl_dic.

   str_dic ‘T’.APPEND str_dic TO tbl_dic.

   str_dic ‘U’.APPEND str_dic TO tbl_dic.

   str_dic ‘V’.APPEND str_dic TO tbl_dic.

   str_dic ‘W’.APPEND str_dic TO tbl_dic.

   str_dic ‘X’.APPEND str_dic TO tbl_dic.

   str_dic ‘Y’.APPEND str_dic TO tbl_dic.

   str_dic ‘Z’.APPEND str_dic TO tbl_dic.

   str_dic ‘a’.APPEND str_dic TO tbl_dic.

   str_dic ‘b’.APPEND str_dic TO tbl_dic.

   str_dic ‘c’.APPEND str_dic TO tbl_dic.

   str_dic ‘d’.APPEND str_dic TO tbl_dic.

   str_dic ‘e’.APPEND str_dic TO tbl_dic.

   str_dic ‘f’.APPEND str_dic TO tbl_dic.

   str_dic ‘g’.APPEND str_dic TO tbl_dic.

   str_dic ‘h’.APPEND str_dic TO tbl_dic.

   str_dic ‘i’.APPEND str_dic TO tbl_dic.

   str_dic ‘j’.APPEND str_dic TO tbl_dic.

   str_dic ‘k’.APPEND str_dic TO tbl_dic.

   str_dic ‘l’.APPEND str_dic TO tbl_dic.

   str_dic ‘m’.APPEND str_dic TO tbl_dic.

   str_dic ‘n’.APPEND str_dic TO tbl_dic.

   str_dic ‘o’.APPEND str_dic TO tbl_dic.

   str_dic ‘p’.APPEND str_dic TO tbl_dic.

   str_dic ‘q’.APPEND str_dic TO tbl_dic.

   str_dic ‘r’.APPEND str_dic TO tbl_dic.

   str_dic ‘s’.APPEND str_dic TO tbl_dic.

   str_dic ‘t’.APPEND str_dic TO tbl_dic.

   str_dic ‘u’.APPEND str_dic TO tbl_dic.

   str_dic ‘v’.APPEND str_dic TO tbl_dic.

   str_dic ‘w’.APPEND str_dic TO tbl_dic.

   str_dic ‘x’.APPEND str_dic TO tbl_dic.

   str_dic ‘y’.APPEND str_dic TO tbl_dic.

   str_dic ‘z’.APPEND str_dic TO tbl_dic.

   str_dic ‘+’.APPEND str_dic TO tbl_dic.

   str_dic ‘/’. APPEND str_dic TO tbl_dic.

   lv_cociente = 1.

   WHILE lv_cociente <> 0.

     lv_cociente = lv_numero DIV lv_base.

     lv_resto = lv_numero MOD lv_base.

     IF lv_resto = 0.

       str_dic = ‘0’.

     ELSE.

       READ TABLE tbl_dic INTO str_dic INDEX lv_resto.

     ENDIF.

     CONCATENATE str_dic

                 lv_palabra

            INTO lv_palabra.

     lv_numero = lv_cociente.

   ENDWHILE.

   IF strlen( lv_palabra ) = 1.

     CONCATENATE ‘0’

                 lv_palabra

            INTO lv_palabra.

   ENDIF.

   u_cifrado = lv_palabra.

ENDFORM.                    “big_base_convert

*&———————————————————————*

*&      Form  allegedrc4

*&———————————————————————*

*   * Algoritmo Alleged RC4

*———————————————————————-*

*   * @param string $mensaje: mensaje a cifrar

*   * @param string $llave: llave a utilizar para el cifrado

*   * @return string: cadena cifrada

*———————————————————————-*

FORM allegedrc4 USING u_mensaje  TYPE char256

                       u_llaverc4 TYPE char256

                       u_arc4     TYPE char256.

   DATA:

         lv_x              TYPE i,

         lv_y              TYPE i,

         lv_index1         TYPE i,

         lv_index2         TYPE i,

         lv_nmen           TYPE i,

         lv_i              TYPE i,

         lv_cifrado        TYPE char256,

         lv_strlen_llave   TYPE i,

         lv_strlen_mensaje TYPE i,

         lv_uccp           TYPE i,

         lv_z              TYPE i.

   DATA: lv_bita TYPE x,

         lv_bitb TYPE x,

         lv_bitc TYPE x.

   CLEAR: tbl_state, str_state1.

   lv_x = 0.

   lv_y = 0.

   lv_index1 = 0.

   lv_index2 = 0.

   lv_nmen = 0.

   lv_i = 1.

   str_stateline = 0.

   DO 256 TIMES.

     str_state1line = lv_i.

     APPEND str_state1 TO tbl_state.

     lv_i = lv_i + 1.

   ENDDO.

   lv_i = 0.

   lv_strlen_llave = strlen( u_llaverc4 ).

   lv_strlen_mensaje = strlen( u_mensaje ).

   WHILE lv_i < 256.

     CALL METHOD cl_abap_conv_out_ce=>uccpi

       EXPORTING

         char = u_llaverc4+lv_index1(1)

       RECEIVING

         uccp = lv_uccp.

     IF lv_i = 0.

       str_state1 = str_state.

     ELSE.

       READ TABLE  tbl_state INTO str_state1 INDEX lv_i.

     ENDIF.

     lv_index2 ( lv_uccp + str_state1line + lv_index2 ) MOD 256.

*READ

     IF lv_i = 0.

       str_state1 = str_state.

     ELSE.

       READ TABLE tbl_state INTO str_state1 INDEX lv_i.

     ENDIF.

*–

     IF lv_index2 = 0.

       str_state2 = str_state.

     ELSE.

       READ TABLE  tbl_state INTO str_state2 INDEX lv_index2.

     ENDIF.

*SWAP

     IF lv_i = 0.

       str_state = str_state2.

     ELSE.

       MODIFY tbl_state FROM str_state2 INDEX lv_i.

     ENDIF.

*–

     IF lv_index2 = 0.

       str_state = str_state1.

     ELSE.

       MODIFY tbl_state FROM str_state1 INDEX lv_index2.

     ENDIF.

     lv_index1 = ( lv_index1 + 1 ) MOD lv_strlen_llave.

     lv_i = lv_i + 1.

   ENDWHILE.

   lv_i = 0.

   WHILE lv_i < lv_strlen_mensaje.

     lv_x = ( lv_x + 1 ) MOD 256.

     IF lv_x = 0.

       str_state1 = str_state.

     ELSE.

       READ TABLE  tbl_state INTO str_state1 INDEX lv_x.

     ENDIF.

     lv_y = ( str_state1line + lv_y ) MOD 256.

*READ

     IF lv_x = 0.

       str_state1 = str_state.

     ELSE.

       READ TABLE tbl_state INTO str_state1 INDEX lv_x.

     ENDIF.

*–

     IF lv_y = 0.

       str_state2 = str_state.

     ELSE.

       READ TABLE  tbl_state INTO str_state2 INDEX lv_y.

     ENDIF.

*SWAP

     IF lv_x = 0.

       str_state = str_state2.

     ELSE.

       MODIFY tbl_state FROM str_state2 INDEX lv_x.

     ENDIF.

*–

     IF lv_y = 0.

       str_state = str_state1.

     ELSE.

       MODIFY tbl_state FROM str_state1 INDEX lv_y.

     ENDIF.

* ^ = XOR function

     CALL METHOD cl_abap_conv_out_ce=>uccpi

       EXPORTING

         char = u_mensaje+lv_i(1)

       RECEIVING

         uccp = lv_uccp.

*READ

     IF lv_x = 0.

       str_state1 = str_state.

     ELSE.

       READ TABLE tbl_state INTO str_state1 INDEX lv_x.

     ENDIF.

*–

     IF lv_y = 0.

       str_state2 = str_state.

     ELSE.

       READ TABLE  tbl_state INTO str_state2 INDEX lv_y.

     ENDIF.

     lv_z = ( str_state1line + str_state2line ) MOD 256.

     IF lv_z = 0.

       str_state1 = str_state.

     ELSE.

       READ TABLE  tbl_state INTO str_state1 INDEX lv_z.

     ENDIF.

     lv_bita = lv_uccp.

     lv_bitb = str_state1line.

     lv_bitc = lv_bita BIT-XOR lv_bitb.

     lv_nmen = lv_bitc.

     PERFORM big_base_convert USING lv_nmen

                                    ’16’

                                    lv_cifrado.

     CONCATENATE u_arc4

                 lv_cifrado

            INTO u_arc4.

     lv_i = lv_i + 1.

   ENDWHILE.

ENDFORM.                                                    “allegedrc4

*&———————————————————————*

*&      Form  calcsum

*&———————————————————————*

*       text

*———————————————————————-*

*      –>U_NUMBER   text

*———————————————————————-*

FORM calcsum USING u_number.

   DATA: lv_c      TYPE char256,

         lv_n      TYPE char256,

         lv_len    TYPE char256,

         lv_i      TYPE i,

         lv_ni     TYPE char256,

         lv_i8     TYPE char256,

         lv_pini   TYPE char256.

   DATA: lv_char1 TYPE char256,

         lv_char2 TYPE char256.

   lv_n = u_number.

   CALL FUNCTION ‘STRING_REVERSE’

     EXPORTING

       string    = lv_n

       lang      = ‘E’

     IMPORTING

       rstring   = lv_n

     EXCEPTIONS

       too_small = 1

       OTHERS    = 2.

   IF sysubrc <> 0.

* Implement suitable error handling here

   ENDIF.

   lv_c = 0.

   lv_i = 0.

   lv_len = strlen( lv_n ).

   WHILE lv_i < lv_len.

     lv_ni = lv_n+lv_i(1).

     lv_i8 = ( ( lv_i + 1 ) MOD 8 ).

     IF lv_i8 = 0.

       lv_pini = v_p+lv_ni(1).

     ELSE.

       READ TABLE tbl_table_p INTO str_table INDEX lv_i8.

       lv_pini = str_tableline+lv_ni(1).

     ENDIF.

     IF lv_c = 0.

       lv_c = v_d+lv_pini(1).

     ELSE.

       READ TABLE tbl_table_d INTO str_table INDEX lv_c.

       lv_c = str_tableline+lv_pini(1).

     ENDIF.

     lv_i = lv_i + 1.

   ENDWHILE  .

   WRITE u_number TO lv_char1 LEFT-JUSTIFIED.

   lv_char2 = v_inv+lv_c(1).

   CONCATENATE lv_char1

               lv_char2

          INTO lv_char1.

   u_number = lv_char1.

ENDFORM.                    “calcsum

*&———————————————————————*

*&      Form  verhoeff_add_recursive

*&———————————————————————*

*       text

*———————————————————————-*

*      –>V_NUMBER   text

*      –>V_DIGITS   text

*———————————————————————-*

FORM verhoeff_add_recursive USING u_number

                                   u_digits.

   DATA: lv_temp TYPE char256,

         lv_aux  TYPE i.

   lv_temp = u_number.

   lv_aux = u_digits.

   WHILE lv_aux > 0.

     PERFORM calcsum USING lv_temp.

     lv_aux = lv_aux 1.

   ENDWHILE.

   u_number = lv_temp.

ENDFORM.                    “verhoeff_add_recursive

TOP Include:

FUNCTION-POOL zsdbo_cod_control.            “MESSAGE-ID ..

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

*  Tipos

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

*Types

TYPES: BEGIN OF ty_table,

         line(10) TYPE c,

        END OF  ty_table.

TYPES: BEGIN OF typ_state,

         line TYPE i,

        END OF typ_state.

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

*  Tabelas e Estruturas

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

*Tabelas

DATA: tbl_table_d   TYPE TABLE OF ty_table,

       tbl_table_p   TYPE TABLE OF ty_table.

DATA: tbl_state TYPE TABLE OF typ_state.

DATA: tbl_sumas TYPE TABLE OF typ_state.

*Estruturas

DATA: str_table     TYPE ty_table,

       str_ztsd068   TYPE ztsd068.

DATA: str_state  TYPE typ_state,

       str_state1 TYPE typ_state,

       str_state2 TYPE typ_state.

DATA: str_sumas TYPE typ_state.

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

*  Variaveis

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

*Variaveis

DATA: v_autorizacion TYPE char256, “nro de autorizacion de la factura

       v_factura      TYPE char256, “nro de factura

       v_nitci        TYPE char256, “nit o ci del cliente

       v_fecha        TYPE char256, “fecha de la transaccion (Ymd)

                                   “e.g. para el 10/08/2010: 20100810

       v_monto        TYPE char256, “monto de la transaccion sin decimales

       v_llave        TYPE char256, “llave de dosificacion

       v_codigo       TYPE char256, “codigo de control generado

       v_suma         TYPE char256. “Somatoria.

DATA: v_suma_n(256)     TYPE n,

       v_factura_n(256TYPE n,

       v_nitci_n(256)    TYPE n,

       v_fecha_n(256)    TYPE n,

       v_monto_n(256)    TYPE n.

DATA: v_d(10TYPE c,

       v_p(10)   TYPE c,

       v_inv(10) TYPE c.

DATA: v_digitos(5TYPE n,

       v_len         TYPE i,

       v_len_a       TYPE i,

       v_sub_llave   TYPE char256.

DATA: v_mensaje        TYPE char256,

       v_llaverc4       TYPE char256,

       v_arc4           TYPE char256,

       v_codcontrol_raw TYPE char256,

       v_codcontrol     TYPE char256.

DATA: v_suma_total   TYPE i,

       v_strlen_arc4  TYPE i,

       v_sumas1       TYPE i,

       v_i            TYPE i,

       v_x            TYPE i,

       v_aux          TYPE i,

       v_total        TYPE i,

       v_stsp         TYPE i,

       v_digitossum   TYPE i,

       v_dec2         TYPE p DECIMALS 2.

DATA: v_len_max   TYPE i,

       v_len_llave TYPE i,

       v_len_aux   type i.

Saludos,
Dalmo Costa

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Ivan Gestiada

    This code helps a lot.  The custom table mentioned on this code would need to be adjusted based on your client but that should be straight forward. 

    (0) 

Leave a Reply