14 TH Aug
14 TH Aug
Logistics
WORKSTREAM Process
SUB-STREAM
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal
DOCUMENT NAME & LOCATION: information - values_textsvalues texts
DOCUMENT VERSION: 144.0
DATE: 12th Aug0808DecFeb 20242
READERSHIP:
SUMMARY:
Amendment History
RITM000002135690INC00000XXXXXXX – BRD
Diesel Distribution BR Tax Team requested
additional mandatory requirement for Fuels NF-
eProject
• (34_CR) CR#13 – Derive BR State (Region) to
corresponding XML tag (“Fuel Origin” area) from the
referenced NF-e(‘s) informed manually on ZB05 Text
block (following entry rules) for relevant Business
scenarios like “Shipment to Warehouse” and “Diesel
B Sales”.
0908th Feb Mauricio
4.0 o Change BADI_REQUIREMENT_26 –
Dec 20242 Depending on the process, the ZB05 text Tanniguchi
treatment is distinct: for ‘Diesel B Sales’,
ZB05 is expected to have two lines related
to Diesel A and Biodiesel NF-e’s
(mandatorily in this order and just this
number of lines). For ‘Shipment to
Warehouse’, however, the referenced
acquisition NF-e is expected to be on just
one line as just one grade is being
handled per transaction.
RITM000002278935INC00000XXXXXXX – BRio
Rio de Janeiro Office BR Tax Team requested
additional mandatory requirement for Fuels NF-
eProject
• (35_RTM) Turn available the Payment Info on NF-
e/DANFe for “NF-e Complementar” as per requested
by bpCE Business during BRio Workshop.
o Change BADI_REQUIREMENT_09 –
Check new parameter values (instead of
01st Apr08 Dec hard coded ones) on TVARVC (NF Mauricio
4.0
20242 Doctypes) to fill ET_TRADENOTES. In Tanniguchi
case NO PARAMETER is found, then
assume default Doctypes ‘1’ (Normal) and
‘2’ (Complementar)
o Change BADI_REQUIREMENT_12 –
Check new parameter values (instead of
hard coded ones) on TVARVC (NF
Doctypes) to fill ET_PAYMENT. In case
NO PARAMETER is found, then assume
default Doctypes ‘1’ (Normal) and ‘2’
(Complementar).
RITM000002278935INC00000XXXXXXX – BRio
Rio de Janeiro Office BR Tax Team requested
additional mandatory requirement for Fuels NF-
eProject
• (38_ITC) BUG 6797442 - Due to the need to
calculate and inform ICMS Exempt Value (“ICMS
Desonerado”) and its Reason on FCC scenarios
(otherwise SEFAZ Rejection error 934)
o New BADI_REQUIREMENT_27 – Create
05th Jun08 Dec new table to control application for “ICMS Mauricio
4.0
20242 Desonerado” on scenarios (mainly based Tanniguchi
on Issuance State and CST) and feed tags
related to vICMSDeson and MotDesICMS
o Change BADI_REQUIREMENT_05 –
Create new item text block with “ICMS
Desonerado” value and its “Motivo de
Desoneração”, controlled via TVARVC
o BADI_REQUIREMENT_18 – Create new
header text block with “ICMS Desonerado”
total value and “Motivo de Desoneração”,
controlled via TVARVC
RITM000002278935INC00000XXXXXXX – BRio
Rio de Janeiro Office BR Tax Team requested
additional mandatory requirement for Fuels NF-
eProject
• (40_UAT) BUG 6891059 – When having both ICMS
and FCP taxation, the ICMS Base value is shown
doubled on DANFe PDF (on XML is ok).
o Change DANFe Print Program – Adjust
#vlbcicmsnota with new logic to correctly
obtain the Total ICMS Base from all NF
Items, without doubling its value in case
21st Jun08 Dec ICMS FCP Tax is relevant on document. Mauricio
4.0
20242 • (41_CR) CR#02 – New BR Tax Team request to Tanniguchi
have PROCON (Consumer Protection Agency) fixed
text on all NF-e’s issued on Rio de Janeiro (only) –
manually or automatically.
o Change BADI_REQUIREMENT_05 –
Include new fixed text block for PROCON
for O2C Automatic issued NF-e’s
o Change BADI_REQUIREMENT_19 –
Include new fixed text block for PROCON
for Manual NFe’s issued (“NF Writer”)
o Change BADI_REQUIREMENT_20 –
Include new fixed text block for PROCON
for PtP Automatic issued NF-e’s
RITM000002474916INC00000XXXXXXX – BRD
Diesel Distribution BR Tax Team requested
additional mandatory requirement for Fuels NF-
eProject
• (43_CR) CR#14 - to be possible to issue GM RPTA
Differential Invoices (Sales Deals) for both Credit
and Debit situations respecting BR Legal
requirements for NF-e: on DEBIT situation, a “NF-e
Complementar” is mandatory to be issued, while on
CREDIT a special “NF Credit” record (no issuance)
is required to obey SAP BR Localization design
(otherwise error message).
o Change BADI_REQUIREMENT_26 – As
1208th Aug per requested by BR Tax Team, when “NF Mauricio
4.0 Complementar” is issued for GM RPTA
Dec 20242 Tanniguchi
Fuels, the ICMS Monophasic calculation
and tags feed for CST ‘61’ should be
suppressed.
• (44_CR) CR#14 – Standard SAP on SLL-NFE does
not fill tag qbcmonoret when value is zeroed from
ECC, leading to a non-XML tag creation and SEFAZ
error 769. This scenario is required for NF-e
Complementar with CST61 (all ICMS tags under
CST61 are zeroed, but all present on document).
o New
ENHANCEMENT_REQUIREMENT_06 –
SEFAZ ERROR 769 for ICMS CST61 on
NF-e Complementar. Tag qbcmonoret
must be present on ICM61 under ICMS
Group on NFe- XML.
Quality review
Distribution
Version Date
1 BUSINESS SCOPE..................................................................................................... 15
1.1 Business Requirements........................................................................................................................................16
1.2 Benefits..................................................................................................................................................................19
1.3 Assumptions..........................................................................................................................................................19
3.4 BADI Requirement 04: Sales order / Billing / Purchase Order information..................................................25
3.6 BADI Requirement 06: Feed Referenced NF Document by the Access Key informed on indicated Text ID
Field 45
3.14 BADI Requirement 14: Select the table of variant variables (TVARVC) table where TVARVC-SIGN =
“I”, TVARVC_OPTI = “EQ” and TVARVC-NAME = SYMBRET_NFCAT. Get the value of TVARVC-LOW.70
3.18 BADI Requirement 18: NFe Item Additional Info for SD................................................................................78
3.19 BADI Requirement 19: NFe Additional Header Info for Manually created NF-e’s (NF Writer)................87
3.21 BADI Requirement 99: Substitution of Z Text variables at final “Additional Information” area on NF-e.
Valid for SD or MM Automatic NFs..............................................................................................................................98
3.22 BADI Requirement 22: Legal requirement in Brazil to have 0 quantity on items of “Nota Fiscal
Complementar” – no matter for price or tax complement...........................................................................................99
3.23 BADI Requirement 23: NFe Item Additional Info for MM Automatic NF..................................................100
3.24 BADI Requirement 24: NFe Item Additional Info for NF Writer (Manually created)...............................104
3.25 BADI Requirement 25: Fuels qTemp tag filling from automatic Transactions...........................................107
3.26 BADI Requirement 26: New ICMS Adrem (“Monofasico”) Fuels Tax amounts and “Fuel Origin” NF-e
tags 112
3.27 BADI Requirement 27: Calculate and feed XML tags for “ICMS Desonerado” and controls its
application (including “Motivo de Desoneração”)......................................................................................................128
3.27.1 New Table, view - Maintenance of “ICMS Desonerado” Control and Parameters.....................................129
3.27.2 New Transaction (Tax Data – End User) for Maintenance view.................................................................129
3.27.3 Functional Logic...........................................................................................................................................130
7.2 Form: SAP Script / Smartform Details – DanFe and Printing program......................................................158
7.2.1 Form Main Requirements.............................................................................................................................158
7.2.2 Form Layout.................................................................................................................................................158
7.2.3 Page Break Requirement..............................................................................................................................159
7.2.4 Standard Texts (if SAPscript).......................................................................................................................159
7.2.5 Text Modules (if Smartforms)......................................................................................................................159
7.2.6 Layout Details – DanFe and Printing program.............................................................................................161
11.3 Module Function in SLL-NFE to collect and send NF-e XML data..............................................................185
17.2 To-Be process - SLL-NFE & SAP-ECC Other Enhancements for NFe – bp Specific Requirements:......200
17.2.1 ENHANCEMENT_REQUIREMENT_01: SEFAZ ERROR 858...............................................................200
17.2.2 ENHANCEMENT_REQUIREMENT_02: ICOS/NGRD COUNTERPARTIES – STREET x STREET2
INFO 202
17.2.3 ENHANCEMENT_REQUIREMENT_03: SEFAZ ERROR 362 – FUELS NFE MANDATORY
CARRIER.....................................................................................................................................................................203
17.2.4 ENHANCEMENT_REQUIREMENT_04: SPECIAL STOCK PARTNER FOR 3RD PARTY WH ON NF
204
17.2.5 ENHANCEMENT_REQUIREMENT_05: GM RPTA “Differential Invoice” treatment for BR Legal
Requirements (including “NF-e Complementar” when DEBIT).................................................................................204
17.2.6 ENHANCEMENT_REQUIREMENT_06: SEFAZ ERROR 769 – ICMS CST 61....................................205
21 APPENDIX..............................................................................................................237
21.1 SEFAZ Technical Notes.....................................................................................................................................237
21.1.1 (Version 1.0 – Brazil Trading Migration Project – 2022)............................................................................237
21.1.2 (Version 2.0 – Brazil Diesel Distribution Project – 2023)...........................................................................237
21.1.3 (Version 4.0 – Brazil Rio de Janeiro Office Project – 2024).......................................................................238
1 BUSINESS SCOPE
The Brazilian Invoice legal document “Nota Fiscal Eletrônica” or “NF-e” is the electronic format defined by an
agreement among State Tax Authorities in 2008 to substitute the former paper printed format (Model 1/A).
The electronic issuance (XML file) by contributor, submission to and approval from Tax Authority web
servers must be performed for ALL tangible goods movements (or services covered by ICMS regulation)
between two different contributors with different Tax Numbers (“CNPJ”) no matter they’re from the same
Company (exp: Plants of same Company but with different CNPJ inscriptions) or not (exp: a Customer, a
Contracted Warehouse Partner, etc). However, even with the legal electronic XML file, it’s also required to
have the contents printed on a form with legal defined layout to follow with the goods (for state border
inspections by Tax Authority when required). This form is named DANF-e (“Documento Auxiliar de NF-e”).
All those steps must be performed BEFORE the physical shipment: that means, the goods cannot be
shipped while NF-e is not electronically approved and DANFe is printed to follow them. For the mentioned
ICMS covered services, by other side, NF-e is issued after their execution or supplying (exp: utilities).
When taking BP Organizational and Processes scope into consideration for this Functional Specification, NF-
e must be considered on:
Company Codes:
BR0K – BPCE GPTA GM (TS IT) and
BR0L – BPCE GPTA FCC (TS ITHO)
BR0M – BPCE RPTA GM (TS IT) and
BR0N – BPCE RPTA FCC (TS ITHO)
Processes:
Energy Sales (Outbound NF-e).
and their exceptions where NF-e is required per Brazilian regulation:
o Debit Note (Outbound Complementary NF-e) – Customer charged less than the correct
value.
o Refusal (Inbound NF-e) – In case the maximum period for NF-e cancellation has expired.
Purchasing (Inbound booking NF-e).
and exceptions where NF-e is required per Brazilian regulation:
o Returns to Vendor (Outbound NF-e)
Other non-core operational activities where tangible goods must be sent or received and NF-e is
required per Brazilian regulation.
Fuel Sales (Outbound NF-e).
and their exceptions where NF-e is required per Brazilian regulation:
o Debit Note (Outbound Complementary NF-e) – Customer charged less than the
correct value.
o Return (booking Customer NF-e) and Refusal (Inbound NF-e) – In case the maximum
period for NF-e cancellation has expired.
Fuels Import Purchasing (Inbound NF-e issuance).
Shipment to Vendor Contracted Warehouse (Outbound NF-e) and Symbolic Return from
Vendor Contracted Warehouse (booking Vendor NF-e).
The image below provides an overall SAP system process perspective for outbound process (Sales and
Distribution and Materials Management) where a NF-e is automatically issued and electronically validated by
the Tax Authority (SEFAZ).
https://wiki.scn.sap.com/wiki/display/LOCLA/Basic+Sales+Process+in+Brazil
The Business Requirements related to the NF-e scope described on previous topic could be resumed in five
capabilities to provide Business Areas to perform their transactions with minimum impacts and
accomplishing with Brazilian requirements for issuance or booking NF-e’s when necessary.
Those capabilities are:
C1) Generation of all necessary and mandatory data for having a NF-e issuance approval by SEFAZ
Tax Authority, according to the nature of operation and required taxation.
C2) Formatting and electronically handling the NF-e information with Tax Authority (SEFAZ) on
required schemas, protocols, webservices, in a way that it’s transparent to the final user, being for
new submission for approval, cancellation request of an approved document. It also includes the
necessary functionalities to handle NF-e issuance in contingency mode.
C3) Provide a monitoring cockpit to check status of documents, while being possible to select the
necessary ones for manual triggering of the cancellations, resubmissions or inutilizations.
C4) Printout of DANF-e or generate its PDF file to be possible to go together with any tangible goods
(legal requirement) or to be sent as a formal Energy invoicing to Customers.
C5) Automatically sending e-mail to Customers, Vendors or pre-defined Partners (exp: carriers)
containing NF-e XML file and DANF-e and then accomplishes the mandatory legal requirement to
make this information available to the recipient.
1 1 – Billing Document is created by using SAP transactions or from an SD Order or from a Delivery
document. Accounting document is automatically created;
(START – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
1a – (Diesel Distribution) Due to BR requirements for Fuels NF-e (legal texts and other legal NF-e
1a linkages), a complimentary transaction must be filled by user to be possible to provide legal texts
information not possible to be input on OTP Systems frontend (mainly OWB). A transaction Z for that
info maintenance (per OWB Shipment / Parcel code) is provided.
(END – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
2 2 - SAP BR Localization automatically creates an additional SAP Nota Fiscal document, that contains
all data necessary to generate a NF-e. SAP Nota Fiscal Document can also be manually created by a
special transaction named “NF Writer”, for special scenarios like Inbound NF-e for Import;
3 3 – Some series of additional bp logic on an SAP developed functionality (inside an SAP extension
named BADI) automatically generates and / or fills mandatory fields and texts required for NF-e
issuance but not accomplished by SAP Standard BR Localization (Customer logic). That information will be
saved on SAP Tables regarding SAP NF Document;
4 - A standard SAP program running in job will perform the legal NF-e numbering for the SAP NF
4
Document and will create an output message (ZE01, class NF), that contains a specific program to
send all necessary XML data contents to SAP SLL-NFE client (via RFC connection);
5 – SAP SLL-NFE tool for Messaging control receives the XML data from SAP ECC and assembles
5
the effective NF-e XML formatted file and sent it to SEFAZ (webservice) after some prior checks.
Specific enhancements were done in SAP Std to accomplish NF-e XML requirements for Fuels (SEFAZ 858)
not supported so far by SAP Std BR LocalizationSAP SLL-NFE tool for Messaging control receives the XML
data from SAP ECC and assembles the effective NF-e XML formatted file and sent it to SEFAZ (webservice)
after some prior checks;
6 – SAP SLL-NFE then captures back (webservice) the return from SEFAZ for each sent XML file;
6
7 – In case SEFAZ rejects or denies the NF-e, then SLL-NFE returns the information to SAP ECC (via
7 RFC) and update SAP NF Standard tables, reflecting it on SAP NF-e Monitor for further user actions;
8 – In case SEFAZ returns OK, then SLL-NFE returns the information to SAP ECC (via RFC) and
8 update SAP NF Standard tables with ok status (including in SAP NF-e Monitor) and other SEFAZ info
(protocol number, etc), enabling next steps to generate DANF-e;
9 10 9 and 10 – With NF-e approved, DANF-e can be printed out on SAP ECC (automatically or not
depending on spool settings). Also, the program to send e-mails with approved NF-e XML file
(legal requirement), set as job, can now detect that NF-e is approved;
11 11 – Once NF-e is approved, job to send e-mails can send the XML file (and DANFe PDF) to the
inbox of Main NF-e recipient (the legal requirement);
11a
11a – In case a bpCE Central Inbox dedicated for automatically store NF-e’s is defined on parameter
table TVARVC (ZSD_EMAIL_DNFXML_BPINBOX), then e-mail will be sent also to this address;
12 12 - In case a Carrier (Partner Function ‘SP’) is defined on SAP NF Document, then e-mail will be sent
to it too;
13 - This is necessary as contracted Carrier must issue another legal document (CT-e) based on bp
13
NF-e information;
14 – In case a Withdrawal location / External Warehouse (Partner Function ‘SB’) is defined on SAP
14
NF Document, then e-mail will be sent to it;
15 15 - In this case, this is related to current External Warehousing process where the Vendor must issue
a Symbolic Return NF-e to bp based on Sales NF-e issued by bp;
1.2 Benefits
Make BP accomplish legal requirements related to issuance or booking NF-e’s and then enabling all its
Business transactions for charging BP’s Customers on Energy Sales core Business and for supporting any
tangible goods movements necessary on Company’s operational Outbound and Inbound transactions (no
matter for stockable or non-stockable items).
1.3 Assumptions
(DANF-e Printout) As the Brazilian Regulation for NF-e requires all NF-e texts to be in the
Portuguese language, all SAP objects (Standard or Brazilian Localization ones) must have
descriptions mandatorily created in PT (Portuguese) language, as the printing program will always
technically get all texts in that language irrespective of the user’s language. In case an object
relevant for NF-e, does not present translation to PT language, then no text (blank) will be shown
on the corresponding DANF-e field / area.
(DANF-e Printout) All Master Data (Customer, Vendor, Material) fields are required by the
Standard BR Localization to feed the SAP NF Document and thus, the NF-e layout must be filled
in accordance. Some examples are - ‘District’, ‘House Number’ in address area for Vendors and
Customers, ‘Control Code’ (“NCM”) for Material or Services.
(DANF-e Printout) It will be considered multipage NF-e implementation.
(Send E-Mail) Due to strict need to send e-mail and respective attachments to Brazilian Customer
/ Vendor and Partners only, all texts to be composed into the e-mail to be sent (Subject, Body
Text, Footer) will be in Portuguese (PT) language.
(Send E-Mail) It’s mandatory that the e-mail on Customer / Vendor Master Data to receive NF-e
files from BP is correct (“NFEXML” string stamp on notes field besides NF-e e-mail inbox
address), otherwise or no e-mail will be sent (if not informed) or it will be sent to an incorrect
address / inbox.
(DANF-e Printout) As A/R values and dates (including the ones from individual instalments)
from Billing accounting document (when selling energy) must be printed on the DANF-e
invoice, then this will be generated only if that corresponding accounting document is
posted and not blocked for any reason.
(Send E-Mail) To reduce complexity / cost / maintenance of the solution, key object to interface
with user will be the SAP NF Document number (internal unique number for NF-e’s, issued or
booked) and not the own NF-e legal number (that could repeat depending on the Business Place
and even for distinct series). This is due the SAP NF Document be the key for the output
messages when using Standard SAP tools for those objects. Relationship NF-e x SAP NF
Document is easily consulted at matchcode of transaction J1B3N (for massive way, in table
J_1BNFDOC).
For Business users, that means that in case of an exception and the e-mail must be sent or resent
by accessing manually the transaction, to inform the SAP NF Document (J1B3N Doc number), this
can be obtained by navigating from any document of the SD flow (Order, Delivery or Billing) to the
NF document or directly in J1B3N transaction by using the matchcode to inform other search
criteria (NF-e, Series, Branch, etc).
This enhancement is already developed in the PRC system to issue the XML file for nota fiscal.
PRC design uses standard SAP functionality (CL_NFE_PRINT) to generate the XML file for nota
fiscal and send to Brazilian authorities. The Business Add-in for nota fiscal uses variant data,
customer, vendor and material information and sales/billing data to fill nota fiscal tags for XML file.
2.2 To-Be process – NFe BADI:
This enhancement will be developed considering the same solution implemented in PRC. The BADI
definition is CL_NFE_PRINT J_1BNF_ADD_DATA, that is triggered everytime an SAP Nota fiscal
Document is created automatically when (and indicated Method to be used):
a BR billing document is saved (Method ADD_DATA)
a Credit note related to a BR Purchase Vendor return is posted (Method ADD_DATA)
a NF relevant Material movement is created (exp: STO 862) (Method ADD_DATA)
a manual SAP NF Document (“NF Writer”) is created (Method ADD_DATA_J1B1N)
To generate and send the XML contents for nota fiscal, a job will be scheduled to run periodically for
getting the latest SAP nota fiscal documents created into ECC system. This job will call program
J_BNFECALLRFC for assigning the legal 9 digits number and run the Business Add-in to
send via RFC all the mandatory information for the XML file to be assembled by SLL-NFE
solution (former SAP GRC-NFE). Then SLL-NFE will perform the webservice messages
handling with SEFAZ Tax Authority.
Important Remark: BADI J_1BNF_ADD_DATA is the one recommended by SAP to persist
(save) new data created by SEFAZ tax Authority starting from NF-e version 3.10, as SAP has
been created fields and also tables so far to support those constant new informationthat
constant new information. Former BADI is technically triggered after SAP NF Document is
saved on database: that is not ok when objective is to keep all legal data stored on SAP and
not only to send to messaging system (dynamic data). Another SAP definition is that, once
new BADI is activated, former BADI cannot be used anymore. The former PRC enhancement
done to superpose that rule and enable both BADIs running together (a change on Standard
SAP code, something to be avoided) will not be implemented in PRI.
Even with that, both Former CL_NFE_PRINT and new J_1BNF_ADD_DATA will continue to work
together on NF Writer transaction, while former BADI implementation is active.
(END – 11_UAT: Changes V2.0 – 04th Jul 2022)
No additional security requirements, as this BADI will run in the background when sending nota fiscal
documents to the Brazilian government.
Output Parameters:
OUT_HEADER
OUT_COBRANCA
OUT_VOLUME
OUT_REF
OUT_REB
OUT_REFPROC
OUT_ADD_INFO
Changing Parameters:
CH_EXTENSION1
CH_EXTENSION2
Both methods will be necessary as per the segregation defined by SAP. However, for
each Business requirement below, it will be defined if that will be applicable for both
methods or not.
OBS: Also, some functional/technical details will be exposed as not necessarily the logic
and / or information availability for each Method will be the same.
Functional logics
3.1 BADI Requirement 01: Indication of NF-e issuance on Test environment
All nota fiscal documents issued to the Brazilian Government Tax Authority via test environment
must fulfill some legal indicators on NF-e XML and DANF-e files.
In case the NF-e is being issued by a Customer system test environment – mandatorily linked
to SEFAZ Tax Authority NF-e test environment named “Homologação” – some NF-e XML
tags must be filled as indicated below:
out_header-tpamb must be equal to ‘2’ (otherwise ‘1’);
out_header-e_xnome as the following text string “NF-
E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL”.
To get this name, select the table TVARVC with TVARVC-SIGN = I,
TVARVC_OPTI = EQ and TVARVC-NAME equals to Z_NOTAFISCAL_NAME.
Get the value of TVARVC-L and Z_NOTAFISCAL_NAME2. Concatenate both
TVARVC-LOW found and fill out the field, out_header-e_xnome in the uppercase.
As bp has a rule to set SAP Quality Clients as “Production” (Table T000), then the
Standard SAP BR Localization logic based on this information to define communication with
SEFAZ Tax Authority Production (“Produção”) or Test (“Homologação”) does not work when in
QA.
New persistent BADI’s are not able to change “tpamb” tag as former BADI and so, no possibility
to keep former logic (commented above).
As a prodedure from now on, QA clients should be opened for manual configuration adjust on
BR Branches for defining “TPAMB” as ‘2-Homologacao’, while Golden configuration will remain
with field in blank, meaning environment based on T000 (for Production and effective non-
Production environments).
Scope
=> For both Application automatic issued NF-e’s and Manually issued NF-e’s
(“NF Writer”).
For each nota fiscal document, the country code tag (c1_pais) has to be 1058.
This functionality is now provided by SAP Standard Brazilian Localization: no need to
implement any logic on BADI J_1BNF_ADD_DATA.
Configuration on IMG view J_1BEFDV_COUNTRY will be necessary for Country ‘BR’ and
BCB (Brazil Central Bank) code ‘1058’.
Scope
=> For both Application automatic issued NF-e’s and Manually issued NF-e’s
(“NF Writer”).
For nota fiscal documents issued with id_dest = 2 (Interstate operation), the tags <t2_placa>,
<t2_uf1> and <t2_rntc> have to be blank.
(Legal requirement from official SEFAZ Tax Authority Technical Note 2016.002 v1.61)
Scope
=> Application automatic issued NF-e’s: For accomplishing that, just don’t
move customized source info for tags <t2_placa>, <t2_uf1> and <t2_rntc> on items b)
and c) of the next Requirement 05 topic, when IS_HEADER-ID_DEST = ‘2’.
=> Manually issued NF-e’s (“NF Writer”): (By procedure) User must not fill
corresponding fields on SAP NF Document when on a Interstate situation or when it
is not transportation relevant.
3.4 BADI Requirement 04: Sales order / Billing / Purchase Order information
This requirement will be accomplished on next topic, together with other Texts on Complementary
information.
The complementary information tag is a fusion of text IDs and the logic to find the texts is
the same, changing only the text ID.
Select table J_1BNFLIN where DOCNUM = IN_DOC-DOCNUM and REFTYP = BI. Get the
value of REFKEY, deleting the duplicated entries.
Select table VBRP with VBELN = J_1BNFLIN-REFKEY. Get the values of VGBEL and
J_1BTXSDC.
Some Header Texts used in PRC to derive information to NFe XML tags or texts will be
kept to not change operational procedures (on commercial and/or logistics areas). A new
functionality to be possible to parameterize the SEQUENCE of the texts will be
implemented (using TVARVC table). However, massive technical changes will be
performed by new implementation on BADI J_1BNF_ADD_DATA, Method ADD_DATA,
including segregated Function Modules or Includes for each functionality:
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding fields.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
* Check if it’s a new NF issuance (not booking)
CHECK is_header-form IS NOT INITIAL
* Read current “Complementary Info” text block to control legal maximum length (5000)
READ (saplj1bg)wnfftx INTO lt_wnfftx
* Get maximum number of chars for “Complement info” area (current legal = 5000)
DATA: lv_maxlen NUMERIC
SELECT low FROM tvarvc INTO lv_maxlen WHERE
Name = ‘ZSD_NFE_CMPLINF_MAXLEN’
ENDIF
CASE ls_sequence-low
WHEN ‘ZSD_NFE_CMPLINF_HDTX_DRVINFO’
*** a) (Text) To fill driver’s detail,
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
* Check NF Type is different from Adjust (exp: Complementary)
CHECK is_header-doctyp NE ‘2’
(END – 07_UAT: Changes V2.0 – 29th Jun 2022)
Read parameter table (TVARVC) record in an variable ls_tvarvc table using following
criteria:
NAME = ls_sequence-low
IF found AND ls_tvarvc-low IS NOT INITIAL
Language = PT
Name = VBRP-VGBEL
Object = VBBK
ID = <ls_tvarvc-low> ***must be “ZBxx”
Language = PT
Name = it_vbrp-vgbel ** Premise: all Billing items from same Delivery/Sales Order
Object = “VBBK”
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
IF sy-subrc IS INITIAL and tdline IS NOT INITIAL
Try to split tdline at “;” into two fields for lv_cnh and lv_drivername.
ENDIF
ENDIF
WHEN ‘ZSD_NFE_CMPLINF_HDTX_FREETXT’
*** b) (Text) To get a free manual header text (Máx = 400 chars)
Read parameter table (TVARVC) record in ana variable ls_tvarvc table using following
criteria:
NAME = ls_sequence-low
IF found AND ls_tvarvc-low IS NOT INITIAL
Name = it_vbrp-vgbel ** Premise: all Billing items from same Delivery/Sales Order
Object = “VBBK”
IF sy-subrc IS INITIAL and tdline IS NOT INITIAL
DATA: lv_maxfree NUMERIC
* Get parameter with max number of chars for free text block
lv_maxfree = ls_tvarvc-high
IF sy-subrc IS NOT INITIAL OR lv_maxfree > 700 OR lv_maxfree IS INITIAL
* If parameter is not correctly defined, fix the maximum
lv_maxfree = 700
ENDIF
lv_tdline = tdline
* Check number of chars on free text block (tdline)
IF QtyChars[lv_tdline] > lv_maxfree
Truncate string lv_tdline to a maximum of characters defined by lv_maxfree
ENDIF
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
ENDIF
ENDIF
WHEN ‘ZSD_NFE_CMPLINF_HDTX_TRUCKDTLS’
*** c) (Text and XML Tags) To fill national register of truck details
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
* Check NF Type is different from Adjust (exp: Complementary)
CHECK is_header-doctyp NE ‘2’
(END – 07_UAT: Changes V2.0 – 29th Jun 2022)
Read parameter table (TVARVC) record in an variable ls_tvarvc table using following
criteria:
NAME = ls_sequence-low
IF found AND ls_tvarvc-low IS NOT INITIAL
* SEFAZ Rule: don’t inform Vehicles info for interstate transaction (error 868)
IF is_header-id_dest <>≠ ‘2’
* Only first line is valid (premise: one truck/tractor per NFe)
CLEAR: lv_t1placa, lv_t1uf1 lv_t1rntc
Get tdline and split string at character “;” into lv_t1placa, lv_t1uf1 and lv_t1rntc
* Feed NF Header info fields
ES_HEADER-PLACA = lv_t1placa
ES_HEADER-UF1 = lv_t1uf1
ES_HEADER-RNTC = lv_t1rntc
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
ENDIF
ENDIF
ENDIF
WHEN ‘ZSD_NFE_CMPLINF_HDTX_TRAILDTLS’
*** c) (Text and XML Tags) To fill national register of trailers’ details (more than one possible),
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
* Check NF Type is different from Adjust (exp: Complementary)
CHECK is_header-doctyp NE ‘2’
(END – 07_UAT: Changes V2.0 – 29th Jun 2022)
Read parameter table (TVARVC) record in an variable ls_tvarvc table using following
criteria:
NAME = ls_sequence-low
IF found AND ls_tvarvc-low IS NOT INITIAL
ENDIF
ENDIF
ENDIF
ENDIF
WHEN ‘ZSD_NFE_CMPLINF_HDTX_DG_GATEC’
*** c) (Text) To fill UN Dangerous goods info (premise: one item per NFe)
Read parameter table (TVARVC) record in an variable ls_tvarvc table using following
criteria:
NAME = ls_sequence-low
IF found AND ls_tvarvc-low IS NOT INITIAL
WHEN ‘ZSD_NFE_CMPLINF_HDTX_SD_DOCSNR’
*** c) (Text) To fill SD Order, Delivery (if exists), Billing and Customer PO number (if exists) info
Read parameter table (TVARVC) record in an variable ls_tvarvc table using following
criteria:
NAME = ls_sequence-low
IF found AND ls_tvarvc-low IS NOT INITIAL
CLEAR: lv_docs
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
IF it_nflin-aubel IS NOT INITIAL
lv_docs = CONCATENATE lv_docs // “; Ordem: “ // it_vbrp-aubel INTO lv_docs
IF it_vbrp-vgbel <>≠ it_vbrp-aubel AND it_vbrp-vbtypvgtyp = ‘J’
lv_docs = CONCATENATE lv_docs // “; Remessa: “ // it_vbrp-vgbel INTO lv_docs
ENDIF
IF is_vbrk-vbeln IS NOT INITIAL
lv_docs = CONCATENATE lv_docs // “; Fatura: “ // is_vbrk-vbeln INTO lv_docs
ENDIF
IF it_nflin-xped IS NOT INITIAL
lv_docs = CONCATENATE lv_docs // “; Pedido: “ // it_nflin-xped INTO lv_docs
ENDIFD
e) To get price memory, call function “READ_TEXT” with the following parameters:
ID = ZB05 (TVARVC_NAME = NFE_ZB05)
Language = PT
Name = VBRP-VGBEL
Object = VBBK
Get tdline.
(ZB05 was discontinued in DANFE printing program and on BADI CL_NFE_PRINT in PRC: the
codings to assign read lines were commented).
WHEN ‘ZSD_NFE_CMPLINF_HDTX_DSCSUFRMA’
Select table KNA1 where KUNNR = IN_DOC-PARID. Get the value of ADRNR and
SUFRAMA.
*** c) (Text) To fill SUFRAMA Code and ICMS Discount on a Sales to ZFM
Read parameter table (TVARVC) record in an variable ls_tvarvc table using following
criteria:
NAME = ls_sequence-low
IF found AND ls_tvarvc-low IS NOT INITIAL
lv_taxtypzf = ls_tvarvc-low
lt_nfstx = it_nfstx
CLEAR: lv_dsczf
LOOP ON lt_nfstx INTO ls_nfstx
IF ls_nfstx-taxtyp = lv_taxtypzf
lv_dsczf = lv_dsczf + ABS( ls_nfstx-taxval )
ENDIF
ENDLOOP
IF lv_dsczf IS NOT INITIAL AND is_header-isuf IS NOT INITIAL
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
CONCATENATE lv_appendtextlv_appendtext // “; Abatimento de ICMS Referente à
Isenção em Vendas p/ Zona Franca: R$ “ // lv_dsczf INTO lv_appendtextlv_appendtext
CONCATENATE lv_appendtextlv_appendtext // “; Registro do Cliente na SUFRAMA: “ //
is_header-isuf INTO lv_appendtextlv_appendtext
CONCATENATE lv_appendtext // “Abatimento de ICMS Referente à Isenção em Vendas
p/ Zona Franca:R$ “ // lv_dsczf // “; “ INTO lv_appendtext
CONCATENATE lv_appendtext // “Registro do Cliente na SUFRAMA:“ // is_header-isuf
// “; “ INTO lv_appendtext
(END – 07_UAT: Changes V2.0 – 29th Jun 2022)
ENDIF
ENDIF
WHEN ‘ZSD_NFE_CMPLINF_HDTX_EMAIL’
*** (Text) Contact e-mail (NOT the NF-e destination one, marked with flag “Do not use communication
number”)
Read parameter table (TVARVC) record in an variable ls_tvarvc table using following
criteria:
NAME = ls_sequence-low
IF found AND ls_tvarvc-low IS NOT INITIAL
lv_txtadrt = ls_tvarvc-low
CLEAR: ls_smtptxt
(START – 08_UAT: Changes V2.0 – 29th Jun 2022)
DELETE lt_email WHERE remark IS NOT EQUAL TO lv_txtadrt
(END – 08_UAT: Changes V2.0 – 29th Jun 2022)
LOOP ON lt_email INTO ls_email
IF ls_smtptxt IS INITIAL
(START – 08_UAT: Changes V2.0 – 29th Jun 2022)
CONCATENATE “; E-MAIL: “ // ls_ email-smtp_addr INTO ls_smtptxt
ELSE
CONCATENATE ls_smtptxt // “; “ // ls_ email-smtp_addr INTO ls_smtptxt
WHEN ‘ZSD_NFE_CMPLINF_HDTX_FCP_TOT’
*** (Text) Total of FCP Tax, if exists
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_sequence-low
IF found AND lt_tvarvc IS NOT INITIAL
lt_taxtypfcp = lt_tvarvc
lt_nfstx = it_nfstx
CLEAR: lv_fcpval
LOOP ON lt_nfstx INTO ls_nfstx
IF ( ls_nfstx-taxtyp on lt_taxtypfcp-low ) AND ( ls_nfstx-stattx IS INITIAL )
lv_fcpval = lv_fcpval + ABS( ls_nfstx-taxval )
ENDIF
ENDLOOP
IF lv_fcpval IS NOT INITIAL
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
WHEN ‘ZSD_NFE_CMPLINF_HDTX_FCPST_TOT’
*** (Text) Total of FCP-ST Tax, if exists
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_sequence-low
lt_nfstx = it_nfstx
CLEAR: lv_fcpstval
LOOP ON lt_nfstx INTO ls_nfstx
IF ( ls_nfstx-taxtyp on lt_taxtypfcpst-low ) AND ( ls_nfstx-stattx IS INITIAL )
lv_fcpstval = lv_fcpstval + ABS( ls_nfstx-taxval )
ENDIF
ENDLOOP
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
IF lv_fcpval IS NOT INITIAL
WHEN ‘ZSD_NFE_CMPLINF_HDTX_LOCRET’
*** (Text) For the Partner, if any, that is marked as “Local de Retirada”
When selling directly from External Vendor Warehouse, the location will be identified by
Partner Function ‘SB’ (Special Stock) that will be included as NF Partners on view J_1BADV
(even restricted to SAP maintenance). On view J_1BNFE_PAR_MAPV, this SB partner –
together with combinations with relevant NF Types – will be defined as “Local de Retirada”.
ENDIF
ENDLOOP
ENDIF
WHEN ‘ZSD_NFE_CMPLINF_HDTX_LOCENT’
*** (Text) For the Partner, if any, that is marked as “Local de Entrega”
When specific Partner Function is defined as “Local de Entrega” per NF Type on view
J_1BNFE_PAR_MAPV, and existing this entry on TVARVC, the text will be assembled and
inserted on “Dados Adicionais” area of NF-e.
lt_locent = lt_tvarvc
SORT lt_locent BY low ASCENDING
ENDIF
ENDLOOP
ENDIF
WHEN ‘ZSD_NFE_CMPLINF_HDTX_ZSWH_NFE’
* ENH026 will treat user access to fill ZB05 text on the correct manner and just for the
* document types enabled (via item category ZSMB and its returns so far).
Read parameter table (TVARVC) record in a variable ls_tvarvc table using following criteria:
NAME = ls_sequence-low
LOW = it_vbrp[1]-pstyv
IF found AND ls_tvarvc-high IS NOT INITIAL
* One of three possibilities is expected as per the following offered to end used
* during ENH026 processing to create such reference:
* Option A: <SAP NF DOCNUM>;<blank>
* Option B: <blank>;<Access key of the reference NFe>
* Option C: <SAP NF DOCNUM>;<Access key of the reference NFe> =< Redundant
* The logic below will always start searching using SAP NF Doc internal number and,
* in case not found, will test searching by 44 digits Access Key (if filled)
* OBS: Just one line is expected and will be read (the first): others, if exist, will not
* be considered
IF lv_docnum IS INITIAL
IF lv_accesskey IS NOT INITIAL
DATA:
lv_regio TYPE RANGE OF j_1bregio,
lv_nfyear TYPE RANGE OF j_1byear,
lv_nfmonth TYPE RANGE OF j_1bmonth,
lv_stcd1 TYPE RANGE OF j_1bstcd1,
lv_model TYPE RANGE OF j_1bmodel,
lv_serie TYPE RANGE OF j_1bseries,
lv_nfnum9 TYPE RANGE OF j_1bnfnum9,
lv_docnum9 TYPE RANGE OF j_1bdocnum9,
lv_cdv TYPE RANGE OF j_1bcheckdigit.
lv_regio = lv_accesskey(2)
lv_nfyear = lv_accesskey+2(2)
lv_nfmonth = lv_accesskey+4(2)
lv_stcd1 = lv_accesskey+6(14)
lv_model = lv_accesskey+20(2)
lv_serie = lv_accesskey+22(3)
lv_nfnum9 = lv_accesskey+25(9)
lv_docnum9 = lv_accesskey+34(9)
lv_cdv = lv_accesskey+43(1)
IF sy-subrc IS INITIAL
SELECT docnum FROM j_1bnfe_active INTO lv_docnum WHERE
CANCEL IS INITIAL
DOCSTA = ‘1’
REGIO = lv_regio
NFYEAR = lv_nfyear
NFMONTH = lv_nfmonth
STCD1 = lv_stcd1
MODEL = lv_model
SERIE = lv_serie
NFNUM9 = lv_nfnum9
DOCNUM9 = lv_docnum9
CDV = lv_cdv
IF sy-subrc IS NOT INITIAL
CLEAR: lv_docnum
ENDIF
ENDIF
ENDIF
ELSE
SELECT * FROM j_1bnfdoc WHERE docnum = lv_docnum AND
cancel IS INITIAL AND
docstat = ‘1’
IF sy-subrc IS NOT INITIAL
CLEAR: lv_docnum
ENDIF
ENDIF
IF lv_docnum IS NOT INITIAL
* NF Doc number on database: not cancelled and NF-e approval status = ‘1-Authorized’
SELECT * FROM j_1bnfdoc INTO ls_nfdoc WHERE docnum = lv_docnum
SELECT * FROM tvarvc INTO ls_tvarvc_nftyp WHERE
name = ‘ZSD_NFE_USER_ADDINFOINP_NFTYPE’
low = ls_nfdoc-nftyp
(START – 32_UAT: RITM000001897233 Changes V4.0 – 25th Sep 2023)
partner_not_found = 1
address_not_found = 2
OTHERS = 3.
ELSEIF ls_nfdoc-partyp = ‘C’
CALL FUNCTION 'J_1B_NF_CUSTOMER_READ'
EXPORTING
partner_id = ls_nfdoc-parid
read_address = 'X'
IMPORTING
parnad = ls_partner
address = ls_address
address1 = ls_address1
EXCEPTIONS
partner_not_found = 1
address_not_found = 2
OTHERS = 3.
ENDIF
IF sy-subrc IS INITIAL and ls_partner IS NOT INITIAL
* In case et_item text already filled, preserves original text block before adding new one
IF lv_field_amount_total IS NOT INITIAL
CONCATENATE lv_appendtext // “;” // ls_tvarvc_icmsdeson-high //
// lv_field_amount_total INTO lv_appendtext
WHEN ‘ZSD_NFE_CMPLINF_HDTX_PROCON’
** As this is a 100% fixed text, text block will be possible to maintain on SO10 transaction in
case future changes are necessary (no program change)
CLEAR: lt_ltext, ls_ltext, ls_tvarvc_procon
Read parameter table (TVARVC) in an internal variable ls_tvarvc_procon the unique record with
following criteria:
NAME = ls_sequence-low AND
LOW = is_header-branch AND
HIGH IS NOT INITIAL
IF sy-subrc IS INITIAL AND ls_tvarvc_procon IS NOT INITIAL
CALL FUNCTION Read_Text USING
EXPORTING
ID = ‘ST’
Language = PT
Name = ls_tvarvc_procon-high
Object = ‘TEXT’
IMPORTING
lines = lt_ltext
Select the table of variant variables (TVARVC) table where TVARVC-SIGN = “I”,
TVARVC_OPTI = “EQ” and TVARVC-NAME = SYMBRET_NFCAT. Get the value of
TVARVC-LOW.
If IN_DOC-NFTYPE is in TVARVC-LOW,
If the values found in READ_TEXT for ID ZB01 and ZB02 are in blank, concatenate
out_header-infcomp, values from ID ZB03, ZB04 and ADR6-SMTP-ADDR.
If any value was found in ZB01 and/or ZB02, concatenate out_header-infcomp, values
from ID ZB03, ZB04, “PLACA DO(S) VEICULO(S):”, ZB01 “-“ “PLACA DO(S)
ENDCASE
ENDLOOP
ENDIF
ENDIF
ENDIF
ENDLOOP
ENDIF
(END – 14_UAT: Changes V2.0 – 25th Jul 2022)
3.6 BADI Requirement 06: Feed Referenced NF Document by the Access Key informed on
indicated Text ID Field
f) To get the access key from the reference document, call function “READ_TEXT” with the
following parameters:
ID = ZB06 (TVARVC_NAME = NFE_ZB06)
Language = PT
Name = VBRP-VGBEL
Object = VBBK
Get tdline and fill the tag b12_refnfe.
New BADI doesn't support direct update of reference access key but the related SAP NF document
instead. So, the new logic will look for this SAP NF Doc using the access key informed and will
update the DOCREF field on NF Header. In case the SAP NF doc is not found (invalid entry in ZB06
text), then no reference will be informed.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding fields.
model = ls_acckey-model
serie = ls_acckey-serie
nfnum9 = ls_acckey-nfnum9
docnum9 = ls_acckey-docnum9
cdv = ls_acckey-cdv
IF sy-subrc IS INITIAL
* SAP NF Doc related to access key found: update reference field on current NF Doc header
MODIFY (saplj1bg)wnfdoc-docref FROMWITH lv_docref CONTENTS
ENDIF
ENDIF
ENDIF
ENDIF
(refnfe = acckey of the original nota fiscal referenced. To get the value of acckey and fill
the refnfe tag field in XML, with IN_DOC-DOCNUM value, go to J_1BNFDOC and get
DOCREF. If J_1BNFE_ACTIVE-DOCNUM = J_1BNFDOC-DOCREF, concatenate the field
values below, to have the value for the field acckey: J_1BNFE_ACTIVE-REGIO + NFYEAR
+ NFMONTH + STCD1 + MODEL + SERIE + NFNUM9 + TPEMIS + DOCNUM8 + CDV
This functionality is now provided by SAP Standard Brazilian Localization. Once field
J_1BNFDOC-DOCREF is filled, corresponding Access Key is captured (assembled) from
J_1BNFE_ACTIVE table and will feed BA02-refNFe tag: no need to implement any logic
Scope
=> For both Application automatic issued NF-e’s and Manually issued NF-e’s
(“NF Writer”).
Time stamp NF Doc related to a NF-e issuance with Date and Time when document is
being effectively created plus a delta period defined by a parameter (HHMMSS). An
exception parameter per NF Type can be created.
Scope
=> For both Application automatic issued NF-e’s and Manually issued NF-e’s
(“NF Writer”). Implement logic on both Methods ADD_DATA and ADD_DATA_J1B1N
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
*1st step: Get Timezone from Business Place issuing the NFe
CALL FUNCTION tz_location_timezone
EXPORTING
COUNTRY = ls_address-land1
REGION = ls_address-regio
IMPORTING
TIMEZONE = lv_timezone
*3rd step: convert obtained Timestamp to Date/Time related to Time Zone of the
* Business Place Location
CALL FUNCTION ib_convert_from_timestamp
EXPORTING
I_TIMESTAMP = lv_timestamp
I_TZONE = lv_timezone
IMPORTING
E_DATLO = lv_datlo
E_TIMLO = lv_timlo
C14B_ADD_TIME.
Update ES_HEADER-HSAIENT with E_ENDTIME
ES_HEADER-DSAIENT with E_ENDDATE
Endif
Endif (if not using ls_name)
(if no register – including the “default” - is found, no delta time will be added)
[3.9] BADI Requirement 09: Installments InfoPayment tags (Tradenotes) + Grupo Fatura
To fill the Payment tags, the information has to be selected from BSID and BSAD tables
by using the Function Module “DETERMINE_DUE_DATE” to calculate the invoice due
date.
The sequence number(OUT_COBRANCA-NDUP_NEW) will be increased for all new
register at BSID or BSAD.
To get the data:
Fields Declaration:
Declare a custom variable LF_NDUP type N length 1 (to work as a sequential number, 1, 2
3, etc..)
Declare a custom variable LF_MORE_PARC type C length 1 (control whether a text will be
printed in the last line).
Declare a custom table LT_BSID type BSID (to retrieve data from BSID and BSAD)Declare
a custom table LT_LIN type J_1BNFLIN.
Declare a custom structure LS_FAEDE type FAEDE (used in function
DETERMINE_DUE_DATE).
Declare a custom structure LW_E_FAEDE type FAEDE (used in function
DETERMINE_DUE_DATE).
Declare a custom variable LF_REF_NUMBER type J_1BINTERF-XBLNR.
Functional Logic:
If J_1BNFDOC-DIRECT = “2”, select table J_1BNFNAD where DOCNUM = IN_DOC-
DOCNUM and PARVW = “RG”. Get the value of PARID.
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding fields.
Implementation Logic
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
key = xaccit-awkeyawref
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
IF sy-subrc IS INITIAL AND NOT lt_fxacccr IS INITIAL AND NOT lt_fxaccit IS INITIAL
* Import was OK and structures are not empty
CLEAR lt_cust_lines
CLEAR ls_cust
READ it_partner-parid USING parvw = ‘RG’ *** Payer
IF sy-subrc IS INITIAL and it_partner-parid IS NOT INITIAL
lv_kunnr = it_partner-parid
ENDIF
LOOP lt_fxaccit INTO ls_fxaccit WHERE
bschl = ‘01’
kunnr = lv_kunnr
IF sy-subrc IS INITIAL
* Customer accounting line found (A/R)
ls_tradenotes-ndup = ls_cust_line-posnr
* Per NT 2016.002, ndup just with 3 algarisms (XXX)
ls_tradenotes-ndup = ls_cust_line-posnr+7(3)
OUT_VOLUME-T4_PESOL = IN_DOC-NTGEW
OUT_VOLUME-T4_PESOB = IN_DOC-BRGEW
OUT_VOLUME-T4_QVOL = OUT_VOLUME-T4_QVOL + J_1BNFLIN-MENGE
OUT_VOLUME-T4_ESP = J_1BNFLIN-MEINS
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding fields.
Standard SAP BR Localization fills new structure ET_TRANSVOL but with information from Billing
document, not from Delivery (in case it exists). Note by the example above that even the logistics
updating the gross weight on Delivery header, this information is not reflected on NF Doc Header
neither on TRANSVOL line.
OBS: On current bp BR scenarios, it will be premised that no packaging functionality will be active
on delivery document
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
CLEAR lv_delivery
IF iv_applic = ‘BI’
* Check if Billing is related to a Delivery Doc
* Premise: read 1st Billing item is enough
CHECK ( it_vbrp-vgtyp = ‘J’ OR it_vbrp-vgtyp = ‘T’ )
lv_delivery = it_vbrp-vgbel
ELSE
* Get the STO Delivery related to the movement that generated the NF
* Premise: read 1st NF item is enough
IF it_nflin-reftyp = ‘MD’ and is_mkpf IS NOT INITIAL
lv_delivery = is_mkpf-le_vbeln
ENDIF
ENDIF
ls_transvol-qvol = is_header-shpunt
ENDIF
ls_transvol-pesol = lv_ntgew
ls_transvol-pesob = lv_brgew
MODIFY et_transvol FROMUSING ls_transvol
ENDIF
ENDIF
ENDIF
ENDIF
Select the table of variant variables (TVARVC) where TVARVC-SIGN = “I”, TVARVC_OPTI
= “BT” and TVARVC-NAME = Z_NOTAFISCAL_MODFRETE. Get the values of TVARVC-
LOW and TVARVC-HIGH.
If IN_DOC-INCO1 is found in TVARVC-LOW, fill OUT_HEADER-T_MODFRETE = TVARVC-
HIGH.
This functionality is now provided by SAP Standard Brazilian Localization: no need to
implement any logic on BADI J_1BNF_ADD_DATA.
Configuration on IMG view J_1BMODFRETE_DET will be necessary for PRI Incoterms to
be used in Brazil.
Scope
=> For both Application automatic issued NF-e’s and Manually issued NF-e’s
(“NF Writer”).
Screenshot from SEFAZ Tax Authority document with all necessary information to
compose a legal NF-e XML file.
(SEFAZ Technical Note 2016.002 v1.61)
Scope
(START – 03_CT1: Changes V2.0 – 26th May 2022)
=> Only for Application automatic issued NF-e’s.
=> For both Application automatic issued NF-e’s and Manually issued NF-e’s (“NF
Writer”).
Implementation Logic
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
CLEAR: ls_payment
ls_payment-counter = 0001
ls_payment-tpag = ‘90’
ls_payment-vpag = <empty>
APPEND et_payment with ls_payment
ENDIF
(START – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)
ENDIF
(END – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)
(END – 03_CT1: Changes V2.0 – 26th May 2022)
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
CLEAR: et_payment
* Billing application: check if associated Billing type is registered as a valid parameter (relevant) into
TVARVC
(START – 16_UAT: Changes V2.0 – 17th Aug 2022)
SELECT SINGLE FROM tvarvc INTO lv_xpag WHERE
Name = ‘ZSD_NFE_ADDDT_PAYINFO_99_XPAG’
(START – 16_UAT: Changes V2.0 – 17th Aug 2022)
SELECT <fkart values> FROM tvarvc WHERE
Name = ‘ZSD_NFE_ADDDT_PAYINFO_FKART’
IF sy-subrc IS INITIAL AND NOT lt_fxacccr IS INITIAL AND NOT lt_fxaccit IS INITIAL
IF sy-subrc IS INITIAL AND NOT lt_fxacccr IS INITIAL AND NOT lt_fxaccit IS INITIAL
* Import was OK and structures are not empty
CLEAR lt_cust_lines
CLEAR ls_cust
CLEAR lv_cust_pay
READ it_partner-parid USING parvw = ‘RG’ *** Payer
IF sy-subrc IS INITIAL and it_partner-parid IS NOT INITIAL
lv_kunnr = it_partner-parid
ENDIF
LOOP lt_fxaccit INTO ls_fxaccit WHERE
bschl = ‘01’
kunnr = lv_kunnr
IF sy-subrc IS INITIAL
* Customer accounting line found (A/R)
IF is_header-id_dest = ‘3’
* For Export, value in BRL is in FXACCIT structure
ELSE
ls_payment-vpag = is_header-nftot.
(START – 02_CT1: Changes V2.0 – 18th May 2022)
MODIFY et_payment FROMwith ls_payment
APPEND et_payment FROMwith ls_payment
(END – 02_CT1: Changes V2.0 – 18th May 2022)
ELSE
ls_payment-counter = 0001
ls_payment-tpag = ‘99’
(START – 16_UAT: Changes V2.0 – 17th Aug 2022)
ls_payment-xpag = lv_xpag
(START – 16_UAT: Changes V2.0 – 17th Aug 2022)
ls_payment-vpag = lv_cust_pay
(START – 02_CT1: Changes V2.0 – 18th May 2022)
MODIFY et_payment FROMwith ls_payment
APPEND et_payment FROMwith ls_payment
(END – 02_CT1: Changes V2.0 – 18th May 2022)
MODIFY et_payment with ls_payment
ENDIF
* Billing document for SALES: get payment method from PAYER Customer Code
READ it_partner-parid USING parvw = ‘RG’ *** Payer
IF sy-subrc IS INITIAL and it_partner-parid IS NOT INITIAL
* Payer found
* OBS: In case multiple Payment Methods exist, always will be considered the first one (first character)
SELECT zwels(1) FROM knb1 INTO lv_zwels WHERE
kunnr = it_partner-parid AND
bukrs = is_header-bukrs
IF sy-subrc IS INITIAL and ls_zwels IS NOT INITIAL
* Payment Method found on Payer’s Customer Master: now read from/to on Z parameter table to SEFAZ
value
Concatenate ‘ZSD_NFE_PAYM_METH_’ with lv_zwels
into lv_name
READ parameter table (TVARVC) record in an internal ls_tvarvc
ENDIF
ENDIF
(START – 02_CT1: Changes V2.0 – 18th May 2022)
ELSE
* Payment Method NOT found on Payer’s Customer Master
ls_payment-counter = 0001
ls_payment-tpag = ‘99’
ls_payment-vpag = lv_cust_pay
MODIFY et_payment FROMwith ls_payment
(END – 02_CT1: Changes V2.0 – 18th May 2022)
ENDIF
(START – 02_CT1: Changes V2.0 – 18th May 2022)
ELSE
* Payer not found
ls_payment-counter = 0001
ls_payment-tpag = ‘99’
ls_payment-vpag = lv_cust_pay
MODIFY et_payment FROMwith ls_payment
(END – 02_CT1: Changes V2.0 – 18th May 2022)
ENDIF
ELSE *** lv_cust_pay = 0.
* No A/R lines (no Customer Payment)
CLEAR: ls_payment
ls_payment-counter = 0001
ls_payment-tpag = ‘90’
ls_payment-vpag = <empty>
(START – 02_CT1: Changes V2.0 – 18th May 2022)
MODIFY et_payment FROMwith ls_payment
APPEND et_payment with ls_payment
(END – 02_CT1: Changes V2.0 – 18th May 2022)
MODIFY et_payment with ls_payment
ENDIF
ELSE *** IMPORT not successful or accounting structures empty
CLEAR: ls_payment
ls_payment-counter = 0001
ls_payment-tpag = ‘90’
ls_payment-vpag = <empty>
(START – 02_CT1: Changes V2.0 – 18th May 2022)
MODIFY et_payment FROMwith ls_payment
APPEND et_payment with ls_payment
(END – 02_CT1: Changes V2.0 – 18th May 2022)
ENDIF
Select table TVARVC where TVARVC-SIGN = “I”, TVARVC_OPTI = “EQ” and TVARVC-
NAME = Z_NOTAFISCAL_INDPRES. Get the value of TVARVC-LOW.
Fill out_header-ind_pres with TVARVC-LOW.
Definition of Presence Indicator can be set by automatic created NF Type in a more specific
way using TVARVC table. In case no specific value is defined, default ‘…’ will be used.
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding field.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
CLEAR: lt_tvarvc
SELECT * FROM tvarvc INTO lt_tvarvc WHERE
Name = ‘ZSD_NFE_PRES_INDIC_NFTYPE’
* Sort internal table by LOW (NF Type) and not by NUMB key (sequence)
SORT lt_tvarvc BY name low ASCENDING
* 1st attempt: try to read using current NF Type
READ lt_tvarvc INTO ls_tvarvc USING
Name = ‘ZSD_NFE_PRES_INDIC_NFTYPE’
Low = is_header-nftype
IF sy-subrc = 0 AND ls_tvarvc-high IS NOT INITIAL
* 1st attempt successful: feed field related to NF-e tag
ES_HEADER- IND_PRES = ls_tvarvc-high(1)
ELSE
* 2nd attempt: try to read “generic” NF Type
READ lt_tvarvc INTO ls_tvarvc USING
Name = ‘ZSD_NFE_PRES_INDIC_NFTYPE’
Low = ‘**’
IF sy-subrc = 0 AND ls_tvarvc-high IS NOT INITIAL
* 2nd attempt successful: feed field related to NF-e tag
ES_HEADER- IND_PRES = ls_tvarvc-high(1)
ELSE
* No success: fix value ‘1’
ES_HEADER- IND_PRES = ‘1’
ENDIF
ENDIF
For O2C:
3.12[3.14] BADI Requirement 14: Select the table of variant variables (TVARVC) table where
TVARVC-SIGN = “I”, TVARVC_OPTI = “EQ” and TVARVC-NAME =
SYMBRET_NFCAT. Get the value of TVARVC-LOW.
If any value is found in the selection above and IN_DOC-NFTYPE is in TVARVC-LOW values, get the
billing document and item number.
If J_1BNFLIN-VBELN is not in blank, select table VBRP where VBELN = J_1BNFLIN-REFKEY and
POSNR = J_1BNFLIN-REFITM. Get the values of AUBEL and AUPOS. If any value is found,
OUT_ITEM-XPED = VBRP-AUBEL and OUT_ITEM = VBRP-AUPOS.
Fill NF Item tags xPed and nItemPed with SD Order related to SAP NF Doc that originated
the NF-e.
Scope
=> Only for Application automatic issued NF-e’s.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
If any value is found in the selection above and IN_DOC-NFTYPE is in TVARVC-LOW values, select
TVARVC table where TVARVC-SIGN = “I”, TVARVC_OPTI = “EQ” and TVARVC_NAME =
Z_NOTAFISCAL_GTIN. Get the value of TVARVC_LOW.
Fill:
out_item-cean = TVARVC_LOW
out_item-ceantrib = TVARVC_LOW
For items that do not have GTIN code, it’s mandatory to fill the tags cEAN and cEANTrib
with phrase “SEM GTIN”.
Scope
(START – 04_CT1: Changes V2.0 – 18th May 2022)
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding field.
=> For both Application automatic issued NF-e’s and Manually issued NF-e’s (“NF
Writer”).
Implementation Logic
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
Fill mandatory XML tags related to Fuels section not filled by SAP: <CIDE>qBCProd,
<CIDE>vAliqProd and <CIDE>vCIDE.
Scope
=> Only for Application billing automatic issued NF-e’s. For manual SAP NF
Docs (transaction J1B1N), user must provide information on corresponding field.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
* Avoid issues in case variable not filled: default value will be ‘ZCID’. If not, change program
IF ls_tvarvc-low IS INITIAL
ls_tvarvc-low = “ZCID”
ENDIF
(START – 26_INC: Changes V4.0 – 08th Dec 2022)
ls_fuel-vCIDE = ls_nfstx-taxval
(START – 26_INC: Changes V4.0 – 08th Dec 2022)
For P2P:
Select the table of variant variables (TVARVC) table where TVARVC-SIGN = “I”, TVARVC_OPTI =
“EQ” and TVARVC-NAME = SYMBRET_NFCAT. Get the value of TVARVC-HIGH.
Fill mandatory XML tags related to ICMS-ST “Repasse” (for CST 60) not filled by SAP:
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding field.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
ENDIF
ENDLOOP
ENDLOOP
ENDIF
Some texts used in PRC related to items (specific tax values, dangerous goods, ANP
code, etc) will be moved to corresponding < infAdProd> tag on NFe XML. Each text will be
controlled – like done on header texts – by a new functionality to parameterize both the
activation/insertion and the SEQUENCE of the texts (using TVARVC table). Changes will
be performed by new implementation on BADI J_1BNF_ADD_DATA, Method ADD_DATA,
including segregated Function Modules or Includes for each functionality:
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding fields.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
* Check if it’s a new NF issuance (not booking)
CHECK is_header-form IS NOT INITIAL
* Check NF generate from a Billing document
CHECK iv_applic EQ ‘BI’
* Check NF Type is different from Adjust or Return
CHECK is_header-doctyp NE ‘2’ AND is_header-doctyp NE ‘6’
* Check BR Company Code active or not
SELECT * FROM tvarvc INTO lt_tvarvc WHERE
Name = ‘ZSD_NFE_CMPLINF_BUKRS’
* Get maximum number of chars for “infAdProd” area (current legal = 500)
DATA: lv_maxitmlen NUMERIC
SELECT low FROM tvarvc INTO lv_maxitmlen WHERE
Name = ‘ZSD_NFE_CMPLINF_ITMMAXLEN’
ENDIF
CASE ls_itm_sequence-low
WHEN ‘ZSD_NFE_CMPLINF_ITTX_FCP’
*** a) (Text) FCP Tax,
* Copy internal structures to keep their integrity
CLEAR ls_nflin , lt_nflin, lt_nfstx
COPY it_nflin TO lt_nflin
COPY it_nfstx TO lt_nfstx
SORT lt_nfstx BY docnum itmnum taxtyp
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_itm_sequence-low
IF lt_tvarvc IS NOT INITIAL
WHEN ‘ZSD_NFE_CMPLINF_ITTX_FCPST’
*** a) (Text) FCP ST Tax,
* Copy internal structures to keep their integrity
CLEAR ls_nflin , lt_nflin, lt_nfstx
COPY it_nflin TO lt_nflin
COPY it_nfstx TO lt_nfstx
SORT lt_nfstx BY docnum itmnum taxtyp
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_itm_sequence-low
IF lt_tvarvc IS NOT INITIAL
WHEN ‘ZSD_NFE_CMPLINF_ITTX_ICMS60’
(START – 18_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
*** a) (Text) For “ICMS Repasse” in case ICMS CST 60 and values exist on ZSTR Tax Type (that
gathers values from ZST* conditions from Fuels pricing): Statistical calculated value of ICMS withheld on
previous supply chain step (by ICMS-ST) based on medium average. Values will be move from Pricing
condition types to a new ZSTR “dummy” Tax Type (defined by this TVARVC variable) to be possible to
have the values directly in SAP NF Document.
* Copy internal structures to keep their integrity
CLEAR ls_nflin , lt_nflin, lt_nfstx
COPY it_nflin TO lt_nflin
COPY it_nfstx TO lt_nfstx
SORT lt_nfstx BY docnum itmnum taxtyp
Read parameter table (TVARVC) record in a variable lv_tvarvc (just one value expected)
using following criteria:
NAME = ls_itm_sequence-low
IF lv_tvarvc IS NOT INITIAL
ENDIF
ENDLOOP
ENDIF
*** a) (Text) For “ICMS Repasse” in case ICMS CST 60 and values exist on et_item fields for
“Repasse” (filled by previous BADI_REQUIREMENT_17).
CLEAR ls_nflin, ls_item, lv_appendtextitm
COPY it_nflin TO lt_nflin
LOOP lt_ nflin INTO ls_nflin
lv_tabix = sy-tabix
READ lt_item INTO ls_item USING
itmnum = ls_nflin-itmnum
* Loop on NF additional BADI fields for ALL items to check “ICMS Repasse” informed on
* BADI_REQUIREMENT_17 (or not)
IF ls_nflin-taxsit =’6’ AND ls_nflin ls_item-vbcstret IS NOT INITIAL
* “ICMS Repasse” found and with tax base not null: use this for the text and end (next NF item)
* In case et_item text already filled, preserves original text block before adding new one
READ lt_item INTO ls_item USING
itmnum = ls_nflin-itmnum
lv_appendtextitm = ls_item-infadprod
(START – 25_UAT: RITM000001588724 Changes V3.0 – 22nd Nov 2022)
CONCATENATE lv_appendtextitm // “ ICMS retido anteriormente conf. art. 412, inciso II do
RICMS/SP. Base de cálculo unitária em: “ // $y01 // “ retida anteriormente R$ “ // $w01 // “ / Valor
ICMS unitário em: “ // $y01 // “ retido anteriormente R$ “ // $x01 // “;” // INTO lv_appendtextitm
(START – 39_ITC: RITM000002278935 Changes V4.0 – 14th Jun 2024)
CONCATENATE lv_appendtextitm // “ ICMS pago p/substituicao tributaria conf.inciso
II, art.412 RICMS/SP. ICMS-ST Repasse p/ “ // $y01 // “ Base de Calculo unitaria:R$ “ // $w01 // “,
valor unitario: R$ “ // $x01 // “;” // INTO lv_appendtextitm
CONCATENATE lv_appendtextitm // “ICMS pago p/substituicao tributaria conf.inciso II,
art.412 RICMS/SP. ICMS-ST Repasse p/ “ // $y01 // “ Base de Calculo unitaria:R$ “ // $w01 // “,
valor unitario: R$ “ // $x01 // “;” // INTO lv_appendtextitm
(END – 39_ITC: RITM000002278935 Changes V4.0 – 14th Jun 2024)
(END – 25_UAT: RITM000001588724 Changes V3.0 – 22nd Nov 2022)
##### PLEASE REVIEW TEXT BLOCK ABOVE AND NEW SPACINGS ###
Where: $w01 = ls_nflin ls_item-vbcstret
$x01 = ls_nflin ls_item-vicmsstret
$y01 = ls_nflin-meins
ls_item-infadprod = lv_appendtextlv_appendtextitm
MODIFY lt_item FROMUSING ls_item USING TABIX = lv_tabix
ENDIF
ENDLOOP
ENDIF
(END – 18_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
WHEN ‘ZSD_NFE_CMPLINF_ITTX_ANP’
*** a) (Text) For ANP Code for Fuels (Brazilian Petroleum Agency). Field is on Material Master Data
and it’s supplied by SAP Std Brazilian Localization (mandatory on NF-e specific tag for this purpose in case item
is a fuel or lubricant)
* Copy internal structures to keep their integrity
CLEAR ls_nflin , lt_nflin, lt_fuel
COPY it_nflin TO lt_nflin
COPY et_fuel TO lt_fuel
SORT lt_fuel BY docnum itmnum
Read parameter table (TVARVC) record in a variable lv_tvarvc (just one value expected)
using following criteria:
NAME = ls_itm_sequence-low
IF lv_tvarvc IS NOT INITIAL
ENDCASE
ENDLOOP (lt_itm_sequence)
* table it_item has all final text blocks: move to et_item only with restricted length
CLEAR: ls_item
LOOP lt_item INTO ls_item
lv_tabix = sy-tabix
IF ls_item-infadprod is NOT INITIAL
* Check number of chars for overflow situation
lv_remain = lv_maxlenitm – QtyChars[ls_item-infadprod]
IF QtyChars[ls_item-infadprod] > lv_remain
* Total item block collected surpasses the maximum defined: truncate
lv_string = ls_item-infadprod
Truncate string lv_string (cutting from end to begin) to a maximum of characters defined
by lv_remain
(START – 25_UAT: RITM000001588724 Changes V3.0 – 22nd Nov 2022)
CONDENSE lv_string
(END – 25_UAT: RITM000001588724 Changes V3.0 – 22nd Nov 2022)
ls_item-infadprod = lv_string
MODIFY et_item FROMUSING ls_item using TABIX = lv_tabix
ENDIF
ENDIF
ENDLOOP
Scope
=> Only for Manually created NF-e’s.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
* Check if it’s a new NF issuance (not booking)
CHECK is_header-form IS NOT INITIAL
* Check NF manual (J1B1N)
CHECK is_header_manual IS NOT INITIAL
* Check NF Type is different from Correction or Cancel
CHECK is_header-doctyp NE ‘3’ AND is_header-doctyp NE ‘5’
* Check BR Company Code active or not
(START – 22_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
SELECT * FROM tvarvc INTO lt_tvarvc WHERE
Name = ‘ZSD_NFE_CMPLINF_BUKRS’
* Get maximum number of chars for “infcpl” area (current legal = 5000)
* OBS: Legal tech restriction by SEFAZ valid for both SD and MM
DATA: lv_maxlen NUMERIC
SELECT low FROM tvarvc INTO lv_maxlen WHERE
Name = ‘ZSD_NFE_CMPLINF_MAXLEN’
ENDIF
CASE ls_sequence-low
WHEN ‘ZMM_NFE_CMPLINF_HDTX_FCP_TOT’
*** (Text) Total of FCP Tax, if exists
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_sequence-low
IF found AND lt_tvarvc IS NOT INITIAL
lt_taxtypfcp = lt_tvarvc
lt_nfstx = it_nfstx
CLEAR: lv_fcpval
LOOP ON lt_nfstx INTO ls_nfstx
IF ( ls_nfstx-taxtyp on lt_taxtypfcp-low ) AND ( ls_nfstx-stattx IS INITIAL )
lv_fcpval = lv_fcpval + ABS( ls_nfstx-taxval )
ENDIF
ENDLOOP
IF lv_fcpval IS NOT INITIAL
CONCATENATE lv_appendtextj1 // “Valor Total FCP:R$ “ // lv_fcpval // “;” INTO
lv_appendtextj1
ENDIF
ENDIF
WHEN ‘ZMM_NFE_CMPLINF_HDTX_FCPST_TOT’
*** (Text) Total of FCP-ST Tax, if exists
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_sequence-low
IF found AND lt_tvarvc IS NOT INITIAL
lt_taxtypfcpst = lt_tvarvc
lt_nfstx = it_nfstx
CLEAR: lv_fcpstval
LOOP ON lt_nfstx INTO ls_nfstx
IF ( ls_nfstx-taxtyp on lt_taxtypfcpst-low ) AND ( ls_nfstx-stattx IS INITIAL )
lv_fcpstval = lv_fcpstval + ABS( ls_nfstx-taxval )
ENDIF
ENDLOOP
IF lv_fcpstval IS NOT INITIAL
CONCATENATE lv_appendtextj1 // “Valor Total FCP ST:R$ “ // lv_fcpstval // ”;” INTO
lv_appendtextj1
ENDIF
ENDIF
WHEN ‘ZMM_NFE_CMPLINF_HDTX_ICMST_TOT’
*** (Text) Total of FCP Tax, if exists
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_sequence-low
IF found AND lt_tvarvc IS NOT INITIAL
lt_taxtypicmst = lt_tvarvc
lt_nfstx = it_nfstx
CLEAR: lv_icmstval, lv_icmstbas
LOOP ON lt_nfstx INTO ls_nfstx
IF ( ls_nfstx-taxtyp on lt_taxtypicmst-low ) AND ( ls_nfstx-stattx IS INITIAL )
lv_icmstval = lv_icmstval + ABS( ls_nfstx-taxval )
lv_icmstbas = lv_icmstbas + ABS( ls_nfstx-base )
ENDIF
ENDLOOP
IF lv_icmstval IS NOT INITIAL
(START – 25_UAT: RITM000001588724 Changes V3.0 – 22nd Nov 2022)
CONCATENATE lv_appendtextj1 // “ICMS Retido na fonte por Subst. Tributaria com base:
R$ “ // lv_icmstbas // “ e valor: R$ “ // lv_icmstval // “;” INTO lv_appendtextj1
CONCATENATE lv_appendtextj1 // “ICMS pago por substituicao tributaria conf. inciso
II, do art. 412 do RICMS/SP com base: R$ “ // lv_icmstbas // “ e valor: R$ “ // lv_icmstval
// “;” INTO lv_appendtextj1
(END – 25_UAT: RITM000001588724 Changes V3.0 – 22nd Nov 2022)
ENDIF
ENDIF
WHEN ‘ZMM_NFE_CMPLINF_HDTX_PROCON’
** As this is a 100% fixed text, text block will be possible to maintain on SO10 transaction in
case future changes are necessary (no program change)
CLEAR: lt_ltext, ls_ltext, ls_tvarvc_procon
Read parameter table (TVARVC) in an internal variable ls_tvarvc_procon the unique record with
following criteria:
NAME = ls_sequence-low AND
LOW = is_header-branch AND
HIGH IS NOT INITIAL
IF sy-subrc IS INITIAL AND ls_tvarvc_procon IS NOT INITIAL
CALL FUNCTION Read_Text USING
EXPORTING
ID = ‘ST’
Language = PT
Name = ls_tvarvc_procon-high
Object = ‘TEXT’
IMPORTING
lines = lt_ltext
ENDCASE
ENDLOOP
ENDIF
ENDIF
(END – 22_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding fields.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
* Check if it’s a new NF issuance (not booking)
CHECK is_header-form IS NOT INITIAL
* Check if it’s NOT a Billing NF
CHECK iv_applic NOT EQ ‘BI’ AND iv_applic IS NOT INITIAL
* Check NF Type is different from Correction or Cancel
CHECK is_header-doctyp NE ‘3’ AND is_header-doctyp NE ‘5’
* Check if it’s NOT a NF Writer
CHECK is_header-manual IS INITIAL
* Check BR Company Code active or not
* Get maximum number of chars for “Complement info” area (current legal = 5000)
* OBS: Legal tech restriction by SEFAZ valid for both SD and MM
DATA: lv_maxlen NUMERIC
SELECT low FROM tvarvc INTO lv_maxlen WHERE
Name = ‘ZSD_NFE_CMPLINF_MAXLEN’
ENDIF
CASE ls_sequence-low
WHEN ‘ZMM_NFE_CMPLINF_HDTX_MM_DOCSNR’
*** a) (Text) To fill Reference Doc (PO number or Material Doc) info
*** Premise: all items from same original SAP Doc
Read parameter table (TVARVC) record in an variable ls_tvarvc table using following criteria:
NAME = ls_sequence-low
IF found AND ls_tvarvc-low IS NOT INITIAL
CLEAR: lv_docs
WHEN ‘ZMM_NFE_CMPLINF_HDTX_EMAIL’
*** (Text) Contact e-mail (NOT the NF-e destination one, marked with flag “Do not use communication
number”)
Read parameter table (TVARVC) record in an variable ls_tvarvc table using following criteria:
NAME = ls_sequence-low
IF found AND ls_tvarvc-low IS NOT INITIAL
lv_txtadrt = ls_tvarvc-low
IF is_header-partyp = ‘V’
ENDSELECT.
IF lt_email IS NOT INITIAL
CLEAR: ls_smtptxt
DELETE lt_email WHERE remark IS NOT EQUAL TO lv_txtadrt
LOOP ON lt_email INTO ls_email
IF ls_smtptxt IS INITIAL
CONCATENATE “E-mail:“ // ls_ email-smtp_addr // “;” INTO ls_smtptxt
ELSE
CONCATENATE ls_smtptxt // “; “ // ls_ email-smtp_addr INTO ls_smtptxt
ENDIF
ENDLOOP
ENDIF.
ENDIF ** (is_header-partyp = ‘V’)
WHEN ‘ZMM_NFE_CMPLINF_HDTX_FCP_TOT’
*** (Text) Total of FCP Tax, if exists
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_sequence-low
IF found AND lt_tvarvc IS NOT INITIAL
lt_taxtypfcp = lt_tvarvc
lt_nfstx = it_nfstx
CLEAR: lv_fcpval
LOOP ON lt_nfstx INTO ls_nfstx
IF ( ls_nfstx-taxtyp on lt_taxtypfcp-low ) AND ( ls_nfstx-stattx IS INITIAL )
lv_fcpval = lv_fcpval + ABS( ls_nfstx-taxval )
ENDIF
ENDLOOP
IF lv_fcpval IS NOT INITIAL
CONCATENATE lv_appendtext // “Valor Total FCP:R$ “ // lv_fcpval // “;” INTO
lv_appendtext
ENDIF
ENDIF
WHEN ‘ZMM_NFE_CMPLINF_HDTX_FCPST_TOT’
*** (Text) Total of FCP-ST Tax, if exists
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_sequence-low
IF found AND lt_tvarvc IS NOT INITIAL
lt_taxtypfcpst = lt_tvarvc
lt_nfstx = it_nfstx
CLEAR: lv_fcpstval
LOOP ON lt_nfstx INTO ls_nfstx
IF ( ls_nfstx-taxtyp on lt_taxtypfcpst-low ) AND ( ls_nfstx-stattx IS INITIAL )
lv_fcpstval = lv_fcpstval + ABS( ls_nfstx-taxval )
ENDIF
ENDLOOP
IF lv_fcpstval IS NOT INITIAL
CONCATENATE lv_appendtext // “Valor Total FCP ST:R$ “ // lv_fcpstval // ”;” INTO
lv_appendtext
ENDIF
ENDIF
WHEN ‘ZMM_NFE_CMPLINF_HDTX_PROCON’
** As this is a 100% fixed text, text block will be possible to maintain on SO10 transaction in
case future changes are necessary (no program change)
CLEAR: lt_ltext, ls_ltext, ls_tvarvc_procon
Read parameter table (TVARVC) in an internal variable ls_tvarvc_procon the unique record with
following criteria:
NAME = ls_sequence-low AND
LOW = is_header-branch AND
HIGH IS NOT INITIAL
IF sy-subrc IS INITIAL AND ls_tvarvc_procon IS NOT INITIAL
CALL FUNCTION Read_Text USING
EXPORTING
ID = ‘ST’
Language = PT
Name = ls_tvarvc_procon-high
Object = ‘TEXT’
IMPORTING
lines = lt_ltext
ENDCASE
ENDLOOP
ENDIF
ENDIF
LOOP AT lt_nfftx INTO ls_nfftx
* First Adjust standard structure it_nfftx in case Z text variables exist on parameter table
<look for string value on ls_varsubstitute3-low along text record ls_nfftx and, everytime
found, substitute substring into ls_nfftx string per the contents of ls_contents3>
ENDIF
ENDIF
ENDLOOP
ENDIF
(END – 14_UAT: Changes V2.0 – 25th Jul 2022)
* Remove any “Line feed” char from string as it generates XML error on SEFAZ
Substitute any “Return” (Line feed) character to “ “ from es_header-infcpl
ENDIF
Usage example: referenced Nota Fiscal info for legal texts (exp: Nota Fiscal Complementar)
In case a SAP NF Doc is referenced on the header of another that is being issued, look for
special string indicator on parameter table and, if exists, substitute the found string directly on
“Additional Information” for the corresponding NF information represented by the string (or NFe
Number, Series, Issuance Date). The aim for that is support NF reference legal information for
situations where any of the SAP Std BR Localization expected fields are not filled (exp:
Reference-XBLNR, PO Date-BSTDK, etc).
So far only SD Technical variables from Billing execution are defined on TVARVC.
To define MM Technical variables, a debugging must be performed to analyze the availability of
desired information during execution of corresponding transaction.
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding text field.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
* Get existing text variables defined by parameters and their corresponding values
DATA: lt_varsubstitute
SELECT * FROM tvarvc INTO lt_varsubstitute WHERE
Name = ‘ZSD_NFE_VARTEXT_SUBSTITUTE’
ENDIF
ENDIF
ENDLOOP
ENDIF
(END – 14_UAT: Changes V2.0 – 25th Jul 2022)
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding field.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
Some texts used in PRC related to items (specific tax values) will be moved to corresponding <
infAdProd> tag on NFe XML. Each text will be controlled – like done on header texts – by a new
functionality to parameterize both the activation/insertion and the SEQUENCE of the texts (using
TVARVC table). Changes will be performed by new implementation on BADI
J_1BNF_ADD_DATA, Method ADD_DATA, including segregated Function Modules or Includes
for each functionality:
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding fields.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
* Check if it’s a new NF issuance (not booking)
CHECK is_header-form IS NOT INITIAL
* Check if it’s NOT a Billing NF
CHECK iv_applic NOT EQ ‘BI’ AND iv_applic IS NOT INITIAL
* Check NF Type is different from Correction or Cancel
CHECK is_header-doctyp NE ‘3’ AND is_header-doctyp NE ‘5’
* Check if it’s NOT a NF Writer
CHECK is_header-manual IS INITIAL
* Check BR Company Code active or not
SELECT * FROM tvarvc INTO lt_tvarvc WHERE
Name = ‘ZMM_NFE_CMPLINF_BUKRS’
* Get maximum number of chars for “infAdProd” area (current legal = 500)
* Parameter valid for both MM and SD areas
DATA: lv_maxitmlen NUMERIC
SELECT low FROM tvarvc INTO lv_maxitmlen WHERE
Name = ‘ZSD_NFE_CMPLINF_ITMMAXLEN’
ENDIF
CASE ls_itm_sequence-low
WHEN ‘ZMM_NFE_CMPLINF_ITTX_FCP’
*** a) (Text) FCP Tax,
* Copy internal structures to keep their integrity
CLEAR ls_nflin , lt_nflin, lt_nfstx
COPY it_nflin TO lt_nflin
COPY it_nfstx TO lt_nfstx
SORT lt_nfstx BY docnum itmnum taxtyp
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_itm_sequence-low
IF lt_tvarvc IS NOT INITIAL
WHEN ‘ZMM_NFE_CMPLINF_ITTX_FCPST’
*** a) (Text) FCP ST Tax,
* Copy internal structures to keep their integrity
CLEAR ls_nflin , lt_nflin, lt_nfstx
COPY it_nflin TO lt_nflin
COPY it_nfstx TO lt_nfstx
SORT lt_nfstx BY docnum itmnum taxtyp
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_itm_sequence-low
IF lt_tvarvc IS NOT INITIAL
ENDLOOP
ENDLOOP
ENDIF
3.22 BADI Requirement 24: NFe Item Additional Info for NF Writer (Manually created)
Some texts used in PRC related to items (specific tax values) will be moved to corresponding <
infAdProd> tag on NFe XML. Each text will be controlled – like done on header texts – by a new
functionality to parameterize both the activation/insertion and the SEQUENCE of the texts (using
TVARVC table). Changes will be performed by new implementation on BADI
J_1BNF_ADD_DATA, Method ADD_DATA_J1B1N, including segregated Function Modules or
Includes for each functionality:
Scope
=> Only for Manually created NF-e’s.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
* Check if it’s a new NF issuance (not booking)
CHECK is_header-form IS NOT INITIAL
* Check NF manual (J1B1N)
CHECK is_header-manual IS NOT INITIAL
* Check NF Type is different from Correction or Cancel
CHECK is_header-doctyp NE ‘3’ AND is_header-doctyp NE ‘5’
* Check BR Company Code active or not
SELECT * FROM tvarvc INTO lt_tvarvc WHERE
Name = ‘ZMM_NFE_CMPLINF_BUKRS’
* Get maximum number of chars for “infcpl” area (current legal = 5000)
* OBS: Legal tech restriction by SEFAZ valid for both SD and MM
DATA: lv_maxlen NUMERIC
SELECT low FROM tvarvc INTO lv_maxlen WHERE
Name = ‘ZSD_NFE_CMPLINF_MAXLEN’
ENDIF
CASE ls_itm_sequence-low
WHEN ‘ZMM_NFE_CMPLINF_ITTX_FCP’
*** a) (Text) FCP Tax,
* Copy internal structures to keep their integrity
CLEAR ls_nflin , lt_nflin, lt_nfstx
COPY it_nflin TO lt_nflin
COPY it_nfstx TO lt_nfstx
SORT lt_nfstx BY docnum itmnum taxtyp
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_itm_sequence-low
IF lt_tvarvc IS NOT INITIAL
* Found Tax Type(s) related to FCP Tax (for both MM and SD!)
LOOP lt_nflin INTO ls_nflin
* Loop on all NF items to check FCP tax calculated (or not)
LOOP lt_tvarvc INTO ls_tvarvc
READ lt_nfstx INTO ls_nfstx USING
docnum = ls_nflin-docnum
itmnum = ls_nflin-itmnum
taxtyp = ls_tvarvc -low
IF sy-subrc IS INITIAL AND ls_nfstx-taxval IS NOT INITIAL
* FCP Tax Type found and with tax amount not null: use this for the text and end (next NF item)
READ it_item INTO ls_item USING
itmnum = ls_nflin-itmnum
* In case et_item text already filled, preserves original text block before adding new one
lv_appendtextj1itm = ls_item-infadprod
(START – 39_ITC: RITM000002278935 Changes V4.0 – 14th Jun 2024)
CONCATENATE lv_appendtextj1itm // “ Base FCP:” // $q01 // “, % FCP:” // $r01 // “,
Valor FCP:” // $s01 INTO lv_appendtextj1itm
CONCATENATE lv_appendtextj1itm // “Base FCP:” // $q01 // “, % FCP:” // $r01 // “,
Valor FCP:” // $s01 INTO lv_appendtextj1itm
(END – 39_ITC: RITM000002278935 Changes V4.0 – 14th Jun 2024)
WHEN ‘ZMM_NFE_CMPLINF_ITTX_FCPST’
*** a) (Text) FCP ST Tax,
* Copy internal structures to keep their integrity
CLEAR ls_nflin , lt_nflin, lt_nfstx
COPY it_nflin TO lt_nflin
COPY it_nfstx TO lt_nfstx
SORT lt_nfstx BY docnum itmnum taxtyp
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
NAME = ls_itm_sequence-low
IF lt_tvarvc IS NOT INITIAL
* Found Tax Type(s) related to FCP Tax (for both MM and SD!)
LOOP lt_nflin INTO ls_nflin
* Loop on all NF items to check FCP tax calculated (or not)
LOOP lt_tvarvc INTO ls_tvarvc
READ lt_nfstx INTO ls_nfstx USING
docnum = ls_nflin-docnum
itmnum = ls_nflin-itmnum
taxtyp = ls_tvarvc -low
IF sy-subrc IS INITIAL AND ls_nfstx-taxval IS NOT INITIAL
* FCP ST Tax Type found and with tax amount not null: use this for the text and end (next NF item)
READ it_item INTO ls_item USING
itmnum = ls_nflin-itmnum
* In case et_item text already filled, preserves original text block before adding new one
lv_appendtextj1itm = ls_item-infadprod
(START – 39_ITC: RITM000002278935 Changes V4.0 – 14th Jun 2024)
CONCATENATE lv_appendtextj1itm // “ Base FCP ST:” // $t01 // “, % FCP ST:” // $u01
// “, Valor FCP ST:” // $v01 INTO lv_appendtextj1itm
CONCATENATE lv_appendtextj1itm // “Base FCP ST:” // $t01 // “, % FCP ST:” // $u01 // “, Valor
FCP ST:” // $v01 INTO lv_appendtextj1itm
(END – 39_ITC: RITM000002278935 Changes V4.0 – 14th Jun 2024)
Where: $t01 = ls_nfstx-BASE
$u01 = ls_nfstx-RATE
$v01 = ls_nfstx-TAXVAL
ls_item-infadprod = lv_appendtextj1itm
MODIFY lt_item FROMUSING ls_item
EXIT (from LOOP lt_tvarvc > go to next it_nflin item)
ENDIF
ENDLOOP
ENDLOOP
ENDIF
Actual Fuels volume quantity at loading room temperature in case the corresponding invoiced
quantity is not at the same reference temperature (exp: theoretical 20 Celsius Degrees as per
required by BR regulation). For integrated NFs (MM, SD), this information must be provided by
Customer Logic.
However, as the field is optional (from SEFAZ technical perspective – “Ocor.” column on below
image), to facilitate the design and guarantee the required, no matter the invoiced quantity (NF
item quantity) is different or not from the quantity provided at room temperature, the value will
be always fed on that tag.
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding fields.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
* In case no record is found for the application, look for “*” application as the default rule.
* In case no record is found on TVARVC, assume rule ‘<blank>’
* Rules per each possible value assigned to application
* ‘A’ – Check if an "additional quantity” value exists on application document item for the same NF
* Item UoM: if found and it’s different value from NF Item, copy it to “qtemp”, otherwise copy NF item
* quantity to “qtemp” always.
* ‘B’ – Check if an "additional quantity” value exists on application document item for the same NF Item
* UoM: if found and it’s different value from NF Item, copy it to “qtemp”, otherwise keep “qtemp” (blank or
* not).
* ‘C’ – Copy NF item quantity to “qtemp” always: no other checks
itmnum = ls_nflin-itmnum
IF sy-subrc IS INITIAL AND ls_nflin-menge IS NOT INITIAL
CASE lv_rule
WHEN ‘A’
* ‘A’ – Check if an "additional quantity” value exists on application document item for the same NF
* Item UoM: if found and it’s different value from NF Item, copy it to “qtemp”, otherwise copy NF item
* quantity to “qtemp” always.
CASE iv_applic
WHEN ‘BI’
COPY it_vbrp TO lt_vbrp
* (FACT) This BADI logic processes ONE Billing document / NF per run, that means, in case
* a collective Billing tun is processed and multiple documents are going to be created,
* each one individually is treated here (on is_vbrk and it_vbrp). In case of merging of
* predecessor document item(s) into a single Billing document, it_vbrp will reflect this.
lt_wvbrk = (SAPLJ1BG)wvbrk
SORT lt_wvbrk BY vbeln ASCENDING
READ TABLE lt_wbrk USING KEY
VBELN = ls_nflin-refkey
IF sy-subrc IS INITIAL
lv_vbrk_tabix = sy-tabix
lv_vbeln = CONCATENATE “$” // (lv_vbrk_tabix with zeroes on the left to complete total of
9 digits)
** Example: in case lv_vbrk_tabix = 1, then lv_vbeln = ‘$000000001’
** in case lv_vbrk_tabix = 3, then lv_vbeln = ‘$000000003’
** in case lv_vbrk_tabix = 11, then lv_vbeln = ‘$000000011’
READ TABLE lt_vbrp INTO ls_vbrp WITH KEY
VBELN = lv_vbeln
POSNR = ls_nflin-refitm
ELSE
* If any error, use only item to read other structure (as by above FACT)
SORT lt_vbrp BY vbeln posnr ASCENDING
READ TABLE lt_vbrp INTO ls_vbrp WITH KEY
POSNR = ls_nflin-refitm
ENDIF
IF sy-subrc IS INITIAL AND ( ls_vbrp-vgtyp = ‘J’ OR ls_vbrp-vgtyp = ‘T’ )
**Premise on IS-OIL environments => Table LIPSO2 with “Additional Quantities” item tab
**technically available. In case NOT, see the below statement
Attention here: if the functional “select” and “sy-subrc NOT INITIAL” below cannot be used as a technical ABAP “select”
statement on environments where IS-OIL is not implemented to check existence of LIPSO2 table (causing short dump), please
implement correct coding to first check data dictionary object existence.
SELECT * FROM lipso2 INTO ls_lipso2 WHERE
vbeln = ls_vbrp-vgbel
posnr = ls_vbrp-vgpos
msehi = ls_nflin-meins
IF sy-subrc IS INITIAL AND ls_lipso2-adqntp IS NOT INITIAL AND ( ls_lipso2-adqntp <>
ls_nflin-menge )
ls_fuel-qtemp = ls_lipso2-adqntp
MODIFY lt_fuel FROM ls_fuel
ELSE
ls_fuel-qtemp = ls_nflin-menge
MODIFY lt_fuel FROM ls_fuel
ENDIF
ELSE
ls_fuel-qtemp = ls_nflin-menge
MODIFY lt_fuel FROM ls_fuel
ENDIF
WHEN ‘LI’
COPY it_rseg TO lt_rseg
READ lt_rseg INTO ls_rseg WITH KEY
BELNR = ls_nflin-refkey(10)
GJAHR = ls_nflin-refkey+10(4)
POSNR = ls_nflin-refitm
IF sy-subrc IS INITIAL AND ls_rseg-lfbnr IS NOT INITIAL
**Premise on IS-OIL environments => Table LIPSO2 with “Additional Quantities” item tab
**technically available. In case NOT, see the below statement
Attention here: if the functional “select” and “sy-subrc NOT INITIAL” below cannot be used as a technical ABAP “select”
statement on environments where IS-OIL is not implemented to check existence of LIPSO2 table (causing short dump), please
implement correct coding to first check data dictionary object existence.
WHEN ‘IV’
* IV application is related to NF-e’s generated directly by Movement Types (exp: BR 862 STO, etc)
* On bpCE current scope there is no such scenario. With that said, adopt default rule
ls_fuel-qtemp = ls_nflin-menge
MODIFY lt_fuel FROM ls_fuel
WHEN ‘B’
* ‘B’ – Check if an "additional quantity” value exists on application document item for the same NF Item
* UoM: if found and it’s different value from NF Item, copy it to “qtemp”, otherwise keep “qtemp” (blank or
* not).
CASE iv_applic
WHEN ‘BI’
COPY it_vbrp TO lt_vbrp
* (FACT) This BADI logic processes ONE Billing document / NF per run, that means, in case
* a collective Billing tun is processed and multiple documents are going to be created,
* each one individually is treated here (on is_vbrk and it_vbrp). In case of merging of
* predecessor document item(s) into a single Billing document, it_vbrp will reflect this.
lt_wvbrk = (SAPLJ1BG)wvbrk
SORT lt_wvbrk BY vbeln ASCENDING
READ TABLE lt_wbrk USING KEY
VBELN = ls_nflin-refkey
IF sy-subrc IS INITIAL
lv_vbrk_tabix = sy-tabix
lv_vbeln = CONCATENATE “$” // (lv_vbrk_tabix with zeroes on the left to complete total of
9 digits)
** Example: in case lv_vbrk_tabix = 1, then lv_vbeln = ‘$000000001’
** in case lv_vbrk_tabix = 3, then lv_vbeln = ‘$000000003’
** in case lv_vbrk_tabix = 11, then lv_vbeln = ‘$000000011’
READ TABLE lt_vbrp INTO ls_vbrp WITH KEY
VBELN = lv_vbeln
POSNR = ls_nflin-refitm
ELSE
* If any error, use only item to read other structure (as by above FACT)
SORT lt_vbrp BY vbeln posnr ASCENDING
READ TABLE lt_vbrp INTO ls_vbrp WITH KEY
POSNR = ls_nflin-refitm
ENDIF
IF sy-subrc IS INITIAL AND ( ls_vbrp-vgtyp = ‘J’ OR ls_vbrp-vgtyp = ‘T’ )
**Premise on IS-OIL environments => Table LIPSO2 with “Additional Quantities” item tab
**technically available. In case NOT, see the below statement
Attention here: if the functional “select” and “sy-subrc NOT INITIAL” below cannot be used as a technical ABAP “select”
statement on environments where IS-OIL is not implemented to check existence of LIPSO2 table (causing short dump), please
implement correct coding to first check data dictionary object existence.
SELECT * FROM lipso2 INTO ls_lipso2 WHERE
vbeln = ls_vbrp-vgbel
posnr = ls_vbrp-vgpos
msehi = ls_nflin-meins
WHEN ‘IV’
* IV application is related to NF-e’s generated directly by Movement Types (exp: BR 862 STO, etc)
* On bpCE current scope there is no such scenario. With that said, adopt default rule
ls_fuel-qtemp = ls_nflin-menge
MODIFY lt_fuel FROM ls_fuel
WHEN ‘C’
* ‘C’ – Copy NF item quantity to “qtemp” always: no other checks
ls_fuel-qtemp = ls_nflin-menge
MODIFY lt_fuel FROM ls_fuel
ENDCASE
ENDLOOP
The creation of new Legislation regarding ICMS “Monofasico” (Adrem) taxation for Fuels
taxation, substituting common ICMS percentage rates and credit / debit activities along the
supply chain, reflected on a huge volume of SAP OSS Notes (on ECC and SLL-NFE).
Specifically for some specific fiscal scenarios calculation and feeding some new NF-e tags, SAP
has not provided the final logics but, instead, let the Customer – via BADIs and even
enhancement points – develop its necessary rules.
correct Supplier state from the corresponding acquisition (Purchasing) NF-e, selected from a
FIFO balance control of NF-e’s (offline system) in the moment of loading/shipment. This is
requirement is valid for any subsequent NF-e issued for the grade that was previously acquired,
no matter itself or blended on a Diesel B final product.
(END – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding fields.
The rational for calculating and/or feeding necessary fields is represented on the below attached
spreadsheet that was used to conceptually understand and define the necessary math logic as
expected by Tax Authority provided documentation.
Important remark: the correct set of NF fields per CST will not be 100% hard coded here but
will be also driven by the attached spreadsheet filling that will happen by Tax user on ENH029
transaction. So, for the correct result, BR Tax user must fill that transaction table correctly (full
understanding).
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices. Special attention to ‘MODIFY’ and ‘INSERT’ as per considered
functional below but not necessarily correct from ABAP perspective.
* One of three possibilities is expected as per the following offered to end used
* during ENH026 processing to create such reference:
* Option A: <SAP NF DOCNUM>;<blank>
DATA:
lv_regio TYPE RANGE OF j_1bregio,
lv_nfyear TYPE RANGE OF j_1byear,
lv_nfmonth TYPE RANGE OF j_1bmonth,
lv_stcd1 TYPE RANGE OF j_1bstcd1,
lv_model TYPE RANGE OF j_1bmodel,
lv_serie TYPE RANGE OF j_1bseries,
lv_nfnum9 TYPE RANGE OF j_1bnfnum9,
lv_docnum9 TYPE RANGE OF j_1bdocnum9,
lv_cdv TYPE RANGE OF j_1bcheckdigit.
* Check if information from 1st line is valid (existing NF)
IF lv_docnum1 IS INITIAL
IF lv_accesskey1 IS NOT INITIAL
lv_regio = lv_accesskey1(2)
lv_nfyear = lv_accesskey1+2(2)
lv_nfmonth = lv_accesskey1+4(2)
lv_stcd1 = lv_accesskey1+6(14)
lv_model = lv_accesskey1+20(2)
lv_serie = lv_accesskey1+22(3)
lv_nfnum9 = lv_accesskey1+25(9)
lv_docnum9 = lv_accesskey1+34(9)
lv_cdv = lv_accesskey1+43(1)
CLEAR: lv_docnum1
ENDIF
ENDIF
IF lv_docnum2 IS INITIAL
IF lv_accesskey2 IS NOT INITIAL
CLEAR: lv_regio, lv_nfyear, lv_nfmonth, lv_stcd1, lv_model, lv_serie,
lv_nfnum9, lv_docnum9, lv_cdv
lv_regio = lv_accesskey2(2)
lv_nfyear = lv_accesskey2+2(2)
lv_nfmonth = lv_accesskey2+4(2)
lv_stcd1 = lv_accesskey2+6(14)
lv_model = lv_accesskey2+20(2)
lv_serie = lv_accesskey2+22(3)
lv_nfnum9 = lv_accesskey2+25(9)
lv_docnum9 = lv_accesskey2+34(9)
lv_cdv = lv_accesskey2+43(1)
IF sy-subrc IS INITIAL
* Only NF Types defined on parameter will be accepted
IF ls_nfdoc-id_dest <> ‘3’ AND ls_nfdoc-regio IS NOT INITIAL
* If valid NF-e is not a foreign trade one, use BR State from the Partner
lv_brstate1 = ls_nfdoc-regio
ELSE
* If valid NF-e is a foreign trade one, use BR State from the Business Place
IF sy-subrc IS INITIAL
* Only NF Types defined on parameter will be accepted
IF ls_nfdoc-id_dest <> ‘3’ AND ls_nfdoc-regio IS NOT INITIAL
* If valid NF-e is not a foreign trade one, use BR State from the Partner
lv_brstate2 = ls_nfdoc-regio
* If valid NF-e is a foreign trade one, use BR State from the Business Place
ELSE
CALL FUNCTION 'J_1BREAD_BRANCH_DATA'
EXPORTING
branch = ls_nfdoc-branch
bukrs = ls_nfdoc-bukrs
IMPORTING
address = ls_branch_address
EXCEPTIONS
branch_not_found =1
address_not_found =2
company_not_found =3
OTHERS =4
IF sy-subrc IS INITIAL AND ls_branch_address-regio IS NOT INITIAL
lv_brstate2 = ls_branch_address-regio
ENDIF
ENDIF
ENDIF
ENDIF
* Read per parameters if Material Origin indicates a 100% full origin or not (multiple origins)
IF sy-subrc IS INITIAL
lv_orig100% = ‘X’
ELSE
CLEAR lv_origin100%
ENDIF
* Read per parameters if Material Origin indicates a Domestic or Imported one.
READ lt_tvarvc_icmsadrem-high INTO lv_origcomb WITH KEY
NAME = ‘ZSD_ICMSADREM_ORIGCOMB’
LOW = ls_nflin-matorg
HIGH IS NOT INITIAL
ENDIF
(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
* If, for Grade ANP Code, 2 NF-e references are expected (blended)
ELSEIF lv_nfreflines = ‘2’
IF lv_brstate1 IS NOT INITIAL AND lv_brstate2 IS NOT INITIAL
* Two valid NF-e references were provided for the blended Grade (main component Grade
* and then secondary component, in this order)
IF lv_brstate1 = lv_brstate2
* However, the BR States from the two NF-e references ARE THE SAME: so, create
* just 1 Origin line
IF lv_origcomb = ‘0’
CLEAR: ls_nffuelorigin
ls_nffuelorigin-mandt = sy-mandt
ls_nffuelorigin-docnum = ls_nflin-docnum
ls_nffuelorigin-itmnum = ls_nflin-itmnum
ls_nffuelorigin-ind_import = ‘0’
ls_nffuelorigin-c_uf_origin = lv_brstate1
ls_nffuelorigin-p_origin = 100
APPEND ls_nffuelorigin TO et_fuelorigin
ELSEIF lv_origcom = ‘1’
CLEAR: ls_nffuelorigin
ls_nffuelorigin-mandt = sy-mandt
ls_nffuelorigin-docnum = ls_nflin-docnum
ls_nffuelorigin-itmnum = ls_nflin-itmnum
ls_nffuelorigin-ind_import = ‘1’
ls_nffuelorigin-c_uf_origin = lv_brstate1
ls_nffuelorigin-p_origin = 100
APPEND ls_nffuelorigin TO et_fuelorigin
ENDIF
ELSE
* BR States from the two NF-e references ARE DISTINCT: so, create
* 2 Origin lines
IF lv_origcomb = ‘0’
CLEAR: ls_nffuelorigin
ls_nffuelorigin-mandt = sy-mandt
ls_nffuelorigin-docnum = ls_nflin-docnum
ls_nffuelorigin-itmnum = ls_nflin-itmnum
ls_nffuelorigin-ind_import = ‘0’
ls_nffuelorigin-c_uf_origin = lv_brstate1
ls_nffuelorigin-p_origin = ( 100 – ls_icms_adrem_param-mixture )
APPEND ls_nffuelorigin TO et_fuelorigin
ls_nffuelorigin-c_uf_origin = lv_brstate2
ls_nffuelorigin-p_origin = ls_icms_adrem_param-mixture
APPEND ls_nffuelorigin TO et_fuelorigin
ELSEIF lv_origcom = ‘1’
CLEAR: ls_nffuelorigin
ls_nffuelorigin-mandt = sy-mandt
ls_nffuelorigin-docnum = ls_nflin-docnum
ls_nffuelorigin-itmnum = ls_nflin-itmnum
ls_nffuelorigin-ind_import = ‘1’
ls_nffuelorigin-c_uf_origin = lv_brstate1
ls_nffuelorigin-p_origin = ( 100 – ls_icms_adrem_param-mixture )
APPEND ls_nffuelorigin TO et_fuelorigin
ls_nffuelorigin-c_uf_origin = lv_brstate2
ls_nffuelorigin-p_origin = ls_icms_adrem_param-mixture
APPEND ls_nffuelorigin TO et_fuelorigin
ENDIF
ENDIF ** BR State1 = BR State2
ELSE ** BR State1 and/or BR State2 is INITIAL
* Not all two valid NF-e references were provided for the blended Grade (main component Grade
* and then secondary component, in this order). Get BR State info from Z Table for ICMS Mono
IF lv_origcom = ‘0’ ** National origin
CLEAR: ls_nffuelorigin
ls_nffuelorigin-mandt = sy-mandt
ls_nffuelorigin-docnum = ls_nflin-docnum
ls_nffuelorigin-itmnum = ls_nflin-itmnum
ls_nffuelorigin-ind_import = ‘0’
ls_nffuelorigin-c_uf_origin = lv_brstate2
ls_nffuelorigin-p_origin = ls_icms_adrem_param-mixture
APPEND ls_nffuelorigin TO et_fuelorigin
ENDIF
ELSE ** lv_brstate2 IS INITIAL
IF ( ls_nffuelorigin-c_uf_origin = ls_icms_adrem_param-uf_aux )
ls_nffuelorigin-p_origin = 100
APPEND ls_nffuelorigin TO et_fuelorigin
ELSE
ls_nffuelorigin-p_origin = ( 100 – ls_icms_adrem_param-mixture )
APPEND ls_nffuelorigin TO et_fuelorigin
ls_nffuelorigin-c_uf_origin = ls_icms_adrem_param-uf_aux
ls_nffuelorigin-p_origin = ls_icms_adrem_param-mixture
APPEND ls_nffuelorigin TO et_fuelorigin
ENDIF
ENDIF ** lv_brstate2
(END – 37_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
ENDIF
ENDIF ** lv_brstate1 IS NOT INITIAL AND lv_brstate2 IS NOT INITIAL
ENDIF ** lv_nfreflines
(END – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
ELSE ** lv_orig100% is blank
* If Material Origin indicates multiple origin sources, create two records
(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
* This is current valid ONLY FOR BLENDED Grades (exp: Diesel B)
* So, no check for qty of lines per ANP Code needs to be performed
* (main component Grade and then secondary component, in this order)
(START – 37_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
* When multiple origins (National and Import contents), PREMISE is that
* Diesel A is the Imported one and Biodiesel is National (so far,
* as per Business definitions)
(END – 37_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
* IMPORTANT: if premises above are changed, then below logic must be adjusted
IF ls_tvarvc_icmsadrem-low = ‘0’
(START – 37_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
IF lv_origcom = ‘0’ ** National origin
(END – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
CLEAR: ls_nffuelorigin
ls_nffuelorigin-mandt = sy-mandt
ls_nffuelorigin-docnum = ls_nflin-docnum
ls_nffuelorigin-itmnum = ls_nflin-itmnum
ls_nffuelorigin-ind_import = ‘0’
(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
IF lv_brstate1 IS NOT INITIAL
ls_nffuelorigin-c_uf_origin = lv_brstate1
ELSE
(END – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
ls_nffuelorigin-c_uf_origin = ls_icms_adrem_param-uf
(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
ENDIF
(END – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
ls_nffuelorigin-p_origin = ( 100 – ls_icms_adrem_param-mixture * 100 )
APPEND ls_nffuelorigin TO et_fuelorigin
ls_nffuelorigin-ind_import = ‘1’
(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
IF lv_brstate2 IS NOT INITIAL
ls_nffuelorigin-c_uf_origin = lv_brstate2
ELSE
(END – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
ls_nffuelorigin-c_uf_origin = ls_icms_adrem_param-uf_aux
(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
ENDIF
(END – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
ls_nffuelorigin-p_origin = ( ls_icms_adrem_param-mixture * 100 )
APPEND ls_nffuelorigin TO et_fuelorigin
(END – 37_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
IF sy-subrc EQ 0
READ TABLE it_nfstx INTO ls_nfstx WITH KEY
DOCNUM = ls_nflin-docnum
ITMNUM = ls_nflin-itmnum
TAXTYP = lv_taxtyp_adrem
IF sy-subrc EQ 0 AND ls_nfstx-pauta_base IS NOT INITIAL
READ TABLE et_item INTO ls_item WITH KEY
DOCNUM = ls_nflin-docnum
ITMNUM = ls_nflin-itmnum
IF sy-subrc IS INITIAL
ls_item-ADREMICMSPDIF = ls_icms_adrem_param-reduc_perc_aux
ls_item-VICMSMONOOP = ls_icms_adrem_param-adremicms * (
ls_icms_adrem_param-mixture / 100 ) * ls_nfstx-pauta_base
ls_item-VICMSMONODIF = ls_item-VICMSMONOOP * ( ls_item-ADREMICMSPDIF /
100 )
* Update correct line on et_item with corresponding fields (updated or not) on auxiliary string
MODIFY et_item FROM ls_item
ENDIF
ENDIF
ENDIF
* CST ‘61’ (already paid) – line with Adrem Taxtyp will not exist on NFSTX
ELSEIF lv_taxsit_out = ‘61’
READ TABLE et_item INTO ls_item WITH KEY
DOCNUM = ls_nflin-docnum
ITMNUM = ls_nflin-itmnum
IF sy-subrc IS INITIAL
IF icms_adrem_param-mixture-aux NE 100
(START – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
* NF-e Complementar: get item quantity from corresponding Billing item
IF is_header-doctyp = ‘2’ AND ls_vbrp-fkimg IS NOT INITIAL
lv_calc1 = ls_vbrp-fkimg / ( ( 100 - icms_adrem_param-mixture_aux ) / 100 )
ELSE
(END – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
lv_calc1 = ls_nflin-menge / ( ( 100 - icms_adrem_param-mixture_aux ) / 100 )
(START – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
ENDIF
(END – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
ELSE
* Premise: if user incorrectly defines “mixture_aux” as 100%, will consider 0% (invalid input)
(START – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
* NF-e Complementar: get item quantity from corresponding Billing item
IF is_header-doctyp = ‘2’ AND ls_vbrp-fkimg IS NOT INITIAL
lv_calc1 = ls_vbrp-fkimg
ELSE
(END – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
lv_calc1 = ls_nflin-menge
(START – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
ENDIF
(END – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
ENDIF
lv_calc2 = ls_icms_adrem_param-adremicms_aux * ( 100 - ls_icms_adrem_param-
reten_perc ) / 100
ls_item-QBCMONORET = lv_calc1
ls_item-ADREMICMSRET = lv_calc2
lv_calc3 = lv_calc1 * lv_calc2
lv_calc4 = lv_calc3 * ( 100 - ls_icms_adrem_param-mixture_aux ) / 100
lv_calc5 = lv_calc3 * ( ls_icms_adrem_param-mixture_aux / 100 ) * (
ls_icms_adrem_param-reten_perc_aux / 100 )
ls_item-VICMSMONORET = lv_calc4 + lv_calc5
* Update correct line on et_item with corresponding fields (updated or not) on auxiliary string
MODIFY et_item FROM ls_item
ENDIF
* CST ‘15’ (already paid) – line with Adrem Taxtyp will not exist on NFSTX
ELSEIF lv_taxsit_out = ‘15’
READ TABLE et_item INTO ls_item WITH KEY
DOCNUM = ls_nflin-docnum
ITMNUM = ls_nflin-itmnum
IF sy-subrc IS INITIAL
IF ls_icms_adrem_param-reduc_perc_aux > 0
ls_item-MOTREDADREM = ls_icms_adrem_param-reduc_reason
ls_item-PREDADREM = ls_icms_adrem_param-reduc_perc_aux
* Update correct line on et_item with corresponding fields (updated or not) on auxiliary string
MODIFY et_item FROM ls_item
ENDIF
ENDIF
ENDIF ** lv_taxsit_out
(START – 43_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)
ENDIF ** sy-subrc IS INITIAL (valid FKART)
(END – 43_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)
ENDIF
ENDIF
ENDLOOP
(END – 29_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
Some Fiscal SD automatic scenarios for FCC OtC (like Asset Sales to bp affiliates) by Rio de
Janeiro Office require ICMS taxation with base reduction and the feeding of the “ICMS
Desonerado” (ICMS Exempt) value and reason on specific XML tags for NF-e. The calculation
for the “supposed” value left to be charged is not done by SAP Standard BR Localization as
multiple calculation rules can exist depending on the involved BR State Legislation. With that
said, it’s required to implement Customer logic for the calculation itself and feeding of mandatory
XML tags for the applicable cases (basically dependent on BR STATE + ICMS CST).
In case, for the relevant scenarios, the “ICMS Desonerado” and its “Motivo” (Reason) are not
informed on NF-e XML tags, the document is rejected by Tax Authority (Error SEFAZ 934).
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding fields.
3.25.1[3.18.1] New Table, view - Maintenance of “ICMS Desonerado” Control and Parameters
Please create new table and view (suggestion: ZSD_BR_ICMS_DESONERA) following the below contents:
Field name Description Key Optional / Technical Reference Validation, Error
Mandatory Message and
Comments
UF Plant BR State (Fiscal Y Mandatory ZSD_BR_ICMS_ADRM-UF_PLANT Please use check table
Region) related to linked to the field
the issuing or reference (if necessary,
receiving bp Plant assume fixed Country =
‘BR’)
CST ICMS Tributary Code Y Mandatory ZSD_BR_ICMS_ADRM-CST Please make Domain
Situation available on field
selection values (on
view, use user values
converted – 2 chars -
as per existing Field
conversion)
NF Doc Type Nota Fiscal Type Y Optional J_1BNFDOC-J_1BDOCTYP Please use check table
linked to the field
reference
NF Type Nota Fiscal Y Optional J_1BNFDOC-J_1BNFTYPE Please use check table
Document type linked to the field
reference
CFOP CFOP Code and Y Optional J_1BNFLIN- J_1BCFOP Please use check table
Extension linked to the field
reference
Valid From Start date of register Y Mandatory ZSD_BR_ICMS_ADRM- VALID_FROM
validity
MOTDESICMS ICMS Exception N Optional J_1BNFLIN- MOTDESICMS Please use check table
Reason linked to the field
reference
STATCALCMETH Type of Calculation N Optional New Z Data element (suggestion: Please create / use
for Statistical ICMS ZSD_ICMSDESON_STATCALCMETH), check table for enabling
Exempt CHAR 1, with corresponding new selection list on
Domain values: table/view field
‘A’ Description: RJ ICMS Statistical
Exempt using just ICMS Rate (no
PIS/COFINS)
‘B’ Description: (Future use)
‘C’ Description: (Future use)
3.25.2[3.18.2] New Transaction (Tax Data – End User) for Maintenance view
Implement a new transaction (suggestion: ZSD_BR_ICMS_DESONERA) using SM30 with access initially
to the DISPLAY mode of a view based on new table to be created as per described below. User should
always hit “Edit (pencil)” button to access change mode.
As the contents are related to Fiscal control, this transaction should be assigned to a profile role related to
that bpCE Group (as suggestion, the same profile where current existing “ZSD_BR_ICMS_ADREM” and
ZSD_BR_ICMS_BENEFCOD transactions are assigned to).
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all
syntax corrections, internal objects clearing and analysis in terms of better performance
and best coding practices.
ENDIF.
IF ls_icmsdes IS NOT INITIAL
* A relevant record on Statistical “ICMS Desonerado” was found
* check the calculation rule and calculates value for STSTCL_VICMSDESON
IF ls_icmsdes = ‘A’
* Rule is ‘A - ICMS Statistical using just ICMS Rate (no PIS/COFINS)’
* Formula: ICMS Desonerado = Preço na Nota Fiscal * (1 - (Alíquota * (1 - Percentual de redução da BC)))
* / (1 - Alíquota) - Preço na Nota Fiscal
*IMPORTANT: The ICMS Rate MUST include FCP if exists
*
* Read relevant tax values for the rule (if exist!)
READ TABLE lt_nfstx INTO ls_nfstx WITH KEY
DOCNUM = ls_nflin-docnum AND
ITMNUM = ls_nflin-itmnum AND
RATE IS NOT INITIAL
STATTX IS INITIAL AND
BASERED1 IS NOT INITIAL
TAXGRP = ‘ICMS’
IF sy-subrc IS INITIAL AND ls_nfstx IS NOT INITIAL
* Read all relevant ICMS tax type lines for the rule (if exist!)
READ TABLE lt_nfstx INTO lt_nfstx_icms WITH KEY
DOCNUM = ls_nflin-docnum AND
ITMNUM = ls_nflin-itmnum AND
RATE IS NOT INITIAL
STATTX IS INITIAL AND
BASERED1 IS NOT INITIAL
TAXGRP = ‘ICMS’
IF sy-subrc IS INITIAL AND lt_nfstx_icms IS NOT INITIAL
CLEAR: lv_total_icms_rate, ls_nfstx_icms
LOOP AT lt_nfstx_icms INTO ls_nfstx_icms
lv_total_icms_rate = lv_total_icms_rate + ls_nfstx_icms-rate
ENDLOOP
* Any discount just if Base was reduced
IF ls_nfstx-basered1 < 100 AND ls_nfstx-rate < 100 ** Final Base < 100%
* Perform calculation using FLOATING POINT auxiliary variables to guarantee precision
lv_fp_calc1 = ls_nfstx-rate * ( ls_nfstx-basered1 / 100 )
lv_fp_calc2 = 1 – ( lv_fp_calc1 / 100 )
lv_fp_calc3 = lv_fp_calc2 * / ( 1 – ( ls_nfstx-rate / 100 ) )
lv_fp_calc4 = ls_nflin-nfnet * ( lv_fp_calc3 )
* Calculate final value and rounding it to 2 decimal places, as expected by SAP
* If ICMS “Desonerado” reason not yet exist, then update it from parameter table
IF ls_icmsdes-motdesicms IS NOT INITIAL
* If ICMS “Desonerado” reason exists on parameter table then finally update final register
* with both and reason
ls_nflin-MOTDESICMS = ls_icmsdes-motdesicms
MODIFY et_item WITH ls_et_item USING tabix = lv_tabix
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
* ELSEIF ls_icmsdes = ‘B’
* Rule is ‘B’ …
* ...
* ELSEIF ls_icmsdes = ‘C’
* Rule is ‘C’ …
* ...
ENDIF **ls_icmsdes
ENDIF **ls_icmsdes
ENDLOOP ** lt_nflin
TY NU SI OP
NAME PE MB GN TI LOW HIGH CLIE_INDEP
ZSD_BR_ENH011_953_WER
KS_BUPLA S 0 I BT 9000 B202
ZSD_BR_ENH011_953_WER
KS_BUPLA S 1 I BT 9002 B204
ZSD_BR_ENH011_953_WER
KS_BUPLA S 2 I BT 9003 B205
ZSD_BR_ENH011_953_WER
KS_PSTYV S 0 I BT ZTBW ZRBN
ZSD_BR_ENH011_953_WER
KS_VKORG 0 I EQ 5204
ZSD_BR_ENH011_CMETH_
CMETH S 0 I EQ 1
ZSD_BR_ENH011_CMETH_
PSTYV S 0 I EQ ZSMB
ZSD_BR_ENH011_CMETH_
PSTYV S 1 I EQ ZSRP
ZSD_BR_ENH011_CMETH_
PSTYV S 2 I EQ ZRBN
ZSD_BR_ENH011_CMETH_
VKORG S 0 I EQ 5204
ZSD_BR_ENH011_PARTNE
R_AUART S 0 I BT ZROB RE
ZSD_BR_ENH011_PARTNE
R_BUPLA S 0 I BT 9000 0000202401
ZSD_BR_ENH011_PARTNE
R_BUPLA S 1 I BT 9001 0000202811
ZSD_BR_ENH011_PARTNE
R_BUPLA S 2 I BT 9002 0000202812
ZSD_BR_ENH011_PARTNE
R_BUPLA S 3 I BT 9003 0000202827
ZSD_BR_ENH011_SUPPRE
SS_FLDCPY S 0 I EQ ZZDEALTYPE
ZSD_BR_ENH011_SUPPRE
SS_FLDCPY S 1 I EQ ZZDEAL
ZSD_BR_ENH011_SUPPRE
SS_FLDCPY S 2 I EQ ZZSEQUENCE
ZSD_BR_ENH011_SUPPRE
SS_FLDCPY S 3 I EQ ZZSHIPMENT
ZSD_BR_ENH011_SUPPRE
SS_FLDCPY S 4 I EQ ZZPARCEL
ZSD_BR_ENH011_SUPPRE
SS_FLDCPY S 5 I EQ ZZVAVER
ZSD_BR_ENH011_SUPPRE
SS_FLDCPY S 6 I EQ ZZVPVER
ZSD_BR_ENH011_SUPPRE
SS_FLDCPY S 7 I EQ ZZVDVER
ZSD_BR_ME_OUTPMSG_W
ERKS S 0 I BT B202 B208
ZSD_BR_ME_OUTPMSG_W
ERKS S 1 I BT B204 B206
ZSD_BR_ME_OUTPMSG_W
ERKS S 2 I BT B204 B207
ZSD_BR_ME_OUTPMSG_W
ERKS S 3 I BT B205 B210
ZSD_ICMSADREM_ORIG_U
F_ANP S 0 I BT 420102004 1
ZSD_ICMSADREM_ORIG_U
F_ANP S 1 I BT 420102005 1
ZSD_ICMSADREM_ORIG_U
F_ANP S 2 I BT 320101001 1
ZSD_ICMSADREM_ORIG_U S 3 I BT 320101002 1
F_ANP
ZSD_ICMSADREM_ORIG_U
F_ANP S 4 I BT 420105001 1
ZSD_ICMSADREM_ORIG_U
F_ANP S 5 I BT 810102001 1
ZSD_ICMSADREM_ORIG_U
F_ANP S 6 I BT 810102004 1
ZSD_ICMSADREM_ORIG_U
F_ANP S 7 I BT 820101001 1
ZSD_ICMSADREM_ORIG_U
F_ANP S 8 I BT 820101012 2
ZSD_ICMSADREM_ORIG_U
F_ANP S 9 I BT 820101013 2
ZSD_ICMSADREM_ORIG_U
F_ANP S 10 I BT 820101033 2
ZSD_ICMSADREM_ORIG_U
F_ANP S 11 I BT 820101034 2
ZSD_ICMSADREM_ORIG_U
F_ANP S 12 I BT 320102001 2
ZSD_ICMSADREM_ORIG_U
F_ANP S 13 I BT 320102002 2
ZSD_ICMSADREM_ORIG_U
F_ANP S 14 I BT 320102003 2
ZSD_ICMSADREM_ORIG_U
F_ANP S 15 I BT 320102005 2
ZSD_ICMSADREM_ORIG_U
F_FKART S 0 I EQ ZF2B
ZSD_ICMSADREM_ORIG_U
F_FKART S 1 I EQ ZREB
ZSD_ICMSADREM_ORIG_U
F_FKART S 2 I EQ Z1
ZSD_ICMSADREM_ORIG_U
F_FKART S 3 I EQ ZFSB
ZSD_ICMSADREM_ORIG_U
F_TXTBLK S 0 I EQ ZB05
ZSD_NFE_CMPLINF_HDTX_ LOC.RETIRADA - MERCAD.SAIRA DO
LOCRET S 0 I BT SB ARMAZEM GERAL:
ZSD_NFE_CMPLINF_HDTX_
LOCRET S 1 I BT ## LOCAL RETIRADA:
ZSD_NFE_CMPLINF_HDTX_
SD_DOCSNR S 0 I EQ X
ZSD_NFE_CMPLINF_HDTX_
TRAILDTLS S 0 I EQ ZB02
ZSD_NFE_CMPLINF_HDTX_
TRUCKDTLS S 0 I EQ ZB01
ZSD_NFE_CMPLINF_HDTX_
ZSWH_NFE S 0 I EQ ZSMB ZB05
ZSD_NFE_CMPLINF_ITMMA
XLEN S 0 I EQ 500
ZSD_NFE_CMPLINF_ITMTX ZSD_NFE_CMPLINF_ITTX_F
TSEQUENCE S 0 I EQ CP
ZSD_NFE_CMPLINF_ITMTX ZSD_NFE_CMPLINF_ITTX_F
TSEQUENCE S 1 I EQ CPST
ZSD_NFE_CMPLINF_ITMTX ZSD_NFE_CMPLINF_ITTX_I
TSEQUENCE S 2 I EQ CMS60
ZSD_NFE_CMPLINF_ITMTX ZSD_NFE_CMPLINF_ITTX_C
TSEQUENCE S 3 I EQ IDE
ZSD_NFE_CMPLINF_ITTX_A
NPCODE S 0 I BT ANP: MARA-ANP
ZSD_NFE_CMPLINF_ITTX_F
CP S 0 I EQ ICSC
ZSD_NFE_CMPLINF_ITTX_F
CP S 1 I EQ FCP1
ZSD_NFE_CMPLINF_ITTX_F
CP S 2 I EQ FCP2
ZSD_NFE_CMPLINF_ITTX_F
CP S 3 I EQ FCPO
ZSD_NFE_CMPLINF_ITTX_F
CP S 4 I EQ FCPI
ZSD_NFE_CMPLINF_ITTX_F
CPST S 0 I EQ ICFP
ZSD_NFE_CMPLINF_ITTX_F
CPST S 1 I EQ FPS1
ZSD_NFE_CMPLINF_ITTX_F
CPST S 2 I EQ FPS2
ZSD_NFE_CMPLINF_ITTX_F
CPST S 3 I EQ FPSO
ZSD_NFE_CMPLINF_ITTX_F
CPST S 4 I EQ FPSI
ZSD_NFE_CMPLINF_MAXLE
N S 0 I EQ 5000
ZSD_NFE_CMPLINF_TEXTS ZSD_NFE_CMPLINF_HDTX_
EQUENCE S 0 I EQ SD_DOCSNR
ZSD_NFE_CMPLINF_TEXTS ZSD_NFE_CMPLINF_HDTX_
EQUENCE S 1 I EQ EMAIL
ZSD_NFE_CMPLINF_TEXTS ZSD_NFE_CMPLINF_HDTX_
EQUENCE S 2 I EQ DSCSUFRMA
ZSD_NFE_CMPLINF_TEXTS ZSD_NFE_CMPLINF_HDTX_
EQUENCE S 3 I EQ DRVINFO
ZSD_NFE_CMPLINF_TEXTS ZSD_NFE_CMPLINF_HDTX_
EQUENCE S 4 I EQ TRUCKDTLS
ZSD_NFE_CMPLINF_TEXTS ZSD_NFE_CMPLINF_HDTX_
EQUENCE S 5 I EQ TRAILDTLS
ZSD_NFE_CMPLINF_TEXTS ZSD_NFE_CMPLINF_HDTX_
EQUENCE S 6 I EQ DG_GATEC
ZSD_NFE_CMPLINF_TEXTS ZSD_NFE_CMPLINF_HDTX_
EQUENCE S 7 I EQ FREETXT
ZSD_NFE_CMPLINF_TEXTS S 8 I EQ ZSD_NFE_CMPLINF_HDTX_
EQUENCE FCP_TOT
ZSD_NFE_CMPLINF_TEXTS ZSD_NFE_CMPLINF_HDTX_
EQUENCE S 9 I EQ FCPST_TOT
ZSD_NFE_CMPLINF_TEXTS ZSD_NFE_CMPLINF_HDTX_
EQUENCE S 10 I EQ LOCRET
ZSD_NFE_CMPLINF_TEXTS ZSD_NFE_CMPLINF_HDTX_
EQUENCE S 11 I EQ LOCENT
ZSD_NFE_CMPLINF_TEXTS ZSD_NFE_CMPLINF_HDTX_
EQUENCE S 12 I EQ ZSWH_NFE
ZSD_NFE_DSAIENT_HSAIE
NT S 0 I EQ 01:30:00
ZSD_NFE_DSAIENT_HSAIE
NT_Z1 S 0 I EQ 01:30:00
ZSD_NFE_DSAIENT_HSAIE
NT_Z2 S 0 I EQ 01:30:00
ZSD_NFE_DSAIENT_HSAIE
NT_Z5 S 0 I EQ 01:30:00
ZSD_NFE_DSAIENT_HSAIE
NT_Z8 S 0 I EQ 01:30:00
ZSD_NFE_DSAIENT_HSAIE
NT_ZH S 0 I EQ 01:30:00
ZSD_NFE_DSAIENT_HSAIE
NT_ZI S 0 I EQ 01:30:00
ZSD_NFE_DSAIENT_HSAIE
NT_ZJ S 0 I EQ 01:30:00
ZSD_NFE_DSAIENT_HSAIE
NT_ZK S 0 I EQ 01:30:00
ZSD_NFE_DSAIENT_HSAIE
NT_ZX S 0 I EQ 01:30:00
ZSD_NFE_DSAIENT_HSAIE
NT_ZZ S 0 I EQ 01:30:00
ZSD_NFE_SB_PARTNER_P
LANTS S 9 I BT 1074 0000128256
ZSD_NFE_SB_PARTNER_P
LANTS S 10 I BT B210 0000128256
ZSD_NFE_SB_PARTNER_P
LANTS S 11 I BT 2356 0000128256
ZSD_NFE_TEXT_REFACCK
EY S 0 I EQ ZB06
ZSD_NFE_TRADENOTES_B
UKRS S 0 I EQ BR0K
ZSD_NFE_TRADENOTES_B
UKRS S 1 I EQ BR0L
ZSD_NFE_TRADENOTES_B
UKRS S 2 I EQ BR0M
ZSD_NFE_TRADENOTES_B
UKRS S 3 I EQ BR0N
ZSD_NFE_TRDNT_MEMID_
BUKRS S 0 I EQ BR0K
ZSD_NFE_TRDNT_MEMID_
BUKRS S 1 I EQ BR0L
ZSD_NFE_TRDNT_MEMID_
BUKRS S 2 I EQ BR0M
ZSD_NFE_TRDNT_MEMID_
BUKRS S 3 I EQ BR0N
ZSD_NFE_USER_ADDINFOI
NP_NFTYPE S 0 I BT IN Importacao
ZSD_NFE_USER_ADDINFOI
NP_NFTYPE S 1 I BT I1 Compra
ZSD_NFE_USER_ADDINFOI
NP_NFTYPE S 2 I BT ZE Devolucao
ZSD_NFE_USER_ADDINFOI
NP_NFTYPE S 3 I BT Z5 Entrada (Recusa)
ZSD_NFE_USER_ADDINFOI
NP_TXTBLK S 0 I BT ZLF ZB00
ZSD_NFE_USER_ADDINFOI
NP_TXTBLK S 1 I BT ZLF ZB01
ZSD_NFE_USER_ADDINFOI
NP_TXTBLK S 2 I BT ZLF ZB02
ZSD_NFE_USER_ADDINFOI
NP_TXTBLK S 3 I BT ZLF ZB03
ZSD_NFE_USER_ADDINFOI
NP_TXTBLK S 4 I BT ZLF ZB04
ZSD_NFE_USER_ADDINFOI
NP_TXTBLK S 5 I BT ZLF ZB05
ZSD_NFE_USER_ADDINFOI
NP_TXTBLK S 6 I BT ZLSA ZB00
ZSD_NFE_USER_ADDINFOI
NP_TXTBLK S 7 I BT ZLSA ZB01
ZSD_NFE_USER_ADDINFOI
NP_TXTBLK S 8 I BT ZLSA ZB02
ZSD_NFE_USER_ADDINFOI
NP_TXTBLK S 9 I BT ZLSA ZB03
ZSD_NFE_USER_ADDINFOI
NP_TXTBLK S 10 I BT ZLSA ZB04
ZSD_NFE_USER_ADDINFOI
NP_TXTBLK S 11 I BT ZLSA ZB05
ZSD_NFE_VARTEXT_SUBS
TITUTE S 0 I BT #%ZRFNFNR%# (SAPLJ1BG)WR_HEADER-NFENUM
ZSD_NFE_VARTEXT_SUBS
TITUTE S 1 I BT #%ZRFNFSR%# (SAPLJ1BG)WR_HEADER-SERIES
ZSD_NFE_VARTEXT_SUBS
TITUTE S 2 I BT #%ZRFNFDT%# (SAPLJ1BG)WR_HEADER-PSTDAT
ZSD_NFE_XMLTAG_FUEL_
CIDE S 0 I EQ ZCID
Following IMG configuration view related to SAP Std Brazilian Localization will be
necessary to provide the ISO codes for Countries, as required on NF-e XML file.
Not applicable.
4.3 Enhancements – NFe BADI
Not applicable.
Not applicable.
4.5 Data Migration – NFe BADI
Not applicable.
4.5.1 Issue LogBehavioural Change – NFe BADI
Doc x-ref Description Notes Owner
Raise invoice against an 02 Create a billing document with reference Nota Fiscal is
existing Sales Order. to the sales document. automatically posted.
Nota fiscal document 03 Check nota fiscal document. SAP Nota fiscal
posted for the billing document has all
created in previous step. contents to be provided
by BADI. Information
must be on XML
generated by SLL-NFE
application system
Create a credit invoice in 02 Create Credit Invoice for the PO The invoice is posted
MIRO for the mentioned and the tax was values
PO, and use the NF Type and % , are similar to
“Z4” doing the reference to the tax in the original
the original Nota Fiscal nota fiscal
posted in the first delivery
The print program and smartform were already developed in the PRC system with DANF-e being
issued by that system.
The To-Be functionality will generate the same DANF-e output in terms of layout and format of fonts,
logo, etc. However, some specific logics to support other Business areas than Gas and Energy (exp:
Oil, Lubricants, etc) will not be taken into PRI design. By other side, updates and new requirements
released by SEFAZ Tax Authority related to NF-e contents that affect DANF-e will be considered.
6.2.1 Functional design of the report logic – DanFe and Printing program
As per the described Business Requirement in section 1.1, development must be done to properly
issue a DANF-e printout from an electronically approved NF-e by SEFAZ Tax Authority, following all
the technical and functional requirements legally defined in the last version of “Manual de Orientação
ao Contribuinte” available on “Documentos” session of
https://www.nfe.fazenda.gov.br/portal/principal.aspx. This development is specific for Brazil.
SAP Smartform will then basically follow the rules defined in “Manual de Orientação ao Contribuinte”
and the specific additional details (logo, font format, etc) being used in the current PRC Production
environment. SAP Standard BR Localization reference Smartform object for DANF-e is
J_1B_NF_SMARTFORMS.
The Print program will mainly use the data provided by J_1BNF* tables that comprise of an SAP NF
Document (exp: J_1BNFDOC-Header, J_1BNFLIN-Items, J_1BNFSTX-Tax Values, etc) and
additional SAP standard tables when necessary information is not available on the first ones. SAP
Standard BR Localization reference print program for DANF-e is J_1BNFPR.
Transaction code – The authorization is inherent to J1B3N transaction, from where the printout
command is provided by the user.
7 TECHNICAL DESIGN – DANFE AND PRINTING PROGRAM
Implement the Print Program for DANF-e i.e. based on SAP Standard Brazilian Localization
J_1BNFPR reference andcontains generally 66% to 80% of the necessary contents. The standard
J_1BNFPR program is currently associated with the output message ZE01 but it will be replaced by
the new Z as soon as this is available for initial tests.
7.1.1 Data Mapping and Logic Matrix – DanFe and Printing program
Refer to the attached documents with defined fields to be provided by the Print program. Internal
structures (like J_1BPRNF*) were already mapped from J_1BNFPR SAP Standard BR Localization
program and majority of the fields won’t require transformation. However, some of them will require
program enhancements to fulfil specific BP needs.
As most of the former CL_NFE_PRINT BADI functionalities were migrated to the new
J_1BNF_ADD_DATA BADI for data persistence on SAP NF tables, many data is now available
and ready to be got by print Program and DANFe.
(VERSION 1.0)
ENH010_DANFe_For
m_Layout.rtf
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
#nrnota J_1BPRNFHD-NFENUM NF-e number (9 All H 10 N/A
Digits) page
s
#ser J_1BPRNFHD-SERIES NF-e Series (3 All H 10 N/A
Chars) page
s
#sn J_1BPRNFHD-DIRECT Direction If field value is '1' or '4', then print "0". If it's All H 8 N/A
equal to '2' or '3', print "1". page
s
1 Incoming
2 Outgoing
3 Outgoing Returns of Stock Transfers
4 Incoming Returns of Stock Transfers
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
AUTHTIME Authority
#inscrestadempresa J_1BPRNFIS-STAINS NF Issuer - State All H 8 N/A
Inscription page
s
#inscrestadsubstituto J_1BPRNFIS- NF Issuer - State Only if the selection below find some All H 8 N/A
STATE_INSC Inscription on information. Select from J_1BTXST1 where page
destination state J_1BTXST1-LAND1 = J_1BPRNFIS-LAND1 s
in case ICMS and J_1BTXST1-SHIPFROM = J_1BPRNFIS-
Substituicao TXJCD (3) andJ_1BTXST1-shipTo =
Tributatiria J_1BPRNFDE-TXJCD (3) and J_1BTXST1-
(ICMS-ST) MATNR = J_1BPRNFLI-MATNR
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
gs_firstsf-ort01 = gs_j1bprnfde-ort01
.…
…
IF gs_j1bprnfhd-land1 <> lc_br
CALL FUNCTION j_1bnfe_cust3_read
EXPORTING
iv_bukrs = gs_j1bprnfhd-bukrs
iv_branch = gs_j1bprnfhd-branch
iv_model = gs_j1bprnfhd-model
IMPORTING
es_cust3 = ls_cust3
gs_firstsf-ort02 = ls_cust3-valxbairro
IF gs_j1bprnfde-ort01 IS INITIAL
gs_firstsf-ort01 = ls_cust3-valxmun
ENDIF
ELSE
gs_firstsf-ort01 = gs_j1bprnfde-ort01.
gs_firstsf-ort02 = gs_j1bprnfde-ort02.
ENDIF
gs_firstsf-ort02 = gs_j1bprnfde-ort02.
gs_firstsf-pstlz = gs_j1bprnfde-pstlz.
gs_firstsf-ort01 = gs_j1bprnfde-ort01.
…
(END – 24_UAT: RITM000001588724
Changes V3.0 – 15th Oct 2022)
#fonedestinatario J_1BPRNFDE-TELF1 or NF-e Phone If J_1BPRNFDE-TELF1 ends with ‘…’ it First H 8 N/A
SADR-TELF1 means that more data needs to be retrieved page
for the partner. only
If J_1BPRNFHD-PARXCPDK is filled with ‘X’
then keep using field J_1BPRNFDE-TELF1.
If field J_1BPNFHD-PARTYP = ‘C’
(Customer) then select field ADRNR from
table KNA1 where KUNNR = J_1BPRNFHD-
PARID.
If field J_1BPNFHD-PARTYP = ‘V’ (Vendor)
then select field ADRNR from table LFA1
where LIFNR = J_1BPRNFHD-PARID.
Call function ADDR_GET and fill
ADDRESS_SELECTION-ADDRNUMBER
with ADRNR. The returned structure SADR
will be filled with the desired data.
#ufdest J_1BPRNFDE-REGIO or NF-e Recipient - If J_1BPRNFDE-LAND1 ne ‘BR’ then print First H 8 N/A
‘EX’ State ‘EX’ else J_1BPRNFDE-REGIO. page
only
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
#horasaida J_1BPRNFHD- Outbound or First H 8 N/A
HSAIENT Inbound page
( From / To only
Plant) -
generally the
NF-e approved
date
[#fatura1 #vencfat1 #vlfat1], J_1BPRNFHD- FATURA/ (v4.0 SYMBRET_CAT not used anymore) First H 8 N/A
[#fatura2 #vencfat2 #vlfat2],
[#fatura3 #vencfat3 #vlfat3], NFENUM + / + DUPLICATA Select the table of variant variables page
[#fatura4 #vencfat4 #vlfat4], LF_NPARC or (Installment (TVARVC) table where TVARVC-SIGN = “I”, only
[#fatura5 #vencfat5 #vlfat5], <empty> number) TVARVC_OPTI = “EQ” and TVARVC-NAME
[#fatura6 #vencfat6 #vlfat6], = SYMBRET_NFCAT. Get the value of
[#fatura7 #vencfat7 #vlfat7],
[#fatura8 #vencfat8 #vlfat8] TVARVC-HIGH).
If J_1BNFDOC-NFTYPE = TVARVC-HIGH
content, let this field in Blank;
Else:
The data of invoice(parcels) need to be
obtained of BSID table(open items) and
BSAD(Cleared items).
The DETERMINE_DUE_DATE function can
be used to calculate the expiration dates
of values payable and discount. Each item
of BSID and BSAD means a new parcel to
be print in a new line.
The sequence number will be increased
for all new register( field PARC).
The rules to extraction are:
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
From Layout 3.10, SAP provided a new
table J_1BNFTRADENOTES to save the
instalments when a “Fatura” NF-e is
generated. With the migration from the
former BADI to the new one, this table is
now being filled during Billing creation
(customer logic). Read
J_1BNFTRADENOTES records with
DOCNUM. If records found, then Loop and
show:
J_1BNFTRADENOTES-NDUP |
J_1BNFTRADENOTES-DVENC|
J_1BNFTRADENOTES-VDUP as sample
below (with two installments):
#vlicmsnota J_1BPRNFHD- VALOR DO ICMS Tax rate value. Do not print if negative First H 8 N/A
ICMSVAL (if positive) ICMS (ICMS Tax or zero (0). page
or SPACE Amount) only
(START - 42_UAT: RITM000002278935
Changes V4.0 – 08th Jul 2024)
ICMS Tax Amount. Send only if
J_1BPRNFHD-ICMSVAL field> 0 (not null).
* Premise: For ICMS Tax Types NOT
STATISTICAL related to "ICMS" Tax Group,
EXCEPT FCP Tax Types, effective tax
amount is the summing up of tax value
greater than zero for each NF item.
CLEAR: lv_icmsval, lt_tvarvc_icmsval
SELECT * FROM tvarvc INTO
lt_tvarvc_icmsval WHERE
NAME =
'ZSD_DANFE_ICMSVAL_TXTY_EXCLUSN'
SORT lt_tvarvc_icmsval BY name low
ASCENDING
LOOP AT j_1bnflin INTO ls_nflin WHERE
docnum = <NF Doc being printed, j_1bnfdoc-
docnum>
LOOP AT j_1bnfstx INTO ls_nfstx WHERE
docnum = ls_nflin-docnum AND itmnum =
ls_nflin-itmnum AND taxgrp = 'ICMS' AND
taxval IS NOT INITAL AND stattx IS INITIAL
* Check if Tax type is not in the exclusion list
provided by TVARVC specific parameter
IF ls_nfstx-taxtyp NOT IN
lt_tvarvc_icmsval
lv_icmsval = lv_icmsval + ls_nfstx-
taxval
EXIT
ENDLOOP
ENDLOOP
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
NF Total ICMS Base = lv_icmsval
(END – 42_UAT: RITM000002278935
Changes V4.0 – 08th Jul 2024)
If J_1BNFDOC-NFTYPE = TVARVC-HIGH
content, the value for this variable must be
J_1BNFDOC-NFNET
Else
If field J_1BPRNFHD-DIRECT equal 2 or 3.
the code to discount treatment of ICMS is:
If field J_1BPRNFLI-REFTYP = ‘BI’ and
field J_1BPRNFLI-NFDIS has a value then:
Select field KNUMV from table VBRK
where field VBELN = field J_1BPRNFLI-
REFKEY(10).
If found then:
Select one record from table KONV
where field KSCHL = ‘ICZF’ (ICMS tax
reduction)
If found (meaning a discount or
rounding exists) then:
If field KONV-KSCHL = ‘ICZF’ then:
• print summation of field J_1BPRNFHD-
NFNET + J_1BPRNFHD-NFDIS in LOGICAL
BOX 04, field labeled “VALOR DOS
PRODUTOS”
Endif
Endif
Endif
else.
print J_1BPRNFHD-NFNET.
endif."
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
#idfr 0- Frete p/conta do FRETE POR (START – 24_UAT: RITM000001588724 First H 8 N/A
remetente CONTA (Freight Changes V3.0 – 15th Oct 2022) page
1- Frete p/conta do in charge to) On Method PROCESS_FIRST of Report only
destinatario ZSD_O2C_FOUT_DANFE, change current
2- Frete p/conta de block below:
terceiros …
3- Transp.proprio * Filling the IDFR field value based on
p/conta do remetente MODFRETE value.
4- Transp.proprio IF gs_headernf-modfrete EQ '1'. "Due to
p/conta do destinatario the receiver
9- Sem frete0- Frete gs_firstsf-idfr = lc_idr1.
estipulado pelo ELSEIF gs_headernf-modfrete EQ '0'. "Due
remetente to the issuer
1- Frete estipulado pelo gs_firstsf-idfr = lc_idr2.
destinatário ENDIF.
2- Frete estipulado por …
terceiros to include additional values and descriptions
3- Transporte próprio as described/listed below:
estipulado pelo 0- Frete p/conta do remetente
remetente 1- Frete p/conta do destinatario
4- Transporte próprio 2- Frete p/conta de terceiros
estipulado pelo 3- Transp.proprio p/conta do remetente
destinatário 4- Transp.proprio p/conta do destinatario
9- Sem frete 9- Sem frete
#codantt1, #codantt2, CÓDIGO ANTT (v4.0 SYMBRET_CAT not used anymore) First H 8 N/A
#codantt3 (National Select the table of variant variables page
#rntc1, #rntc2, #rntc3 Transportation (TVARVC) table where TVARVC-SIGN = “I”, only
Agency Code) TVARVC_OPTI = “EQ” and TVARVC-NAME
= SYMBRET_NFCAT. Get the value of
TVARVC-HIGH).
If J_1BNFDOC-NFTYPE = TVARVC-HIGH
content, let this field in Blank;
Else:
To find this information, it is necessary
use the logic below:
Check if exists a valid Delivery Text ID on
TVARVC variable
'ZSD_DANFE_DLV_TXT_ID_ANTT'
If NOT, does not fill anything (blank on
DANF-e fields)
If YES, select VBRP item, first occurrence,
where VBELN equal J_1BNFLIN-REFKEY
(also first occurrence > premise: all NF
items came from same Billing doc).
Use the funtion READ_TEXT informing: ID
equal the one designated by TVARVC
variable
'ZSD_DANFE_DLV_TXT_ID_ANTT',
Language equal PT, Name equal VBRP-
VGBEL, OBJECT equal VBBK.
The read text MUST be composed with
max 3 strings (premise - bitruck) separated
by ";". The splitted parts, in sequence, will
represent: #codantt1;#codantt2;#codantt3.
Vehicles RNTC:
#rntc1 J_1BNFDOC-RNTC
#rntc2 J_1BNFTRAILER[1]-RNTC
#rntc3 J_1BNFTRAILER[2]-RNTC
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
#placa1, #placa2, PLACA DO (v4.0 SYMBRET_CAT not used anymore) First H 8 N/A
#placa3 VEÍCULO Select the table of variant variables page
(Vehicle Plate) (TVARVC) table where TVARVC-SIGN = “I”, only
TVARVC_OPTI = “EQ” and TVARVC-NAME
= SYMBRET_NFCAT. Get the value of
TVARVC-HIGH).
If J_1BNFDOC-NFTYPE = TVARVC-HIGH
content, let this field in Blank;
Else:
To find this information, it is necessary
use the logic below:
Check if exists a valid Delivery Text ID on
TVARVC variable
'ZSD_DANFE_DLV_TXT_ID_PLATES'
If NOT, does not fill anything (blank on
DANF-e fields)
If YES, select VBRP item, first occurrence,
where VBELN equal J_1BNFLIN-REFKEY
(also first occurrence > premise: all NF
items came from same Billing doc).
Use the funtion READ_TEXT informing: ID
equal the one designated by TVARVC
variable
'ZSD_DANFE_DLV_TXT_ID_PLATES',
Language equal PT, Name equal VBRP-
VGBEL, OBJECT equal VBBK.
The read text MUST be composed with
max 3 strings (premise - bitruck) separated
by ";". The splitted parts, in sequence, will
represent: #placa1;#placa2;#placa3.
Plate numbers:
#placa1 J_1BNFDOC-PLACA
#placa2 J_1BNFTRAILER[1]-PLACA
#placa3 J_1BNFTRAILER[2]-PLACA
#ufpl1, #ufpl2, #ufpl3 UF (State of the (v4.0 SYMBRET_CAT not used anymore) First H 8 N/A
Vehicle Plate) Select the table of variant variables page
(TVARVC) table where TVARVC-SIGN = “I”, only
TVARVC_OPTI = “EQ” and TVARVC-NAME
= SYMBRET_NFCAT. Get the value of
TVARVC-HIGH).
If J_1BNFDOC-NFTYPE = TVARVC-HIGH
content, let this field in Blank;
Else:
To find this information, it is necessary
use the logic below:
Check if exists a valid Delivery Text ID on
TVARVC variable
'ZSD_DANFE_DLV_TXT_ID_UFPLAT'
If NOT, does not fill anything (blank on
DANF-e fields)
If YES, select VBRP item, first occurrence,
where VBELN equal J_1BNFLIN-REFKEY
(also first occurrence > premise: all NF
items came from same Billing doc).
Use the funtion READ_TEXT informing: ID
equal the one designated by TVARVC
variable
'ZSD_DANFE_DLV_TXT_ID_UFPLAT',
Language equal PT, Name equal VBRP-
VGBEL, OBJECT equal VBBK.
The read text MUST be composed with
max 3 strings (premise - bitruck) separated
by ";". The splitted parts, in sequence, will
represent: #ufpl1;#ufpl2;#ufpl3.
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
Use the funtion READ_TEXT informing: ID
equal the one designated by TVARVC
variables:
ZSD_NFE_CMPLINF_HDTX_TRUCKDTLS
and
ZSD_NFE_CMPLINF_HDTX_TRAILDTLS
Language equal PT, Name equal VBRP-
VGBEL, OBJECT equal VBBK
Plate State => if exists per line, is the 2nd
string after first ";" separator
Plate UFs:
#ufpl1 J_1BNFDOC-UF1
#ufpl2 J_1BNFTRAILER[1]-VEH_UF
#ufpl3 J_1BNFTRAILER[2]-VEH_UF
#cnpjtransp MY_CARRIER-CGC or CNPJ (v4.0 SYMBRET_CAT not used anymore) First H 8 N/A
MY_CARRIER-CPF TRANSPORTA Select the table of variant variables page
DOR (Carrier (TVARVC) table where TVARVC-SIGN = “I”, only
CNPJ) TVARVC_OPTI = “EQ” and TVARVC-NAME
= SYMBRET_NFCAT. Get the value of
TVARVC-HIGH).
If J_1BNFDOC-NFTYPE = TVARVC-HIGH
content, loop in J_1BDYNAD and check if
exist PARVW = “SP”. If not exist “SP”, get the
information from PARVW = “LF”, or else:
CNPJ information from J_1BDYNAD-CGC
field, but if is blank, get the CPF information
from J_1BDYNAD-CPF. But if “SP” exist, so
get the same information field from this “SP”
line.
Else:
If field J_1BPRNFTR-NAME1 is empty and
field J_1BPRNFTR-STRAS is empty then
send SPACE otherwise
if J_1BPRNFTR-STKZN = ‘X’ then write
J_1BPRNFTR-CPF (natural person) else
write J_1BPRNFTR-CGC (legal person).
Respect the output length: 18 for CGC
layout xx.xxx.xxx/xxxx-xx and 14 for CPF
layout xxx.xxx.xxx-xx. Use write statement
because of the domain conversion routine.
#enderecotransp MY_CARRIER-STRAS ENDEREÇO First H 8 N/A
TRANSPORTA page
DORA (Carrier only
Address)
#cidadetransp MY_CARRIER-ORT01 MUNICÍPIO Only if J_1BPRNFTR-STRAS is not empty First H 8 N/A
TRANSPORTA page
DORA (Carrier only
City)
#uftran MY_CARRIER-REGIO UF First H 8 N/A
TRANSPORTA page
DORA (Carrier only
State)
#inscrestadtransp MY_CARRIER-STAINS INSCRIÇÃO First H 8 N/A
ESTADUAL page
TRANSPORTA only
DORA (Carrier
State
Inscription)
#qtvolume (START – 22_UAT: QUANTIDADE (START – 22_UAT: RITM000001588724 First H 8 N/A
RITM000001588724 VOLUMES (Qty Changes V3.0 – 15th Oct 2022) page
Changes V3.0 – 15th of Handling only
Oct 2022) Units) Get value using new specific
J_1BNFTRANSVOL:
J_1BPRNFHD-ANZPK∑ Read all records of table and ∑QVOL
J_1BNFTRANSVOL- IF ∑QVOL IS NOT INITIAL
QVOL Use ∑QVOL on GS_FIRST-QTVOL
or ELSEIF ∑QVOL = 0 AND J_1BPRNFHD-
J_1BPRNFHD-ANZPK ANZPK IS NOT INITIAL
or Use J_1BPRNFHD-ANZPK on
∑Item Qty GS_FIRST-QTVOL
Else
(END – 22_UAT: Use ∑Item Qty
RITM000001588724
Changes V3.0 – 15th (END – 22_UAT: RITM000001588724
Oct 2022) Changes V3.0 – 15th Oct 2022)
#especievolume (START – 22_UAT: ESPÉCIE (Type (START – 22_UAT: RITM000001588724 First H 8 N/A
RITM000001588724 of HU) Changes V3.0 – 15th Oct 2022) page
Changes V3.0 – 15th only
Oct 2022) CREATE new GS_FIRST-ESP CHAR40 to
support this DANFe field and substitute
Concatenation of current UNIT3 GS_FIRST-ESVOL
J_1BNFTRANSVOL- CONCATENATE( J_1BNFTRANSVOL-ESP
ESP of all existing records, separated by '/' into
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
or lv_esp, truncating by field limit of 40
J_1BPRNFHD-SHPUNT chars)
or IF lv_esp IS NOT INITIAL
UoM (on chars) Use lv_esp on GS_FIRST-ESP
or ELSEIF lv_esp IS INITIAL AND
‘*’ J_1BPRNFHD-SHPUNT IS NOT INITIAL
Use J_1BPRNFHD-SHPUNT on
(END – 22_UAT: GS_FIRST-ESP
RITM000001588724 ELSE
Changes V3.0 – 15th CHECK UoM of all items
Oct 2022) IF UoM are the same
Use UoM (on char string) on
GS_FIRST-ESP
ELSE
Use ‘*’
ENDIF
ENDIF
#marcavolume (START – 22_UAT: MARCA (Brand) (START – 22_UAT: RITM000001588724 First H 8 N/A
RITM000001588724 Changes V3.0 – 15th Oct 2022) page
Changes V3.0 – 15th only
Oct 2022) CREATE new GS_FIRST-MARCA CHAR24
to support this DANFe field (does not exist
Concatenation of currently)
J_1BNFTRANSVOL- CONCATENATE( J_1BNFTRANSVOL-
MARCA MARCA of all existing records, separated
or by '/' into lv_marca, truncating by field limit
J_1BPRNFHD- of 24 chars)
SHPMRK IF lv_marca IS NOT INITIAL
Use lv_marca on GS_FIRST-MARCA
(END – 22_UAT: ELSEIF lv_marca IS INITIAL AND
RITM000001588724 J_1BPRNFHD-SHPMRK IS NOT INITIAL
Changes V3.0 – 15th Use J_1BPRNFHD-SHPMRK on
Oct 2022) GS_FIRST-MARCA
ENDIF
#pesoliquidototal (START – 22_UAT: PESO LÍQUIDO (START – 22_UAT: RITM000001588724 First H 8 N/A
RITM000001588724 (Shipment Net Changes V3.0 – 15th Oct 2022) page
Changes V3.0 – 15th weight) only
Oct 2022) Get value using new specific
J_1BNFTRANSVOL:
∑ J_1BNFTRANSVOL- Read all records of table and sumup the
PESOL values on field PESOL
or IF ∑PESOL > 0
J_1BPRNFHD- Use ∑PESOL on GS_FIRST-NTGEW
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
NTGEW ELSE
Use J_1BPRNFHD-NTGEW on
(END – 22_UAT: GS_FIRST-NTGEW
RITM000001588724 ENDIF
Changes V3.0 – 15th
Oct 2022) (END – 22_UAT: RITM000001588724
J_1BPRNFHD-NTGEW Changes V3.0 – 15th Oct 2022)
TEXTO DE
ITEM para
Código ANP
(Item individual
text for ANP
Code – SAP breaks automatically the max 500
Brazilian char block inserted on BADI structure into
Petroleum n lines x 72 char before saving on text
Agency, if
applied, but
on/off
controlled by
TVARVC)
table
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
Service)
$g01, $g02, $g03, $g04, MY_ITEMS-NFQTY QUANT. Main H 8 N/A
$g05, $g06, $g07 (Quantity of detai
Material or l
Service)
$h01, $h02, $h03, $h04, MY_ITEMS-NFPRI VALOR Main H 8 N/A
$h05, $h06, $h07 UNITÁRIO (Unit detai
value with l
embedded
taxes for the
Material or
Service)
$i01, $i02, $i03, $i04, MY_ITEMS-NFNET Bill to - VALOR Main H 8 N/A
$i05, $i06, $i07 TOTAL detai
l
$j01, $j02, $j03, $j04, J_1BNFSTX-BASE B. CALC. ICMS Print only if not statistical (J_1BPRNFLI- Main H 8 N/A
$j05, $j06, $j07 when TAXGRP = (ICMS Tax ICMSSTAT = space). detai
“ICMS” Calculation l
Basis)
$o01, $o02, $o03, $o04, J_1BNFSTX-BASE B.CÁLC. ICMS Print only if not statistical (field Main H 8 N/A
$o05, $o06, $o07 when TAXGRP = ST (ICMS-ST J_1BNFSTX-STATTX = space). detai
“ICST” Tax Calculation l
Basis)
$k01, $k02, $k03, $k04, J_1BNFSTX-TAXVAL VALOR ICMS Print only if not statistical (campo Main H 8 N/A
$k05, $k06, $k07 when TAXGRP = (ICMS Tax J_1BPRNFLI-ICMSSTAT = space). detai
“ICMS” Amount) l
$p01, $p02, $p03, $p04, J_1BNFSTX-TAXVAL VALOR ICMS Print only if not statistical (campo Main H 8 N/A
$p05, $p06, $p07 when TAXGRP = ST (ICMS-ST J_1BNFSTX-STATTX = space). detai
“ICST” Tax Amount) l
$l01, $l02, $l03, $l04, MY_ITEMS-IPIVAL VALOR IPI (IPI Main H 8 N/A
$l05, $l06, $l07 Tax Amount) detai
l
$m01, $m02, $m03, MY_ITEMS-ICMSRATE ICMS (ICMS Main H 8 N/A
$m04, $m05, $m06, Rate) detai
$m07 l
$n01, $n02, $n03, $n04, MY_ITEMS_IPIRATE IPI (IPI Rate) Main H 8 N/A
$n05, $n06, $n07 detai
l
#inscrmunicipaliss J_1BPRNFHD-MUNINS INSCRIÇÃO if J_1BPRNFHD-ISSPBASE or First H 8 N/A
or blank MUNICIPAL J_1BPRNFHD-ISSSBASE are not null, page
(Municipality J_1BPRNFHD-MUNINS, if no blank only
Inscription - for
being an ISS
Tax Service
Provider)
#vltotalsevicos VALOR TOTAL First H 8 N/A
DOS SERVIÇOS page
(Total value of only
the Services
provided -
involving ISS
Tax)
#vlbciss J_1BPRNFHD- BASE DE if J_1BPRNFHD-ISSPBASE are not null, First H 8 N/A
ISSPBASE or CÁLCULO DO J_1BPRNFHD-ISSPBASE. page
J_1BPRNFHD- ISSQN (ISS Tax If J_1BPRNFHD-ISSSBASE are not null, only
ISSSBASE Calculation J_1BPRNFHD-ISSSBASE.
Basis) Never two fields are filled together.
#informacoescomplem INFORMAÇÕES (START – 10_UAT: Changes V2.0 – 29th Jun First H 8 N/A
entares COMPLEMENT 2022) page
ARES only
(Complementat The complementary information is a
y Information) concatenation of texts already provided by
SAP Standard BR Localization (exp: from
Tax Laws) and some customized text ids
and logic to find them.
(v4.0 source of SAP Standard BR
Localization texts in NF)
The SAP NF Doc Texts are located in
J_1BNFFTX table, that contains both
header and items texts and must be read
by DOCUMENT NUMBER KEY (DOCNUM
field) while keeping ordering by increasing
Sequence Number and Line Number. All
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
the texts must be directed as a block
(respecting a minimum separation) to this
#informacoescomplementares area.
If J_1BNFDOC-NFTYPE = TVARVC-HIGH
content, get the texts from header and item
level texts and observations: J_1BNFFTX-
MESSAGE (item/header) + J_1BNFDOC-
OBSERVAT
Else:
In BP the unique difference is the Order
Header Text ID being looked for depending
on NF Type
(J_1BPRNFHD-NFTYPE). So far we have
for NF categories Z2, Z8 and ZX:
Label R/3 Field Functionality Calculation logic Print Label Fon Font Outp
on Positio t form ut
Page n at forma
t
#razaosocialempresa Concatenate NF Issuer Name All H 8 N/A
J_1BPRNFIS-NAME1 / page
J_1BPRNFIS-NAME2 / s
J_1BPRNFIS-NAME3 /
J_1BPRNFIS-NAME4
digits, including 0’s on the left)
OBJECT = ‘J_1BNFDOC’
IMPORTING
LINES = lt_lines
Note A: If this field must be calculated from other fields then please provide detailed logic with an example.
Note B: Provide information such as:
This field will appear in all the pages
This will appear only in the first page
This will not appear in first page but will appear on every other page
Note C: If the position of this field on Paper is important then specify this measurement here along with the unit
Note D: Helvetica (H) or Times (T)
Note E: Bold (B), Italics (I), Underlined (U). Also, size such as 10, 11, 12, etc.
Note F: Special formatting requirements (e.g.: do not display leading zeroes, date format YYYYMMDD)
7.2 Form: SAP Script / Smartform Details – DanFe and Printing program
Orientation: Landscape
Special stationary to be used: N/A
Frequency and Timing On demand
However, this SAP Standard layout does not accomplish the minimum requirements for DANFe Layout
required by SEFAZ Tax Authority on its “Manual de Orientação ao Contribuinte” for Landscape format
chosen by BP.
The final format to be reached is displayed by the following image (the attached file contains the original
information captured by the image to facilitate analysis):
Note A: This is the language in which the original layout is created. This will be ‘EN’ (English) in
general.
Note B: Specify if the text module needs to be translated to all languages or to selected languages
or does not need to be translated. If a translation is needed, then this will be done via transaction
code SE63.
Note C: This Style name will be defined in Smartforms and will contain the Paragraph and
character formats needed to output the text modules.
Output message type ZE01 review to change to new print program and smartform.
Not applicable.
8.3 Enhancements – DanFe and Printing program
Not applicable.
8.4 Interfaces – DanFe and Printing program
Not applicable.
8.5 Data Migration – DanFe and Printing program
Not applicable.
8.5.1 Issue LogBehavioural Change
Doc x-ref Description Notes Owner
8.5.2 Notes
Doc x-ref Description Owner
For O2C:
Test Step Step Description Expected Results
Condition
Create DANF-e for an 01 (VA01) Create Sales order with NF-e approved:
Energy sales invoicing. Energy item already created, with all issuance of DANF-e by
data ok to be validated by SEFAZ and J1B3N must be
ready to be billed. successful (output
02 (VF01) Bill Sales Order message with “green”
03 (J1B3N) Once NF-e is approved, status)
execute output message run
Create DANF-e for an 01 (VA01) Create Sales order with NF-e should not be
Energy sales invoicing w/o Energy item already created, with all submitted to SEFAZ.
posting to accounting data ok to be validated by SEFAZ and Also, DANF-e issuance
(error). ready to be billed. not possible (output
02 (VF01) Bill Sales Order BUT BEFORE remains pending:
SAVING, go to Billing header and “yellow” status).
remove ‘Customer Classification
Accounting Group’ to force error and
then save.
03 (J1B3N) Try to issue DANF-e but
system will report ‘0 of 1 messages
processed’.
Create DANF-e for an 01 (VA01) Create Sales order with NF-e not approved:
Energy sales invoicing with Energy item already created, with all issuance by J1B3N
NF-e rejected by SEFAZ data ok to be validated by SEFAZ and must be not successful
ready to be billed. (“red” status on output
02 (VA02) Before going to Billing, change message).
ICMS Tax Law for another one that is
not compatible with ICMS Tax
Calculation (if ICMS is calculated,
then choose an ‘Exempt’ Tax Law, for
example).
03 (VF01) Bill Sales Order
04 (J1BNFE) Monitor NF-e until it’s
rejected by SEFAZ.
05 (J1B3N) Try to issue DANF-e but
system will report ‘0 of 1 messages
processed’.
For P2P:
Test Step Step Description Expected Results
Condition
Create DANF-e for an 01 (MIRO) transaction “Credit” to a NF-e approved:
Return to Vendor previous invoice posted issuance of DANF-e by
02 Return the total quantity J1B3N must be
03 Save and go to NF monitor successful (output
04 (J1BNFE) send the nota to SEFAZ message with “green”
and get the authorization status)
05 (J1BNFE/J1B3N) print the DANF-e
06 Reverse the goods
The program is job scheduled (about each 5 to 10 min frequency) but the transaction enables the ad-hoc
actions when necessary (one SAP NF Document per run). A log was developed to indicate the faulty results
and then enable user actions.
The approach here will make use of existing output message functionalities to avoid the building of additional
logs, reprocessing and status reports – all of them in anyway offered by Standard SAP.
The output message that will create the e-mail and files to be attached on it, will be linked to SAP NF
Document to be possible to trace the actions. All the relevant information for successful or unsuccessful
processing will be saved on output message log.
New ECC Z program for Output message (application NF, transmission medium ‘8’ – need to
confirm technically) to generate both DANF-e PDF and NF-e XML files: after that, create and send
e-mail where those files will be attached on. E-mail address will be the one defined on Customer
Master Data of Ship-To Customer.
New ECC Z Transaction with Z program for user foreground execution with logic to call RSNAST0D
but using fixed selection variant(s) to restrict the consulting to specific NF output message for e-mail
sending. User can check status and log of messages generated for a specific NF-e using SAP NF
Document number and resubmit a new sending in case some conditions are met.
New ECC Requirement routine for NF output message procedure to control no e-mail issuance when
user executing DANF-e reprint in J1B3N and e-mail output message has been successfully
processed.
SAP SLL-NFE Module Function that will be called via RFC by ECC Output message routine to
provide all NF-e XML contents of the official document already approved by Tax Authority and stored
on that messaging system.
ECC Job for SAP Standard RSNAST00 program to execute new output message to be created for E-
mail sending with DANF-e PDF and NF-e XML files. The frequency (minimum daily) will be defined
yet.
Regarding the new four components, we have planned the following functional behaviors:
o Check if there is a Carrier (‘SP’) Partner on SAP NF Doc and that partner also has a not
blank e-mail defined: get the one set as “Standard” and not linked to a Person;
o If there is a Carrier (‘SP’) Partner on SAP NF Doc AND that partner doesn’t have any e-
mail with string “NFEXML” defined on besides “notes” field AND Partner (‘SP’) is in
one of the registers of parameter table with “error” flag active THEN set Output
Message status to ‘error’ (red) and log “ <”Carrier XXXXXXXXXX has no e-mail address
defined. NF-e XXXXXXXXX-SSS, Branch BBBB was not sent to ANYONE including main NF
Partner. After corrections, for new attempt, use transaction <new transaction code>”;
o If NOT, set Output Message status to ‘error’ (red) and log “ <”Carrier XXXXXXXXXX has
no e-mail address defined. NF-e XXXXXXXXX-SSS, Branch BBBB was not sent to
anyone it. After corrections, for new attempt, use transaction <new transaction code>”.
o If there is a Carrier (‘SP’) Partner on SAP NF Doc AND that partner has e-mail(s) with
string “NFEXML” defined on besides corresponding “notes” field, append the e-mail(s)
on an internal table PARTNERS_EMAILS;
o If there is an Withdrawal / External Warehouse (‘SB’) Partner on SAP NF Doc AND that
Partner Code is different from the NF Main Partner Code AND that partner doesn’t have
any e-mail with string “NFEXML” defined on besides “notes” field AND Partner (‘SB’) is
in one of the registers of parameter table with “error” flag active THEN set Output
Message status to ‘error’ (red) and log “ <”External Warehouse XXXXXXXXXX has no e-
mail address defined. NF-e XXXXXXXXX-SSS, Branch BBBB was not sent to ANYONE
including main NF Partner. After corrections, for new attempt, use transaction <new
transaction code>”;
o If there is a Withdrawal / External Warehouse (‘SB’) Partner on SAP NF Doc AND that
Partner Code is different from the NF Main Partner Code AND that partner has e-mail(s)
with string “NFEXML” defined on besides corresponding “notes” field, append the e-
mail(s) on an internal table PARTNERS_EMAILS;
(START – 17_UAT: Changes V2.0 – 22nd Aug 2022)
o Read parameter table for existing bpCE Central inbox email address using following as
criteria: NAME = ZSD_EMAIL_DNFXML_BPINBOX. Read first by NFe Company code and, if
not successful, read with that in blank. If found, append the e-mail(s) on internal table
PARTNERS_EMAILS. OBS: Multiple e-mails can exist per Company Code or on the overall
(blank);
Generate virtual NF-e XML file by accessing GRC NF-e system via RFC.
If XML generation NOT OK (RFC error for example), set Output Message status to
‘pending’ (yellow) => FINISH (will be processed again on next job run)
(START – 23_ELS: Changes V3.0 – 15th Oct 2022)
If OK, Assemble / create e-mail with standard subject, body and other BP
definitions and attach both files. Send to the e-mail addresses defined in
Customer/Vendor and Carrier Master Table PARTNERS_EMAILS.
If OK, Assemble / create e-mail with sender by checking TVARVC parameter
table records under name per ZSD_EMAIL_DNFXML_SENDER (read first
occurrence by Company Code – on tvarvc-low - and, not found, using it as
blank), standard subject, body and other BP definitions and attach both files.
(END – 23_ELS: Changes V3.0 – 15th Oct 2022)
Functional design of the new Z transaction / Z program for User Consulting or re-submission
Once entering the transaction, the following selection screen is shown:
User must select radio butom for selection criteria between two options:
o (Default) Informing directly SAP NF Document number related to desired NF-e (or NF-e’s);
o Inform indirect criteria to obtain SAP NF Documents by using NF-e information like legal 9
digits number, Partner Type/Number, etc. Only Company Code and Business Place are
mandatory in case this selection option is chosen;
After that, user can select the possible message view modes:
o (Default) “List messages pending processed with errors” : in this case report RSNAST0D will
run with fixed variant but first:
Depending on the chosen selection criteria, once obtained the SAP NF Document
numbers, DELETE from the list the ones that have in NAST as last occurrence:
Application = ‘NF’
Object key = <SAP NF Document numbers>
Output Type = <Output Type defined in parameter, not fixed>
Transmission medium = <Transmission medium defined in parameter, not fixed>
Processing status = ‘1’ (Processed Successfully) OR ‘0‘ (Not Processed)
For the found SAP NF Docs with previously unsuccessfully processed e-mail
messages, call RSNAST0D using the variant defined on parameter <Variant1>:
Application = ‘NF’
Object key = <SAP NF Document numbers chosen by user, direct or indirectly>
Output Type = <Output Type defined in parameter, not fixed>
Transmission medium = <Transmission medium defined in parameter, not fixed>
Selection Type = ‘4’ (Error messages – only new messages)
Let RSNAST0D delivers its standard List and then user can select which register(s)
to consult the error log or to reprocess (after taking the correction actions);
o “List messages processed ok” : in this case report RSNAST0D will run with fixed variant
where:
Depending on the chosen selection criteria, once obtained the SAP NF Document
numbers, filter only the ones that have in NAST table:
Application = ‘NF’
Object key = <SAP NF Document numbers>
Output Type = <Output Type defined in parameter, not fixed>
Transmission medium = <Transmission medium defined in parameter, not fixed>
Processing status = at least one occurrence with ‘1’ (Processed Successfully)
AND NOT
Processing status = no one occurrence with ‘0‘ (Not Processed)
For the found SAP NF Docs with previously successfully processed e-mail sent, call
RSNAST0D using the variant defined on parameter <Variant2>:
Application = ‘NF’
Object key = <Selected SAP NF Documents from previous step>
Output Type = <Output Type defined in parameter, not fixed>
Transmission medium = <Transmission medium defined in parameter, not fixed>
Selection Type = ‘2’ (Repeat Processing)
Let RSNAST0D delivers its standard List and then user can select which register(s)
to reprocess;
If user returns back from RSNAST0D list screen, it must returns to Z transaction initial selection
screen:
Functional design of the Module Function in SLL-NFE to collect and send NF-e XML data
Receive Access Key (44 positions).
Read table /xnfe/outnfexml using type = ‘1’ and Access Key
If NOT found
o Return code 2 > End
If found
o Return XML
Security
Transaction code
The new Z transaction will require authorization objects for the following organization / transactional
elements:
o Company Code
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all syntax
corrections, internal objects clearing and analysis in terms of better performance and best
coding practices.
Once new output message application ‘NF’ starts processing (Status NAST-VSTAT = ‘ ‘ pending).
Check if SAP NF Doc (Select J_1BNFDOC-CANCEL using DOCNUM = NAST-OBJKY) is
CANCELLED (J_1BNFDOC-CANCEL = ‘X’) or NF-e status (Select J_1BNFDOC-DOCSTAT using
DOCNUM = NAST-OBJKY) is DENIED (J_1BNFDOC-DOCSTAT = ‘3’).
If YES, set Output Message status to ‘processed’ (green NAST-VSTAT = ‘1’) and log specific
message “NF-e <J_1BNFDOC-NFENUM>//”-“//<J_1BNFDOC-SERIES>, Branch <J_1BNFDOC-
BRANCH> cancelled or denied: not necessary to send e-mail.”. => FINISH.
If NOT, check if NF-e status is still INITIAL (J_1BNFDOC-DOCSTAT = ‘ ’) or REJECTED
(J_1BNFDOC-DOCSTAT = ‘2’)
If YES, set Output Message status to ‘pending’ (yellow NAST-VSTAT = ‘0’) => FINISH (will be
processed again on next job run).
If NOT.
Check if NF Partner code has e-mail(s) defined with stamp “NFEXML” on “notes” field: Select
J_1BNFDOC-PARTYP
o If J_1BNFDOC-PARTYP = ‘C’, Select lv_addr = KNA1-ADRNR using KNA1-KUNNR =
J_1BNFDOC-PARID
o If J_1BNFDOC-PARTYP = ‘V’, Select lv_addr = LFA1-ADRNR using LFA1-LIFNR =
J_1BNFDOC-PARID
o If J_1BNFDOC-PARTYP = ‘B’, Select lv_addr = J_1BBRANCH-ADRNR using
J_1BBRANCH-BUKRS = J_1BNFDOC-BUKRS and J_1BBRANCH-BRANCH =
J_1BNFDOC-BRANCH
o Read lv_email = ADR6-SMTP_ADDR using ADR6-ADDRNUMBER = lv_addr,
PERSNUMBER = <blank>, DATE_FROM <= sy_datum
o SELECT adrt INTO lt_adrt USING
ADDRNUMBER = lv_addr AND
PERSNUMBER = <blank> AND
DATE_FROM <= sy_datum AND
COMM_TYPE = ‘INT’ AND
REMARK = ‘NFEXML’. ** No matter the language(s)
o ELIMINATE MULTIPLE ENTRIES of lt_adrt with same lt_adrt-consnumber
o If lt_adrt IS NOT INITIAL
SELECT adr6 INTO lt_nfe_emails USING
ADDRNUMBER = lv_addr AND
PERSNUMBER = <blank> AND
DATE_FROM <= sy_datum AND
CONSNUMBER = <CONSNUMBER values on lt_adrt> AND
FLG_NOUSE = <blank> AND
SMTP_ADDR <>≠ <blank>.
If NOT (lv_email is INITIAL) lt_nfe_emails IS INITIAL for NF Partner, set Output Message status to
‘error’ (red NAST-VSTAT = ‘2’) and log specific message “Customer/Vendor XXXXXXXXXX has no e-
mail address defined. NF-e <J_1BNFDOC-NFENUM>//”-“//<J_1BNFDOC-SERIES>, Branch
<J_1BNFDOC-BRANCH> e-mail was not sent. After correction, for new attempt, use transaction [new
transaction code]”.
** At this point the NF Partner was checked to have NO e-mail(s) for receiving XML files from bp. Nothing
will be sent, but will be checked if error log messages must be increased with info about e-mail missing
also for Carrier and/or Withdrawal Location / External Warehouse.
o Check if there is a Carrier (‘SP’) Partner on SAP NF Doc:
Else If YES (lv_email is NOT INITIAL) lt_nfe_emails IS NOT INITIAL for NF Partner
o SELECT tvarvc INTO lt_tvarvc USING name = ZSD_EMAIL_DNFXML_PARTNERS_ERR
READ lt_tvarvc-high INTO lv_sb_flag USING low = ‘SB’
IF sy-subrc IS NOT INITIAL THEN CLEAR lv_sb_flag
READ lt_tvarvc-high INTO lv_sp_flag USING low = ‘SP’
IF sy-subrc IS NOT INITIAL THEN CLEAR lv_sp_flag
o Check if there is a Carrier (‘SP’) Partner on SAP NF Doc:
(SELECT parid INTO lv_carrier FROM J_1BNFNAD WHERE DOCNUM = J_1BNFDOC-
DOCNUM AND POSNR = ‘000000’ AND PARVW = ‘SP’)
and that partner also has a not blank e-mail(s) defined with stamp “NFEXML” on “notes”
field: get the one set as “Standard” and not linked to a Person;
(Select lv_addr = LFA1-ADRNR using LFA1-LIFNR = lv_carrier)
Read lv_email = ADR6-SMTP_ADDR using ADR6-ADDRNUMBER = lv_addr,
PERSNUMBER = <blank>, DATE_FROM <= sy_datum AND FLGDEFAULT = ‘X’)
CLEAR lt_adrt
SELECT adrt INTO lt_adrt USING
ADDRNUMBER = lv_addr AND
PERSNUMBER = <blank> AND
DATE_FROM <= sy_datum AND
COMM_TYPE = ‘INT’ AND
REMARK = ‘NFEXML’. ** No matter the language(s)
ELIMINATE MULTIPLE ENTRIES of lt_adrt with same lt_adrt-consnumber
CLEAR lt_nfe_emails_tmp
If lt_adrt IS NOT INITIAL
SELECT adr6 INTO lt_nfe_emails_tmp USING
ADDRNUMBER = lv_addr AND
PERSNUMBER = <blank> AND
DATE_FROM <= sy_datum AND
CONSNUMBER = <CONSNUMBER values on lt_adrt> AND
FLG_NOUSE = <blank> AND
SMTP_ADDR <>≠ <blank>.
Check if lv_email_carrier lt_nfe_emails_tmp is found and it’s not blank IS INITIAL
CLEAR lt_nfe_emails_tmp
Endif
(START – 17_UAT: Changes V2.0 – 22nd Aug 2022)
CLEAR: lt_bpinbox ls_tvarvc lv_sender
SELECT tvarvc INTO lt_tvarvc WHERE
NAME = ZSD_EMAIL_DNFXML_BPINBOX
(START – 23_ELS: Changes V3.0 – 15th Oct 2022)
AND ZSD_EMAIL_DNFXML_SENDER
(END – 23_ELS: Changes V3.0 – 15th Oct 2022)
IF sy-subrc IS INITIAL and lt_tvarvc IS NOT INITIAL
(START – 23_ELS: Changes V3.0 – 15th Oct 2022)
SORT lt_tvarvc BY low numb ASCENDING
SORT lt_tvarvc BY name low numb ASCENDING
lv_sender = ls_tvarvc-high
ENDIF
ENDLOOP
IF lv_sender IS INITIAL
LOOP AT lt_tvarvc INTO ls_tvarvc WHERE low = <blank> AND NAME =
ZSD_EMAIL_DNFXML_SENDER
IF ls_tvarvc-high IS NOT INITIAL
lv_sender = ls_tvarvc-high
ENDIF
ENDLOOP
ENDIF
IF lv_sender IS INITIAL
lv_sender = ‘[email protected]’
ENDIF
(END – 23_ELS: Changes V3.0 – 15th Oct 2022)
(END – 17_UAT: Changes V2.0 – 22nd Aug 2022)
If lv_error = ‘X’
FINISH processing with status to ‘error’ (red) and the current built log
Else
o If YES
If XML generation NOT OK due to another communication error (exp: RFC error
due to invalid login or authorization), set Output Message status to ‘pending’
(yellow NAST-VSTAT = ‘0’) => FINISH (will be processed again on next job run)
If XML generation NOT OK due to error returned from GRC, set Output Message
status to ‘error’ (red NAST-VSTAT = ‘2’) and log “Error XML returned from GRC
for NF-e <J_1BNFDOC-NFENUM>//”-“//<J_1BNFDOC-SERIES>, Branch
<J_1BNFDOC-BRANCH> e-mail was not sent. After correction, for new attempt,
use transaction [new transaction code]” => FINISH.
If no errors so far, then apply the PARSE_XML Method
If XML Parsing NOT OK (lv_status IS NOT INITIAL), set Output Message status to
‘error’ (red NAST-VSTAT = ‘2’) and log “Error in XML Parsing / Conversion for NF-e
<J_1BNFDOC-NFENUM>//”-“//<J_1BNFDOC-SERIES>, Branch <J_1BNFDOC-
BRANCH> e-mail was not sent. After correction, for new attempt, use transaction
[new transaction code]” => FINISH
If XML Parsing OK (lv_status IS INITIAL) Get Issuer Company Code Name
CALL FUNCTION 'BAPI_COMPANYCODE_GETDETAIL'
EXPORTING
companycodeid = J_1BNFDOC-BUKRS
IMPORTING
companycode_detail = LS_COMP_CODE_DETAILS
companycode_address = LS_COMP_CODE_ADDRESS
Once entering the new Z transaction, the following selection screen is shown:
(Radio Button Select Selection Criteria Area 1 (per SAP Default option (set)
1) NF Document Numbers only)
table (massively).
NF Type Select Option Selection by NF Type(s) defined per BP Fiscal Area to distinguish NF-e’s per
(Selection Criteria Area 2 – Field must be administrative criteria
closed if Radio Button 1 is selected)
Created on Select Option Creation date of SAP NF Document related to the NF-e (generally the NF-e
(Selection Criteria Area 2 – Field must be Document Date)
closed if Radio Button 1 is selected)
NF Entrada Select Option If set (‘X’), indicates selection of Inbound NF-e’s issued
(Selection Criteria Area 2 – Field must be
closed if Radio Button 1 is selected)
Company Code Select Option Selection per Company Code (MANDATORY)
(Selection Criteria Area 2 – Field must be
closed if Radio Button 1 is selected)
Business Place Select Option Selection per Business Place (“Filial”) (MANDATORY)
(Selection Criteria Area 2 – Field must be
closed if Radio Button 1 is selected)
NF Partner Select Option C = Customer
Code (Selection Criteria Area 2 – Field must be V = Vendor
closed if Radio Button 1 is selected) B = Branch
Partner ID Select Option (According to the previous field, associate the correct check table to the
(Selection Criteria Area 2 – Field must be matchcode – KNA1, LFA1, J_1BBRANCH)
closed if Radio Button 1 is selected) Customer, Vendor or Branch code related to the main NF Partner
One-time Select Option Select NF-e(s) created base on One-time account
account (Selection Criteria Area 2 – Field must be
closed if Radio Button 1 is selected)
Nine-digit Select Option NF-e legal 09 digit number
number (Selection Criteria Area 2 – Field must be
closed if Radio Button 1 is selected)
List messages (Selection Criteria Area 2 – Field must be (Default) Will run RSNAST0D report and result list will contain only output
pending closed if Radio Button 1 is selected) messages that presented errors (status = ‘2’ or signal = red). Then user can
processed with check processing log and take further actions or reprocess message in case
errors those actions were already taken.
List messages Radio Button for List presentation Will run RSNAST0D report and result list will contain only output messages that
processed ok ran successfully (status = ‘1’ or signal = green). Then user can resend
(to resend) message/e-mail if necessary.
User must select radio butom for selection criteria between two options:
o (Default) Informing directly SAP NF Document number related to desired NF-e (or NF-e’s);
o Inform indirect criteria to obtain SAP NF Documents by using NF-e information like legal 9
digits number, Partner Type/Number, etc. Only Company Code and Business Place are
mandatory in case this selection option is chosen;
After that, user can select the possible message view modes:
o (Default) “List messages pending processed with errors” : in this case report RSNAST0D will
run with fixed variant but first:
Depending on the chosen selection criteria, once obtained the SAP NF Document
numbers (in internal table lt_sapnfdocs), DELETE from the list the ones that have in
NAST table as last occurrence:
Application = ‘NF’
Object key = <SAP NF Document numbers>
Output Type = <(TVARVC) ‘ZSD_EMAIL_DNFXML_OUTTYP’>
Transmission medium = <(TVARVC) ‘ZSD_EMAIL_DNFXML_TRXMED’>
Processing status = ‘1’ (Processed Successfully) OR ‘ ‘ (Pending)
OBJKY = <lt_sapnfdocs>
KSCHL = <(TVARVC) ‘ZSD_EMAIL_DNFXML_OUTTYP’>
NACHA = <(TVARVC) ‘ZSD_EMAIL_DNFXML_TRXMED’>
For the remaining SAP NF Docs with unsuccessfully processed e-mail messages,
call RSNAST0D using the variant defined on parameter <Variant1>:
Application = ‘NF’
Object key = <SAP NF Document numbers chosen by user, direct or indirectly>
Output Type = <(TVARVC) ‘ZSD_EMAIL_DNFXML_OUTTYP’>
Transmission medium = <(TVARVC) ‘ZSD_EMAIL_DNFXML_TRXMED’>
Selection Type = ‘4’ (Error messages – only new messages)
Let RSNAST0D delivers its standard List and then user can select which register(s)
to consult the error log or to reprocess (after taking the correction actions).
o “List messages processed ok” : in this case report RSNAST0D will run with fixed variant
where:
Depending on the chosen selection criteria, once obtained the SAP NF Document
numbers (in internal table lt_sapnfdocs), filter only the ones that have in NAST
table:
Application = ‘NF’
Object key = <SAP NF Document numbers>
Output Type = <(TVARVC) ‘ZSD_EMAIL_DNFXML_OUTTYP’>
Transmission medium = <(TVARVC) ‘ZSD_EMAIL_DNFXML_TRXMED’>
Processing status = at least one occurrence with ‘1’ (Processed Successfully)
AND NOT
Processing status = no one occurrence with ‘ ’ (Pending Successfully)
For the found SAP NF Docs with previously successfully processed e-mail sent, call
RSNAST0D using the variant defined on parameter <Variant2>:
Application = ‘NF’
Let RSNAST0D delivers its standard List and then user can select which register(s)
to reprocess;
If user returns back from RSNAST0D list screen, it must returns to Z transaction initial selection
screen:
11.3 Module Function in SLL-NFE to collect and send NF-e XML data
Once entering on requirement routine (please create LV61B9XX on VOFM transaction as showed on
image below. Please set new routine as application ‘NF’ (suggestion as shown bellow on PDI
environment – not saved !):
CLEAR lt_nast
* Read messages table looking for existing previous ones for the NF-e
SELECT * FROM NAST INTO lt_nast WHERE
KAPPL = ‘NF’
OBJKY = MSG_OBJKY
KSCHL = G_T685B[1]-KSCHL
NACHA = G_T685B[1]-NACHA
ZSD_EMAIL_DNFXML_BPINBOX S 0 I BT [email protected]
ZSD_EMAIL_DNFXML_OUTTYP S 0 I EQ ZEML
ZSD_EMAIL_DNFXML_PARTNERS_ERR S 0 I BT SB X
ZSD_EMAIL_DNFXML_PARTNERS_ERR S 1 I BT SP
ZSD_EMAIL_DNFXML_RFC_DEST S 0 I EQ NFE_OUT
ZSD_EMAIL_DNFXML_SENDER S 0 I BT [email protected]
ZSD_EMAIL_DNFXML_TRXMED S 0 I EQ 5
Condition records for ZEML must be created on transaction J1BG to determine the desired scenarios where
emails with DANF-e and XML files must be sent.
NFENUM>//”-“//<J_1B
NFDOC-SERIES>,
Branch <J_1BNFDOC-
BRANCH> sent to
<lv_email>,
<lv_email_carrier>
successfully.”
Create DANF-e for an 01 (XD02) Guarantee that Customer NF-e should be
Energy sales invoicing w/ Master Data has no e-mail defined approved by SEFAZ.
incorrect all data ok, except (VA01) Create Sales order with DANF-e must be
Customer Master without 02 Energy item already created, with all issued but no e-mail
any e-mail defined 03 data ok. sent. Output message
(VF01) Bill Sales Order must log:
(J1B3N) Once new NF-e is approved, Customer/Vendor
execute output message run XXXXXXXXXX has no
e-mail address
defined. NF-e
<J_1BNFDOC-
NFENUM>//”-“//<J_1B
NFDOC-SERIES>,
Branch <J_1BNFDOC-
BRANCH> e-mail was
not sent. After
correction, for new
attempt, use
transaction [new
transaction code]
Testing documents will be uploade in Team’s folder below after unit Test.
Unit Testing Evidences – under BR0K and BR0L
Note: Sections for SLL-NFe and SAP PO are related to functionalities required to integrate SAP PRI with Brazilian
legal entity SEFAZ for Nfe purposes. In this context, SAP PO stands for SAP Process Orchestration a middleware
required to enable the integration.
This enhancement is already developed in PRC system to issue the XML file for nota fiscal.
PRC design uses standard SAP functionality (CL_NFE_PRINT) to generate the XML file for nota fiscal and send to
Brazilian authorities. The Business Add-in for nota fiscal uses variant data, customer, vendor and material
information and sales/billing data to fill nota fiscal tags for XML file.
14.2 To-Be process - SLL-NFE & SAP PO:
This enhancement will be developed considering the same solution implemented in PRC. The BADI definition is
CL_NFE_PRINT. Nota fiscal will be created automatically once billing document is saved.
To generate and send the XML file for nota fiscal, a job will be scheduled to run periodically getting the latest nota
fiscal documents created in the system. This job will call program J_BNFECALLRFC to number and run the
Business Add-in to generate the mandatory information for XML file before sending to GRC.
Concept
SAP Electronic Invoicing for Brazil (SAP Nota Fiscal Eletrônica, SAP NFE) utilizes different components to
meet government requirements, all while enabling a high degree of flexibility to ensure your business benefits.
Flow:
1 2 3
SAP SAP SAP
ECC SLL-NFE SEFAZ
6 5 PO 4
1 - SAP ECC send the NFe data to SLL-
NFe.
2 – SLL-NFe receives the data and check if the CNPJ is set in the environment, do the XML validation(some
standard validation), sign the XML with the certificate and sends to SAP PO.
3– SAP PO communicate with SEFAZ by SOAP ADAPTER , sending the NFe data received from SLL-NFe.
4- SEFAZ (Brazilian government system) checks the Data received and return the status for the
document(Approval or reject).
5 - SAP PO return the data received from SEFAZ to SLL-NFe.
6 – SLL-NFe return to SAP ECC the status set by SEFAZ.
15.2 Architecture of BP environments with SLL-NFe:
SAP ECC
Is the application system responsible for the NFe data. All the validations, calculations and content of NFe
data XML is from here to SLL-NFe
SEFAZ
Brazilian government system responsible to check and validate the data of XML, after the validation SEFAZ
will return with a status where the respective NFe document will be accept or reject.
SAP Nota Fiscal Eletrônica (SAP NFE) runs in different components when communicating with regional tax
authorities. SAP NFE gives you access to monitors with differing levels of detail to control the communication
process and to solve problems.
The monitoring options in SAP Nota Fiscal Eletrônica (SAP NFE) provide you with a single point-of-entry for
tracking the communication statuses of NF-es (both individual and batched), and the communication process
between the NFE application and the authorities' system. In case of communication failures, the NFE monitors
allow you to trigger resending and rechecking of NF-es, batches, and related messages.
The NF-e Monitor (Outbound) displays an overview list of all NF-es sent individually to government systems
and to business partners, along with all NF-e-related messages. You can also resend certain messages
from the filtered lists in this monitor. Is this monitor, is possible, as well, to see the XML file or, for example,
resend the check status of determined document in case of rejection as (204 – Duplicity of Nfe document)
The NF-e Batch Monitor (Outbound) displays the messages you send to and receive from government
systems about the status of NF-e batches.In this monitor is possible to resend the batch in error case, or
finish the actual batch and create a new one.
The NF-e Service Status Monitor (Outbound) displays the messages you send to and receive from
government systems about government Web service availability.
The Monitor for Outbound Analysis lets you analyze your processing time for outbound NF-es.
States(Region)
o We need to set it in the SLL-Nf the regions that will be to communicate with SEFAZ, so it
should be set here:
Set the logical system and enter tax number (CNPJ), with the region of the authority system you want to
communicate with, and determine whether will be used the homologation or production SEFAZ systems
Batches
o The batches from SLL-NFe to SEFAZ will contain 1 nfe per batch or the maximum size of
500.000 Bytes.
SAP PO
In SAP PO we need to set the scenarios provide by standard SAP NFe solution, setting the
communication channels to communicate with SLL-NFe environments and Sefaz:
Scenarios:
Incoming Interfaces:
CTE300_CTEDIST_AEX_Outbound_CTeDistRequest_Sync
Collect inbound Cte documents in SEFAZ
NFE400_NFEDIST_AEX_Outbound_NFeDistRequest_Sync
Collect inbound Nfe documents in SEFAZ
Outgoing Interfaces:
NFE400_NFEBATCH_AEX_Outbound_NFeBatch
Sending NFe batches to Sefaz
NFE400_NFEBATSR_AEX_Outbound_NFeBatchStatusRequest
Response status for each batch sent to Sefaz
NFE400_NFEEV_AEX_Outbound_NFeEvent
Send events to Sefaz from Nfe(Correction Letter, cancel Nfe e etc..)
NFE400_NFESC_AEX_Outbound_NFeStatusCheck
Check the status of Nfe in Sefaz
NFE400_NFESKIPR_AEX_Outbound_NFeSkipRequest
Send Skip Nfe to Sefaz
NFE400_NFESRVSC_AEX_Outbound_NFeServiceStatusCheck_Sync
Check the status of Sefaz service(it is up or down)
CTE300_CTESC_AEX_WebAS_Outbound_CTeStatusCheck
Check the status of Cte in Sefaz (async)
CTE300_CTESC_AEX_WebAS_Outbound_CTeStatusCheck_SYNC
Check the status of Cte in Sefaz (sync)
In the SOAP Sender Channel that receives messages from SAP NFE system, we need to fill the HTTP
Destination field of the Acknowledgement Handling tab with the destination created in NWA Destination
Configuration. The sender channels for an NFE backend can be reused across all scenarios, whereas
the receiver channels for a government system are scenario-specific.
To receiver channels, Maintain the correct target URL (see SEFAZ web site - https://www.nfe.fazenda.gov.br/) and
the correct client certificate for every receiver channel.
Shared PI systems:
Its is important to inform that PI systems IF8 and IR8 are shared between 3 differents PRC,PRO and PRI. As the
sender are different we don’t have a risk of overwrite some objects, however the communication channels with
SEFAZ will be reused in PI environments.
It means, we already have these communication channels being used in IF8 and IR8 to other SLL-Nfe environments
and the name of the party (PI object) and communication channels are the same. It is not an issue, although we
have a certificate in this communication channel, SEFAZ will not reject the connection as this certificate is used only
to do the handshake and not to sign the XML of Nfe.
We have to route the messages to the correct SEFAZ system, depends on the region. The authorizing systems
responsible for each region can be a SEFAZ (Secretaria da Fazenda) or a SEFAZ VIRTUAL (SVXX) system. If this
state system fails due to a technical reason (for example, application error, server or network overload), companies
cannot receive the authorization immediately. As an alternative, the government provides the SEFAZ VIRTUAL
Contingency (SVC-XX) systems.
Each region has a code and depends on the field cUF in the XML and the field of tpEmis the receiver condition
determination will direct the message for the correspondent SEFAZ.
Certificate
Certificate
o To sign the NFe is necessary to apply the certificate of BP in STRUST transcation in SLL-
NFe, this certificate must be renewed 1 time per year(always respecting the expiration date of
it).
16.1.1 o Is necessary to associate this certificate with respective tax number, as below in
SPRO -> System Response for Own Tax Numbers(example Rio de Janeiro)
o The certificate from BP have to be uploaded in the JAVA stack , as well, to allow the SAP PO
to do the handshake with SEFAZ during the communications. This certificate should be
installed in an Keystore Entry / Keystore View with the names as below showed, this names
are been used in the communication channels in SAP PO:
.
o and another in SLL-NFE (Method FILL_NFE_DET_IMPOSTO_400, Class
/XNFE/CL_T2PROXY_NFE_400): on this point, the aim was to – once ICMSST block of tags
was got due to the forcing ST Tax Group on ECC side (just before RFC Call) – change back
the value of VBCSTRET to 0 in case it own the “trigger value” 9999999999999.99 also forced
on ECC side as per previous item.
17.2 To-Be process - SLL-NFE & SAP-ECC Other Enhancements for NFe – bp Specific
Requirements:
The Product(s) on the transaction is(are) Fuels and its(or at least one of the) ANP code(s) is(are) on
the list of required mandatory carrier information (“Manual de Orientação do Contribuinte” – section
8.11)
Freight mode is the one derived from the Incoterm;
In case the above is fully accomplished, then a Vendor code will be read from a Parameter table and
inserted on Billing header creation as ‘SP’ Partner.
(START – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
Due to Diesel Distribution initiative, physical shipments will be in place to move fuels among bpCE
Warehouse partners (Diesel A and other imported) and to final Customer Counterparties (the sales of
Blended Diesel B) with actual Carrier services being contracted and paid by bpCE. With that requirement
in place, Carrier information will be provided per transaction and so, its indication must be moved to the
corresponding physical transaction NF-e.
Due to the modelling already in place by OTP Systems and SAP PRI (stablished by previous T&S Global
Truck and Rail initiative), Carrier partner should be indicated by user on OWB System front-end and then
will flow to SAP PRI corresponding documents, not on a SAP Partner Function but, instead, on a
customized bp field. The NF-e solution for BR - using this functionality as a base starting point – will need
to capture the Carrier information on a non-SAP Standard source and contents format and convert it to a
‘SP’ (Forward Agent) partner – ‘CR’ in EN - into corresponding SAP Document, assigning a related
Counterparty code (SAP Vendor Master Code – prerequisite).
The logic described above must be included BEFORE the existing logic to support new scenarios where
Carrier could be informed at OTP/OWB and come to SAP PRI.
(END – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all syntax
corrections, internal objects clearing and analysis in terms of better performance and best
coding practices.
o Create new FUNCTION GROUP zsd_xnfe (it’s a suggestion: please use correct PRI name
conventions if necessary);
o On TOP definitions of new FUNCTION GROUP define two new Global structures:
lt_nfe_prod_comb TABLE TYPE /xnfe/if_nfe_prod_comb_400_t
lt_nfe_det_prod TABLE TYPE /xnfe/if_nfe_det_prod_400_t
lt_nfe_imposto_cofins TABLE TYPE /xnfe/if_nfe_imposto_cofins_t
lt_nfe_imposto_icms TABLE TYPE /xnfe/if_nfe_imposto_icms_400_t
o On new FUNCTION GROUP create two Function Modules:
ZSD_XNFE_EXPORT_NF_GLOBAL_INFO
Export Parameters
o it_nfe_prod_comb TYPE /xnfe/if_nfe_prod_comb_400_t
o it_nfe_det_prod TYPE /xnfe/if_nfe_det_prod_400_t
o it_nfe_imposto_cofins TYPE /xnfe/if_nfe_imposto_cofins_t
o it_nfe_imposto_icms TYPE /xnfe/if_nfe_imposto_icms_400_t
Import Parameters
o (none)
Functional Logic:
(Just move exported contents to corresponding Global variables)
lt_nfe_prod_comb = it_nfe_prod_comb
lt_nfe_det_prod = it_nfe_det_prod
lt_nfe_imposto_cofins = it_nfe_imposto_cofins
lt_nfe_imposto_icms = it_nfe_imposto_icms
ZSD_XNFE_IMPORT_NF_GLOBAL_INFO
Export Parameters
o (none)
Import Parameters
o et_nfe_prod_comb TYPE /xnfe/if_nfe_prod_comb_400_t
o et_nfe_det_prod TYPE /xnfe/if_nfe_det_prod_400_t
o et_nfe_imposto_cofins TYPE /xnfe/if_nfe_imposto_cofins_t
o et_nfe_imposto_icms TYPE /xnfe/if_nfe_imposto_icms_400_t
Functional Logic:
(Just move contents of Global variables to Import variables)
et_nfe_prod_comb = lt_nfe_prod_comb
et_nfe_det_prod = lt_nfe_det_prod
et_nfe_imposto_cofins = lt_nfe_imposto_cofins
et_nfe_imposto_icms = lt_nfe_imposto_icms
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all syntax
corrections, internal objects clearing and analysis in terms of better performance and best
coding practices.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all syntax
corrections, internal objects clearing and analysis in terms of better performance and best
coding practices.
* SEFAZ Error 858: Tratment for Fuels NF-e on ICMS60 X ICMSST Group of tags
* As per expected by SEFAZ (not supported so far by SAP Std BR Localization),
* ICMS60 group cannot be used and must be substituted by a ICMSST one, with
* VBCSTDEST and VICMSSTDEST present and zeroed on intrastate transactions.
* Use COFINS and ICMS info to help finding WHICH NF item is being processed
CLEAR: lv_item
LOOP AT lt_nfe_imposto_cofins INTO ls_nfe_imposto_cofins WHERE
CST = <COFINS>-CHOICE-COFINSQTDE-CST
V_COFINS = <COFINS>-CHOICE-COFINSQTDE-V_COFINS
Q_BCPROD = <COFINS>-CHOICE-COFINSQTDE-Q_BCPROD
V_ALIQ_PROD = <COFINS>-CHOICE-COFINSQTDE-V_ALIQ_PROD
READ lt_nfe_imposto_icms INTO lxs_nfe_imposto_icms USING
ID = ls_nfe_imposto_cofins-id
IF sy-subrc IS INITIAL
IF ls_nfe_imposto_icms-orig = <CHOICE>-SEQUENCE-ICMS-CHOICE-ICMS60-ORIG AND
ls_nfe_imposto_icms-cst = <CHOICE>-SEQUENCE-ICMS-CHOICE-ICMS60-CST AND
ls_nfe_imposto_icms-v_bcstret = <CHOICE>-SEQUENCE-ICMS-CHOICE-ICMS60-SEQUENCE-V_BCSTRET AND
ls_nfe_imposto_icms-v_icmsstret = <CHOICE>-SEQUENCE-ICMS-CHOICE-ICMS60-SEQUENCE-V_ICMSSTRET AND
ls_nfe_imposto_icms-p_st = <CHOICE>-SEQUENCE-ICMS-CHOICE-ICMS60-SEQUENCE-P_ST AND
ls_nfe_imposto_icms-v_icmssubstituto = <CHOICE>-SEQUENCE-ICMS-CHOICE-ICMS60-SEQUENCE-
V_ICMSSUBSTITUTO.
lv_item = ls_nfe_imposto_icms-id
EXIT
ENDIF
ENDIF
ENDLOOP
IF lv_item IS NOT INITIAL
* By available info, NF item was found
READ lt_nfe_prod_comb INTO ls_nfe_prod_comb USING
ID = lv_item
IF sy-subrc IS INITIAL AND ls_nfe_prod_comb-anp IS NOT INITIAL
* ANP Code for item exists and should be checked against the list foreseen by SEFAZ Error 858
* The List of valid ANP Codes is on TVARVC of ECC Client, not on SLL-NFE Client
SELECT * FROM tvarvc INTO lt_tvarvc WHERE
( NAME LIKE 'ZXNFE#_ENH010#_SEFAZ#_858%' ESCAPE '#' )
IF sy-subrc IS INITIAL AND lt_tvarvc IS NOT INITIAL
* Parameters related to ECC Client and RFC Connection per instance are on TVARVC of SLL-NFE Client
SORT lt_tvarvc BY name number ASCENDING
* Parameters related to ECC Client
* Build ICMSST
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-ORIG = ls_nfe_imposto_icms-orig
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-CST = ls_nfe_imposto_icms-cst
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-V_BCSTRET = ls_nfe_imposto_icms-v_bcstret
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-P_ST = ls_nfe_imposto_icms-p_st
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-V_ICMSSUBSTITUTO = ls_nfe_imposto_icms-
v_icmssubstituto
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-V_ICMSSTRET = ls_nfe_imposto_icms-v_icmsstret
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-V_BCSTDEST = ls_nfe_imposto_icms-v_bcstdest
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-V_ICMSSTDEST = ls_nfe_imposto_icms-v_icmsstdest
IF ls_nfe_imposto_icms-v_bcfcpstret IS NOT INITIAL
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-SEQUENCE-V_BCFCPSTRET = ls_nfe_imposto_icms-
v_bcfcpstret
ENDIF
IF ls_nfe_imposto_icms-p_fcpstret IS NOT INITIAL
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-SEQUENCE-P_FCPSTRET = ls_nfe_imposto_icms-
p_fcpstret
ENDIF
IF ls_nfe_imposto_icms-v_fcpstret IS NOT INITIAL
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-SEQUENCE-V_FCPSTRET = ls_nfe_imposto_icms-
v_fcpstret
ENDIF
IF ls_nfe_imposto_icms-p_red_bcefet IS NOT INITIAL
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-SEQUENCE1-P_RED_BCEFET = ls_nfe_imposto_icms-
p_red_bcefet
ENDIF
IF ls_nfe_imposto_icms-v_bcefet IS NOT INITIAL
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-SEQUENCE1-V_BCEFET = ls_nfe_imposto_icms-v_bcefet
ENDIF
IF ls_nfe_imposto_icms-p_icmsefet IS NOT INITIAL
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-SEQUENCE1-P_ICMSEFET = ls_nfe_imposto_icms-
p_icmsefet
ENDIF
IF ls_nfe_imposto_icms-v_icmsefet IS NOT INITIAL
<CHOICE>-SEQUENCE-ICMS-CHOICE-ICMSST-SEQUENCE1-V_ICMSEFET = ls_nfe_imposto_icms-
v_icmsefet
ENDIF
On PRI, as that system has direct integration with ICos/NGRD and so all counterparties were created
automatically and following specific rules of filling of SAP ECC fields on Master Data, the necessary and
expected requirements by BR SAP Std NF cannot be accomplished for the “Street” information as on the
Vendor’s and Customer’s Master Data that information is mainly on ADRC- STR_SUPPL1 (“Street2”). After
many attempts to solve the BR NF-e legal requirement at NGRD to SAP PRI level (IDOC), the solution for an
ECC was requested. Due to that, after a series of analysis and tests, the following was proposed (with a
impact study submitted and approved by bp SAP Architect).
Create a New Enhancement Point at the end of the Module Funtion J_1B_NF_VENDOR_READ
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all syntax
corrections, internal objects clearing and analysis in terms of better performance and best
coding practices.
address-stras = lv_stras
address1-street = address1-str_suppl1
ENDIF
ENDIF
Create a New Enhancement Point at the end of the Module Funtion J_1B_NF_CUSTOMER_READ
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all syntax
corrections, internal objects clearing and analysis in terms of better performance and best
coding practices.
address1-street = address1-str_suppl1
ENDIF
ENDIF
Legal requirement in Brazil for Sales Fuels NF-e’s: Carrier Partner must be informed no matter the transaction is
NOT Freight relevant. The criteria for accessing that situation are:
• Billing / Transaction in NF relevant
• There is a NF Type associated and its Doc Type is ‘1-Normal’ OR ‘6-Return’
• There is NO Carrier Partner (SP) on Billing Header
(START – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
• (*) There is NO Carrier info on OTP<>PRI expected Z field for that info, or the contents
cannot be converted on an existing Counterparty SAP Vendor Master Data
• (*) There is NO Carrier info as an SAP Vendor Code on new Z Transaction/Table to support
complimentary info for NF-e, linked to the OTP/OWB Shipment Code.
(END – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
(START – 33_UAT: RITM000001897233 Changes V4.0 – 30th Oct 2023)
• There is NO info on OTP<>PRI additional Z field (“BOL #” on OWB side, ZZBOLNUM on SAP
side) for that info, or the contents cannot be converted on an existing Counterparty SAP
Vendor Master Data
(END – 33_UAT: RITM000001897233 Changes V4.0 – 30th Oct 2023)
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs (transaction
J1B1N), user must provide information on corresponding field.
Please perform a new include implementation on Billing User Exit RV60AFZD, Form
USEREXIT_NEWROLE_XVBPAK_AVBPAK.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all syntax
corrections, internal objects clearing and analysis in terms of better performance and best
coding practices.
FORM USEREXIT_NEWROLE_XVBPAK_AVBPAK.
…
**********************************************************************************
* BR Fuels Sales NF-e: Carrier for NF-e non-Freight relevant
* sales transactions (ENH010)
**********************************************************************************
* Legal requirement to have Carrier partner (SP) on Fuels Sales NF-e’s, no matter
* the transaction is non-Freight relevant. The logic below will be applied in case
* NO CARRIER partner is found on this situation
INCLUDE zsd_br_nfe_carrier.
ENDFORM.
(INCLUDE zsd_br_nfe_carrier)
IF sy-subrc IS INITIAL
* OBS: Note that if multiple SAP Vendor Master on distinct Account Groups exist for the
* same NAME4 carrier, then the first occurrence will be used
lv_carrier = ls_lfa1-lifnr
ENDIF
ENDIF
ENDIF
IF lv_carrier IS INITIAL
(END – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
* At least one item is relevant: check if Carrier was defined for the
* NFe BR Freight mode of the Incoterm on parameter table
SELECT inco1 FROM likp INTO lv_inco1
WHERE VBELN = ls_lips-vbeln
IF sy-subrc IS INITIAL AND lv_inco1 IS NOT INITIAL
SELECT modfrete FROM j_1bmodfrete_det INTO lv_modfrete
WHERE INCO1 = lv_inco1
IF sy-subrc IS INITIAL AND lv_modfrete IS NOT INITIAL
READ lt_tvarvc INTO ls_tvarvc USING
NAME = ‘ZSD_NFE_SEFAZ_362_CARRIER’
LOW = lv_modfrete
IF sy-subrc IS INITIAL AND ls_tvarvc-high NOT INITIAL
(START – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
lv_carrier = ls_tvarvc-high
ENDIF
ENDIF
ENDIF
ENDIF
(END – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
* Info about CarrierNFe Freight mode of the Incoterm on parameter table
CALL FUNCTION ‘j_1b_nf_vendor_read’
EXPORTING
(START – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
partner_id = ls_tvarvc-high
partner_id = lv_carrier
OTP<>PRI integration required changes to remove SAP stock control on 3rd Parties per ‘Special Stock’
functionality and substitute it per new segregated Plants. However, to keep all the NF requirements regarding
3rd Party information, ‘SB’ partner will be used now only in Billing document by insertion when a “3rd Party
Plant” is detected on TVARVC parameters, feeding the corresponding SAP Customer Master for it.
The following must be:
• All Plants related to OTP Locations that will support the 3rd Party Warehouse Locations must
be listed on TVARVC records for a variable name with the corresponding SAP Customer
Master code representing such WH Vendor.
• All address and Tax IDs information (with e-mail inbox to receive bpCE NF-e XML and
DANFe) must be created correctly on an SAP Customer Master (Integrated or not with
NGRD)
Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs (transaction
J1B1N), user must provide information on corresponding field.
Please perform a new segregated include implementation on Billing User Exit RV60AFZD, Form
USEREXIT_NEWROLE_XVBPAK_AVBPAK.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all syntax
corrections, internal objects clearing and analysis in terms of better performance and best
coding practices.
FORM USEREXIT_NEWROLE_XVBPAK_AVBPAK.
…
**********************************************************************************
* BR Fuels Sales NF-e: Carrier for NF-e non-Freight relevant
* sales transactions (ENH010)
**********************************************************************************
* Legal requirement to have Carrier partner (SP) on Fuels Sales NF-e’s, no matter
* the transaction is non-Freight relevant. The logic below will be applied in case
* NO CARRIER partner is found on this situation
INCLUDE zsd_br_nfe_carrier.
(START – 28_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
**********************************************************************************
* BR Fuels Sales NF-e: 3rd Party Warehouse on NF-e per ‘SB’ Special
* Stock Partner function (ENH010)
**********************************************************************************
* Legal requirement to support 3rd Party Warehouse information on Fuels
* Sales NF-e’s (XML Texts and Sending e-mail with files)
INCLUDE zsd_br_nfe_sb_partner.
(END – 28_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
ENDFORM.
(START – 28_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
(INCLUDE zsd_br_nfe_sb_partner)
…
IF lv_flag IS NOT INITIAL.
*Begin of Mod-001
CLEAR: lv_carrier.
IF vbap-zzcarrierfein IS NOT INITIAL.
SELECT SINGLE zzcarriername FROM zsd_carriertab
INTO @DATA(lv_carriername)
WHERE zzcarrierfein = @vbap-zzcarrierfein.
IF sy-subrc EQ 0 AND lv_carriername IS NOT INITIAL.
* Association between Carrier code came from OTP/OWB and a potential Counterparty
* was found on table ZSD_CARRIERTAB. Now check that “Carrier name” is a NAME4
* on any SAP Vendor Master Data (“NAME4” is the linkage information between NGRD
* and SAP Vendor/Customer Master)
READ TABLE lt_tvarvc INTO ls_tvarvc WITH KEY name = 'ZSD_NFE_SEFAZ_362_KTOKK'.
IF sy-subrc EQ 0.
SELECT SINGLE lifnr FROM lfa1 INTO @DATA(lv_lifnr)
WHERE name4 = @lv_carriername
AND loevm IS INITIAL.
AND ktokk = @ls_tvarvc-low.
IF sy-subrc EQ 0.
* OBS: Note that if multiple SAP Vendor Master on distinct Account Groups exist for the
* same NAME4 carrier, then the first occurrence will be used
lv_carrier = lv_lifnr.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
* (Additional attempt) In case OWB “BOL Carrier” field cannot be used, alternative usage
* of field “BOL #” can be performed by user manually filling Carrier Counterparty description
* (the one that unity identifies Counterparty on OTP and “Name 4” on PRI systems).
IF lv_carrier IS INITIAL.
IF vbap-zzbolnum IS NOT INITIAL.
READ TABLE lt_tvarvc INTO ls_tvarvc WITH KEY name = 'ZSD_NFE_SEFAZ_362_KTOKK'.
IF sy-subrc EQ 0.
SELECT SINGLE lifnr FROM lfa1 INTO @DATA(lv_lifnr)
WHERE name4 = @vbap-zzbolnum
AND ktokk = @ls_tvarvc-low
AND loevm IS INITIAL.
IF sy-subrc EQ 0.
* OBS: Note that if multiple SAP Vendor Master on distinct Account Groups exist for the
* same NAME4 carrier, then the first occurrence will be used
lv_carrier = lv_lifnr.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
IF lv_carrier IS INITIAL.
*End of Mod-001
…
(END – 33_UAT: RITM000001897233 Changes V4.0 – 30th Oct 2023)
As per SAP IS-OIL OSS Note “1129623 - Error 8B 552 in VF01 for differential invoice Brazil OIBX”, NF Type
for Differential Invoice is hard coded to “N2” (NF Complementar, Former Legal Model “01-Paper Form”, not “55-
NFe”), which demands usage of specific user exit “PERFORM saplj1bg_001(zzusroih_j1b)”
Scope
=> Only for Application automatic issued NF-e’s on SD module using IS-OIL. For manual
SAP NF Docs (transaction J1B1N), user must provide all information on corresponding fields.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all syntax
corrections, internal objects clearing and analysis in terms of better performance and best
coding practices.
* Check if NF Type from parameter is valid and it’s a ‘2-Complementar’ for Debit Notes
SELECT * FROM j_1baa INTO ls_j1baa WHERE
NFTYPE = ls_tvarvc-high(2)
IF sy-subrc IS INITIAL AND ls_j1baa-dctype = ‘2’
t_l_nftype = ls_j1baa-nftype
ENDIF
ENDIF
ELSE
* Total document net is less or equal to zero: CREDIT NOTE
READ lt_tvarvc INTO ls_tvarvc USING
NAME = ‘ZSD_NFE_DIFFERINV_NFTYPE_CRED’
LOW = t_wvbrk-fkart
IF sy-subrc IS INITIAL AND ls_tvarvc-high IS NOT INITIAL
* Check if NF Type from parameter is valid and it’s a ‘3-Correction’ for Debit Notes
SELECT * FROM j_1baa INTO ls_j1baa WHERE
NFTYPE = ls_tvarvc-high(2)
IF sy-subrc IS INITIAL AND ls_j1baa-dctype = ‘3’
t_l_nftype = ls_j1baa-nftype
ENDIF
ENDIF
ENDIF
ENDIF
(END – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all syntax
corrections, internal objects clearing and analysis in terms of better performance and best
coding practices.
OBS: Below is a functional logic, not a real and ready ABAP coding. So please make all syntax
corrections, internal objects clearing and analysis in terms of better performance and best
coding practices.
* SEFAZ Error 858: Tratment for Fuels NF-e on ICMS60 X ICMSST Group of tags
* As per expected by SEFAZ (not supported so far by SAP Std BR Localization),
* ICMS60 group cannot be used and must be substituted by a ICMSST one, with
* VBCSTDEST and VICMSSTDEST present and zeroed on intrastate transactions.
* Call RFC to read TVARVC from ECC side with valid ANP Codes for SEFAZ 858
CALL FUNCTION 'RFC_READ_TABLE' DESTINATION lv_rfccnx
EXPORTING
query_table = 'TVARVC'
delimiter = ';'
no_data =''
TABLES
options = lt_options
fields = lt_fields
data = lt_temp
EXCEPTIONS
table_not_available = 1
table_without_data = 2
option_not_valid =3
field_not_valid =4
not_authorized =5
data_buffer_exceeded = 6
OTHERS = 7.
IF sy-subrc EQ 0 AND lt_temp IS NOT INITIAL.
* ANP Entries from ECC found: check if ANP from NF item is valid
SORT lt_temp BY wa ASCENDING.
READ TABLE lt_temp INTO DATA(ls_temp) WITH KEY wa = ls_nfe_prod_comb-c_prod_anp.
IF sy-subrc EQ 0.
* ANP Code valid for SEFAZ 858 Error treatment of ICMS Tax Block
* First undo ICMS60 tags
CLEAR: <choice>-sequence-icms-choice-icms60-orig,
<choice>-sequence-icms-choice-icms60-cst,
<choice>-sequence-icms-choice-icms60-sequence-v_bcstret,
<choice>-sequence-icms-choice-icms60-sequence-p_st,
<choice>-sequence-icms-choice-icms60-sequence-v_icmssubstituto,
<choice>-sequence-icms-choice-icms60-sequence-v_icmsstret,
<choice>-sequence-icms-choice-icms60-sequence1-v_bcfcpstret,
<choice>-sequence-icms-choice-icms60-sequence1-p_fcpstret,
<choice>-sequence-icms-choice-icms60-sequence1-v_fcpstret,
<choice>-sequence-icms-choice-icms60-sequence2-p_red_bcefet,
<choice>-sequence-icms-choice-icms60-sequence2-v_bcefet,
<choice>-sequence-icms-choice-icms60-sequence2-p_icmsefet,
<choice>-sequence-icms-choice-icms60-sequence2-v_icmsefet.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*
(END – 44_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)
TVARVC Parameters for Legal Control of valid ANP Codes for SEFAZ 858 error treatment (on ECC
Client)
Selection Field
Variable Name type Number INCL/EXCL Option Field Value Value CHAR01 data element for SYST
ZSD_XNFE_ANP_SEFAZ_858 S 0 I EQ 210203001
ZSD_XNFE_ANP_SEFAZ_858 S 1 I EQ 320101001
ZSD_XNFE_ANP_SEFAZ_858 S 2 I EQ 320101002
ZSD_XNFE_ANP_SEFAZ_858 S 3 I EQ 320102002
ZSD_XNFE_ANP_SEFAZ_858 S 4 I EQ 320102001
ZSD_XNFE_ANP_SEFAZ_858 S 5 I EQ 320102003
ZSD_XNFE_ANP_SEFAZ_858 S 6 I EQ 320102005
ZSD_XNFE_ANP_SEFAZ_858 S 7 I EQ 320201001
ZSD_XNFE_ANP_SEFAZ_858 S 8 I EQ 320103001
ZSD_XNFE_ANP_SEFAZ_858 S 9 I EQ 220102001
ZSD_XNFE_ANP_SEFAZ_858 S 10 I EQ 320301001
ZSD_XNFE_ANP_SEFAZ_858 S 11 I EQ 320103002
ZSD_XNFE_ANP_SEFAZ_858 S 12 I EQ 820101032
ZSD_XNFE_ANP_SEFAZ_858 S 13 I EQ 820101026
ZSD_XNFE_ANP_SEFAZ_858 S 14 I EQ 820101027
ZSD_XNFE_ANP_SEFAZ_858 S 15 I EQ 820101004
ZSD_XNFE_ANP_SEFAZ_858 S 16 I EQ 820101005
ZSD_XNFE_ANP_SEFAZ_858 S 17 I EQ 820101022
ZSD_XNFE_ANP_SEFAZ_858 S 18 I EQ 820101031
ZSD_XNFE_ANP_SEFAZ_858 S 19 I EQ 820101030
ZSD_XNFE_ANP_SEFAZ_858 S 20 I EQ 820101014
ZSD_XNFE_ANP_SEFAZ_858 S 21 I EQ 820101006
ZSD_XNFE_ANP_SEFAZ_858 S 22 I EQ 820101015
ZSD_XNFE_ANP_SEFAZ_858 S 23 I EQ 820101025
ZSD_XNFE_ANP_SEFAZ_858 S 24 I EQ 820101017
ZSD_XNFE_ANP_SEFAZ_858 S 25 I EQ 820101018
ZSD_XNFE_ANP_SEFAZ_858 S 26 I EQ 820101019
ZSD_XNFE_ANP_SEFAZ_858 S 27 I EQ 820101020
ZSD_XNFE_ANP_SEFAZ_858 S 28 I EQ 820101021
ZSD_XNFE_ANP_SEFAZ_858 S 29 I EQ 420105001
ZSD_XNFE_ANP_SEFAZ_858 S 30 I EQ 420101005
ZSD_XNFE_ANP_SEFAZ_858 S 31 I EQ 420101004
ZSD_XNFE_ANP_SEFAZ_858 S 32 I EQ 420102005
ZSD_XNFE_ANP_SEFAZ_858 S 33 I EQ 420102004
ZSD_XNFE_ANP_SEFAZ_858 S 34 I EQ 420104001
ZSD_XNFE_ANP_SEFAZ_858 S 35 I EQ 820101033
ZSD_XNFE_ANP_SEFAZ_858 S 36 I EQ 820101034
ZSD_XNFE_ANP_SEFAZ_858 S 37 I EQ 420106001
ZSD_XNFE_ANP_SEFAZ_858 S 38 I EQ 820101011
ZSD_XNFE_ANP_SEFAZ_858 S 39 I EQ 820101003
ZSD_XNFE_ANP_SEFAZ_858 S 40 I EQ 820101013
ZSD_XNFE_ANP_SEFAZ_858 S 41 I EQ 820101012
ZSD_XNFE_ANP_SEFAZ_858 S 42 I EQ 420106002
ZSD_XNFE_ANP_SEFAZ_858 S 43 I EQ 830101001
ZSD_XNFE_ANP_SEFAZ_858 S 44 I EQ 420301004
ZSD_XNFE_ANP_SEFAZ_858 S 45 I EQ 420202001
ZSD_XNFE_ANP_SEFAZ_858 S 46 I EQ 420301001
ZSD_XNFE_ANP_SEFAZ_858 S 47 I EQ 420301002
ZSD_XNFE_ANP_SEFAZ_858 S 48 I EQ 410103001
ZSD_XNFE_ANP_SEFAZ_858 S 49 I EQ 410101001
ZSD_XNFE_ANP_SEFAZ_858 S 50 I EQ 410102001
ZSD_XNFE_ANP_SEFAZ_858 S 51 I EQ 430101004
ZSD_XNFE_ANP_SEFAZ_858 S 52 I EQ 510101001
ZSD_XNFE_ANP_SEFAZ_858 S 53 I EQ 510101002
ZSD_XNFE_ANP_SEFAZ_858 S 54 I EQ 510102001
ZSD_XNFE_ANP_SEFAZ_858 S 55 I EQ 510102002
ZSD_XNFE_ANP_SEFAZ_858 S 56 I EQ 510201001
ZSD_XNFE_ANP_SEFAZ_858 S 57 I EQ 510201003
ZSD_XNFE_ANP_SEFAZ_858 S 58 I EQ 510301003
ZSD_XNFE_ANP_SEFAZ_858 S 59 I EQ 510103001
ZSD_XNFE_ANP_SEFAZ_858 S 60 I EQ 510301001
ZSD_XNFE_ANP_SEFAZ_858 S 61 I EQ 820101016
TVARVC Parameters for Legal Control of valid ANP Codes for SEFAZ 362 error treatment (on ECC
Client)
Variable Name Selection type Number INCL/EXCL Option Field Value Field Value CHAR01 data element for SYST
ZSD_NFE_SEFAZ_362_ANP S 0 I EQ 210101001
ZSD_NFE_SEFAZ_362_ANP S 1 I EQ 210201001
ZSD_NFE_SEFAZ_362_ANP S 2 I EQ 210201002
ZSD_NFE_SEFAZ_362_ANP S 3 I EQ 210201003
ZSD_NFE_SEFAZ_362_ANP S 4 I EQ 210202001
ZSD_NFE_SEFAZ_362_ANP S 5 I EQ 210202002
ZSD_NFE_SEFAZ_362_ANP S 6 I EQ 210202003
ZSD_NFE_SEFAZ_362_ANP S 7 I EQ 210203001
ZSD_NFE_SEFAZ_362_ANP S 8 I EQ 210203002
ZSD_NFE_SEFAZ_362_ANP S 9 I EQ 210204001
ZSD_NFE_SEFAZ_362_ANP S 10 I EQ 210204002
ZSD_NFE_SEFAZ_362_ANP S 11 I EQ 210301001
ZSD_NFE_SEFAZ_362_ANP S 12 I EQ 210301002
ZSD_NFE_SEFAZ_362_ANP S 13 I EQ 210302001
ZSD_NFE_SEFAZ_362_ANP S 14 I EQ 210302002
ZSD_NFE_SEFAZ_362_ANP S 15 I EQ 210302003
ZSD_NFE_SEFAZ_362_ANP S 16 I EQ 210302004
ZSD_NFE_SEFAZ_362_ANP S 17 I EQ 220101001
ZSD_NFE_SEFAZ_362_ANP S 18 I EQ 220101002
ZSD_NFE_SEFAZ_362_ANP S 19 I EQ 220101003
ZSD_NFE_SEFAZ_362_ANP S 20 I EQ 220101004
ZSD_NFE_SEFAZ_362_ANP S 21 I EQ 220101005
ZSD_NFE_SEFAZ_362_ANP S 22 I EQ 220101006
ZSD_NFE_SEFAZ_362_ANP S 23 I EQ 220102001
ZSD_NFE_SEFAZ_362_ANP S 24 I EQ 220102002
ZSD_NFE_SEFAZ_362_ANP S 25 I EQ 320101001
ZSD_NFE_SEFAZ_362_ANP S 26 I EQ 320101002
ZSD_NFE_SEFAZ_362_ANP S 27 I EQ 320101003
ZSD_NFE_SEFAZ_362_ANP S 28 I EQ 320102001
ZSD_NFE_SEFAZ_362_ANP S 29 I EQ 320102002
ZSD_NFE_SEFAZ_362_ANP S 30 I EQ 320102003
ZSD_NFE_SEFAZ_362_ANP S 31 I EQ 320102004
ZSD_NFE_SEFAZ_362_ANP S 32 I EQ 320103001
ZSD_NFE_SEFAZ_362_ANP S 33 I EQ 320103002
ZSD_NFE_SEFAZ_362_ANP S 34 I EQ 320201001
ZSD_NFE_SEFAZ_362_ANP S 35 I EQ 320201002
ZSD_NFE_SEFAZ_362_ANP S 36 I EQ 320301001
ZSD_NFE_SEFAZ_362_ANP S 37 I EQ 320301002
ZSD_NFE_SEFAZ_362_ANP S 38 I EQ 410101001
ZSD_NFE_SEFAZ_362_ANP S 39 I EQ 410101002
ZSD_NFE_SEFAZ_362_ANP S 40 I EQ 410102001
ZSD_NFE_SEFAZ_362_ANP S 41 I EQ 410102002
ZSD_NFE_SEFAZ_362_ANP S 42 I EQ 410103001
ZSD_NFE_SEFAZ_362_ANP S 43 I EQ 420101003
ZSD_NFE_SEFAZ_362_ANP S 44 I EQ 420101004
ZSD_NFE_SEFAZ_362_ANP S 45 I EQ 420101005
ZSD_NFE_SEFAZ_362_ANP S 46 I EQ 420102003
ZSD_NFE_SEFAZ_362_ANP S 47 I EQ 420102004
ZSD_NFE_SEFAZ_362_ANP S 48 I EQ 420102005
ZSD_NFE_SEFAZ_362_ANP S 49 I EQ 420102006
ZSD_NFE_SEFAZ_362_ANP S 50 I EQ 420104001
ZSD_NFE_SEFAZ_362_ANP S 51 I EQ 420105001
ZSD_NFE_SEFAZ_362_ANP S 52 I EQ 420201001
ZSD_NFE_SEFAZ_362_ANP S 53 I EQ 420201002
ZSD_NFE_SEFAZ_362_ANP S 54 I EQ 420201003
ZSD_NFE_SEFAZ_362_ANP S 55 I EQ 420202001
ZSD_NFE_SEFAZ_362_ANP S 56 I EQ 420301001
ZSD_NFE_SEFAZ_362_ANP S 57 I EQ 420301002
ZSD_NFE_SEFAZ_362_ANP S 58 I EQ 420301003
ZSD_NFE_SEFAZ_362_ANP S 59 I EQ 510101001
ZSD_NFE_SEFAZ_362_ANP S 60 I EQ 510101002
ZSD_NFE_SEFAZ_362_ANP S 61 I EQ 510101003
ZSD_NFE_SEFAZ_362_ANP S 62 I EQ 510102001
ZSD_NFE_SEFAZ_362_ANP S 63 I EQ 510102002
ZSD_NFE_SEFAZ_362_ANP S 64 I EQ 510102003
ZSD_NFE_SEFAZ_362_ANP S 65 I EQ 510201001
ZSD_NFE_SEFAZ_362_ANP S 66 I EQ 510201002
ZSD_NFE_SEFAZ_362_ANP S 67 I EQ 510201003
ZSD_NFE_SEFAZ_362_ANP S 68 I EQ 510301001
ZSD_NFE_SEFAZ_362_ANP S 69 I EQ 510301002
ZSD_NFE_SEFAZ_362_ANP S 70 I EQ 510301003
ZSD_NFE_SEFAZ_362_ANP S 71 I EQ 540101001
ZSD_NFE_SEFAZ_362_ANP S 72 I EQ 540101002
ZSD_NFE_SEFAZ_362_ANP S 73 I EQ 810101001
ZSD_NFE_SEFAZ_362_ANP S 74 I EQ 810101002
ZSD_NFE_SEFAZ_362_ANP S 75 I EQ 810101003
ZSD_NFE_SEFAZ_362_ANP S 76 I EQ 810102001
ZSD_NFE_SEFAZ_362_ANP S 77 I EQ 810102002
ZSD_NFE_SEFAZ_362_ANP S 78 I EQ 810102003
ZSD_NFE_SEFAZ_362_ANP S 79 I EQ 810102004
ZSD_NFE_SEFAZ_362_ANP S 80 I EQ 810201001
ZSD_NFE_SEFAZ_362_ANP S 81 I EQ 810201002
ZSD_NFE_SEFAZ_362_ANP S 82 I EQ 820101001
ZSD_NFE_SEFAZ_362_ANP S 83 I EQ 820101002
ZSD_NFE_SEFAZ_362_ANP S 84 I EQ 820101003
ZSD_NFE_SEFAZ_362_ANP S 85 I EQ 820101004
ZSD_NFE_SEFAZ_362_ANP S 86 I EQ 820101005
ZSD_NFE_SEFAZ_362_ANP S 87 I EQ 820101006
ZSD_NFE_SEFAZ_362_ANP S 88 I EQ 820101007
ZSD_NFE_SEFAZ_362_ANP S 89 I EQ 820101008
ZSD_NFE_SEFAZ_362_ANP S 90 I EQ 820101009
ZSD_NFE_SEFAZ_362_ANP S 91 I EQ 820101010
ZSD_NFE_SEFAZ_362_ANP S 92 I EQ 820101011
ZSD_NFE_SEFAZ_362_ANP S 93 I EQ 820101012
ZSD_NFE_SEFAZ_362_ANP S 94 I EQ 820101013
ZSD_NFE_SEFAZ_362_ANP S 95 I EQ 820101014
ZSD_NFE_SEFAZ_362_ANP S 96 I EQ 820101015
ZSD_NFE_SEFAZ_362_ANP S 97 I EQ 820101016
ZSD_NFE_SEFAZ_362_ANP S 98 I EQ 820101017
ZSD_NFE_SEFAZ_362_ANP S 99 I EQ 820101018
ZSD_NFE_SEFAZ_362_CARRIER S 0 I BT 0
ZSD_NFE_SEFAZ_362_CARRIER S 1 I BT 1
ZSD_NFE_SEFAZ_362_CARRIER S 2 I BT 2
ZSD_NFE_SEFAZ_362_CARRIER S 3 I BT 3
ZSD_NFE_SEFAZ_362_CARRIER S 4 I BT 4
(May 2024 – This MODFRETE is not
acceptable by SEFAZ on Fuel SALES.
So, no matter feeding a carrier or not,
ZSD_NFE_SEFAZ_362_CARRIER S 5 I BT 9 202402 SEFAZ return error code (362 or 825)
ZSD_NFE_SEFAZ_362_CFOP S 0 I EQ 5655
ZSD_NFE_SEFAZ_362_CFOP S 1 I EQ 1661
ZSD_NFE_SEFAZ_362_CFOP S 2 I EQ 6655
Variable Name Selection type Number INCL/EXCL Option Field Value Field Value CHAR01 data element for SYST
ZXNFE_ENH010_SEFAZ_858_RFC_CNX S 0 I BT PDI
ZXNFE_ENH010_SEFAZ_858_RFC_CNX S 3 I BT PSI
TVARVC Parameters for ‘Street’ information from “Street2” or standard “Street” depending on
Counterparty be handled by ICos/NGRD or not (on ECC Client)
Variable Name Selection type Number INCL/EXCL Option Field Value Field Value CHAR01 data element for SYST
ZMM_NFE_VEND_ADDR_ICOS_ACCTGRP S 0 I EQ ZI01
ZMM_NFE_VEND_ADDR_ICOS_ACCTGRP S 1 I EQ ZI04
ZSD_NFE_CUST_ADDR_ICOS_ACCTGRP S 0 I EQ ZI01
ZSD_NFE_CUST_ADDR_ICOS_ACCTGRP S 1 I EQ ZI04
ZSD_BR_ENH011_DIFFINV_PSTYV S I BT ZTBW K(
ZSD_BR_ENH011_DIFFINV_VKORG S I EQ 5204
ZSD_NFE_DIFFERINV_NFTYPE_CRED S I BT Z1 Z3
ZSD_NFE_DIFFERINV_NFTYPE_DEBI S I BT Z1 Z2
N/A
Testing documents will be uploaded in Team’s folder below after unit Test.
Unit Testing Evidence – under BR0M
21 APPENDIX
21.1[16.4] SEFAZ Technical Notes
“NT2020.005 - 1.21 New validation rules Technical Note 2020.005 Oct 28th,
Regras de (version 1.21 of Oct 28th , 2021
Validação” 2021) is mandatory and was
considered required by bp.
SAP has already released the
solution for NT legal version
1.21.
“NT2020.006 - 1.30 New validation rules for Marketplace and others: This Technical Note is related Jun 09th,
Intermediador Transaction intermediator to new fiscal requirements. 2021
e Marketplace” Tax Team considered as
required by bp. SAP has
released solution for NT legal
version 1.20.
• Action pending: to
confirm with bp
Finance if codes
related to Fat-e
apply (antecipação
de recebíveis)
“NT2020.007 - 1.10 New Nfe event “Ator Interessado na NF-e”: Carrier As from discussed during (N/A)
Evento_Ator 1.30 March 23rd and 24th 2020, in
Nfe SAP PRI the Technical Notes
Transportador” 2020.007 (version 1.10),
2021.001 (version 1.00) were
considered as non-mandatory
and on hold:
• For TN 2020.007,
no SAP solution
yet planned for
ECC/S4 so far (17th
Jan, 2024) on Legal
Change
Notification do SAP
ONE Support
Launchpad.
“NT2021.001 - 1.00 New Nfe event “Comprovante de Entrega” da NF-e As from discussed during (N/A)
Evento March 23rd and 24th this year,
Comprovante in SAP PRI the Technical
Entrega Nfe” Notes 2020.007 (version 1.10),
2021.001 (version 1.00) were
considered as non-mandatory
and on hold:
• For TN 2021.001,
no formal SAP
solution yet
planned so far
(Aug 26th) on Legal
Change
Notification do SAP
ONE Support
Launchpad.
“NT2021.002 – 1.10 Adaptations for “Nota Fiscal Fácil” (“Easy NF”) As from discussed during (N/A)
Nota Fiscal BR02 Workshop on November
Fácil” 22nd, 2021, this is not relevant
to bp PRI (no “Nota Fiscal
Fácil”)
“NT2021.003 – 1.00 New validation rules for cEAN e cEANTrib na NF- As from discussed during BR02 (N/A)
Regras de Workshop on November 22nd,
validação 2021, this is not relevant to bp
cEAN PRI (no products with EAN code)
“NT2021.004 – 1.30 New validation rules for Carrier area, new fields for FCP- Included in Scope by approved Apr 15th,
Regras de ST Change Request #6 2022
validação e
Novos Campos
“NT2023.001 – 1.20 New fields and Technical Note 2023.001 (initial version 1.00 on Mar 13th, Apr 11th 2023
ICMS Monofásico validation rules 2023) is mandatory and was considered required by
para bp. SAP will progressively release the solution for IS-OIL
Combustíveis” (TAXBRJ), SLL-NFE and ECC (TAXBRA, just for non-IS-
OIL installations).
“NT2019.001 – 1.61 New fields and Technical Note 2019.001 (initial version 1.00 on Mar 13th, Apr 1st 2024
ICMS Monofásico validation rules 2023) is mandatory and was considered required by
para bp. May affected info is the RJ “Benefit Code”
Combustíveis”