You are on page 1of 36

EHP7 for SAP ERP

6.0
April 2014
English

NF-e Smart Forms


Smart Forms Configuration Guide

SAP AG
Dietmar-Hopp-Allee 16
69190 Walldorf
Germany
SAP Best Practices NF-e Smart Forms: Configuration Guide

Copyright
2014 SAP AG or an SAP affiliate company. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the
express permission of SAP AG. The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components
of other software vendors.
National product specifications may vary.
These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational
purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors
or omissions with respect to the materials. The only warranties for SAP Group products and services are
those that are set forth in the express warranty statements accompanying such products and services, if
any. Nothing herein should be construed as constituting an additional warranty.
SAP and other SAP products and services mentioned herein as well as their respective logos are
trademarks or registered trademarks of SAP AG in Germany and other countries. Please see
http://www.sap.com/corporate-en/legal/copyright/index.epx#trademark for additional trademark information
and notices.

SAP AG Page 2 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

Icons

Icon Meaning
Caution

Example

Note

Recommendation

Syntax

External Process

Business Process Alternative/Decision Choice

Typographic Conventions

Type Style Description


Example text Words or characters that appear on the screen. These include field
names, screen titles, pushbuttons as well as menu names, paths and
options.
Cross-references to other documentation.
Example text Emphasized words or phrases in body text, titles of graphics and tables.
EXAMPLE TEXT Names of elements in the system. These include report names,
program names, transaction codes, table names, and individual key
words of a programming language, when surrounded by body text, for
example, SELECT and INCLUDE.
Example text Screen output. This includes file and directory names and their paths,
messages, source code, names of variables and parameters as well as
names of installation, upgrade and database tools.
EXAMPLE TEXT Keys on the keyboard, for example, function keys (such as F2) or the
ENTER key.
Example text Exact user entry. These are words or characters that you enter in the
system exactly as they appear in the documentation.
<Example text> Variable user entry. Pointed brackets indicate that you replace these
words and characters with appropriate entries.

SAP AG Page 3 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

Content

NF-e Smart Forms.......................................................................................................................... 5


1 Purpose................................................................................................................. 5
2 Configuration: NF-e Smart Forms.........................................................................5
2.1 Create development class ZNFE..........................................................................5
2.2 Create Table Types............................................................................................... 6
2.2.1 Create Table Type ZNFYINVOICE..................................................................6
2.2.2 Create Table Type ZNFYITEM........................................................................7
2.3 Create Data Dictionary Objects.............................................................................8
2.3.1 Create Data Structure ZNFEDANFE_OTHERS..............................................8
2.3.2 Create Data Structure ZNFEDANFE_HEADER............................................10
2.3.3 Create Data Structure ZNFECONTIGEKEY..................................................11
2.4 Create function group Z_DANFE_CONTING......................................................13
2.5 Create function module ZNFE_CREATE_CONTI_CHECK_DIGIT....................14
2.6 Create BAdI Definitions (Business Add-Ins)........................................................17
2.7 Create Classic BAdI implemenation ZCL_NFE_PRINT......................................20
2.8 Create programs................................................................................................. 23
2.8.1 Create program ZNFE_J_1BNFPR_PRINTINC............................................23
2.8.2 Create program ZNFE_PRINT_DANFE........................................................24
2.9 Create Smart Forms............................................................................................26
2.9.1 Create Form Z_NFDANFE_PORTRAIT_SAP...............................................26
2.9.2 Create Form Z_NFDANFE_PORTRAIT_SAP...............................................27
2.10 Define System Barcodes.....................................................................................28
2.11 Create new transaction ZNFENUMCHECK........................................................28
2.12 Create new transaction ZNFENUMGAPS...........................................................30
2.12.1 Create program Z_NFE_LIST_NUMGAPS...................................................30
2.12.2 Create transaction ZNFENUMGAPS............................................................34

SAP AG Page 4 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

SAP AG Page 5 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

NF-e Smart Forms


1 Purpose
Your Company is implementing NF-e in Brazil, and has applied notes related to note 989115 -
Nota Fiscal Eletrnica. The functionality delivered requires a model for SMARTFORM of the
DANFE (Documento Auxiliar da Nota Fiscal Eletrnica), which substitutes the Nota Fiscal Model
1/1A nowprinted on "Formulrio Contnuo".

2 Configuration: NF-e Smart Forms


Use
Whenever a NF-e is sent to the government (XML file), and there is goods movement, a DANFE
must be printed in order to accompany the goods.

Procedure
Please follow the steps below in order to upload the SMARTFORM and implement the DANFE.

.2.1 Create development class ZNFE


Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools ABAP Workbench Overview Object Navigator


Menu SAP Ferramentas ABAP Workbench Sntese Object
Navigator
Transaction Code SE80

2. On the Object Navigator screen, click on button.

3. In the combo box, select . A blank field under this combo box is
presented:

4. In the blank field, enter ZNFE.

5. Click on <display> button.


6. Confirm the pop-up screen to create the package.
7. In the Package Builder: Create Package pop-up window, make the following entries:

SAP AG Page 6 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

Field name Description User action and values Comment


Short Description NFe - Print DANFE
Software HOME
Component
Package Type

Applic. <LEAVE BLANK> Do not enter any


Component value
Transport Layer <LEAVE BLANK> Do not enter any
value

8. Press <save> button.


9. A change request is required to save the package into the system.

.2.2 Create Table Types


2.2.1 Create Table Type ZNFYINVOICE
Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools ABAP Workbench Development ABAP


Dictionary
Menu SAP Ferramentas ABAP Workbench Desenvolvimento
Dictionary
Transaction Code SE11

2. On the ABAP Dictionary: Initial Screen screen, mark the radio button

3. In the blank field in front of radio button , enter ZNFYINVOICE

4. Click on button.

5. In the Create Type ZNFYINVOICE pop-up, choose


and press ENTER key to proceed.
6. In the Dictionary: Maintain Table Type screen, make the following entries:

Field name Description User action and values Comment


Short Description Invoice

7. In the Line Type tab page, make the following entries:

SAP AG Page 7 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

Field name Description User action and values Comment


Line Type J_1BPRNFFA

8. In the Initialization and Access tab page, make the following entries:

Field name Description User action and values Comment


Initial Line Number 0
Access

9. In the Primary Key tab page, make the following entries:

Field name Description User action and values Comment


Key definition

Key Category

10. Click on <activate> button

In the Create Object Directory Entry pop-up window, enter package ZNFE and click on
<save>,

2.2.2 Create Table Type ZNFYITEM


Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools ABAP Workbench Development ABAP


Dictionary
Menu SAP Ferramentas ABAP Workbench Desenvolvimento
Dictionary
Transaction Code SE11

2. On the ABAP Dictionary: Initial Screen screen, mark the radio button

3. In the blank field in front of radio button , enter ZNFYITEM

4. Click on button.

5. In the Create Type ZNFYITEM pop-up, choose and


press ENTER key to proceed.
6. In the Dictionary: Maintain Table Type screen, make the following entries:

SAP AG Page 8 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

Field name Description User action and values Comment


Short Description DANFE - Item

7. In the Line Type tab page, make the following entries:

Field name Description User action and values Comment


Line Type J_1BPRNFLI

8. In the Initialization and Access tab page, make the following entries:

Field name Description User action and values Comment


Initial Line Number 0
Access

9. In the Primary Key tab page, make the following entries:

Field name Description User action and values Comment


Key definition

Key Category

10. Click on <activate> button

In the Create Object Directory Entry pop-up window, enter package ZNFE and click on
<save>,

.2.3 Create Data Dictionary Objects


2.3.1 Create Data Structure ZNFEDANFE_OTHERS
Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools ABAP Workbench Development ABAP


Dictionary
Menu SAP Ferramentas ABAP Workbench Desenvolvimento
Dictionary
Transaction Code SE11

2. On the ABAP Dictionary: Initial Screen screen, mark the radio button

SAP AG Page 9 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

3. In the blank field in front of radio button , enter ZNFEDANFE_OTHERS

4. Click on button.
5. In the Create Type ZNFEDANFE_OTHERS pop-up window, select

and press ENTER key to proceed.


6. In the Dictionary: Maintain Structure screen, make the following entries:

Field name Description User action and values Comment


Short Description DANFE - Others
Information

7. In the Components tab page, make the following entries:

Component Component Type


FREIGHT <LEAVE BLANK>
UF_PLATE REGIO
BRAND_VOL <LEAVE BLANK>

8. Click on <enter>

9. Click on button and change the following entries:

Component Data type Length


FREIGHT NUMC 1
BRAND_VOL CHAR 60

10. Click on <enter>

11. Click on <activate> button

12. In the Create Object Directory Entry pop-up window, enter package ZNFE and click on
<save>,

SAP AG Page 10 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

2.3.2 Create Data Structure ZNFEDANFE_HEADER


Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools ABAP Workbench Development ABAP


Dictionary
Menu SAP Ferramentas ABAP Workbench Desenvolvimento
Dictionary
Transaction Code SE11

2. On the ABAP Dictionary: Initial Screen screen, mark the radio button

3. In the blank field in front of radio button , enter ZNFEDANFE_HEADER

4. Click on button.
5. In the Create Type ZNFEDANFE_HEADER pop-up window, select

and press ENTER key to proceed.


6. In the Dictionary: Maintain Structure screen, make the following entries:

Field name Description User action and values Comment


Short Description DANFE - Header

7. In the Components tab page, make the following entries:

Component Component Type


ISSUER J_1BPRNFIS
DESTINATION J_1BPRNFDE
CARRIER J_1BINNAD
NOTA_FISCAL J_1BPRNFHD
OTHERS ZNFEDANFE_OTHERS
NFE J_1BNFE_ACTIVE
ITEM ZNFYITEM
INVOICE ZNFYINVOICE
TEXT1 TSFTEXT
TEXT2 TSFTEXT
OBSERV1 <LEAVE BLANK>
OBSERV2 <LEAVE BLANK>

SAP AG Page 11 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

8. Click on <enter>

9. Click on button and change the following entries:

Component Data type


OBSERV1 STRING
OBSERV2 STRING

10. Click on <enter>

11. Click on <activate> button

12. In the Create Object Directory Entry pop-up window, enter package ZNFE and click on
<save>.

2.3.3 Create Data Structure ZNFECONTIGEKEY


Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools ABAP Workbench Development ABAP


Dictionary
Menu SAP Ferramentas ABAP Workbench Desenvolvimento
Dictionary
Transaction Code SE11

2. On the ABAP Dictionary: Initial Screen screen, mark the radio button

SAP AG Page 12 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

3. In the blank field in front of radio button , enter ZNFECONTIGEKEY

4. Click on button.
5. In the Create Type ZNFECONTIGEKEY pop-up window, select

and press ENTER key to proceed.


6. In the Dictionary: Maintain Structure screen, make the following entries:

Field name Description User action and values Comment


Short Description DANFE - Estrutura Chave
de Contingencia

7. In the Components tab page, make the following entries:

Component Component Type


REGIO J_1BREGIO
TPEMISS
STCD1 J_1BSTCD1
VTOTAL
ICMSP
ICMSS
DDEMISS
CDV J_1BCHECKDIGIT

8. Click on <enter>

9. Click on button and change the following entries:

SAP AG Page 13 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

Component Data Type Length


TPEMISS CHAR 1
VTOTAL CHAR 14
ICMSP CHAR 1
ICMSS CHAR 1
DDEMISS CHAR 2

10. Click on <enter>

11. Click on <activate> button

12. In the Create Object Directory Entry pop-up window, enter package ZNFE and click on
<save>

.2.4 Create function group Z_DANFE_CONTING


Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools ABAP Workbench Overview Object Navigator


Menu SAP Ferramentas ABAP Workbench Sntese Object
Navigator
Transaction Code SE80

2. On the Object Navigator screen, click on button.

3. In the combo box, select . A blank field under this combo box is
presented:

4. In the blank field, enter Z_DANFE_CONTING

5. Click on <display> button.


6. Confirm the pop-up screen to create the function group
7. In the Create function group pop-up window, make the following entries:

SAP AG Page 14 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

Field name Description User action and values Comment


Short Text Calcula Dig Verificador da Contingncia

8. Click .

9. In the Create Object Directory Entry pop-up window, enter package ZNFE and click on
<save>.

.2.5 Create function module


ZNFE_CREATE_CONTI_CHECK_DIGIT
Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools ABAP Workbench Development Function


Builder
Menu SAP Ferramentas ABAP Workbench Desenvolvimento
Function Builder
Transaction Code SE37

2. On the Function Builder: Initial Screen screen, enter


ZNFE_CREATE_CONTI_CHECK_DIGIT

3. Click on button.
4. In the Create Function Module pop-up window, make the following entries:

Field name Description User action and values Comment


Function module ZNFE_CREATE_CONTI_CHECK_DIGIT
Function group Z_DANFE_CONTING
Short Text Create Cont. check digit

5. Click . Confirm the pop-up regarding the function module name.


6. In the Function builder: change ZNFE_CREATE_CONTI_CHECK_DIGIT screen, click on
Changing tab page. Then, make the following entries:

Parameter Name Typing Associated Type Short Text


C_CONTINGKEY TYPE ZNFECONTIGEKEY Structure Key Contingency

7. Click <enter>

SAP AG Page 15 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

8. Click on tab page

9. Insert the following source-code after the function module`s description (in the previous
screen, line number 7).

SAP AG Page 16 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

DATA: lv_index TYPE i VALUE 35,


lv_step TYPE i VALUE 1,
lv_value TYPE i,
lv_total TYPE i,
lv_cd TYPE i.

DO 35 TIMES.
ADD 1 TO lv_step.
IF lv_step > 9.
lv_step = 2.
ENDIF.

lv_index = lv_index - 1.

*** CHECK lv_index > 0.

lv_value = c_contingkey+lv_index(1).

lv_value = lv_value * lv_step.

lv_total = lv_total + lv_value.

ENDDO.

lv_value = lv_total MOD 11.

IF lv_value = 0 OR
lv_value = 1.
lv_cd = 0.
ELSE.
lv_cd = 11 - lv_value.
ENDIF.

c_contingkey+35(1) = lv_cd.

SAP AG Page 17 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

10. Click on <check>. No syntax errors must be found.

11. Click on <activate>.

12. Once the system presents a message confirming that it was activated, click on <exit>.

.2.6 Create BAdI Definitions (Business Add-Ins)


Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools ABAP Workbench Utilities Business Add-Ins


Definition
Menu SAP Ferramentas ABAP Workbench Utilitrios Business
Add-Ins Definio
Transaction Code SE18

2. On the BAdI Builder: Initial Screen for Definitions screen, choose the
radio button.

3. Enter ZNFE as enhancement spot name and click on


4. In the Create enhancement spot window, make the following entries:

SAP AG Page 18 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

Field name Description User action and values Comment


Short Text BADI - Nota fiscal Eletronica DANFE

5. Click on <continue>

6. Enter the package ZNFE and click on <save>


7. Enter a change request to save your entries.
8. In the Enhancement spot ZNFE change screen, click on Enh.Spot Element Definitions tab
page.

9. Into the tab page, click on <create> and make the following entries:

Field name Description User action and values Comment


Name ZNFE
Short Description BADI - Nota fiscal Eletronica DANFE

10. Deselect the flag .

11. Expand the ZNFE node and double-click on


12. In the Interface screen section, make the following entries:

Field name Description User action and values Comment


Interface ZIF_EX_NFE

13. Click on <change interface>. In the pop-up, choose to create the


interface.

14. Enter the package ZNFE and click on <save>


15. Enter a change request to save your entries.
16. In the Class Builder: Change interface ZIF_EX_NFE screen, click on Methods tab page and
make the following entries:

Method Level Description


DEFINED_PRINTING Static Method Set the program for printing
PRINTING Static Method Routine call at the time of printing
FILLING_DANFE Static Method Filling Field of DANFE

17. Click on <enter> to confirm your entries.

SAP AG Page 19 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

18. In the Class Builder: Change Interface ZIF_EX_NFE screen, click on

line and then click on button, Make the


following entries:

Parameter Type Associated Type Description


I_DOCNUM Importing J_1BDOCNUM Doc. Number
E_RETORNO Exporting SY-SUBRC Return Value

19. Click on <enter> to confirm your entries. Click <back>


20. In the Class Builder: Change Interface ZIF_EX_NFE screen, click on
line and then click on button, Make the
following entries:

Parameter Type Associated Type Description


NF Importing J_1BPRNFHD Imprimir NF: cabealho do documento
INVOICE Changing ZNFYINVOICE Faturas
TEXT Changing J_1BPRNFTX Imprimir NF: textos
CARRIER Changing J_1BINNAD Interface: nome parceiro e endereo
STATE_VEHICLE Changing REGIO Regio (pas, estado, provncia, condado)
LICENSE_PLATE Changing TRAID Identificao do transporte

21. Click on <enter> to confirm your entries. Click <back>


22. In the Class Builder: Change Interface ZIF_EX_NFE screen, click on
line and then click on button, Make the following
entries:

Parameter Type Associated Type Description


DANFE Changing ZNFEDANFE_HEADER DANFE

23. Click on <enter> to confirm your entries. Click <back>

SAP AG Page 20 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

24. In the Class Builder: Change Interface ZIF_EX_NFE screen, click on <activate>. The
message Object(s) activated is presented.

25. Click twice to leave SE18.

.2.7 Create Classic BAdI implemenation


ZCL_NFE_PRINT
Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools ABAP Workbench Utilities Business Add-Ins


Implementation
Menu SAP Ferramentas ABAP Workbench Utilitrios Business
Add-Ins Implementao
Transaction Code SE19

2. On the BAdI Builder: Initial Screen for Implementations screen, in the Create
Implementation screen section, choose the radio button and make the
following entry:

Field name Description User action and values Comment


BAdI name CL_NFE_PRINT

3. Click on button.
4. In the Business Add-In: Create Implemenation pop-up, make the following entries:

Field name Description User action and values Comment


Implementation ZCL_NFE_PRINT
Name

5. Click on <continue>
6. In the Business Add-In Builder: Change implementation ZCL_NFE_PRINT screen, make the
following entries:

Field name Description User action and values Comment


Implementation ZCL_NFE_PRINT
Short Text

7. Click on <activate>

SAP AG Page 21 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

8. Enter the package ZNFE and click on <save>


9. Enter a change request to save your entries

10. Click on the Interface tab page and double-click on method.


11. In the Class Builder: Class ZCL_IM_CL_NFE_PRINT change screen is presented

12. The following source-code must be inserted:


DATA: wa_item TYPE j_1bnflin.

*** dados adicionais


FIELD-SYMBOLS: <xmlh> TYPE j1b_nf_xml_header,
<wk_item> TYPE table.

ASSIGN ('(SAPLJ_1B_NFE)xmlh') TO <xmlh>.

*** Busca o CNAE e TIPO DE IMPRESSO


out_header-docnum = in_doc-docnum.
out_header-tpimp = '1'.
out_header-c1_cnae = '1234567'.
MOVE-CORRESPONDING out_header TO <xmlh>.

*** Definio de frete - In ***


IF in_doc-inco1 EQ 'CIF'.
<xmlh>-t_modfrete = '1'.
MOVE-CORRESPONDING <xmlh> TO out_header.
ENDIF.

IF in_doc-inco1 EQ 'FOB'.
<xmlh>-t_modfrete = '0'.
MOVE-CORRESPONDING <xmlh> TO out_header.
ENDIF.

SAP AG Page 22 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

*** Dados do ITEM.


ASSIGN ('(SAPLJ_1B_NFE)WK_ITEM[]') TO <wk_item>.
IF <wk_item> IS ASSIGNED.

READ TABLE <wk_item> INTO wa_item INDEX 1.

*** Tratativa para tirar o valor negativo do desconto .


if wa_item-netdis < 0.
wa_item-netdis = wa_item-netdis * -1.
endif.

ENDIF.

13. Click on <check> to verify its syntax.

14. Click on <activate>

SAP AG Page 23 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

.2.8 Create programs


2.8.1 Create program ZNFE_J_1BNFPR_PRINTINC
Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools ABAP Workbench Development ABAP Editor


Menu SAP Ferramentas ABAP Workbench Desenvolvimento
Editor ABAP
Transaction Code SE38

2. On the ABAP Editor: Initial Screen screen, enter ZNFE_J_1BNFPR_PRINTINC

3. Choose
4. In the ABAP: Program Attributes ZNFE_J_1BNFPR_PRINTINC change screen, make the
following entries:

Field name Description User action and values Comment


Title PRINTINC
Type

Status

Application

5. Click

6. Choose package ZNFE and click


7. Enter a change request to save your entries.

8. Open the file ZNFE_J_1BNFPR_PRINTINC.TXT and copy its content.

path for the file: both NFe_Files.zip and the Quick Guide used for the related solution
are attached to the same SAP Note.

9. In the ABAP Editor: Change Report ZNFE_J_1BNFPR_PRINTINC screen, replace the


current source-code to the source-code copied from the TXT file.

SAP AG Page 24 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

10. Click <check> button to verify its syntax.

11. Click on <Activate> .

2.8.2 Create program ZNFE_PRINT_DANFE


Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools ABAP Workbench Development ABAP Editor


Menu SAP Ferramentas ABAP Workbench Desenvolvimento
Editor ABAP
Transaction Code SE38

2. On the ABAP Editor: Initial Screen screen, enter ZNFE_PRINT_DANFE

3. Choose
4. In the ABAP: Program Attributes ZNFE_PRINT_DANFE change screen, make the following
entries:

Field name Description User action and values Comment


Title Nota Fiscal Printing
Type

SAP AG Page 25 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

Field name Description User action and values Comment


Status

Application

5. Click

6. Choose package ZNFE and click


7. Enter a change request to save your entries.

8. Open the file ZNFE_PRINT_DANFE.txt and copy its content.

path for the file: both NFe_Files.zip and the Quick Guide used for the related solution
are attached to the same SAP Note.

9. In the ABAP Editor: Change Report ZNFE_PRINT_DANFE screen, replace the current
source-code to the source-code copied from the TXT file.

SAP AG Page 26 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

10. Click <check> button to verify its syntax.

11. Click on <Activate>

.2.9 Create Smart Forms


2.9.1 Create Form Z_NFDANFE_PORTRAIT_SAP
Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools Form Printout Smart Forms


Menu SAP Ferramentas Impresso de formulrio Smart Forms
Transaction Code SMARTFORMS

2. On the SAP Smart Forms: Initial Screen screen, choose radio button.

3. Enter Z_NFDANFE_PORTRAIT_SAP and click


4. In the SAP Form Builder: Change form Z_NFDANFE_PORTAIT_SAP screen, choose Utilities
Upload
5. Browse for the file z_nfdanfe_portrait_sap_novo.xml

path for the file: both NFe_Files.zip and the Quick Guide used for the related solution
are attached to the same SAP Note.

6. Confirm the overwriting.

7. Click on <check> to verify the form.

8. Click on <activate>

9. Enter the package ZNFE and click on <save>.


10. Enter a change request to save your entries.

2.9.2 Create Form Z_NFDANFE_PORTRAIT_SAP


Procedure
1. Access the activity using one of the following navigation options:

SAP AG Page 27 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

SAP Menu Tools Form Printout Smart Forms


Menu SAP Ferramentas Impresso de formulrio Smart Forms
Transaction Code SMARTFORMS

2. On the SAP Smart Forms: Initial Screen screen, choose radio button.

3. Enter Z_NFSTDANFE_SAP and click


4. In the SAP Form Builder: Change form Z_NFSTDANFE_SAP screen, choose Utilities
Upload
5. Browse for the file sfstyle-z_nfstdanfe_sap.xml

path for the file: both NFe_Files.zip and the Quick Guide used for the related solution
are attached to the same SAP Note..

6. Confirm the overwriting.

7. Click on <check> to verify the form.

8. Click on <activate>

9. Enter the package ZNFE and click on <save>.


10. Enter a change request to save your entries.

.2.10Define System Barcodes


Procedure
1. Access the activity using one of the following navigation options:

SAP Menu Tools Form Printout Administration Font


Menu SAP Ferramentas Impresso de formulrio Administrao
Fonte
Transaction Code SE73

2. In the SAPscript Font Maintenance: Initial Screen screen, choose

radio button.

3. Click on button

4. In the SAPscript Font Maintenance: change system bar codes screen, click on <create>

SAP AG Page 28 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

5. In the Choose bar code technology pop-up, click on and make the
following entries:

Field name Description User action and values Comment


Barcode name ZZDANFE
Short Text Barcode DANFE

6. In the Bar code symbology pop-up, choose radio button.

7. In the Barcode alignment pop-up, choose radio button.


8. In the Code 128 bar code parameters, make the following entries:

Field name Description User action and values Comment


Narrow Module Width 06
Linear Height 0210
Code128 Mode A

9. Save your entries.


10. Enter a change request to save your entries.

.2.11Create new transaction ZNFENUMCHECK


Procedure
1. Access the activity using one of the following navigation options:

Transaction Code SE93

2. In Maintain Transaction screen, make the following entries:

Field name Description User action and values Comment


Transaction code ZNFENUMCHECK

3. Click on button.
4. In Create Transaction pop-up window, make the following entries:

Field name Description User action and values Comment


Short Text Maint. Number Ranges
Checks for NF-e

Choose

SAP AG Page 29 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

5. Click on <continue>
6. In Create parameter transaction screen, make the following entries:

Field name Description User action and values Comment


Transaction SM30

Choose

Choose

Choose all GUI Support options:


In the Default Values screen section, make the following entries:

Field name Description User action and values Comment


Name of screen field SHOW
Value X
Name of screen field VIEWNAME
Value J_1BNFENUMCHECKV

7. Save your entries.


8. Enter the package ZNFE
9. Enter a workbench request

.2.12Create new transaction ZNFENUMGAPS


2.12.1 Create program Z_NFE_LIST_NUMGAPS
Procedure
1. Access the activity using one of the following navigation options:

Transaction Code SE38

2. In ABAP Editor: Initial Screen screen, make the following entries:

SAP AG Page 30 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

Field name Description User action and values Comment


Program ZNFE_LIST_NUMGAPS

3. Click on button.
4. In the ABAP: Program Attributes ZNFE_LIST_NUMGAPS Change pop-up window, make the
following entries:

Field name Description User action and values Comment


Title ZNFE_LIST_NUMGAPS
Type
Status
Application

Mark

Mark

5. Click on
6. Enter the package ZNFE
7. Enter a workbench request
8. In the ABAP Editor: Change report ZNFE_LIST_NUMGAPS screen, replace the current code
to the following source-code:
*&---------------------------------------------------------------------*
*& Report ZNFE_LIST_NUMGAPS
*&---------------------------------------------------------------------*
*& List NF-e Numbering Gaps
*& Basically, a list of table J_1BNFENUMGAP
*&---------------------------------------------------------------------*
REPORT znfe_list_numgaps.
*========================================================
==============*
* TABLES, INCLUDES, STRUCTURES, DATAS, ... *
*========================================================
==============*

*----------------------------------------------------------------------*
* TABLES *
*----------------------------------------------------------------------*
TABLES: j_1bnfenumgap. "NF-e Numbering Gaps

*----------------------------------------------------------------------*
* INCLUDES *

SAP AG Page 31 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

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

*----------------------------------------------------------------------*
* STRUCTURES *
*----------------------------------------------------------------------*
* NF-e Numbering Gaps structure ----------------------------------------
DATA: it_numgap TYPE TABLE OF j_1bnfenumgap.

**----------------------------------------------------------------------*
** DATA AND CONSTANTS *
**----------------------------------------------------------------------*
* Workarea for data fetch
DATA: wk_numgap LIKE LINE OF it_numgap.

DATA: gr_table TYPE REF TO cl_salv_table,


gr_error TYPE REF TO cx_salv_error,
gr_functions TYPE REF TO cl_salv_functions,
gr_display TYPE REF TO cl_salv_display_settings,
gr_columns TYPE REF TO cl_salv_columns_table,
gr_column TYPE REF TO cl_salv_column_table.
*
*========================================================
==============*
* EVENTS *
*========================================================
==============*
INITIALIZATION.

START-OF-SELECTION.
PERFORM get_data.

END-OF-SELECTION.
PERFORM display_data.

*========================================================
==============*
* PROGRAM *
*========================================================
==============*
*
*
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* Get data in table J_1BNFENUMGAP.
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*

SAP AG Page 32 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

FORM get_data.

* Retrieve all data into internal table


SELECT *
INTO TABLE it_numgap
FROM j_1bnfenumgap.

ENDFORM. " GET_DATA


*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_data .

* create ALV instance with class-method cl_salv_table=>factory


TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* list_display = IF_SALV_C_BOOL_SAP=>FALSE
* r_container =
* container_name =
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = it_numgap.

CATCH cx_salv_msg INTO gr_error.


MESSAGE e111(nr).
* Error when constructing ALV grid
ENDTRY.

* Turn on all ALV Grid functions


gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).

gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( text-001 ).

gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( text-002 ).
gr_column->set_long_text( text-002 ).
gr_column->set_medium_text( text-002 ).
gr_column->set_short_text( text-002 ).

SAP AG Page 33 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

* Display ALV Grid


gr_table->display( ).

ENDFORM. " DISPLAY_DATA

9. Scroll-down to the following code section:

10. Double-click on . Click on YES to create the object.


11. In the ABAP Text Elements: Change Text Symbols Language English screen, make the
following entries

Field name Description User action and values Comment


Symbol 001 Automatically created
Text List NF-e Numbering
Gaps
Symbol 002
Text ID

12. Select both lines and choose Goto Translation


13. Enter Target Language: PT
14. For each text, enter the suggested translation:

EN PT
List NF-e Numbering Gaps Listagem de Gaps
ID ID
ZNFE_LIST_NUMGAPS ZNFE_LIST_NUMGAPS

SAP AG Page 34 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

15. For each translated line, click on <new/create proposal> icon. In the next screen, click on

button. All lines must present a green status after these steps.

16. Save you entries and choose <back> to leave the translation screen.
17. Back to the ABAP Text Elements: Change Text Symbols Language English screen,click on

<activate>

18. Select all ZNFE_LIST_NUMGAPS entries and click on

2.12.2 Create transaction ZNFENUMGAPS


Procedure
1. Access the activity using one of the following navigation options:

Transaction Code SE93

2. In Maintain Transaction screen, make the following entries:

Field name Description User action and values Comment


Transaction code ZNFENUMGAPS

3. Click on button.
4. In Create Transaction pop-up window, make the following entries:

Field name Description User action and values Comment


Short Text List NF-e Numbering
Gaps

Choose

5. Click on <continue>
6. In Create report transaction screen, make the following entries:

Field name Description User action and values Comment


Program ZNFE_LIST_NUMGAPS
Selection Screen 1000
Authorization Object F_BKPF_BUK

Choose

SAP AG Page 35 of 36
SAP Best Practices NF-e Smart Forms: Configuration Guide

Choose all GUI Support options:

7. Click on button.
8. In the Values of Ch pop-up window, make the following entries:

Fields Values
ACTVT 03
BUKRS <leave empty>

9. Save your entries


10. Enter the package ZNFE
11. Enter a workbench request

SAP AG Page 36 of 36