0% found this document useful (0 votes)
150 views4 pages

Criar Função DMEE

This document contains code for two SAP exit functions: 1. ZZDMEE_EXIT_CNPJ_BP retrieves the Brazilian tax identification number (CNPJ) from master data tables and returns it. 2. ZZDMEE_EXIT_BARCODE_EXT retrieves barcode data from document items or from transaction tables and formats/returns it based on bank and document type. It was created by copying an exit function template.

Uploaded by

Thiago
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
150 views4 pages

Criar Função DMEE

This document contains code for two SAP exit functions: 1. ZZDMEE_EXIT_CNPJ_BP retrieves the Brazilian tax identification number (CNPJ) from master data tables and returns it. 2. ZZDMEE_EXIT_BARCODE_EXT retrieves barcode data from document items or from transaction tables and formats/returns it based on bank and document type. It was created by copying an exit function template.

Uploaded by

Thiago
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Função ZZDMEE_EXIT_CNPJ_BP

copiei DMEE_EXIT_TEMPLATE para ZZDMEE_EXIT_CNPJ_BP

texto fonte:
FUNCTION ZZDMEE_EXIT_CNPJ_BP.
*"--------------------------------------------------------------------
--
*"*"Interface local:
*"  IMPORTING
*"     VALUE(I_TREE_TYPE) TYPE  DMEE_TREETYPE
*"     VALUE(I_TREE_ID) TYPE  DMEE_TREEID
*"     VALUE(I_ITEM)
*"     VALUE(I_PARAM)
*"     VALUE(I_UPARAM)
*"  EXPORTING
*"     REFERENCE(O_VALUE)
*"     REFERENCE(C_VALUE)
*"     REFERENCE(N_VALUE)
*"     REFERENCE(P_VALUE)
*"  TABLES
*"      I_TAB
*"--------------------------------------------------------------------
--
*{   INSERT         S4DK900961                                  
      1

* Template function module -------------------------------------------
-*

  DATA: ls_item    TYPE dmee_paym_if_type,
        l_cnpj(20) TYPE c,
        l_taxnum   LIKE dfkkbptaxnum-taxnum.

  ls_item = i_item.

  CLEAR l_taxnum.
  SELECT SINGLE taxnum INTO l_taxnum
                       FROM dfkkbptaxnum
                      WHERE partner EQ ls_item-fpayh-gpa1r
                        AND taxtype EQ 'BR1'.
  IF NOT l_taxnum IS INITIAL.
    CONCATENATE '000000'
                l_taxnum
           INTO l_cnpj.
    c_value = l_cnpj.
  ELSE.
    CLEAR l_taxnum.
    SELECT SINGLE taxnum INTO l_taxnum
                         FROM dfkkbptaxnum
                        WHERE partner EQ ls_item-fpayh-gpa1r
                          AND taxtype EQ 'BR2'.
    IF NOT l_taxnum IS INITIAL.
      CONCATENATE '000000000'
                  l_taxnum
             INTO l_cnpj.
      c_value = l_cnpj.
    ENDIF.
  ENDIF.
*}   INSERT
ENDFUNCTION.

Função ZZDMEE_EXIT_BARCODE_EXT

copiei DMEE_EXIT_TEMPLATE_EXTEND_ABA para ZZDMEE_EXIT_BARCODE_EXT

texto fonte:
FUNCTION ZZDMEE_EXIT_BARCODE_EXT.
*"--------------------------------------------------------------------
*"*"Interface local:
*"  IMPORTING
*"     VALUE(I_TREE_TYPE) TYPE  DMEE_TREETYPE_ABA
*"     VALUE(I_TREE_ID) TYPE  DMEE_TREEID_ABA
*"     VALUE(I_ITEM)
*"     VALUE(I_PARAM)
*"     VALUE(I_UPARAM)
*"     REFERENCE(I_EXTENSION) TYPE  DMEE_EXIT_INTERFACE_ABA
*"  EXPORTING
*"     REFERENCE(O_VALUE)
*"     REFERENCE(C_VALUE)
*"     REFERENCE(N_VALUE)
*"     REFERENCE(P_VALUE)
*"  TABLES
*"      I_TAB
*"--------------------------------------------------------------------
*{   INSERT         S4DK901029                                  
      1

* Extended template function module ---------------------------------
--*
DATA: lv_glo_ref1 TYPE fac_glo_ref1,
      lv_name     TYPE thead-tdname,
      ls_item     TYPE dmee_paym_if_type.
*
ls_item = i_item.
lv_name = ls_item-fpayp-doc2r.
*
IF ls_item-fpayhx-formz EQ 'TAXUT'.
  CLEAR lv_glo_ref1.
  SELECT SINGLE glo_ref1 INTO lv_glo_ref1
                         FROM bseg
                        WHERE bukrs EQ ls_item-fpayp-doc2r(4)
                          AND belnr EQ ls_item-fpayp-doc2r+4(10)
                          AND gjahr EQ ls_item-fpayp-doc2r+14(4)
                          AND buzei EQ ls_item-fpayp-doc2r+18(3).
  IF NOT lv_glo_ref1 IS INITIAL.
    IF strlen( lv_glo_ref1 ) EQ 48.
      IF LS_ITEM-FPAYHX-UBNKL(3) EQ '341'.     " ITAU
        c_value = lv_glo_ref1.
      ELSEIF LS_ITEM-FPAYHX-UBNKL(3) EQ '237'. " BRADESCO
        CONCATENATE lv_glo_ref1(11)
                    lv_glo_ref1+12(11)
                    lv_glo_ref1+24(11)
                    lv_glo_ref1+36(11)
               INTO c_value.
      ELSE.                                    " OUTROS
        c_value = lv_glo_ref1.
      ENDIF..
      CONDENSE c_value NO-GAPS.
    ELSE.
      c_value = lv_glo_ref1.
    ENDIF.
  ELSE.
    c_value = lv_glo_ref1.
  ENDIF.
ENDIF.
**
**** Linhas abaixo usar quando o cod de barras estiver no texto
***  DATA: lt_lines    TYPE TABLE OF tline,
***        lw_lines    TYPE tline,
***        lw_header   TYPE thead,
***        lv_old_line TYPE thead-tdtxtlines,
***        lv_name     TYPE thead-tdname,
***        ls_item     TYPE dmee_paym_if_type.
***
***  ls_item = i_item.
***
***  lv_name = ls_item-fpayp-doc2r.
***
***  " Buscar o Código de barras gerado
***  CALL FUNCTION 'READ_TEXT'
***    EXPORTING
***      id                      = '0001'
***      language                = sy-langu
***      name                    = lv_name
***      object                  = 'DOC_ITEM'
***    IMPORTING
***      header                  = lw_header
***      old_line_counter        = lv_old_line
***    TABLES
***      lines                   = lt_lines
***    EXCEPTIONS
***      id                      = 1
***      language                = 2
***      name                    = 3
***      not_found               = 4
***      object                  = 5
***      reference_check         = 6
***      wrong_access_to_archive = 7
***      OTHERS                  = 8.
***
***  READ TABLE lt_lines INTO lw_lines INDEX 1.
***  IF sy-subrc IS INITIAL.
***
***    IF ls_item-fpayhx-formz EQ 'MUNIC' OR
***       ls_item-fpayhx-formz EQ 'DARF'.
***
***      IF strlen( lw_lines-tdline ) EQ 48.
***        CONCATENATE lw_lines-tdline(11)
***                    lw_lines-tdline+12(11)
***                    lw_lines-tdline+24(11)
***                    lw_lines-tdline+36(11)
***               INTO c_value.
***        CONDENSE c_value NO-GAPS.
***      ELSE.
***        c_value = lw_lines-tdline.
***      ENDIF.
***    ELSE.
***      c_value = lw_lines-tdline.
***    ENDIF.
***  ENDIF.

*}   INSERT
ENDFUNCTION.

You might also like