0% found this document useful (0 votes)
106 views245 pages

14 TH Aug

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

14 TH Aug

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

Trading and Shipping

Logistics

Functional Design Document


Enhancements for NF-e (Brazil)

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

Version Date Comment By Approved


Initial version
OBS: Created from previous last reviewed / approved version
in 27th Mar 2021 (“DEL22-New Sale and Purchase Processes
for Brazil – Consolidated”) for Single Ledger Project (SLP)
rollout for Brazil, that was postponed to be included on this
new BR Trading Migration scope.

Changes / Additional scope for BR Trading


Migration Project:
 Migration of functionalities from former
CL_NFE_PRINT BADI to SAP recommended BADI Mauricio
1.0 08th Feb 2022 J_1BNF_ADD_DATA since NF-e Layout 3.10 and Tanniguchi
do not migrate from PRC SAP Standard logic
intervention to keep CL_NFE_PRINT working.
 Include Partner ‘SB’ (Withdrawal Location /
External Warehouse) as additional one to send
XML and DANFe files automatically on fuels
scenario.
 Include new requirements related to CIDE Tax
(XML Tags and Text), FCP / FCP-ST Texts, ICMS
“Repasse” Text, ANP Code Text.
 Include appendix for SAP OSS Notes
Implemented.
Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Version Date Comment By Approved


2.0 Adjusts due to the following:
• (01_CT1) ADO Bug 3247450: Just documenting
procedure to bp QA Client opening for manual adjust
of BR Branches configuration related to “Type of
Environment” due to bp definitions (NO CODE
CHANGES);
• (02_CT1) ADO Bug 3257728: Adjusts related to
Payment Tag error and also the adoption of new
SAP Table J_1BPAG provided by SAP OSS Notes Mauricio
18th May 2022 for SEFAZ 2020.006; Tanniguchi
• (03_CT1) Payment Tag duplication error due to
navigation on MIRO transaction (changing NF Type).
Also, include same logic on J1B1N. Method
• (04_CT1) Tags CEAN and CEANTRIB will be feed
with “SEM GTIN” string in case blank on J1B1N.
• (05_CT1) Tag nDUP specified with incorrect number
of algarisms: must be max 3. Also “Grupo Fatura”
tags were missed: logic added.

• (06_CT1) Correct original specification for "Local de


Mauricio
14th Jun 2022 Entrega" and "Local de Retirada" text block
composition, both on BADI_REQUIREMENT 05. Tanniguchi

29th Jun 2022 Changes / Additional scope for BR Trading Mauricio


Migration Project UAT: Tanniguchi
• (07_UAT) ADO BUG 3416069 - BADI Requirement
05: Moving Texts to field “InfCpl” on header as
expected by new SAP modelling – including J1B1N
(use “Additional Information” tab and Free text for
Company). New BADI Requirements 19 and 20 to
be implemented;
• (08_UAT) Error on implemented coding – BADI
Requirement 05:
ZSD_NFE_CMPLINF_HDTX_EMAIL - E-mail from
NF Partner Master Data with TVARVC defined
stamp is being captured with other non-relevant e-
mail addresses incorrectly;
• (09_UAT) BADI Requirement 08: For both
Automatic and J1B1N methods of BADI ADD_DATA,
use as NF “Data / Hora Saída” a calculation based
on the Time Zone of the issuance Business Place to
avoid problems in case system or user Time Zones
are not the one related to the expected by Tax
authority;
• (10_UAT) ADO BUG 3416048 - Correct DANFe
Print Program / Form to get “Dados Adicionais” text
from new es_header-infcpl string;
• (11_UAT) To avoid some conflicts between former
BADI CL_NFE_PRINT and the new
J_1BNF_ADD_DATA (Method ADD_DATA_J1B1N)
– as both are executed on NF Writer – former BADI
Implementation ZFIL_ENH_NFE_APPRV will be
deactivated and code commented.
• (12_ITC) Adjust “ICMS Repasse” text composition
due to adjusts on Tax Type mapping from Pricing to
NF.

Version 21.0 152908-0562-20232 Page 2 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Version Date Comment By Approved


Changes / Additional scope for BR Trading
Migration Project UAT:
• (13_UAT) ADO BUG 3533110 - BADI Requirement
09: As per NF-e rule, Complementary NF and
Returns Inbound NF-e must not have any Payment
information (on both “Payment Method” and Mauricio
25th Jul 2022 Installments). Installments are being placed anyway
and must be checked according to NF type; Tanniguchi
• (14_UAT) ADO BUG 3540031 - BADI Requirement
21 (New) and BADI Requirements 05 and 20
(adjusts): Z Text variables substitution. Initial usage
for legal requirement to Referenced NF-e text
(Number, Series, Issuance Date) on Nota Fiscal
Complementar;

Changes / Additional scope for BR Trading


Migration Project UAT:
• (15_UAT) Change Request 16 – BR Legal Mauricio
17th Aug 2022 Requirement for having 0 quantity on “NF Tanniguchi
Complementar”, no matter price or tax complement;
• (16_UAT) BUG 3640995 – Payment Method ‘99’
mandatory xPAG tag filling (NT 2020.006;

Changes / Additional scope for BR Trading


Migration Project UAT:
Mauricio
22nd Aug 2022 • (17_UAT) Change Request 14 – bpCE Central e- Tanniguchi
mail Inbox to receive approved NF-e XML and
DANFe files;

Changes / Additional scope for BR Trading


Migration Project UAT:
262nd Aug
• (17_UAT) Change Request 14 – bpCE Central e- Erica Vieira
2022 mail Inbox to receive approved NF-e XML and
DANFe filAdd the information about PI shared
between 3 SLL-Nfe environmentses;

Version 21.0 152908-0562-20232 Page 3 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Version Date Comment By Approved


3.0 15th Oct 2022 RITM000001588724 - Adjusts for GM RPTA UAT Mauricio
after GM GPTA and FCC go-live: Tanniguchi
• (18_UAT) ICMS Repasse Adjusts
o (BADI_REQUIREMENT_17) CST ‘60’ (2
CHAR) not read correctly from TAXSIT (1
CHAR).
o (BADI_REQUIREMENT_17) Correct
reading of conditions for “ICMS Repasse”
to corresponding NF Item fields.
o (BADI_REQUIREMENT_18) Change
capture values for “ICMS Repasse” Text
from Tax Type (removed) to conditions.
Correct reading of it_nflin to et_nflin to
check vbcstret not zero
• (19_UAT) DANFe form Adjust: Read Truck and
Trailer(s) info – if exist – from SAP NF Doc fields on
database and not anymore from Sales Order text
(already read to feed those fields).
• (20_UAT) Adjusts due to “Street2” for ICos/NGRD
Counterparties
o (DANFe) Change way to read partners
address from standard functionality to
specific SAP BR Localization one to be
prepared for bp specific assignment of
information for “Street” and “Street2”
differently for ICos/NGRD Counterparties.
o (BADI_REQUIREMENT_05) Correct
coding on composition of “LOCAL DE
ENTREGA” and “LOCAL DE RETIRADA”
texts: ls_partner-name1 and ls_partner-
stras are double referenced.
• (21_UAT) CREATION OF DOCUMENT NEW
SECTIONS for “Other Enhancements on SAP ECC
& SLL-NFE” to accomplish NFe legal requirements
while following PRI bp Template rules or bpCE
specific legal requirements not supported by SAP:
o (ENHANCEMENT_REQUIREMENT_01)
SEFAZ ERROR 858 for ICMS Repasse 60
requirement to have tag group ICMSST
instead onf ICM60 under ICMS Group on
NFe- XML.
o (ENHANCEMENT_REQUIREMENT_02)
Accomplish bpCE Counterparties from
ICos/NGRD with street info for NFe
coming mainly from address “Street2” for
Vendor’s and Customer’s master Data.
o (ENHANCEMENT_REQUIREMENT_03)
As Carrier (SP) Partner is mandatory for
all Fuels NF-e's (Freight relevant or not –
SEFAZ ERROR 362), then NF-e is
generated w/o a SP Partner, one from
Parameter table will be assigned to avoid
rejection. Consider also NF Doc Type ‘6-
Return’ beyond the ‘1-Normal’ one.
• (22_UAT) Defect ADO 3967313
o (DANFe FORM) Re-map Info related to
Packages Type, Model, Qty and Weights.
o (BADI_REQUIREMENT_21) Rename
topic to BADI_REQUIREMENT_99 as it
MUST be the last piece of logic on the
entire method as its aim is to substitute
variables (also in future cases) on final text
blocks of Header (infcpl) and items
(infadprod). In case necessary, move logic
block to the end of Method.
o (BADI_REQUIREMENT_19) New
subtopics for manually created NFe’s
(J1B1N) to automatically assembly
HEADER Texts for Total ICMSST, FCPST
and FCP Taxes. Implemented parameter
control of scope and sequence of texts.
o NEW (BADI_REQUIREMENT_23 and

Version 21.0 152908-0562-20232 Page 4 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Version Date Comment By Approved


BADI_REQUIREMENT_24) New topics
for MM automatic and J1B1N Manually
created NFe’s to automatically assembly
ITEM Texts for Total ICMS FCPST and
FCP Taxes. Implemented parameter
control of scope and sequence of texts.
• (24_UAT) Defect ADO 4041632
o (DANFe FORM) Review ‘Modfrete’ field to
include the current 6 legal values defined
by Tax Authority (in fact, read direct from
SAP NF Document).
o (DANFe FORM) Review ‘District’ and ‘City’
for Foreign Counterparties obeying rule as
per defined for XML file (usage of
‘EXTERIOR’)
o (BADI_REQUIREMENT_10) Generation
of record on TRANSVOL table not being
performed for SD automatic NFs with
Delivery (GM RPTA)
• (25_UAT) BR Tax Team requested adjusts
o (BADI_REQUIREMENT_19) Change
ICMS-ST on MM from “retido na fonte” to
“pago”.
o (BADI_REQUIREMENT_18) Change
‘ICMS Repasse’ fixed part of the text as
per requested by BR Tax Team.
o (BADI_REQUIREMENT_18) Include new
CIDE Tax text item.

INC000002760005 – Remove fixed sender based


on batch user and define bpCE central e-mail
address as sender of all E-mails with NF-e files to
Counterparties
• (23_ELS) Define already existing parameter for
bpCE central e-mail inbox also as “Sender” address
of all e-mails with NF-e files dispatched to
Counterparties;

Version 21.0 152908-0562-20232 Page 5 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Version Date Comment By Approved


RITM000001897233INC00000XXXXXXX – BRD
Diesel Distribution and Rio de Janeiro OfficeBR
Tax Team requested additional mandatory
requirement for Fuels NF-e Project
• (26_RTMINC) New BADI_REQUIREMENT_2516 -
Fill tag ‘qTemp’ NF-e tag when room temperature is
different from the reference Temperature used to
close Deal and Invoice it. Actual quantity must be
provided by physical location measurement and
noted.
• (27_RTM) Change
ENHANCEMENT_REQUIREMENT_03 –
Include logic for new requirement to try to read
“Carrier” info (ZZ field on Order Item) that can come
from OTP/OWB side and, if exists, “translate” it to a
SAP Vendor Master code (Counterparty code) and
then insert ‘SP’ Partner Function (‘Forward Agent’ –
‘CR’ in EN) - in case no ‘SP’ header value already
1508th May exists. Mauricio
4.0
Dec 20232 • (28_RTM) New Tanniguchi
ENHANCEMENT_REQUIREMENT_04 –
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.
• (29_RTM) New BADI_REQUIREMENT_26 - Fill
new list of tags related to ICMS Monophasic
(“ADREM”) as per the rules set by SEFAZ on
NT2023.001.
• (30_RTM) Change BADI_REQUIREMENT_05 –
Include new Text Block ZB05 treatment for
Acquisition (Import or Purchasing) NF-e reference
text (Supplier details and its NF-e info) on Shipment
to Warehouse NF-e’s to External Warehouses.

Changes / Additional scope for BR Diesel


Distribution Project UAT (RITM000001897233):
• (31_UAT) Defect ADO 5635479
o (BADI_REQUIREMENT_05) Review
‘Pedido’ Text source for SD documents to
be from VBRK-BSTNK_VF and not from
2508th Sep J_1BNFLIN-XPED (shorter length), that is Mauricio
4.0
Dec 20232 causing the truncation. Tanniguchi
• (32_UAT) Defect ADO 5624108
o (BADI_REQUIREMENT_05) Change text
ZB05 treatment (for acquisition NF-e
reference text) for Shipment to Warehouse
to include description about the “type” of
referenced NF-e (Purchasing, Import,
Returns, Refusal, etc).

Version 21.0 152908-0562-20232 Page 6 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Version Date Comment By Approved


RITM000001897233INC00000XXXXXXX – BRD
Diesel Distribution and Rio de Janeiro OfficeBR
Tax Team requested additional mandatory
requirement for Fuels NF-e Project
• (33_UAT) Defect ADO 5746458 - to be possible to
issue a NF-e on BRD go-live, user should select the
“BOL Carrier” by selection list, copy the string
(counterparty name) to “BOL #” field and clean the
3008th Oct Dec “BOL Carrier” contents (image below). On SAP the Mauricio
4.0 field ZZBOLCARRIER will be replicated on
20232 corresponding Deal Order item. The current Tanniguchi
ENHANCEMENT_REQUIREMENT_03 solution to
handle carrier for NF-e will be enhanced to consider
field ZZBOLCARRIER with potential source to find
the SAP Counterparty Master Data (using NAME4
field). If found, assign the “Forward Agent” Partner
Function with the found Counterparty code:
otherwise (not successful), follow with current
original logic based on ZZCARRIERFEIN filed.

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).

Version 21.0 152908-0562-20232 Page 7 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Version Date Comment By Approved


RITM000002474916INC00000XXXXXXX – BRD
Diesel Distribution BR Tax Team requested
additional mandatory requirement for Fuels NF-
eProject
• (36_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 New
ENHANCEMENT_REQUIREMENT_05 –
Overwrite ‘N2’ SAP Standard hard coded
NF Type for Differential Invoice (IS-OIL)
with correct NF Type based on parameters
(TVARVC) based on the Differential Billing
NETWR (Net) value on header (for DEBIT
or CREDIT mapping scenario).
2408th May o Change BADI_REQUIREMENT_26 – As Mauricio
4.0 “NF Complementar” has its quantity info
Dec 20242 Tanniguchi
“zeroed” as per previous BR Tax Team
requirement (implemented on previous
GM GPTA Project), then the ICMS
Monophasic calculation (CST ‘61’) should
use the Billing Item quantity in this case,
instead of the NF-e item quantity.
o Change
ENHANCEMENT_REQUIREMENT_03 –
Do not fill Carrier Partner Function (’SP’)
for Differential Invoice.

• (37_CR) CR#13 – Technical error “Error in BADI


Implementation: Table ET_FUELORIGIN has entries
with duplicate keys”, when Billing a Diesel B 2C
without ZB05 Text informed (but required, by
agreed procedure with Business).
o Change BADI_REQUIREMENT_26 –
Error on functional logic when treating
quantity of “Fuel Origin” lines to be
created, due to new incorrect dependency
on CR#13 new variable.

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

Version 21.0 152908-0562-20232 Page 8 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Version Date Comment By Approved


RITM000002278935INC00000XXXXXXX – BRio
Rio de Janeiro Office BR Tax Team requested
additional mandatory requirement for Fuels NF-
eProject
• (39_ITC) BUG 6853092 - Due to SEFAZ Error 225
when having a space character on the very
beginning of NFe header text block “Dados
Adicionais” (Additional Data), removing the current
and potential points where this can happen.
14th Jun08 Dec o Change BADI_REQUIREMENT_18 – Mauricio
4.0
20242 Adjust fixed text block to remove potential Tanniguchi
blank spaces on the main “Dados
Adicionais” NFe field (FCP and FCP ST)
o Change BADI_REQUIREMENT_23 –
Adjust fixed text block to remove potential
blank spaces on the main “Dados
Adicionais” NFe field (FCP and FCP ST)
o Change BADI_REQUIREMENT_24 –
Adjust fixed text block to remove potential
blank spaces on the main “Dados
Adicionais” NFe field (FCP and FCP ST)

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

RITM000002278935INC00000XXXXXXX – BRio Rio


de Janeiro Office BR Tax Team requested
additional mandatory requirement for Fuels NF-
21st Jun08 Dec
4.0 eProject Erica Vieira
20242
• (Only information, no development) - SLL-NFE &
SAP PO: including Rio de Janeiro Business Place
CNPJ info on main SLL-NFE parameters

Version 21.0 152908-0562-20232 Page 9 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Version Date Comment By Approved


RITM000002278935INC00000XXXXXXX – BRio
Rio de Janeiro Office BR Tax Team requested
additional mandatory requirement for Fuels NF-
eProject
• (42_UAT) BUG 6987260 – On DANFE, the ICMS
amount is totalizing both ICMS and FCP: as per Mauricio
4.0 08th Jul 2024 reported by bpCE Tax Team, only ICMS value must
be shown on DANFe “Valor do ICMS”:
Tanniguchi
o Change DANFe Print Program – Adjust
#vlicmsnota with new logic to correctly
summarize ICMS Tax Value from all NF
Items, without taking into consideration
certain Tax Types (currently just FCP
ones).

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

Version Date Comment Reviewed by


12.0
3.0
4.0

Distribution

Version Date

Version 21.0 152908-0562-20232 Page 10 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Sign Off Signatories:


Sign off Date Who
PLA Faisal Khan
Project SPA

1 BUSINESS SCOPE..................................................................................................... 15
1.1 Business Requirements........................................................................................................................................16

1.2 Benefits..................................................................................................................................................................19

1.3 Assumptions..........................................................................................................................................................19

1.4 Dependencies / Constraints..................................................................................................................................19

2 FUNCTIONAL DESIGN – NFE BADI..........................................................................21


2.1 As-Is Process – NFe BADI:..................................................................................................................................21

2.2 To-Be process – NFe BADI:.................................................................................................................................21

2.3 Security – NFe BADI............................................................................................................................................21

3 TECHNICAL DESIGN – NFE BADI.............................................................................22


3.1 BADI Requirement 01: Indication of NF-e issuance on Test environment....................................................22

3.2 BADI Requirement 02: Country Code...............................................................................................................24

3.3 BADI Requirement 03: Shipment tags...............................................................................................................24

3.4 BADI Requirement 04: Sales order / Billing / Purchase Order information..................................................25

3.5 BADI Requirement 05: Complementary information for O2C only...............................................................25

3.6 BADI Requirement 06: Feed Referenced NF Document by the Access Key informed on indicated Text ID
Field 45

3.7 BADI Requirement 07: Complementary information for P2P only................................................................46

3.8 BADI Requirement 08: Outgoing date and time...............................................................................................46

3.9 BADI Requirement 09: Installments Info (Tradenotes) + Grupo Fatura.......................................................50

3.10 BADI Requirement 10: Net / Weight / Volume tags.........................................................................................57

3.11 BADI Requirement 11: Freight mode tag..........................................................................................................60

3.12 BADI Requirement 12: Payment tags + Grupo Fatura:...................................................................................60

Version 21.0 152908-0562-20232 Page 11 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

3.13 BADI Requirement 13: Indpres (Presence Indicator) tag................................................................................68

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.15 BADI Requirement 15: GTIN tags:...................................................................................................................71

3.16 BADI Requirement 16: Fuel tags (CIDE).........................................................................................................73

3.17 BADI Requirement 17: ICMS-ST Tags for “ICMS Repasse”........................................................................75

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.20 BADI Requirement 20: Complementary information for P2P only................................................................92

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

4 DETAILED SAP CONFIGURATION – NFE BADI.....................................................134


4.1 Configuration – NFe BADI................................................................................................................................134

4.2 Master Data – NFe BADI...................................................................................................................................140

4.3 Enhancements – NFe BADI...............................................................................................................................140

4.4 Interfaces – NFe BADI.......................................................................................................................................140

4.5 Data Migration – NFe BADI.............................................................................................................................140


4.5.1 Issue LogBehavioural Change – NFe BADI................................................................................................140
4.5.2 Notes – NFe BADI.......................................................................................................................................140

5 TESTING REQUIREMENT – NFE BADI...................................................................140


5.1 Test cases / scenarios for O2C – NFe BADI.....................................................................................................140

5.2 Test cases / scenarios for P2P – NFe BADI......................................................................................................141

Version 21.0 152908-0562-20232 Page 12 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

6 FUNCTIONAL DESIGN – DANFE AND PRINTING PROGRAM..............................142


6.1 As-Is Process – DanFe and Printing program:................................................................................................142

6.2 To-Be process – DanFe and Printing program:...............................................................................................142


6.2.1 Functional design of the report logic – DanFe and Printing program..........................................................142

6.3 Security – DanFe and Printing program..........................................................................................................142

7 TECHNICAL DESIGN – DANFE AND PRINTING PROGRAM.................................142


7.1 Report – Print Program.....................................................................................................................................142
7.1.1 Data Mapping and Logic Matrix – DanFe and Printing program................................................................143

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

8 DETAILED SAP CONFIGURATION – DANFE AND PRINTING PROGRAM...........161


8.1 Configuration – DanFe and Printing program................................................................................................161

8.2 Master Data – DanFe and Printing program...................................................................................................161

8.3 Enhancements – DanFe and Printing program...............................................................................................161

8.4 Interfaces – DanFe and Printing program.......................................................................................................161

8.5 Data Migration – DanFe and Printing program.............................................................................................161


8.5.1 Issue LogBehavioural Change......................................................................................................................161
8.5.2 Notes.............................................................................................................................................................161

9 TESTING REQUIREMENT – DANFE AND PRINTING PROGRAM.........................162


9.1 Test cases / scenarios – DanFe and Printing program....................................................................................162

10 FUNCTIONAL DESIGN - SEND EMAIL WITH DANFE/XML.................................164


10.1 As-Is Process - Send email with DANFE/XML:..............................................................................................164

10.2 To-Be process - Send email with DANFE/XML:.............................................................................................164

11 TECHNICAL DESIGN - SEND EMAIL WITH DANFE/XML....................................171


11.1 Report - Program for NF Output message.......................................................................................................171

11.2 Z transaction / program for User Log Consulting or Re-submission of Messages......................................180

11.3 Module Function in SLL-NFE to collect and send NF-e XML data..............................................................185

11.4 Requirement routine in NF output message procedure..................................................................................185

Version 21.0 152908-0562-20232 Page 13 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

12 DETAILED SAP CONFIGURATION - SEND EMAIL WITH DANFE/XML.............187


12.1 Configuration - Send email with DANFE/XML..............................................................................................187

12.2 Master Data - Send email with DANFE/XML.................................................................................................188

13 TESTING REQUIREMENT - SEND EMAIL WITH DANFE/XML............................188


13.1 Test cases / scenarios..........................................................................................................................................188

13.2 Functional Testing - for all functionalities:.....................................................................................................189

14 FUNCTIONAL DESIGN - SLL-NFE & SAP PO......................................................190


14.1 As-Is Process - SLL-NFE & SAP PO:..............................................................................................................190

14.2 To-Be process - SLL-NFE & SAP PO:.............................................................................................................190

15 TECHNICAL DESIGN - SLL-NFE & SAP PO........................................................190


15.1 Communication Flow for Sending NF-es:........................................................................................................190

15.2 Architecture of BP environments with SLL-NFe:...........................................................................................190

15.3 Monitor NF-e Outbound - SLL-NFE:..............................................................................................................191

16 DETAILED SAP CONFIGURATION - SLL-NFE & SAP PO..................................193


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).........................................................................................197

17 FUNCTIONAL DESIGN – SLL-NFE & SAP-ECC – OTHER ENHANCEMENTS FOR


NFE – BP SPECIFIC REQUIREMENTS..........................................................................198
17.1 As-Is Process – SLL-NFE & SAP-ECC Other Enhancements for NFe – bp Specific Requirements:.......198
17.1.1 ENHANCEMENT_REQUIREMENT_01: SEFAZ ERROR 858...............................................................198
17.1.2 ENHANCEMENT_REQUIREMENT_02: ICOS/NGRD COUNTERPARTIES – STREET x STREET2
INFO 199
17.1.3 ENHANCEMENT_REQUIREMENT_03: SEFAZ ERROR 362 – FUELS NFE MANDATORY
CARRIER.....................................................................................................................................................................199
17.1.4 ENHANCEMENT_REQUIREMENT_04: SPECIAL STOCK PARTNER FOR 3RD PARTY WH ON NF
199
17.1.5 ENHANCEMENT_REQUIREMENT_05: GM RPTA “Differential Invoice” treatment for BR Legal
Requirements (including “NF-e Complementar” when DEBIT).................................................................................200
17.1.6 ENHANCEMENT_REQUIREMENT_06: SEFAZ ERROR 769 – ICMS CST 61....................................200

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

Version 21.0 152908-0562-20232 Page 14 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

18 TECHNICAL DESIGN - SLL-NFE & SAP-ECC – OTHER ENHANCEMENTS FOR


NFE – BP SPECIFIC REQUIREMENTS..........................................................................206
18.1 ENHANCEMENT_REQUIREMENT_01 – SEFAZ ERROR 858................................................................206

18.2 ENHANCEMENT_REQUIREMENT_02 – ICOS/NGRD COUNTERPARTIES – STREET X STREET2


INFO 212

18.3 ENHANCEMENT_REQUIREMENT_03 – CARRIER ON FUELS SALES NF-E (SEFAZ ERROR 362)


215

18.4 ENHANCEMENT_REQUIREMENT_04 – SPECIAL STOCK PARTNER FOR 3RD PARTY WH ON


NF 220

18.5 ENHANCEMENT_REQUIREMENT_05 – GM RPTA “Differential Invoice” treatment for BR Legal


Requirements (including “NF-e Complementar” when DEBIT)...............................................................................224

18.6 ENHANCEMENT_REQUIREMENT_06 – SEFAZ ERROR 769 – ICMS CST 61....................................226

19 DETAILED SAP CONFIGURATION - SLL-NFE & SAP-ECC – OTHER


ENHANCEMENTS FOR NFE – BP SPECIFIC REQUIREMENTS..................................230
19.1 Configuration......................................................................................................................................................230

19.2 Master Data.........................................................................................................................................................236

20 TESTING REQUIREMENT - SLL-NFE & SAP-ECC – OTHER ENHANCEMENTS


FOR NFE – BP SPECIFIC REQUIREMENTS.................................................................236
20.1 Test cases / scenarios..........................................................................................................................................236

20.2 Functional Testing - for all functionalities:.....................................................................................................236

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

Version 21.0 152908-0562-20232 Page 15 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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).

Version 21.0 152908-0562-20232 Page 16 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

https://wiki.scn.sap.com/wiki/display/LOCLA/Basic+Sales+Process+in+Brazil

1.1 Business Requirements

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

Version 21.0 152908-0562-20232 Page 17 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

To accomplish those capabilities, the following system functionalties will be implemented:


SAP ECC Standard Brazilian Localization configured for OTC and PTP processes
F1
relevant for NF-e issuance / booking, will automatically generate additional SAP NF
Document on document flow (at Billing creation in OTC and at Invoice Verification or Movement
Type creation in PTP). The SAP NF Document, composed by Header, Items, Values and other
structures, contains almost all information required for NF-e, carrying on the variances per nature of
operation and taxation determined by BR Localization parameters or specific condition types on
each item of the SD or MM flows.
However, even SAP Standard BR Localization being responsible to update the
F2 frequent government requirements for new fields on NF-e structures, it was already
planned to not deliver ALL the contents for ALL the fields due to the specific nature of
the rules (customer dependent) or due to its complexity and interpretation dependency. Due to that,
SAP made available specific BADIs for NFto enhance the filling of non-provided contents (including
texts). BADI CL_NFE_PRINT will be used and described ahead in topics named “NFE BADI”.
To align with SAP Strategy to retain data into NF database tables (“persistence”), all logic will
be developed on “new” BADI J_1BNF_ADD_DATA, referred ahead in topics shortly named as
“NFE BADI”.
For the capability to check all consistencies and formatiing the official NF_e XML file
F3 while handling it with Tax Authority by electronic messaging services, we will
implement the SAP tools SLL-NFE and PO (Process Orchestration). SLL-NFE tool
has also some more dedicated monitors for a second / third level of administration in case on
communication or batch issues. This topic will be detailed ahead on sections named with “SLL-NFE
& SAP PO”.
Regarding DANFe printout, SAP delivers only a format base on formar Mod.1-A and
F3 not the Mod.55 required actually. With that said, it’s a must that Customers using SAP
SLL-NFE develop their own printing programs and Smartforms, using as starting point
the SAP provided objects. In this document the topics related with that subject will be indicated with
“DANFE and PRINTING PROGRAM”.
The same occurs for the legal mandatory availability of NF-e XML files to recipients,
F3
generally by e-mail, not provided by SLL-NFE tool. This must be developed by
Customers and, as it will be in BP, generally includes also the DANFe PDF file. The sections for that
will be named with “SEND EMAIL WITH DANFE/XML”.
(START – 21_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
F3
Due to very specific NF-e XML requirements on Fuels area for “ICMS Repasse” and
not so far accomplished by SAP Std BR Localization (SEFAZ Errors 858 and 362), additional
interventions (“enhancements”) on ECC and SLL-NFE are necessary. They will be indicated as
“ECC & SLL-NFE ENHANCEMENTS”.
(END – 21_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
The same occurs for the legal mandatory availability of NF-e XML files to recipients,
F3
generally by e-mail, not provided by SLL-NFE tool. This must be developed by
Customers and, as it will be in BP, generally includes also the DANFe PDF file. The sections for that
will be named with “SEND EMAIL WITH DANFE/XML”.

Version 21.0 152908-0562-20232 Page 18 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Version 21.0 152908-0562-20232 Page 19 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Version 21.0 152908-0562-20232 Page 20 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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;

Version 21.0 152908-0562-20232 Page 21 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

1.4 Dependencies / Constraints

 (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).

Version 21.0 152908-0562-20232 Page 22 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

2 FUNCTIONAL DESIGN – NFE BADI


2.1 As-Is Process – NFe BADI:

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.

(START – 11_UAT: Changes V2.0 – 04th Jul 2022)


New Method ADD_DATA_J1B1N on BADI J_1BNF_ADD_DATA is only accessed once on Business
Place configuration the flag below is active:

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)

2.3 Security – NFe BADI

No additional security requirements, as this BADI will run in the background when sending nota fiscal
documents to the Brazilian government.

Version 21.0 152908-0562-20232 Page 23 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

3 TECHNICAL DESIGN – NFE BADI


Create a new implementation for BADI definition CL_NFE_PRINT J_1BNF_ADD_DATA with the
logic described below.
Following methods have to be enabled with corresponding input/output/changing parameters:
 Method FILL_HEADER to fill Additional NF-e Header Fields:
Input Parameters:
IN_DOC
IN_PARTNER
IN_TEXT
IN_REFER
IN_XML_HEADER

Output Parameters:
OUT_HEADER
OUT_COBRANCA
OUT_VOLUME
OUT_REF
OUT_REB
OUT_REFPROC
OUT_ADD_INFO

Changing Parameters:
CH_EXTENSION1
CH_EXTENSION2

 Methods – ADD_DATA (For automatic generated NFe’s) and ADD_DATA_J1B1N (For


manually created NFe’s):

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.

This functionality is now provided by SAP Standard Brazilian Localization, based on


CNPJ Business Place configuration (“Production” or “Test”) on the current client: no
need to implement any logic on BADI J_1BNF_ADD_DATA.

(START – 01_CT1: Changes V2.0 – 18th May 2022)

Version 21.0 152908-0562-20232 Page 24 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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).

(END – 01_CT1: Changes V2.0 – 18th May 2022)

Scope
=> For both Application automatic issued NF-e’s and Manually issued NF-e’s
(“NF Writer”).

(START – 11_UAT: Changes V2.0 – 04th Jul 2022)


Comment code and deactivate former Implementation ZFIL_ENH_NFE_APPRV on BADI
CL_NFE_PRINT.

Version 21.0 152908-0562-20232 Page 25 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

(START – 11_UAT: Changes V2.0 – 04th Jul 2022)

3.2 BADI Requirement 02: Country Code

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”).

3.3 BADI Requirement 03: Shipment tags

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.

Version 21.0 152908-0562-20232 Page 26 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

3.4 BADI Requirement 04: Sales order / Billing / Purchase Order information

If VBRP-VGBEL is not in blank, concatenate out_header-infcomp + “Ordem de Venda:” +


space + VBRP-VGBEL + “Fatura:” + space + J_1BNFLIN-REFKEY + “Pedido de Compra:”
+ J_1BNFLIN-XPED into out_header-infcomp.
If any value (VBRP-VGBEL or J_1BNFLIN-REFKEY or J_1BNFLIN-XPED) is in blank, the
label (Ordem de Venda, Fatura, Pedido de Compra) will not be printed.

This requirement will be accomplished on next topic, together with other Texts on Complementary
information.

3.5 BADI Requirement 05: Complementary information for O2C only

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:

Version 21.0 152908-0562-20232 Page 27 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

(START – 07_UAT: Changes V2.0 – 29th Jun 2022)


Due to the most recent functionality for supporting “Dados Adicionais” (infAdic) on Nota Fiscal,
NF Header texts on J_1BNFFTX should be moved – via BADI – to structure string
ES_HEADER-INFCPL. When using the new Company Free Text on “Additional Information” tab
of SAP NF Doc, that text goes directly to ES_HEADER-INFCPL string.
Based on the new approach, the logic will be changed to now append all the current text block
assembling into ES_HEADER-INFCPL and not into IT_NFFTX anymore. The important remark
here is that NO “line feed” (line return) characters must exist on the entire string, otherwise XML
schema error will be posted by NF-e messaging system. With that said, additional logic will be
included to remove any “line feed” from the final string;
(END – 07_UAT: Changes V2.0 – 29th Jun 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 NF generate from a Billing document


CHECK iv_applic EQ ‘BI’
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
* Check NF Type is different from Adjust or Return
CHECK is_header-doctyp NE ‘2’ AND is_header-doctyp NE ‘6’
* 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

(END – 07_UAT: Changes V2.0 – 29th Jun 2022)


* Check BR Company Code active or not
SELECT * FROM tvarvc INTO lt_tvarvc WHERE
Name = ‘ZSD_NFE_CMPLINF_BUKRS’

Version 21.0 152908-0562-20232 Page 28 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

CHECK is_header-bukrs IS ON <lt_tvarvc-low values>

* 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’

IF sy-subrc IS NOT INITIAL OR lv_maxlen > 5000 OR lv_maxlen IS INITIAL


lv_maxlen = 5000
ENDIF
SELECT * FROM tvarvc INTO lt_sequence WHERE
Name = ‘ZSD_NFE_CMPLINF_TEXTSEQUENCE’

ENDIF

IF sy-subrc IS INITIAL AND lt_sequence IS NOT INITIAL


SORT lt_sequence BY name type numb ASCENDING
CLEAR: lv_appendtextlv_appendtext
LOOP AT lt_sequence INTO ls_sequence

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

CALL FUNCTION Read_Text USING


ID = ZB00 (TVARVC_NAME = NFE_ZB00)

Version 21.0 152908-0562-20232 Page 29 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

IF split NOT POSSIBLE


lv_drivername = tdline

CONCATENATE lv_appendtextlv_appendtext // “; Motorista: ” // lv_drivername


INTO lv_appendtextlv_appendtext
ELSE
CONCATENATE lv_appendtextlv_appendtext // “; Motorista: ” // lv_drivername
// “; CNH: ” // lv_cnh INTO lv_appendtextlv_appendtext
ENDIF
IF sy-subrc IS INITIAL and tdline IS NOT INITIAL

CLEAR lv_drivername lv_cnh


SPLIT tdline AT ';' INTO lv_drivername AND lv_cnh

IF lv_drivername IS NOT INITIAL AND lv_cnh IS INITIAL


CONCATENATE lv_appendtext // “Motorista:” // lv_drivername // “; ” INTO
lv_appendtext
ELSEIF lv_drivername IS NOT INITIAL AND lv_cnh IS NOT INITIAL
CONCATENATE lv_appendtext // “Motorista:” // lv_drivername // “;CNH:” //
lv_cnh // “; ” INTO lv_appendtext
ENDIF
(END – 07_UAT: Changes V2.0 – 29th Jun 2022)

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

CALL FUNCTION Read_Text USING


ID = ZB04 (TVARVC_NAME = NFE_ZB04)
Language = PT
Name = VBRP-VGBEL
Object = VBBK
ID = <ls_tvarvc-low> ***must be “ZBxx”
Language = PT

Version 21.0 152908-0562-20232 Page 30 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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)

CONCATENATE lv_appendtextlv_appendtext // “; ” // lv_tdline INTO


lv_appendtextlv_appendtext
CONCATENATE lv_appendtext // lv_tdline // “; ” INTO lv_appendtext
(END – 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

CALL FUNCTION Read_Text USING


ID = ZB01 (TVARVC_NAME = NFE_ZB01)
Language = PT
Name = VBRP-VGBEL
Object = VBBK
ID = <ls_tvarvc-low> ***must be “ZBxx”
Language = PT
Name = it_vbrp-vgbel
Object = “VBBK”
IF sy-subrc IS INITIAL and tdline 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)

Version 21.0 152908-0562-20232 Page 31 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

CONCATENATE lv_appendtextlv_appendtext // “; Dados do Veículo/Cavalo: ” //


lv_t1placa // “, “ // lv_t1uf1 // “, “ // “RNTC: “ // lv_t1rntc INTO
lv_appendtextlv_appendtext
IF lv_t1placa IS NOT INITIAL AND lv_t1uf1 IS NOT INITIAL AND lv_t1rntc IS INITIAL
CONCATENATE lv_appendtext // “Dados do Veículo/Cavalo:” // lv_t1placa // “, “ //
lv_t1uf1 // “; “ INTO lv_appendtext
ELSEIF lv_t1placa IS NOT INITIAL AND lv_t1uf1 IS NOT INITIAL AND lv_t1rntc IS NOT
INITIAL
CONCATENATE lv_appendtext // “Dados do Veículo/Cavalo:” // lv_t1placa // “, “ //
lv_t1uf1 // “, “ // “RNTC:“ // lv_t1rntc // “; “ INTO lv_appendtext
ELSEIF lv_t1placa IS NOT INITIAL
CONCATENATE lv_appendtext // “Dados do Veículo/Cavalo:” // lv_t1placa // “; “
INTO lv_appendtext
ENDIF

(END – 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

CALL FUNCTION Read_Text USING


ID = ZB02 (TVARVC_NAME = NFE_ZB02)
Language = PT
Name = VBRP-VGBEL
Object = VBBK
ID = <ls_tvarvc-low> ***must be “ZBxx”
Language = PT
Name = it_vbrp-vgbel
Object = “VBBK”
IF sy-subrc IS INITIAL and tdline IS NOT INITIAL

IF is_header-id_dest <>≠ ‘2’


* Only two first lines are valid (premise: maximum two trailers per NFe > “bitrem”)
CLEAR: lv_t2placa, lv_t2uf1, lv_t2rntc, lv_t3placa, lv_t3uf1 lv_t3rntc
Get tdlines and split string at character “;” into lv_t2placa, lv_t2uf1, lv_t2rntc,
lv_t3placa, lv_t3uf1 AND lv_t3rntc
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)

APPEND new line on ET_TRAILER using


DOCNUM = is_header-docnum
COUNTER = <last counter value existing on ET_TRAILER + 1>
PLACA = lv_t2placa
VEH_UF = lv_t2uf1
RNTC = lv_t2rntc

Version 21.0 152908-0562-20232 Page 32 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

CONCATENATE lv_appendtextlv_appendtext // “; Dados do(s) Reboque(s): ” //


lv_t2placa // “, “ // lv_t2uf1 // “, “ // “RNTC: “ // lv_t2rntc INTO
lv_appendtextlv_appendtext

IF lv_t2placa IS NOT INITIAL


APPEND new line on ET_TRAILER using
DOCNUM = is_header-docnum
COUNTER = <last counter value existing on ET_TRAILER + 1>
PLACA = lv_t2placa
VEH_UF = lv_t2uf1
RNTC = lv_t2rntc
IF lv_t2placa IS NOT INITIAL AND lv_t2uf1 IS NOT INITIAL AND lv_t2rntc IS
INITIAL
CONCATENATE lv_appendtext // “Dados do Reboque 1:” // lv_t2placa // “, “ //
lv_t2uf1 // “; “ INTO lv_appendtext
ELSEIF lv_t2placa IS NOT INITIAL AND lv_t2uf1 IS NOT INITIAL AND lv_t2rntc IS
NOT INITIAL
CONCATENATE lv_appendtext // “Dados do(s) Reboque 1:” // lv_t2placa // “, “ //
lv_t2uf1 // “, “ // “RNTC:“ // lv_t2rntc // “; “ INTO lv_appendtext
ELSEIF lv_t2placa IS NOT INITIAL
CONCATENATE lv_appendtext // “Dados do(s) Reboque 1:” // lv_t2placa // “; “
INTO lv_appendtext
ENDIF
ENDIF
(END – 07_UAT: Changes V2.0 – 29th Jun 2022)

IF lv_t3placa IS NOT INITIAL


APPEND new line on ET_TRAILER using
DOCNUM = is_header-docnum
COUNTER = <last counter value existing on ET_TRAILER + 1>
PLACA = lv_t3placa
VEH_UF = lv_t3uf1
RNTC = lv_t3rntc
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
CONCATENATE lv_appendtextlv_appendtext // “; ” // lv_t3placa // “, “ //
lv_t3uf1 // “, “ // “RNTC: “ // lv_t3rntc INTO lv_appendtextlv_appendtext
IF lv_t3placa IS NOT INITIAL AND lv_t3uf1 IS NOT INITIAL AND lv_t3rntc IS
INITIAL
CONCATENATE lv_appendtext // “Dados do Reboque 2:” // lv_t3placa // “, “ //
lv_t3uf1 // “; “ INTO lv_appendtext
ELSEIF lv_t3placa IS NOT INITIAL AND lv_t3uf1 IS NOT INITIAL AND lv_t3rntc IS
NOT INITIAL
CONCATENATE lv_appendtext // “Dados do Reboque 2:” // lv_t3placa // “, “ //
lv_t3uf1 // “, “ // “RNTC:“ // lv_t3rntc // “; “ INTO lv_appendtext
ELSEIF lv_t3placa IS NOT INITIAL
CONCATENATE lv_appendtext // “Dados do Reboque 2:” // lv_t3placa // “; “
INTO lv_appendtext
ENDIF
(END – 07_UAT: Changes V2.0 – 29th Jun 2022)

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

CALL FUNCTION Read_Text USING

Version 21.0 152908-0562-20232 Page 33 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

ID = ZB03 (TVARVC_NAME = NFE_ZB03)


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”
IF sy-subrc IS INITIAL and tdline IS NOT INITIAL
DATA: lv_maxgatec NUMERIC
* Get parameter with max number of chars for GATEC text block
lv_maxgatec = ls_tvarvc-high
IF sy-subrc IS NOT INITIAL OR lv_maxgatec > 400 OR lv_maxgatec IS INITIAL
* If parameter is not correctly defined, fix the maximum
lv_maxgatec = 400
ENDIF
lv_tdline = tdline
* Check number of chars on free text block (tdline)
IF QtyChars[lv_tdline] > lv_maxgatec
Truncate string lv_tdline to a maximum of character defined by lv_maxgatec
ENDIF
CONCATENATE lv_appendtextlv_appendtext // “; ” // lv_tdline INTO
lv_appendtextlv_appendtext
ENDIF
ENDIF

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

IF it_vbrp-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-vgtyp = ‘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
(START – 31_UAT: RITM000001897233 Changes V4.0 – 26th Sep 2023)
IF it_nflin-xped IS NOT INITIAL
lv_docs = CONCATENATE lv_docs // “Pedido:“ // it_nflin-xped // “; “ INTO lv_docs
ENDIF
IF is_vbrk-BSTNK_VF IS NOT INITIAL
lv_docs = CONCATENATE lv_docs // “Pedido:“ // is_vbrk-bstnk_vf // “; “ INTO
lv_docs
ENDIF
(END – 31_UAT: RITM000001897233 Changes V4.0 – 26th Sep 2023)
ENDIF

ENDIF(END – 07_UAT: Changes V2.0 – 29th Jun 2022)

Version 21.0 152908-0562-20232 Page 34 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

IF lv_docs is NOT INITIAL


CONCATENATE lv_appendtextlv_appendtext // lv_docs INTO
lv_appendtextlv_appendtext
ENDIF
ENDIF

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 )

Version 21.0 152908-0562-20232 Page 35 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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’

Select table ADR6 with ADDRNUMBER = KNA1_ADRNR. Get the value of


SMTP_ADDR.
FLG_NOUSE

*** (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

(START – 08_UAT: Changes V2.0 – 29th Jun 2022)


SELECT b~smtp_addr
IF is_header-partyp = ‘C’
SELECT b~smtp_addr c~ID c~remark

(END – 08_UAT: Changes V2.0 – 29th Jun 2022)


INTO lt_email)
FROM kna1 AS a INNER JOIN adr6 AS b INNER JOIN adrt AS c
ON a~adrnr = b~addrnumber AND b~addrnumber = c~addrnumber
WHERE a~kunnr = is_header-parid
c~remark = lv_txtadrt
(START – 08_UAT: Changes V2.0 – 29th Jun 2022)
b~smtp_addr IS NOT INITIAL
ENDSELECT.
(END – 08_UAT: Changes V2.0 – 29th Jun 2022)

IF lt_email IS NOT INITIAL

Version 21.0 152908-0562-20232 Page 36 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

CONCATENATE “E-mail:“ // ls_ email-smtp_addr // “;” INTO ls_smtptxt


ELSE
CONCATENATE ls_smtptxt // “;“ // ls_ email-smtp_addr // “; “ // INTO ls_smtptxt

(END – 08_UAT: Changes V2.0 – 29th Jun 2022)


ENDIF
ENDLOOP
ENDIF.
(START – 08_UAT: Changes V2.0 – 29th Jun 2022)
ENDIF ** (is_header-partyp = ‘C’)
(END – 08_UAT: Changes V2.0 – 29th Jun 2022)
ENDSELECT.

IF ls_smtptxt IS NOT INITIAL


CONCATENATE lv_appendtextlv_appendtext // ls_smtptxt INTO
lv_appendtextlv_appendtext
ENDIF
ENDIF

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)

CONCATENATE lv_appendtextlv_appendtext // “; Valor Total FCP: R$ “ // lv_fcpval


INTO lv_appendtextlv_appendtext
CONCATENATE lv_appendtext // “Valor Total FCP:R$ “ // lv_fcpval // “;” INTO
lv_appendtext

(END – 07_UAT: Changes V2.0 – 29th Jun 2022)


ENDIF
ENDIF

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

Version 21.0 152908-0562-20232 Page 37 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
IF lv_fcpval IS NOT INITIAL

CONCATENATE lv_appendtextlv_appendtext // “; Valor Total FCP ST: R$ “ // lv_fcpval


INTO lv_appendtextlv_appendtext
IF lv_fcpstval IS NOT INITIAL

CONCATENATE lv_appendtext // “Valor Total FCP ST:R$ “ // lv_fcpstval // ”;” INTO


lv_appendtext
(END – 07_UAT: Changes V2.0 – 29th Jun 2022)
ENDIF
ENDIF

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”.

(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) records in an internal table lt_tvarvc using following
criteria:
NAME = ls_sequence-low
IF found AND lt_tvarvc IS NOT INITIAL
lt_locret = lt_tvarvc
SORT lt_locret BY low ASCENDING

* Copy internal table to avoid errors for free manipulation


lt_nfnad = it_partner
CLEAR: lv_text
LOOP ON lt_nfnad INTO ls_nfnad
IF ls_nfnad-partner_role = ‘1’

Version 21.0 152908-0562-20232 Page 38 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

* Partner function marked as “Withdrawal Place” (Local de Retirada) found


READ TABLE lt_locret INTO ls_locret USING low = ls_nfnad-parvw
IF sy-subrc IS INITIAL
* Specific register per Partner Function on TVARVC found (probably a specific text block …)
lv_text = ls_locret-high
ELSE
* Try to get a generic text block
READ TABLE lt_locret INTO ls_locret USING low = “##”
IF sy-subrc IS INITIAL
* Generic register found
lv_text = ls_locret-high
ELSE
* Even the expected generic text block not found … use a default fixed string at least
lv_text = “LOCAL DE RETIRADA: “
ENDIF
ENDIF
CONCATENATE lv_appendtext // “;” // lv_text // ls_nfnad-name1 // ls_nfnad-name2 // ls_nfnad-
name1 // “ ” // ls_nfnad-stras // “ ” // ls_nfnad-stras // “ ” // ls_nfnad-ort02 // “ ” // ls_nfnad-ort01 // “/” //
ls_nfnad-regio // “ ” // ls_nfnad-pstlz // “ CNPJ:” // ls_nfnad-cgc // “ Inscr.Est:” // ls_nfnad-stains INTO
lv_appendtext(START – 06_CT1: Changes V2.0 – 14th Jun 2022)
CONCATENATE lv_appendtext // “;” // lv_text // ls_nfnad-name1 // ls_nfnad-name2 //
ls_nfnad-name1 // “ ” // ls_nfnad-stras // “ ” // ls_nfnad-stras // “ ” // ls_nfnad-ort02 // “ ” //
ls_nfnad-ort01 // “/” // ls_nfnad-regio // “ ” // ls_nfnad-pstlz // “ CNPJ:” // ls_nfnad-cgc // “
Inscr.Est:” // ls_nfnad-stains INTO lv_appendtext

CONCATENATE lv_appendtext // “;” // lv_text // ls_nfnad-name1 // “<space>” //


ls_nfnad-name2 // “, ” // ls_nfnad-stras // “, ” // ls_nfnad-ort02 // “, ” // ls_nfnad-ort01 // “/” //
ls_nfnad-regio // “, ” // ls_nfnad-pstlz // “ CNPJ:” // ls_nfnad-cgc // “ Inscr.Est:” // ls_nfnad-
stains INTO lv_appendtext
(START – 20_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
Please correct coding

(END – 20_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)


(END – 06_CT1: Changes V2.0 – 14th Jun 2022)

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.

(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) records in an internal table lt_tvarvc using following
criteria:
NAME = ls_sequence-low
IF found AND lt_tvarvc IS NOT INITIAL

Version 21.0 152908-0562-20232 Page 39 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

lt_locent = lt_tvarvc
SORT lt_locent BY low ASCENDING

* Copy internal table to avoid errors for free manipulation


lt_nfnad = it_partner
CLEAR: lv_text
LOOP ON lt_nfnad INTO ls_nfnad
IF ls_nfnad-partner_role = ‘0’

* Partner function marked as “Delivery Place” (Local de Entrega) found


READ TABLE lt_locent INTO ls_locent USING low = ls_nfnad-parvw
IF sy-subrc IS INITIAL
* Specific register per Partner Function on TVARVC found (probably a specific text block …)
lv_text = ls_locent-high
ELSE
* Try to get a generic text block
READ TABLE lt_locent INTO ls_locent USING low = “##”
IF sy-subrc IS INITIAL
* Generic register found
lv_text = ls_locent-high
ELSE
* Even the expected generic text block not found … use a default fixed string at least
lv_text = “LOCAL DE ENTREGA: “
ENDIF
ENDIF
(START – 06_CT1: Changes V2.0 – 14th Jun 2022)

CONCATENATE lv_appendtextlv_appendtext // “;” // lv_text // ls_nfnad-name1 //


ls_nfnad-name2 // ls_nfnad-name1 // “ ” // ls_nfnad-stras // “ ” // ls_nfnad-stras // “ ” //
ls_nfnad-ort02 // “ ” // ls_nfnad-ort01 // “/” // ls_nfnad-regio // “ ” // ls_nfnad-pstlz // “
CNPJ:” // ls_nfnad-cgc // “ Inscr.Est:” // ls_nfnad-stains INTO
lv_appendtextlv_appendtext
CONCATENATE lv_appendtext // “;” // lv_text // ls_nfnad-name1 // “<space>” //
ls_nfnad-name2 // “, ” // ls_nfnad-stras // “, ” // ls_nfnad-ort02 // “, ” // ls_nfnad-ort01 // “/” //
ls_nfnad-regio // “, ” // ls_nfnad-pstlz // “ CNPJ:” // ls_nfnad-cgc // “ Inscr.Est:” // ls_nfnad-
stains INTO lv_appendtext
(START – 20_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
*** Please correct coding ***

(END – 20_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)


(END – 06_CT1: Changes V2.0 – 14th Jun 2022)

ENDIF
ENDLOOP
ENDIF

Version 21.0 152908-0562-20232 Page 40 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

(START – 30_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)

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

CALL FUNCTION Read_Text USING


ID = <ls_tvarvc-high> ***must be “ZBxx”
Language = PT
Name = it_vbrp-vgbel
Object = “VBBK”
IF sy-subrc IS INITIAL and tdline 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

CLEAR: lv_docnum, lv accesskey, ls_nfdoc


Get tdlines and split string at character “;” into lv_docnum, lv_accesskey but
respecting their maximum technical lengths: docnum (J_1BDOCNUM) = 10, accesskey
(J_1B_NFE_ACCESS_KEY_DTEL44) = 44

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)

Version 21.0 152908-0562-20232 Page 41 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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)

(END – 32_UAT: RITM000001897233 Changes V4.0 – 25th Sep 2023)


IF sy-subrc IS INITIAL
* Only NF Types defined on parameter will be accepted (from Suppliers)
IF ls_nfdoc-partyp = ‘V’
CALL FUNCTION 'J_1B_NF_VENDOR_READ'
EXPORTING
partner_id = ls_nfdoc-parid
read_address = 'X'
IMPORTING
parnad = ls_partner
address = ls_address
address1 = ls_address1
EXCEPTIONS

Version 21.0 152908-0562-20232 Page 42 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

* Create text as per provided by BR Tax Team / OPLA


* Remessa simbólica de armazenagem ref. NF-e de <tipo> nº .........., série ......, de
* .../..../..., emitida pela ............., sito à ................ nº ....... .............. - ............/SP,
* CNPJ nº ............ e IE nº .........
(START – 32_UAT: RITM000001897233 Changes V4.0 – 25th Sep 2023)
CONCATENATE lv_appendtext // “Remessa simbólica de armazenagem ref.
NF-e de aquisição nº ” // ls_nfdoc-nfenum // “; série “ // ls_nfdoc-series // “, de ” //
ls_nfdoc-docdat // “, emitida por ” // ls_partner-name1 // “ ” // ls_partner-name2 // “,
sito à ” // ls_address1-STR_SUPPL1 // “ ” // ls_address1-STR_SUPPL2 // “ ” //
ls_address1-STR_SUPPL3 // “ /” // ls_address1-REGION // “, CNPJ nº ” // ls_partner-
cgc // “ e IE nº ” // ls_partner-stains // “;” INTO lv_appendtext

lv_date = Format (ls_nfdoc-docdat) to DD/MM/YYYY

CONCATENATE lv_appendtext // “Remessa simbolica de armazenagem ref.


NF-e de “ // ls_tvarvc_nftyp-high // ” nr ” // ls_nfdoc-nfenum // “; serie “ // ls_nfdoc-
series // “, de ” // lv_date ls_nfdoc-docdat // “, emitida por ” // ls_partner-name1 // “ ” //
ls_partner-name2 // “, sito a ” // ls_address1-STR_SUPPL1 // “ ” // ls_address1-
STR_SUPPL2 // “ ” // ls_address1-STR_SUPPL3 // “ /” // ls_address1-REGION // “,
CNPJ ” // ls_partner-cgc // “ e IE ” // ls_partner-stains // “;” INTO lv_appendtext
(END – 32_UAT: RITM000001897233 Changes V4.0 – 25th Sep 2023)
ENDIF
ENDIF
ENDIF
ENDIF ** tdline IS NOT INITIAL
ENDIF **ls_tvarvc-low IS NOT INITIAL

(END – 30_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)

(START – 38_ITC: RITM000002278935 Changes V4.0 – 05th Jun 2024)


WHEN ‘ZSD_NFE_CMPLINF_HDTX_ICMSDESON’
WARNING - CRITICAL LOGIC IMPLEMENTATION SEQUENCE DEPENDENCY: as the
next logic to be implemented will – if applicable – depends on information generated on new
BADI_REQUIREMENT_27. Please check that BADI_REQUIREMENT_27 for more details:

* Copy internal structures to keep their integrity


field-symbols: <f_fieldname>
CLEAR lt_item_aux, ls_item_aux, lt_tvarvc_icmsdeson, ls_tvarvc_icmsdeson, ls_e_dd03p,
lv_fieldname, lv_field_amount, lv_field_amount_total, lv_descrip, lv_field_value,
lv_field_value_final
COPY et_item TO lt_item_aux
SORT it_item_aux BY itmnum
Read parameter table (TVARVC) records in a table lt_tvarvc_icmsdeson table using
following criteria:
NAME = ls_sequence-low AND
LOW IS NOT INITIAL AND
HIGH IS NOT INITIAL

Version 21.0 152908-0562-20232 Page 43 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

IF lt_tvarvc_icmsdeson IS NOT INITIAL

* Found Text blocks


LOOP lt_tvarvc_icmsdeson INTO ls_tvarvc_icmsdeson
* Loop on all “ICMS Desonerado” variables to be considered on header text block
CLEAR lv_field_amount_total, lv_field_value_final, lv_descrip
CALL FUNCTION 'BUS_DDFIELD_GET'
EXPORTING
i_tabnm = ‘J_1BNF_BADI_ITEM’
i_fldnm = ls_tvarvc_icmsdeson-low
IMPORTING
e_dd03p = ls_e_dd03p
EXCEPTIONS
OTHERS = 1.
IF sy-subrc IS INITIAL
lv_fieldname = CONCATENATE “ET_ITEM-” // ls_tvarvc_icmsdeson-low.
ASSIGN (lv_fieldname) to <f_fieldname>
IF sy-subrc IS INITIAL
* Loop on all items to compose the specific summarized text block
* of the “ICMS Desonerado” variable
LOOP lt_item_aux INTO ls_item_aux
* Check if field on parameter table technically exists (to avoid any dump on reading)
* Premise here is that only et_item (structure type J_1BNF_BADI_ITEM) fields will provide info
CLEAR lv_field_amount, lv_field_value, lv_descrip
IF ls_e_dd03p-datatype = ‘DEC’ or ‘CURR’
* If field is an amount, then sum up with current subtotal
lv_field_amount = <f_fieldname>
lv_field_amount_total = lv_field_amount_total + lv_field_amount
ELSEIF ls_e_dd03p-datatype = ‘CHAR’
* If field is not an amount, concatenate string char value (and description if found)
lv_field_value = <f_fieldname>
IF lv_field_value IS NOT INITIAL.
* Value is not null: Now try to get description (if exists) in case the value is a key
IF ls_e_dd03p-domname IS NOT INITIAL
CALL FUNCTION 'SD_SCD_GET_DOMVALUE_TEXT'
EXPORTING
i_spras = ‘PT’
i_tabname = ‘J_1BNF_BADI_ITEM’
i_fieldname = ls_tvarvc_icmsdeson-low
i_domvalue = lv_variable_value
IMPORTING
e_domval_text = lv_descrip
IF sy-subrc IS INITIAL AND lv_descrip IS NOT INITIAL
lv_field_value = CONCATENATE lv_field_value // “-“ lv_descrip
ENDIF
lv_field_value_final = CONCATENATE lv_field_value_final //
// lv_field_value // “,“
ELSE
lv_field_value_final = CONCATENATE lv_field_value_final //
// lv_field_value // “,“
ENDIF ** ls_e_dd03p-domname
ENDIF ** lv_field_value
ENDIF ** ls_e_dd03p-datatype
ENDLOOP ** lt_item

* 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

Version 21.0 152908-0562-20232 Page 44 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

ELSEIF lv_field_value_final IS NOT INITIAL


CONCATENATE lv_appendtext // “;” // ls_tvarvc_icmsdeson-high //
// lv_field_value_final INTO lv_appendtext
ENDIF
ENDIF ** Assign
ENDIF ** Field does not exist
ENDLOOP ** lt_tvarvc_icmsdeson
ENDIF ** lt_tvarvc_icmsdeson IS NOT INITIAL
(END – 38_ITC: RITM000002278935 Changes V4.0 – 05th Jun 2024)

(START – 41_CR: RITM000002278935 Changes V4.0 – 21st Jun 2024)

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

IF sy-subrc IS INITIAL and lt_ltext IS NOT INITIAL

* Start appending existing text lines


LOOP AT lt_ltext INTO ls_ltext
CONCATENATE lv_appendtext // ls_ltext INTO lv_appendtext
ENDLOOP
CONCATENATE lv_appendtext // “;” INTO lv_appendtext
ENDIF
ENDIF
(END – 41_CR: RITM000002278935 Changes V4.0 – 21st Jun 2024)

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)

Version 21.0 152908-0562-20232 Page 45 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

REBOQUE(S):”. ZB02 and ADR6-SMTP-ADDR into out_header-infcomp separated by


space.
If values were found in READ_TEXT for ID ZB00, concatenate out_header-
infcomp + the two fields from ZB00 (cnh and driver_desp).

ENDCASE
ENDLOOP
ENDIF

* Final text block (lv_appendtextlv_appendtext) to be appended was achieved


(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
IF lv_appendtextlv_appendtext is NOT INITIAL
* Check number of chars for overflow situation
lv_remain = lv_maxlen – QtyChars[it_nfftx]
IF QtyChars[lv_appendtextlv_appendtext] > lv_remain
Truncate string lv_appendtextlv_appendtext (cutting from end to begin) to a maximum of
characters defined by lv_remain
ENDIF

APPEND (saplj1bg)wnfftx WITH lv_appendtextlv_appendtext CONTENTS


* Final text block will be composed by (in this order):
* it_nfftx, es_header-infcpl (if any previous text already exists there) and lv_appendtext
CLEAR ls_initblock
IF lt_nfftx IS NOT INITIAL
lv_seqnum = ‘01’
COPY it_nfftx TO lt_nfftx
SORT lt_nfftx BY docnum SEQNUM LINNUM ASCENDING

(START – 14_UAT: Changes V2.0 – 25th Jul 2022)


* First, check if “text variables” exist to be substituted on SAP it_nfftx as per defined on TVARVC
* Get existing text variables defined by parameters and their corresponding values
DATA: lt_varsubstitute2
SELECT * FROM tvarvc INTO lt_varsubstitute2 WHERE
Name = ‘ZSD_NFE_VARTEXT_SUBSTITUTE’

IF sy-subrc IS INITIAL AND lt_varsubstitute2 IS NOT INITIAL


LOOP AT lt_varsubstitute2 INTO ls_varsubstitute2
IF ls_varsubstitute2-low IS NOT INITIAL AND ls_varsubstitute2-high IS NOT INITIAL
* For the text string to be substituted, obtain the contents into the indicated variable
ls_contents2 = <Read contents of variable name provided by ls_varsubstitute2-high>

IF sy-subrc IS INITIAL and ls_contents2 IS NOT INITIAL


IF <ls_varsubstitute2-high TYPE is DATE>
<Convert ls_contents2 to format DD.MM.YYYY>
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_varsubstitute2-low along text record ls_nfftx and, everytime
found, substitute substring into ls_nfftx string per the contents of ls_contents2>

Version 21.0 152908-0562-20232 Page 46 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

MODIFY lt_nfftx FROMUSING ls_nfftx


ENDLOOP
MODIFY (SAPLJ1BG)WNFFTX[ ] FROMUSING lt_nfftx

ENDIF
ENDIF
ENDLOOP
ENDIF
(END – 14_UAT: Changes V2.0 – 25th Jul 2022)

LOOP lt_nfftx INTO ls_nfftx


IF ls_nfftx-message IS NOT INITIAL
CONCATENATE ls_initblock // ls_nfftx-message INTO ls_initblock
IF ls_nfftx-seqnum = lv_seqnum
CONCATENATE ls_initblock // “ “ INTO ls_initblock
ELSE
CONCATENATE ls_initblock // “; “ INTO ls_initblock
lv_seqnum = ls_nfftx-seqnum
ENDIF
ENDLOOP
ENDIF
IF ls_initblock IS NOT INITIAL
CONCATENATE es_header-infcpl // ls_initblock INTO es_header-infcpl
ENDIF
* Check number of chars for overflow situation
lv_remain = lv_maxlen – QtyChars[es_header-infcpl]
IF lv_appendtext is NOT INITIAL
IF (QtyChars[lv_appendtext] > lv_remain)
Truncate string lv_appendtext (cutting from end to begin) to a maximum of characters
defined by lv_remain
ENDIF
es_header-infcpl // lv_appendtext INTO es_header-infcpl
* 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
(END – 07_UAT: Changes V2.0 – 29th Jun 2022)
ENDIF

Version 21.0 152908-0562-20232 Page 47 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

SELECT low FROM tvarvc INTO lv_txtacckey WHERE


Name = ‘ZSD_NFE_TEXT_REFACCKEY’

IF sy-subrc IS NOT INITIAL AND lv_txtacckey IS NOT INITIAL


CALL FUNCTION Read_Text USING
ID = ZB06 (TVARVC_NAME = NFE_ZB06)
Language = PT
Name = VBRP-VGBEL
Object = VBBK
ID = lv_txtacckey ***must be “ZBxx”
Language = PT
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 AND numofchar(tdline) = 44
* Text found, text line not empty and text line length compatible with a NF-e access key
DATA: ls_acckey TYPE j_1b_nfe_access_key
ls_acckey-regio = tdline(2)
ls_acckey-nfyear = tdline+2(2)
ls_acckey-nfmonth = tdline+4(2)
ls_acckey-model = tdline+20(2)
ls_acckey-serie = tdline+22(3)
ls_acckey-nfnum9 = tdline+25(9)
ls_acckey-docnum9 = tdline+34(9)
ls_acckey-cdv = tdline+43(1)
IF sy-subrc IS INITIAL
* No issue when transposing values: look for SAP NF Doc related to access key
SELECT docnum FROM j_1bnfe_active INTO lv_docref WHERE
regio = ls_acckey-regio
nfyear = ls_acckey-nfyear
nfmonth = ls_acckey-nfmonth

Version 21.0 152908-0562-20232 Page 48 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

3.7 BADI Requirement 07: Complementary information for P2P only

(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”).

3.8 BADI Requirement 08: Outgoing date and time

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.

(START – 09_UAT: Changes V2.0 – 29th Jun 2022)


Due to Time Zone definitions for bp user IDs (cannot set or predefine that all BR users will have
BRAZIL Time Zone as default on their user IDs), the Outgoing Date and Time will be calculated
based on the Time Zone of the Country and Region of the issuance Business Place / Plant. Also,
Creation Date and Time are not available on NF header structure of the BADI (is_header) during
BADI execution, which exactly leads to the need to calculate it correctly by the new methods.
(END – 09_UAT: Changes V2.0 – 29th Jun 2022)

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

If IN_DOC-CRETIM and IN_DOC-PSTDAT are not in blank, call function C14B_ADD_TIME:


Exporting:
I_STARTTIME = IN_DOC-CRETIM
I_STARTDATE = IN_DOC-PSTDAT
I_ADDTIME = 001012
Importing:
E_ENDTIME = OUT_HEADER-HSAIENT
E_ENDDATE = OUT_HEADER-DSAIENT

Version 21.0 152908-0562-20232 Page 49 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Create new implementation on BADI J_1BNF_ADD_DATA, Method ADD_DATA, including


a segregated Function Module or Include with the following functional 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.

Check if a NF-e is being issued (is_header-form IS NOT INITIAL)


Concatenate ‘ZSD_NFE_DSAIENT_HSAIENT_’ with is_header-nftype into ls_name
Read parameter table (TVARVC) records in an internal lt_tvarvc table using following
criteria:
NAME = ‘ZSD_NFE_DSAIENT_HSAIENT*’
If found (sy-subrc = 0)
(START – 09_UAT: Changes V2.0 – 29th Jun 2022)
*Get time zone from NF Header Country and Plant Region from Item
*Premises: Plant of all items the same or at least on the same BR Region (legal req).
IF is_header-land1 IS NOT INITIAL AND it_nflin[1]-werks IS NOT INITIAL.
CALL FUNCTION j_1bread_branch_data
EXPORTING
BRANCH = is_header-branch
BUKRS = is_header-bukrs
IMPORTING
ADDRESS = ls_address

*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

Version 21.0 152908-0562-20232 Page 50 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

TIMEZONE = lv_timezone

*2nd step: convert Local System Date/Time to Timestamp format


IF sy-subrc IS NOT INITIAL OR lv_timezone IS INITIAL.
lv_timezone = ‘BRAZIL’
ENDIF
CALL FUNCTION ib_convert_into_timestamp
EXPORTING
I_DATLO = sy-datlo
I_TIMLO = sy-timlo
I_TZONE = sy-zonlo
IMPORTING
E_TIMESTAMP = lv_timestamp

*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

IF sy-subrc IS NOT INITIAL OR lv_datlo IS INITIAL.


lv_datlo = sy-datlo
lv_timlo = sy-timlo
ENDIF
ENDIF
(END – 09_UAT: Changes V2.0 – 29th Jun 2022)

Read lt_tvarvc into ls_tvarvc using


NAME = ls_name

If found (sy-subrc = 0) and ls_tvarvc-low has the format “HH:MM:SS”

Version 21.0 152908-0562-20232 Page 51 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

(START – 09_UAT: Changes V2.0 – 29th Jun 2022)

Sum up ls_tvarv-low to is_header-credat and is_header-cretim using function module


C14B_ADD_TIME.
Sum up ls_tvarv-low to lv_datlo and lv_timlo using function module
C14B_ADD_TIME.

Update ES_HEADER-HSAIENT with E_ENDTIME


ES_HEADER-DSAIENT with E_ENDDATE

Else (if not using ls_name)


Read lt_tvarvc into ls_tvarvc using
NAME = ‘ZSD_NFE_DSAIENT_HSAIENT’
If found (sy-subrc = 0) and ls_tvarvc-low has the format “HH:MM:SS”
Sum up ls_tvarv-low to is_header-credat and is_header-cretim using function module
C14B_ADD_TIME.

Sum up ls_tvarv-low to lv_datlo and lv_timlo using function module

C14B_ADD_TIME.
Update ES_HEADER-HSAIENT with E_ENDTIME
ES_HEADER-DSAIENT with E_ENDDATE

Version 21.0 152908-0562-20232 Page 52 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Endif
Endif (if not using ls_name)

Endif (if not using ls_name)


Endif (TVARVC registers not found)
ELSE
Update ES_HEADER-HSAIENT with lv_timlo
ES_HEADER-DSAIENT with lv_datlo
ENDIF
(END – 09_UAT: Changes V2.0 – 29th Jun 2022)

(if no register – including the “default” - is found, no delta time will be added)

(Examples – not necessarily valid)

[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.

Version 21.0 152908-0562-20232 Page 53 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Call Function J_1B_NF_NUMBER_CONDENSE with the following parameters:


Exporting:
NF_NUMBER = IN_DOC-NFNUM
SERIES = IN_DOC-SERIES
SUBSERIES = IN_DOC-SUBSERIES
NF_NUMBER9 = IN_DOC-NFENUM
Importing:
REF_NUMBER = LF_REF_NUMBER
*Accounting Open Items
If J_1BNFLIN-REFKEY is not in blank, select table BSID where:
BUKRS = IN_DOC-BUKRS
KUNNR = J_1BNFNAD-PARID
GJAHR = IN_DOC-DOCDAT(4)
XBLNR = Return of function J_1B_NF_NUMBER_CONDENSE (REF_NUMBER)
VBELN = J_1BNFLIN-REFKEY
Get the values of BUKRS, KUNNR, UMSKS, UMSKZ, AUGDT, AUGBL, ZUONR, GJAHR,
BELNR, BUZEI, SHKZG, DMBTR, ZFBDT, ZBD1T, REBZG.
*Accounting Cleared Items
If J_1BNFLIN-REFKEY is not in blank, select table BSAD where:
BUKRS = IN_DOC-BUKRS
KUNNR = J_1BNFNAD-PARID
GJAHR = IN_DOC-DOCDAT(4)
XBLNR = Return of function J_1B_NF_NUMBER_CONDENSE (REF_NUMBER)
VBELN = J_1BNFLIN-REFKEY
Get the values of BUKRS, KUNNR, UMSKS, UMSKZ, AUGDT, AUGBL, ZUONR, GJAHR,
BELNR, BUZEI, SHKZG, DMBTR, ZFBDT, ZBD1T, REBZG.
The processing logic for instalments is explained below:
Clear the variable LF_NDUP.
Loop the custom table LT_BSID.
To each record:
Increase the LF-NDUP (add 1 to LF-NDUP)
Clear the custom structures LW_E_FAEDE and LS_FAEDE
Fill the custom structure LS_FAEDE with the corresponding LT_BSID fields, and field
KOART with “D”:
LS_FAEDE-SHKZG = BSID-SHKZG
LS_FAEDE-KOART = “D”
LS_FAEDE-ZFBDT = BSID-ZFBDT
LS_FAEDE-ZBD1T = BSID-ZBD1T
LS_FAEDE-REBZG = BSID-REBZG

Call the function module DETERMINE_DUE_DATE sending the structure LS_FAEDE.


Receive the values into LW_E_FAEDE.
OUT_COBRANCA-DOCNUM = IN_DOC-DOCNUM
OUT_COBRANCA-NDUP_NEW = LF_NDUP
OUT_COBRANCA-DVENC = LW_E_FAEDE-NETDT
OUT_COBRANCA-VDUP = BSID-DMBTR

OUT_HEADER-VORIG = OUT_HEADER-VORIG + OUT_COBRANCA-VDUP


OUT_HEADER-NFAT = IN_DOC-NFENUM

If OUT_HEADER-VORIG is in blank, move the value of IN_DOC-NFTOT.


OUT_HEADER-VDESC = “0.00”
OUT_HEADER-VLIQ = (OUT_HEADER-VORIG – OUT_HEADER-VDESC)
To fill the Payment tags using the new BADI, the documents are not yet saved on
database (Billing, NF Doc, Accounting Doc). Due to that, it’s necessary to previously
export to memory an image of the accounting document (containing the customer line
items related to payment - if they exist) and import it during NF BADI processing. With
that strategy, data will be saved on new SAP Table for Payment instalments
(“Tradenotes”) J_1BNFTRADENOTES.

(START – 05_CT1: Changes V2.0 – 26th May 2022)

Version 21.0 152908-0562-20232 Page 54 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Layout according to SEFAZ Technical Note 2011.004 tags as shown below:


Layout according to SEFAZ Technical Note 2016.002 tags as shown below:

(END – 05_CT1: Changes V2.0 – 26th May 2022)

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

Function Module that generates accounting info


(RV_ACCOUNTING_DOCUMENT_CREATE) clears all internal structures before ending
and then enters in J_1B Localization logic.
The idea will be, inside RV_ACCOUNTING_DOCUMENT_CREATE Function Module, export
the main accounting line item structures to a memory ID position that will be available to
NF-e BADI read for filling ET_TRADENOTES.

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.

a) Create new logic on SAP Enhancement (CMOD) SDVFX008, Function-exit


EXIT_SAPLV60B_008.

SELECT <bukrs values> FROM tvarvc WHERE


Name = ‘ZSD_NFE_TRDNT_MEMID_BUKRS’

CHECK IF cvbrk-bukrs IS ON <bukrs values>

key = xaccit-awkeyawref

Version 21.0 152908-0562-20232 Page 55 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

fxaccit = “z_fxaccit_” // key


fxacccr = “z_fxacccr_” // key
EXPORT TO MEMORY ID structures defined on variables fXACCCR and fXACCIT

(START – 05_CT1: Changes V2.0 – 26th May 2022)

b) Create new implementation on BADI J_1BNF_ADD_DATA, Method ADD_DATA, changing


ES_HEADER parameter:

Version 21.0 152908-0562-20232 Page 56 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Include Logic as stated below:

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
(START – 13_UAT: Changes V2.0 – 25th Jul 2022)
(START – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)
* Check if it’s NOT a NF “Complementar” AND NOT a Return Inbound NFe
CHECK is_header-doctyp NE ‘2’ AND is_header-doctyp NE ‘6’
* Select valid NF Doctypes as per parameter table
CLEAR: lt_tvarvc_doctyp
SELECT <doctyp> FROM tvarvc INTO lt_tvarvc_doctyp WHERE
Name = ‘ZSD_NFE_ADDDT_PAYINFO_NFDOCTYP’
Low IS NOT INITIAL
IF sy-subrc IS NOT INITIAL OR lt_tvarvc_doctyp IS INITIAL
* In case no parameters are found, set at least a fixed “default” (Doctypes ‘1’ and ‘2’)
Insert two records on lt_tvarvc_doctyp with
LOW = ‘1’ AND
LOW = ‘2’
ENDIF
IF is_header-doctyp IN lt_tvarvc_doctyp-low
(END – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)
(END – 13_UAT: Changes V2.0 – 25th Jul 2022)

* Check BR Company Code active or not


SELECT <bukrs values> FROM tvarvc WHERE
Name = ‘ZSD_NFE_TRADENOTES_BUKRS’

CHECK IF is_vbrk-bukrs IS ON <bukrs values>

IF et_payment IS NOT INITIAL


COPY et_payment TO lt_payment
READ lt_payment USING
vpag IS NOT INITIAL AND
tpag ≠ ‘90’.

Version 21.0 152908-0562-20232 Page 57 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

IF iv_applic = ‘BI’ and sy-subrc IS INITIAL


** Billing application and payment value found
* Fill tags with correspondent values
es_header-nfat = is_vbrk-vbeln
es_header-liq = et_payment-vpag
CLEAR lv_desc
COPY it_nflin TO lt_nflin
LOOP lt_nflin INTO ls_nflin WHERE lt_nflin-itmtyp = ‘01’ OR lt_nflin-itmtyp = ‘Z1’ OR
lt_nflin-itmtyp = ‘Z2’ OR lt_nflin-itmtyp = ‘62’ OR lt_nflin-itmtyp = ‘41’.
lv_desc = lv_desc + ABS(ls_nflin-nfdis) + ABS(ls_nflin-vicmsdeson)
ENDLOOP
es_header-vdesc = lv_disc
es_header-vorig = et_payment-vpag + lv_disc.
ENDIF *** Billing application
ENDIF
(END – 05_CT1: Changes V2.0 – 26th May 2022)

cb) On Create new implementation on BADI J_1BNF_ADD_DATA, Method ADD_DATA,


changeing ET_TRADENOTES parameter:

Include Logic as stated below:

Version 21.0 152908-0562-20232 Page 58 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

(START – 05_CT1: Changes V2.0 – 26th May 2022)

* Check if it’s a new NF issuance (not booking)


CHECK is_header-form IS NOT INITIAL

* Check BR Company Code active or not


SELECT <bukrs values> FROM tvarvc WHERE
Name = ‘ZSD_NFE_TRADENOTES_BUKRS’

CHECK IF is_vbrk-bukrs IS ON <bukrs values>

(END – 05_CT1: Changes V2.0 – 26th May 2022)

IF iv_applic = ‘BI’ *** Billing application


* Try to Import Memory ID’s related to account structures FXACCCR and FXACCIT
key = it_nflin[1]-refkey
fxacccr = “z_fxacccr_” // key
fxacccr = “z_fxacccr_” // key
CLEAR lt_fxacccr lt_fxaccit
IMPORT MEMORY ID
fxacccr INTO lt_fxacccr
fxaccit INTO lt_fxaccit

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)

MOVE CORRESPONDING ls_fxaccit INTO ls_cust


READ lt_fxacccr INTO ls_fxacccr WHERE
awtyp = ls_fxaccit-awtyp
awref = ls_fxaccit-awref
posnr = ls_fxaccit-posnr
IF sy-subrc IS INITIAL

Version 21.0 152908-0562-20232 Page 59 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

MOVE CORRESPONDING ls_fxacccr INTO ls_cust


APPEND ls_cust INTO lt_cust_lines
ENDIF
ENDIF
ENDLOOP
IF lt_cust_lines IS NOT INITIAL
CLEAR lv_counter
LOOP lt_cust_lines INTO ls_cust_line
CLEAR ls_tradenotes
ls_tradenotes-mandt = is_header-mandt
ls_tradenotes-docnum = is_header-docnum
ls_tradenotes-counter = lv_counter + 1
(START – 05_CT1: Changes V2.0 – 26th May 2022)

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)

(END – 05_CT1: Changes V2.0 – 26th May 2022)


IF is_header-id_dest = ‘3’
* Export NF-e: Get value in BRL
ls_tradenotes-vdup = ls_cust_line-absbt
ELSE
ls_tradenotes-vdup = ls_cust_line-wrbtr
ENDIF
CALL FUNCTION j_1bnf_determine_duedate
EXPORTING
iv_zterm = ls_cust_line-zterm
iv_credat = sy-datum
iv_pstdat = is_header-pstdat
iv_docdat = is_header-docdat
cv_zfbdt = ls_cust_line-zfbdt
CHANGING
ls_tradenotes-dvenc = ev_duedate

APPEND ls_tradenotes INTO et_tradenotes


ENDLOOP
ENDIF
ENDIF
ENDIF *** Billing application
(START – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)
ENDIF *** IN lt_tvarvc_doctyp-low
(END – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)

3.9[3.10] BADI Requirement 10: Net / Weight / Volume tags

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.

Version 21.0 152908-0562-20232 Page 60 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

* Check if it’s a new NF issuance (not booking)


CHECK is_header-form IS NOT INITIAL
* Check if it’s not a MANUAL NF issuance
CHECK is_header-manual IS INITIAL
* Check if it’s a Normal or Return NF Doc type
CHECK is_header-doctyp = ‘1’ or is_header-doctyp = ‘6’
* Check if it’s a Billing or STO related NF (Business Place)
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
CHECK iv_applic = ‘BI’ OR is_header-partyp = ‘B’
CHECK iv_applic = ‘BI’ OR (is_header-partyp = ‘B’ AND iv_applic = ‘MD’)

(END – 07_UAT: Changes V2.0 – 29th Jun 2022)

SELECT <bukrs values> FROM tvarvc WHERE


Name = ‘ZSD_NFE_DLV_WEIGHTS_BUKRS’
CHECK is_header-bukrs IS ON <bukrs values>

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

Version 21.0 152908-0562-20232 Page 61 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

lv_delivery = is_mkpf-le_vbeln
ENDIF
ENDIF

CHECK lv_delivery IS NOT INITIAL


* Now the related delivery was found
SELECT * FROM likp INTO ls_likp WHERE
vbeln = lv_delivery
IF sy-subrc = 0
SELECT <lfart values> FROM tvarvc WHERE
Name = ‘ZSD_NFE_DLV_WEIGHTS_NOLFART’
CHECK ls_likp-lfart NOT ON <lfart values>
* Delivery type is NOT on the exclusion list: apply rule
CLEAR lt_vbfa
(START – 24_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
SELECT * FROM vbfa INTO lt_vbfa WHERE
vbelv = lv_delivery
vbtyp_n = ‘X’
vbtyp_v = ls_likp-vbtyp
IF sy-subrc = 0 AND lt_vbfa IS NOT INITIAL
(END – 24_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
* Read Delivery Header weights
IF ls_likp-gewei <>≠ is_header-gewei
(Convert ls_likp-brgew to lv_brgew by unit in is_header-gewei)
(Convert ls_likp-ntgew to lv_ntgew by unit in is_header-gewei)
lv_gewei = ls_header-gewei
ELSE
lv_brgew = ls_likp-brgew
lv_ntgew = ls_likp-ntgew
ENDIF
(START – 24_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
ENDIF
(END – 24_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
* Check none of the Delivery weights is null
IF lv_brgew IS NOT INITIAL AND lv_ntgew IS NOT INITIAL
* Adjust NF header weight fields for Billing or STO cases
IF iv_applic = ‘BI’
(SAPLJ1BG)WNFDOC-brgew = lv_brgew
(SAPLJ1BG)WNFDOC-ntgew = lv_ntgew
ELSE
(SAPLJ1BF)WA_NF_DOC-brgew = lv_brgew
(SAPLJ1BF)WA_NF_DOC-ntgew = lv_ntgew
ENDIF
CLEAR: ls_transvol
IF et_transvol IS INITIAL
* Premise: ET_TRANSVOL is empty
ls_transvol-docnum = is_header-docnum
ls_transvol-counter = ‘0001’
(START – 24_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
ls_transvol-qvol = ls_likp-anzpk
IF ls_likp-anzpk IS NOT INITIAL
ls_transvol-qvol = ls_likp-anzpk
ELSE
ls_transvol-qvol = is_header-anzpk
ENDIF
(START – 24_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
ls_transvol-esp = is_header-shpunt
ls_transvol-pesol = lv_ntgew
ls_transvol-pesob = lv_brgew
APPEND ls_transvol INTO et_transvol
ELSE
* Only update if JUST ONE line already exists
DESCRIBE TABLE et_transvol FIELD LINES ld_lines
IF ld_lines =1
READ et_transvol INTO ls_transvol
IF ls_likp-anzpk IS NOT INITIAL
ls_transvol-qvol = ls_likp-anzpk

Version 21.0 152908-0562-20232 Page 62 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

3.10[3.11] BADI Requirement 11: Freight mode tag

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”).

[3.12] BADI Requirement 12: Payment tags + Grupo Fatura::

If ch_payment is in blank, select table TVARVC where TVARVC-SIGN = “I”, TVARVC_OPTI


= “EQ” and TVARVC-NAME = Z_NFPAYMENT_NFTYPE. Get the values of TVARVC-LOW
and TVARVC-HIGH.
If in_doc-nftype is found in TVARVC-LOW, fill T_PAG with TVARVC-HIGH and V_PAG with
J_1BNFDOC-NFTOT.
Select table TVARVC where TVARVC-SIGN = “I”, TVARVC_OPTI = “EQ” and TVARVC-
NAME = Z_NFPAYMENT_TPAG90. Get the values of TVARVC-LOW.
If in_doc-nftype is not found in TVARVC-LOW, fill T_PAG with TVARVC-LOW and clear
V_PAG.

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)

Version 21.0 152908-0562-20232 Page 63 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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”).

(END – 03_CT1: Changes V2.0 – 26th May 2022)

Implementation Logic

(START – 03_CT1: Changes V2.0 – 26th May 2022)


 Add logic on new implementation on BADI J_1BNF_ADD_DATA, Method
ADD_DATA_J1B1N, changing ET_PAYMENT parameter:

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 BR Company Code active or not
SELECT <bukrs values> FROM tvarvc WHERE
Name = ‘ZSD_NFE_ADDDT_PAYINFO_BUKRS’

CHECK is_header-bukrs IS ON <bukrs values>


* Check if it’s a new NF issuance (not booking)
CHECK is_header-form IS NOT INITIAL
* ET_PAYMENT contents are not provided by SAP. So, in case user has manually provided
* that info in J1B1N fields, then do not provide any data automatically. If not, provide a default
* record
CHECK et_payment IS INITIAL
(START – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)
* Check NF Type is for Adjust or Return: if yes, set tpag to ‘90’
* Check valid NF DocTypes on parameters: if NOT VALID ones, set tpag to ‘90’
(END – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)
(START – 07_UAT: Changes V2.0 – 29th Jun 2022)
IF is_header-doctyp = ‘2’ OR is_header-doctyp = ‘6’
(START – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)
IF is_header-doctyp = ‘2’ OR is_header-doctyp = ‘6’ OR (is_header-doctyp = ‘1’ AND is_header-manual IS
NOT INITIAL AND is_header-direct = ‘1’) OR (is_header-doctyp = ‘1’ AND is_header-manual IS NOT
INITIAL AND is_header-direct = ‘2’ AND is_header-zterm IS INITIAL)
* Select valid NF Doctypes as per parameter table
CLEAR: lt_tvarvc_doctyp
SELECT <doctyp> FROM tvarvc INTO lt_tvarvc_doctyp WHERE
Name = ‘ZSD_NFE_ADDDT_PAYINFO_NFDOCTYP’
Low IS NOT INITIAL
IF sy-subrc IS NOT INITIAL OR lt_tvarvc_doctyp IS INITIAL
* In case no parameters are found, set at least a fixed “default” (Doctypes ‘1’ and ‘2’)
Insert two records on lt_tvarvc_doctyp with
LOW = ‘1’ AND
LOW = ‘2’
ENDIF
* If current document is NOT a valid DocType OR is a valid one but manually created with some
* other specific conditions, set as ‘90’
IF is_header-doctyp NOT IN lt_tvarvc_doctyp-low OR (is_header-doctyp = ‘1’ AND is_header-manual IS
NOT INITIAL AND is_header-direct = ‘1’) OR (is_header-doctyp = ‘1’ AND is_header-manual IS NOT
INITIAL AND is_header-direct = ‘2’ AND is_header-zterm IS INITIAL)
(END – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)
(END – 07_UAT: Changes V2.0 – 29th Jun 2022)

Version 21.0 152908-0562-20232 Page 64 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

* Check NF Type is for Adjust or Return: if yes, set tpag to ‘90’

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)

 Create new implementation on BADI J_1BNF_ADD_DATA, Method


ADD_DATA, changing ET_PAYMENT parameter:

Include Logic as stated below:

Version 21.0 152908-0562-20232 Page 65 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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 BR Company Code active or not


SELECT <bukrs values> FROM tvarvc WHERE
Name = ‘ZSD_NFE_ADDDT_PAYINFO_BUKRS’

CHECK is_header-bukrs IS ON <bukrs values>


(START – 03_CT1: Changes V2.0 – 26th May 2022)
* ET_PAYMENT contents are not provided by SAP. So, in case any previous record exists, it’s
* considered a duplicated entry caused by navigation causes (mainly on MIRO, when changing
* NF Type). With that said, ALL previous existing entries will be DELETED before entering the
* logic (for a review).
* OBS: In case SAP reviews that behavior, the approach above must be reconsidered

CLEAR: et_payment

(END – 03_CT1: Changes V2.0 – 26th May 2022)


(START – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)
* Check NF Type is for Adjust or Return: if yes, set tpag to ‘90’
* Check valid NF DocTypes on parameters: if NOT VALID ones, set tpag to ‘90’
* Select valid NF Doctypes as per parameter table
CLEAR: lt_tvarvc_doctyp
SELECT <doctyp> FROM tvarvc INTO lt_tvarvc_doctyp WHERE
Name = ‘ZSD_NFE_ADDDT_PAYINFO_NFDOCTYP’
Low IS NOT INITIAL
* If current document is NOT a valid DocType, set as ‘90’
IF is_header-doctyp = ‘2’ OR is_header-doctyp = ‘6’
CLEAR: ls_payment
ls_payment-counter = 0001
ls_payment-tpag = ‘90’
ls_payment-vpag = <empty>
APPENDMODIFY et_payment with ls_payment
ELSE
IF sy-subrc IS NOT INITIAL OR lt_tvarvc_doctyp IS INITIAL
* In case no parameters are found, set at least a fixed “default” (Doctypes ‘1’ and ‘2’)
Insert two records on lt_tvarvc_doctyp with
LOW = ‘1’ AND
LOW = ‘2’
ENDIF
IF is_header-doctyp NOT IN lt_tvarvc_doctyp-low
CLEAR: ls_payment
ls_payment-counter = 0001
ls_payment-tpag = ‘90’
ls_payment-vpag = <empty>
APPENDMODIFY et_payment with ls_payment
ELSE
(END – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)
* Normal NF, first check if it´s a Billing application call
IF iv_applic = ‘BI’ *** Billing application

Version 21.0 152908-0562-20232 Page 66 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

* 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 is_vbrk-fkart IS ON <fkart values>


* Try to Import Memory ID’s related to account structures FXACCCR and FXACCIT
key = it_nflin[1]-refkey
fxacccr = “z_fxacccr_” // key
fxacccr = “z_fxacccr_” // key
CLEAR lt_fxacccr lt_fxaccit
IMPORT MEMORY ID
fxacccr INTO lt_fxacccr
fxaccit INTO lt_fxaccit

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)

READ lt_fxacccr INTO ls_fxacccr WHERE


awtyp = ls_fxaccit-awtyp
awref = ls_fxaccit-awref
posnr = ls_fxaccit-posnr
IF sy-subrc IS INITIAL

IF is_header-id_dest = ‘3’
* For Export, value in BRL is in FXACCIT structure

Version 21.0 152908-0562-20232 Page 67 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

lv_cust_pay = lv_cust_pay + ABS[ls_fxaccit-absbt]

ELSE

lv_cust_pay = lv_cust_pay + ABS[ls_fxacccr-wrbtr]


ENDIF
ENDIF
ENDIF
ENDLOOP
IF lv_cust_pay > 0.
CLEAR: ls_payment
IF lv_cust_pay >= is_header-nftot
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 = 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

Version 21.0 152908-0562-20232 Page 68 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

variable using following criteria:


NAME = lv_name

IF FOUND (sy-subrc = 0) and ls_tvarvc-low IS NOT INITIAL


DATA: lv_tpag LIKE j_1bnfe_tpag
lv_tpag = ls_tvarvc-low(2)
* Value in tvarvc-low must be compatible with domain of tPag values: otherwise set it as ‘99’
(START – 02_CT1: Changes V2.0 – 18th May 2022)
* First check existence of new SAP table J_1BPAG for Payment Methods
SELECT * FROM tadir WHERE
PGMID = ‘R3TR’
OBJECT = ‘TABL’
OBJ_NAME = ‘J_1BPAG’
IF sy-subrc IS INITIAL
SELECT * FROM j_1bpag INTO lt_j1bpag
IF sy-subrc IS INITIAL AND lt_j1bpag IS NOT INITIAL
READ lt_j1bpag USING lv_pag
IF sy-subrc IS NOT INITIAL
* If unsuccessful, keep ‘99’ record already defined on initial steps and finish
EXIT
ENDIF
ELSE
* Table J_1BPAG not exists yet on environment: uses former Domain values
CALL FUNCTION ‘FM_DOMAINVALUE_CHECK’
domname = ‘J_1BNFE_TPAG’
domvalue = lv_tpag
IF sy-subrc IS NOT INITIAL
* If unsuccessful, keep ‘99’ record already defined on initial steps and finish
EXIT
ENDIF
ENDIF
IF sy-subrc IS INITIAL
(END – 02_CT1: Changes V2.0 – 18th May 2022)
CLEAR: ls_payment
IF lv_cust_pay >= is_header-nftot.
ls_payment-counter = 0001
ls_payment-tpag = lv_tpag
ls_payment-vpag = is_header-nftot
MODIFY et_payment FROMwith ls_payment
ELSE
ls_payment-counter = 0001
ls_payment-tpag = lv_tpag
ls_payment-vpag = lv_cust_pay
MODIFY et_payment FROMwith ls_payment
ENDIF
(START – 02_CT1: Changes V2.0 – 18th May 2022)
ELSE
ls_payment-counter = 0001
ls_payment-tpag = ‘99’
ls_payment-vpag = is_header-nftot
MODIFY et_payment FROMwith ls_payment
(END – 02_CT1: Changes V2.0 – 18th May 2022)

ENDIF
ENDIF
(START – 02_CT1: Changes V2.0 – 18th May 2022)
ELSE
* Payment Method NOT found on Payer’s Customer Master

Version 21.0 152908-0562-20232 Page 69 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

ELSE *** vbrk-fkart not valid


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
ELSE *** NOT Billing application
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
ENDIF
(START – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)
ENDIF ** lt_tvarvc_doctyp IS NOT INITIAL
(END – 35_RTM: RITM000002278935 Changes V4.0 – 01st Apr 2024)

(START – 05_CT1: Changes V2.0 – 30th May 2022)

Version 21.0 152908-0562-20232 Page 70 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

** Fill mandatory tags on header related to summarize invoice values

IF et_payment IS NOT INITIAL


COPY et_payment TO lt_payment
READ lt_payment USING
vpag IS NOT INITIAL AND
tpag ≠ ‘90’.
IF iv_applic = ‘BI’ and sy-subrc IS INITIAL
** Billing application and payment value found
* Fill tags with correspondent values
es_header-nfat = is_vbrk-vbeln
es_header-liq = et_payment-vpag
CLEAR lv_desc
COPY it_nflin TO lt_nflin
LOOP lt_nflin INTO ls_nflin WHERE lt_nflin-itmtyp = ‘01’ OR lt_nflin-itmtyp = ‘Z1’ OR
lt_nflin-itmtyp = ‘Z2’ OR lt_nflin-itmtyp = ‘62’ OR lt_nflin-itmtyp = ‘41’.
lv_desc = lv_desc + ABS(ls_nflin-nfdis) + ABS(ls_nflin-vicmsdeson)
ENDLOOP
es_header-vdesc = lv_disc
es_header-vorig = et_payment-vpag + lv_disc.
ENDIF *** Billing application
ENDIF
(END – 05_CT1: Changes V2.0 – 30th May 2022)

3.11[3.13] BADI Requirement 13: Indpres (Presence Indicator) tag

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.

Version 21.0 152908-0562-20232 Page 71 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

* Check if it’s a new NF issuance (not booking)


CHECK is_header-form IS NOT INITIAL

* Check BR Company Code active or not


SELECT <bukrs values> FROM tvarvc WHERE
Name = ‘ZSD_NFE_PRES_INDIC_BUKRS’

CHECK is_header-bukrs IS ON <bukrs values>

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

 Method FILL_ITEM to fill Additional NF-e Item Fields – NFe BADI:

Version 21.0 152908-0562-20232 Page 72 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Move the content from IN_XML_ITEM to OUT_ITEM.

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.

Select J_1BNFLIN where DOCNUM = IN_LIN-DOCNUM, ITMNUM = IN_LIN-ITMNUM and REFTYP =


“BI”. Get the values of REFKEY and REFITM.

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.

Create new implementation on BADI J_1BNF_ADD_DATA, Method ADD_DATA, changing


ET_ITEM parameter:

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.

* Check if it’s a new NF issuance (not booking)


CHECK is_header-form IS NOT INITIAL

Version 21.0 152908-0562-20232 Page 73 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

* Check NF generate from a Billing document


CHECK iv_applic EQ ‘BI’
* Check BR Company Code active or not
COPY it_vbrp TO lt_vbrp
LOOP ON it_nflin INTO ls_nflin
* (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 it_vbrp INTO ls_vbrp USING
* Read Billing item by using NF item info
vbeln = ls-nflin-refkey
posnr = ls_nflin-refitm
ELSE
* If any error, use only item to read other structure (as by above FACT)
SORT it_vbrp BY vbeln posnr ASCENDING
READ TABLE it_vbrp INTO ls_vbrp WITH KEY
POSNR = ls_nflin-refitm
ENDIF
IF sy-subrc IS INITIAL
CLEAR: ls_item
COPY et_item TO lt_item
SORT lt_item BY itmnum ASCENDING
READ lt_item INTO ls_item USING ls_nflin-itmnum
* Read corresponding NF item additional info structure
IF sy-subrc IS INITIAL and ls_item IS NOT INITIAL
* Use Order / Itm number linked to Billing item to feed tags XPED and NITEMPED
ls_item-xped = ls_vbrp-aubel
ls_item-nitemped = ls_vbrp-aupos
MODIFY et_item FROMUSING ls_item
ENDIF
ENDIF
* Do that for all NF items
ENDLOOP

3.13[3.15] BADI Requirement 15: GTIN tags:

Check if out_item-cean and out_item-ceantrib are initial.


Select 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, 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”.

(START – 04_CT1: Changes V2.0 – 18th May 2022)

Version 21.0 152908-0562-20232 Page 74 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Create new implementation on BADI J_1BNF_ADD_DATA, Method ADD_DATA, changing


ET_ITEM parameter:
Create new implementation on BADI J_1BNF_ADD_DATA, both Methods ADD_DATA and
ADD_DATA_J1B1N, changing ET_ITEM parameter:

(END – 04_CT1: Changes V2.0 – 18th May 2022)

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”).

(END – 04_CT1: Changes V2.0 – 18th May 2022)

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.

(START – 03_CT1: Changes V2.0 – 26th May 2022)

 Add logic on new implementation on BADI J_1BNF_ADD_DATA, Method


ADD_DATA_J1B1N, changing ET_ITEM parameter:

Version 21.0 152908-0562-20232 Page 75 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

* Check if it’s a new NF issuance (not booking)


CHECK is_header-form IS NOT INITIAL
CLEAR: ls_item
* Check default text to be filled on NF-e XML tag in case GTIN code does not exist
SELECT * FROM tvarvc INTO ls_tvarvc WHERE
Name = ‘ZSD_NFE_GTIN_NULLTXT’

* Avoid issues in case variable not filled


IF ls_tvarvc-low IS INITIAL
ls_tvarvc-low = “SEM GTIN”
ENDIF
* Check all NF items and fill blank tags
LOOP ON et_item INTO ls_item
IF ls_item-cean IS INITIAL
ls_item-cean = ls_tvarvc-low
ENDIF
IF ls_item-cean_trib IS INITIAL
ls_item-cean_trib = ls_tvarvc-low
ENDIF
MODIFY et_item FROMUSING ls_item
ENDLOOP
(END – 03_CT1: Changes V2.0 – 26th May 2022)

 Create new implementation on BADI J_1BNF_ADD_DATA, Method


ADD_DATA, changing ET_ITEM parameter:

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
(START – 04_CT1: Changes V2.0 – 18th May 2022)
* Check NF generate from a Billing document
CHECK iv_applic EQ ‘BI’
(END – 04_CT1: Changes V2.0 – 18th May 2022)
CLEAR: ls_item
* Check default text to be filled on NF-e XML tag in case GTIN code does not exist
SELECT * FROM tvarvc INTO ls_tvarvc WHERE
Name = ‘ZSD_NFE_GTIN_NULLTXT’

* Avoid issues in case variable not filled


IF ls_tvarvc-low IS INITIAL
ls_tvarvc-low = “SEM GTIN”
ENDIF
* Check all NF items and fill blank tags
LOOP ON et_item INTO ls_item
IF ls_item-cean IS INITIAL
ls_item-cean = ls_tvarvc-low
ENDIF
IF ls_item-cean_trib IS INITIAL
ls_item-cean_trib = ls_tvarvc-low
ENDIF
MODIFY et_item FROMUSING ls_item
ENDLOOP

Version 21.0 152908-0562-20232 Page 76 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

3.14[3.16] BADI Requirement 16: Fuel tags (CIDE)

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.

* Check if it’s a new NF issuance (not booking)


CHECK is_header-form IS NOT INITIAL
* Check NF generated from a Billing document
CHECK iv_applic EQ ‘BI’
CLEAR: ls_item
* Check BR Company Code active or not
SELECT * FROM tvarvc INTO ls_tvarvc WHERE
Name = ‘ZSD_NFE_XMLTAG_FUEL_CIDE’

* 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)

(END – 26_INC: Changes V4.0 – 08th Dec 2022)


* Loop on fuel items only
COPY it_nflin TO lt_nflin
COPY it_nfstx TO lt_nfstx FOR ALL ENTRIES WHERE it_nfstx-taxtyp = ls_tvarvc-low
SORT lt_nfstx BY docnum itmnum taxtyp ASCENDING
LOOP ON et_fuel INTO ls_fuel
READ lt_nflin INTO ls_nflin USING
DOCNUM = et_fuel-docnum
ITMNUM = et_fuel-itmnum
READ lt_nfstx INTO ls_nfstx USING
DOCNUM = et_fuel-docnum
ITMNUM = et_fuel-itmnum
TAXTYP = ls_tvarvc-low
IF sy-subrc IS INITIAL
* Premise: CIDE values are already on the same UoM of the NF item
ls_fuel-qbcprod = ls_nflin-menge_trib
ls_fuel-vAliqProd = ls_nfstx-rate

Version 21.0 152908-0562-20232 Page 77 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

ls_fuel-vCIDE = ls_nfstx-taxval
(START – 26_INC: Changes V4.0 – 08th Dec 2022)

(END – 26_INC: Changes V4.0 – 08th Dec 2022)


MODIFY et_fuel FROMUSING ls_fuel
ENDLOOP

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.

Select J_1BNFLIN where DOCNUM = IN_LIN-DOCNUM and ITMNUM = IN_LIN-ITMNUM.

3.15[3.17] BADI Requirement 17: ICMS-ST Tags for “ICMS Repasse”

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.

Version 21.0 152908-0562-20232 Page 78 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Version 21.0 152908-0562-20232 Page 79 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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’
* Read condition types related to each tag
SELECT * FROM tvarvc INTO lt_tvarvc WHERE
Name = ‘ZSD_NFE_XMLTAG_VBCSTRET’
Name = ‘ZSD_NFE_XMLTAG_PST’
Name = ‘ZSD_NFE_XMLTAG_VICMSSUBSTITUTO’
Name = ‘ZSD_NFE_XMLTAG_VICMSSTRET’
Name = ‘ZSD_NFE_XMLTAG_VBCSTDEST’
Name = ‘ZSD_NFE_XMLTAG_VICMSSTDEST’

* Copy internal structures to keep integrity


COPY it_nflin TO lt_nflin
(START – 18_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
CLEAR ls_nflin
DATA: BEGIN OF lt_wkomk OCCURS 0. " Pricing Header
INCLUDE STRUCTURE komk.
DATA: END OF lt_wkomk.

Version 21.0 152908-0562-20232 Page 80 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

(END – 18_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)


COPY (saplj1bg)wkomv[] INTO lt_wkomv
SORT lt_wkomv BY knumv kposn kschl
DELETE lt_wkomv ENTRIES WHERE
kschl ≠ <entries on lt_tvarvc-low>

(START – 18_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)


DELETE lt_wkomv ENTRIES WHERE
kschl <> <entries on lt_tvarvc-low>
* Delete pricing entries for all other Billing docs that can be collective created
COPY (saplj1bg)wkomk[] INTO lt_wkomk
READ lt_wkomk INTO ls_wkomk USING
BELNR = lt_vbrp[1]-vbeln
* lt_vbrp is loaded just with Billing items related to NFe being processed (in case a collective Billing)
DELETE lt_wkomv ENTRIES WHERE
knumv ≠ ls_wkomk-knumv

(END – 18_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)


IF sy-subrc IS INITIAL AND lt_wkomv IS NOT INITIAL AND lt_tvarvc IS NOT INITIAL
* OK> Desired pricing conditions were found for the (some) NF items
* Loop on all NF items to check each one and fill values on tags, if applicable
LOOP lt_nflin INTO ls_nflin
* Check NF item is “Substituído”: if NOT, end
(START – 18_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
CHECK ls_nflin-taxsit = ‘60’
CALL FUNCTION 'CONVERSION_EXIT_TXSIT_OUTPUT'
EXPORTING
input = ls_nflin-taxsit
IMPORTING
output = lv_taxsit.
CHECK lv_taxsit = ‘60’
(END – 18_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)

COPY lt_tvarvc INTO lt_cpytvarvc


SORT lt_cpytvarvc BY low

COPY lt_wkomv INTO lt_cpywkomv


SORT lt_cpywkomv BY knumv kposn kschl
DELETE lt_cpywkomv ENTRIES WHERE
kposn <>≠ ls_nflin-itmnum
* Now loop on found valid conditions to be moved to tags

Version 21.0 152908-0562-20232 Page 81 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

LOOP lt_cpywkomv INTO ls_cpywkomv


READ TABLE lt_cpytvarvc USING low = ls_cpywkomv-kschl
IF sy-subrc IS INITIAL
lv_field = lt_cpytvarvc-name
lv_field = <lv_field> contents string excluding “ZSD_NFE_XMLTAG_”
* Field name for tag must be as part of TVARV variable name !!
(START – 18_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
et_item-<lv_field> = ls_cpywkomv-kwert
IF ls_cpywkomv-krech = ‘A’
et_item-<lv_field> = ls_cpywkomv-kbetr / 10
ELSEIF ls_cpywkomv-krech = ‘C’
et_item-<lv_field> = (ls_cpywkomv-kwert / ls_nflin-menge) / 100
ENDIF
(END – 18_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
et_item-<lv_field> = ls_cpywkomv-kwert

ENDIF
ENDLOOP
ENDLOOP
ENDIF

3.16[3.18] BADI Requirement 18: NFe Item Additional Info for SD

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:

Version 21.0 152908-0562-20232 Page 82 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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’

Version 21.0 152908-0562-20232 Page 83 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

CHECK is_header-bukrs IS ON <lt_tvarvc-low values>

* 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’

IF sy-subrc IS NOT INITIAL OR lv_maxitmlen > 500 OR lv_maxitmlen IS INITIAL


lv_maxlenitm = 500
ENDIF
SELECT * FROM tvarvc INTO lt_sequence WHERE
Name = ‘ZSD_NFE_CMPLINF_ITMTXTSEQUENCE’

ENDIF

IF sy-subrc IS INITIAL AND lt_itm_sequence IS NOT INITIAL


SORT lt_itm_sequence BY name type numb ASCENDING
CLEAR: lv_itm_appendtextitm
COPY et_item TO lt_item
LOOP AT lt_itm_sequence INTO ls_itm_sequence

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

Version 21.0 152908-0562-20232 Page 84 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

* Found Tax Type(s) related to FCP Tax


LOOP lt_nflin INTO ls_nflin
lv_tabix = sy-tabix
* 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 lt_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_appendtextlv_appendtextitm = ls_item-infadprod
(START – 39_ITC: RITM000002278935 Changes V4.0 – 14th Jun 2024)
CONCATENATE lv_appendtextlv_appendtextitm // “ Base FCP:” // $q01 // “, % FCP:”
// $r01 // “, Valor FCP:” // $s01 INTO lv_appendtextlv_appendtextitm
CONCATENATE lv_appendtextlv_appendtextitm // “Base FCP:” // $q01 // “, % FCP:”
// $r01 // “, Valor FCP:” // $s01 INTO lv_appendtextlv_appendtextitm
(END – 39_ITC: RITM000002278935 Changes V4.0 – 14th Jun 2024)
Where: $q01 = ls_nfstx-BASE
$r01 = ls_nfstx-RATE
$s01 = ls_nfstx-TAXVAL
ls_item-infadprod = lv_appendtextlv_appendtextitm
MODIFY lt_item FROMUSING ls_item USING TABIX = lv_tabix
EXIT (from LOOP lt_tvarvc > go to next it_nflin item)
ENDIF
ENDLOOP
ENDLOOP
ENDIF

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

* Found Tax Type(s) related to FCP Tax

Version 21.0 152908-0562-20232 Page 85 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

LOOP lt_nflin INTO ls_nflin


lv_tabix = sy-tabix
* 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 lt_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_appendtextlv_appendtextitm = ls_item-infadprod
(START – 39_ITC: RITM000002278935 Changes V4.0 – 14th Jun 2024)
CONCATENATE lv_appendtextlv_appendtextitm // “ Base FCP ST:” // $t01 // “, %
FCP ST:” // $u01 // “, Valor FCP ST:” // $v01 INTO lv_appendtextlv_appendtextitm
CONCATENATE lv_appendtextlv_appendtextitm // “Base FCP ST:” // $t01 // “, %
FCP ST:” // $u01 // “, Valor FCP ST:” // $v01 INTO lv_appendtextlv_appendtextitm
(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_appendtextlv_appendtextitm
MODIFY lt_item FROMUSING ls_item USING TABIX = lv_tabix
EXIT (from LOOP lt_tvarvc > go to next it_nflin item)
ENDIF
ENDLOOP
ENDLOOP
ENDIF

(Example FCP and FCP ST)

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

* Found Tax Type(s) related to “ICMS Repasse”

Version 21.0 152908-0562-20232 Page 86 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

LOOP lt_nflin INTO ls_nflin


* Loop on all NF items to check “ICMS Repasse” calculated (or not)
READ lt_nfstx INTO ls_nfstx USING
docnum = ls_nflin-docnum
itmnum = ls_nflin-itmnum
taxtyp = lv_tvarvc -low
IF sy-subrc IS INITIAL AND ls_nfstx-taxval IS NOT INITIAL
* “ICMS Repasse” 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_appendtextlv_appendtextitm = ls_item-infadprod
(START – 12_ITC: Changes V2.0 – 13th Jul 2022)
CONCATENATE lv_appendtextlv_appendtextitm // “ ICMS retido anteriormente conf.
art. 412, inciso II do RICMS/SP. Base de cálculo unitária em “ // $y01 // “retida anteriormente “ //
$w01 “ / Valor ICMS unitário em m3 m3 retido anteriormente “ // $x01 INTO
lv_appendtextlv_appendtextitm

Where: $w01 = ls_nfstx-BASE


$x01 = ls_nfstx-TAXVAL
$y01 = ls_nfstx-MEINS

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

Where: $w01 = ls_nfstx-EXCBASE


$x01 = ls_nfstx-TAXVAL
$y01 = ls_nfstx-UNIT
(END – 12_ITC: Changes V2.0 – 13th Jul 2022)
ls_item-infadprod = lv_appendtextitm
MODIFY lt_item FROMUSING ls_item

ENDIF
ENDLOOP
ENDIF

Version 21.0 152908-0562-20232 Page 87 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

*** 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

* Found Text block prefix for ANP Code

Version 21.0 152908-0562-20232 Page 88 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

LOOP lt_nflin INTO ls_nflin


lv_tabix = sy-tabix
* Loop on all NF items to check if ANP code exists
READ lt_fuel INTO ls_fuel USING
docnum = ls_nflin-docnum
itmnum = ls_nflin-itmnum
IF sy-subrc IS INITIAL AND ls_fuel-cprodanp IS NOT INITIAL
* ANP Code found for the item: assemble text and end (next NF item)
READ lt_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_appendtextlv_appendtextitm = ls_item-infadprod
CONCATENATE lv_appendtextlv_appendtextitm // lv_tvarvc-low // ls_fuel-cprodanp
INTO lv_appendtextlv_appendtextitm
ls_item-infadprod = lv_appendtextlv_appendtextitm
MODIFY lt_item FROMUSING ls_item USING TABIX = lv_tabix
ENDIF
ENDLOOP
ENDIF

(START – 25_UAT: RITM000001588724 Changes V3.0 – 22nd Nov 2022)


WHEN ‘ZSD_NFE_CMPLINF_ITTX_CIDE’
*** a) (Text) CIDE 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 CIDE Tax


LOOP lt_nflin INTO ls_nflin
lv_tabix = sy-tabix
* Loop on all NF items to check CIDE 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
* CIDE Tax Type found and with tax amount not null: use this for the text and end (next NF item)

READ lt_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_appendtextitm = ls_item-infadprod
CONCATENATE lv_appendtextitm // “ Valor CIDE: R$ ” // $t01 // “ p/ “ // $u01 //“, Total:
R$ ” // $v01 // “ ;” INTO lv_appendtextitm
Where: $t01 = ls_nfstx-RATE
$u01 = ls_nfstx-UNIT
$v01 = ls_nfstx-TAXVAL
ls_item-infadprod = lv_appendtextitm

Version 21.0 152908-0562-20232 Page 89 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

MODIFY lt_item FROMUSING ls_item USING TABIX = lv_tabix


EXIT (from LOOP lt_tvarvc > go to next it_nflin item)
ENDIF
ENDLOOP
ENDLOOP
ENDIF
(END – 25_UAT: RITM000001588724 Changes V3.0 – 22nd Nov 2022)

(START – 38_ITC: RITM000002278935 Changes V4.0 – 05th Jun 2024)


WHEN ‘ZSD_NFE_CMPLINF_ITTX_ICMSDESON’
WARNING - CRITICAL LOGIC IMPLEMENTATION SEQUENCE DEPENDENCY: as the
next logic to be implemented will – if applicable – depends on information generated on new
BADI_REQUIREMENT_27. Please check that BADI_REQUIREMENT_27 for more details:

* Copy internal structures to keep their integrity


field-symbols: <f_fieldname>
CLEAR ls_item, lt_tvarvc_icmsdeson, ls_tvarvc_icmsdeson, ls_e_dd03p,
lv_fieldname, lv_variable_value, lv_icms_value, lv_descrip
SORT lt_item BY itmnum
Read parameter table (TVARVC) records in a table lt_tvarvc_icmsdeson table using
following criteria:
NAME = ls_itm_sequence-low AND
LOW IS NOT INITIAL AND
HIGH IS NOT INITIAL
IF lt_tvarvc_icmsdeson IS NOT INITIAL

* Found Text blocks


LOOP lt_item INTO ls_item
lv_tabix = sy-tabix
* Loop on all “ICMS Desonerado” variables to be considered on item text block
LOOP lt_tvarvc_icmsdeson INTO ls_tvarvc_icmsdeson
* Check if field on parameter table technically exists (to avoid any dump on reading)
* Premise here is that only et_item (structure type J_1BNF_BADI_ITEM) fields will provide info
CLEAR lv_variable_value, lv_descrip
CALL FUNCTION 'BUS_DDFIELD_GET'
EXPORTING
i_tabnm = ‘J_1BNF_BADI_ITEM’
i_fldnm = ls_tvarvc_icmsdeson-low
IMPORTING
e_dd03p = ls_e_dd03p
EXCEPTIONS
OTHERS = 1.
IF sy-subrc IS INITIAL.
lv_fieldname = CONCATENATE “ET_ITEM-” // ls_tvarvc_icmsdeson-low.
ASSIGN (lv_fieldname) to <f_fieldname>
* Value is not null: Now try to get description (if exists) in case the value is a key
lv_variable_value = <f_fieldname>
IF lv_variable_value IS NOT INITIAL.
* Value is not null: Now try to get description (if exists) in case the value is a key
IF ls_e_dd03p-domname IS NOT INITIAL
CALL FUNCTION 'SD_SCD_GET_DOMVALUE_TEXT'
EXPORTING
i_spras = ‘PT’
i_tabname = ‘J_1BNF_BADI_ITEM’
i_fieldname = ls_tvarvc_icmsdeson-low
I_DOMVALUE = lv_variable_value
IMPORTING
e_domval_text = lv_descrip

Version 21.0 152908-0562-20232 Page 90 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

lv_variable_value = CONCATENATE lv_variable_value // “-“ lv_descrip


ENDIF
* In case et_item text already filled, preserves original text block before adding new one
lv_appendtextlv_appendtextitm = ls_item-infadprod
CONCATENATE lv_appendtextlv_appendtextitm // ls_tvarvc_icmsdeson-high //
lv_variable_value // “, ” INTO lv_appendtextlv_appendtextitm
ls_item-infadprod = lv_appendtextlv_appendtextitm
MODIFY lt_item FROMUSING ls_item using TABIX = lv_tabix
ENDIF
ENDIF ** Field does not exist
ENDLOOP ** lt_tvarvc_icmsdeson
ENDLOOP ** lt_item
ENDIF
(END – 38_ITC: RITM000002278935 Changes V4.0 – 05th Jun 2024)

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

ENDIF (lt_itm_sequence IS NOT INITIAL)

(START – 07_UAT: Changes V2.0 – 29th Jun 2022)


3.17 BADI Requirement 19: NFe Additional Header Info for Manually created NF-e’s (NF
Writer)

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:

Version 21.0 152908-0562-20232 Page 91 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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’

CHECK is_header-bukrs IS ON <lt_tvarvc-low values>

Version 21.0 152908-0562-20232 Page 92 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

SELECT * FROM tvarvc INTO lt_tvarvc WHERE


Name = ‘ZMM_NFE_CMPLINF_BUKRS’

CHECK is_header-bukrs IS ON <lt_tvarvc-low values>


(END – 22_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)

* 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’

IF sy-subrc IS NOT INITIAL OR lv_maxlen > 5000 OR lv_maxlen IS INITIAL


lv_maxlen = 5000
ENDIF

* Final text block will be composed by (in this order):


* it_nfftx, es_header-infcpl (if any previous text already exists there) and lv_appendtext
CLEAR ls_initblock
IF lt_nfftx IS NOT INITIAL
lv_seqnum = ‘01’
COPY it_nfftx TO lt_nfftx
SORT lt_nfftx BY docnum SEQNUM LINNUM ASCENDING
LOOP lt_nfftx INTO ls_nfftx
IF ls_nfftx-message IS NOT INITIAL
CONCATENATE ls_initblock // ls_nfftx-message INTO ls_initblock
IF ls_nfftx-seqnum = lv_seqnum
CONCATENATE ls_initblock // “ “ INTO ls_initblock
ELSE
CONCATENATE ls_initblock // “; “ INTO ls_initblock
lv_seqnum = ls_nfftx-seqnum
ENDIF
ENDLOOP
ENDIF
IF ls_initblock IS NOT INITIAL
CONCATENATE es_header-infcpl // ls_initblock INTO es_header-infcpl
ENDIF

(START – 22_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)


* Get overall sequence of J1B1N Header texts
* Remark: valid only for MM or SD Manual NFs
SELECT * FROM tvarvc INTO lt_sequence WHERE
Name = ‘ZMM_NFE_CMPLINF_J1B1HDRTXTSEQ’

ENDIF

IF sy-subrc IS INITIAL AND lt_sequence IS NOT INITIAL


SORT lt_sequence BY name type numb ASCENDING
CLEAR: lv_appendtextj1
LOOP AT lt_sequence INTO ls_sequence

CASE ls_sequence-low

Version 21.0 152908-0562-20232 Page 93 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

Version 21.0 152908-0562-20232 Page 94 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

(START – 41_CR: RITM000002278935 Changes V4.0 – 21st Jun 2024)

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

IF sy-subrc IS INITIAL and lt_ltext IS NOT INITIAL

* Start appending existing text lines


LOOP AT lt_ltext INTO ls_ltext
CONCATENATE lv_appendtextj1 // ls_ltext INTO lv_appendtextj1
ENDLOOP
CONCATENATE lv_appendtextj1 // “;” INTO lv_appendtextj1
ENDIF
ENDIF
(END – 41_CR: RITM000002278935 Changes V4.0 – 21st Jun 2024)

Version 21.0 152908-0562-20232 Page 95 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

ENDCASE
ENDLOOP
ENDIF

* Check number of chars for overflow situation


lv_remain = lv_maxlen – QtyChars[es_header-infcpl]
IF lv_appendtextj1 is NOT INITIAL
IF (QtyChars[lv_appendtext] > lv_remain)
Truncate string lv_appendtextj1 (cutting from end to begin) to a maximum of characters
defined by lv_remain
ENDIF
es_header-infcpl // lv_appendtextj1 INTO es_header-infcpl
* 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
(END – 22_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)

3.18 BADI Requirement 20: Complementary information for P2P only

A new functionality to be possible to parameterize the SEQUENCE of the texts will be


implemented (using TVARVC table) for MM Texts (Material Document or Invoice Receipt
automatically created NF-e’s). 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
* 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

Version 21.0 152908-0562-20232 Page 96 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

SELECT * FROM tvarvc INTO lt_tvarvc WHERE


Name = ‘ZMM_NFE_CMPLINF_BUKRS’

CHECK is_header-bukrs IS ON <lt_tvarvc-low values>

* 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’

IF sy-subrc IS NOT INITIAL OR lv_maxlen > 5000 OR lv_maxlen IS INITIAL


lv_maxlen = 5000
ENDIF
SELECT * FROM tvarvc INTO lt_sequence WHERE
Name = ‘ZMM_NFE_CMPLINF_TEXTSEQUENCE’

ENDIF

IF sy-subrc IS INITIAL AND lt_sequence IS NOT INITIAL


SORT lt_sequence BY name type numb ASCENDING
CLEAR: lv_appendtext
LOOP AT lt_sequence INTO ls_sequence

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

IF it_nflin[1]-reftyp = ‘MD’ AND it_nflin[1]-refkey IS NOT INITIAL AND it_nflin[1]-xped IS NOT


INITIAL
lv_docs = CONCATENATE lv_docs // “Documento Material/Ano:“ // it_nflin[1]-
refkey(10) // “/“ // it_nflin[1]-refkey+10(4) // “ ,Pedido:“ // it_nflin[1]-xped // “; “ INTO lv_docs
ELSEIF it_nflin[1]-reftyp = ‘MD’ AND it_nflin[1]-refkey IS NOT INITIAL AND it_nflin[1]-xped IS
INITIAL
lv_docs = CONCATENATE lv_docs // “Documento Material/Ano:“ // it_nflin[1]-
refkey(10) // “/“ // it_nflin[1]-refkey+10(4) // “; “ INTO lv_docs
ELSEIF it_nflin[1]-reftyp = ‘LI’ AND it_nflin[1]-refkey IS NOT INITIAL AND it_nflin[1]-xped IS
NOT INITIAL
lv_docs = CONCATENATE lv_docs // “Entrada Fatura/Ano:“ // it_nflin[1]-refkey(10) //
“/“ // it_nflin[1]-refkey+10(4) // “ ,Pedido:“ // it_nflin[1]-xped // “; “ INTO lv_docs
ELSEIF it_nflin[1]-reftyp = ‘LI’ AND it_nflin[1]-refkey IS NOT INITIAL AND it_nflin[1]-xped IS
INITIAL
lv_docs = CONCATENATE lv_docs // “Entrada Fatura/Ano:“ // it_nflin[1]-refkey(10) //
“/“ // it_nflin[1]-refkey+10(4) // “; “ INTO lv_docs
ENDIF

Version 21.0 152908-0562-20232 Page 97 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

IF lv_docs is NOT INITIAL


CONCATENATE lv_appendtext // lv_docs INTO lv_appendtext
ENDIF
ENDIF

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’

SELECT b~smtp_addr c~remark


INTO lt_email)
FROM lfa1 AS a INNER JOIN adr6 AS b INNER JOIN adrt AS c
ON a~adrnr = b~addrnumber AND b~addrnumber = c~addrnumber
WHERE a~lifnr = is_header-parid
c~remark = lv_txtadrt
b~smtp_addr IS NOT INITIAL

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’)

IF ls_smtptxt IS NOT INITIAL


CONCATENATE lv_appendtext // ls_smtptxt INTO lv_appendtext
ENDIF
ENDIF

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

Version 21.0 152908-0562-20232 Page 98 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

(START – 41_CR: RITM000002278935 Changes V4.0 – 21st Jun 2024)

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

Version 21.0 152908-0562-20232 Page 99 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

lines = lt_ltext

IF sy-subrc IS INITIAL and lt_ltext IS NOT INITIAL

* Start appending existing text lines


LOOP AT lt_ltext INTO ls_ltext
CONCATENATE lv_appendtext // ls_ltext INTO lv_appendtext
ENDLOOP
CONCATENATE lv_appendtext // “;” INTO lv_appendtext
ENDIF
ENDIF
(END – 41_CR: RITM000002278935 Changes V4.0 – 21st Jun 2024)

ENDCASE
ENDLOOP
ENDIF

* Final text block will be composed by (in this order):


* it_nfftx, es_header-infcpl (if any previous text already exists there) and lv_appendtext
CLEAR ls_initblock
IF lt_nfftx IS NOT INITIAL
lv_seqnum = ‘01’
COPY it_nfftx TO lt_nfftx
SORT lt_nfftx BY docnum SEQNUM LINNUM ASCENDING

(START – 14_UAT: Changes V2.0 – 25th Jul 2022)


* First, check if “text variables” exist to be substituted on SAP it_nfftx as per defined on TVARVC
* Get existing text variables defined by parameters and their corresponding values
DATA: lt_varsubstitute3
SELECT * FROM tvarvc INTO lt_varsubstitute3 WHERE
Name = ‘ZSD_NFE_VARTEXT_SUBSTITUTE’

IF sy-subrc IS INITIAL AND lt_varsubstitute3 IS NOT INITIAL


LOOP AT lt_varsubstitute3 INTO ls_varsubstitute3
IF ls_varsubstitute3-low IS NOT INITIAL AND ls_varsubstitute3-high IS NOT INITIAL
* For the text string to be substituted, obtain the contents into the indicated variable
ls_contents3 = <Read contents of variable name provided by ls_varsubstitute3-high>

IF sy-subrc IS INITIAL and ls_contents3 IS NOT INITIAL


IF <ls_varsubstitute3-high TYPE is DATE>
<Convert ls_contents3 to format DD.MM.YYYY>

Version 21.0 152908-0562-20232 Page 100 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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>

MODIFY lt_nfftx FROMUSING ls_nfftx


ENDLOOP
MODIFY (SAPLJ1BG)WNFFTX[ ] FROMUSING lt_nfftx

ENDIF
ENDIF
ENDLOOP
ENDIF
(END – 14_UAT: Changes V2.0 – 25th Jul 2022)

LOOP lt_nfftx INTO ls_nfftx


IF ls_nfftx-message IS NOT INITIAL
CONCATENATE ls_initblock // ls_nfftx-message INTO ls_initblock
IF ls_nfftx-seqnum = lv_seqnum
CONCATENATE ls_initblock // “ “ INTO ls_initblock
ELSE
CONCATENATE ls_initblock // “; “ INTO ls_initblock
lv_seqnum = ls_nfftx-seqnum
ENDIF
ENDLOOP
ENDIF
IF ls_initblock IS NOT INITIAL
CONCATENATE es_header-infcpl // ls_initblock INTO es_header-infcpl
ENDIF
* Check number of chars for overflow situation
lv_remain = lv_maxlen – QtyChars[es_header-infcpl]
IF lv_appendtext is NOT INITIAL
IF (QtyChars[lv_appendtext] > lv_remain)
Truncate string lv_appendtext (cutting from end to begin) to a maximum of characters
defined by lv_remain
ENDIF
es_header-infcpl // lv_appendtext INTO es_header-infcpl

Version 21.0 152908-0562-20232 Page 101 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

* 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

(END – 07_UAT: Changes V2.0 – 29th Jun 2022)

(START – 14_UAT: Changes V2.0 – 25th Jul 2022)


(START – 22_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)
BADI Requirement 21: Substitution of Z Text variables at final “Additional Information” area
on NF-e. Valid for SD or MM Automatic NFs.
3.19 BADI Requirement 99: Substitution of Z Text variables at final “Additional Information”
area on NF-e. Valid for SD or MM Automatic NFs.

**** IT MUST BE THE LAST LOGIC ON ENTIRE METHOD OR AT LEAST AFTER


ALL REQUIREMENTS RELATED TO HEADER TEXT BLOCK TREATMENTS ON
es_header-infcpl ***
(END – 22_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)

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.

To 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 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.

* Check if it’s a new NF issuance (not booking)


CHECK is_header-form IS NOT INITIAL
* Check NF Type is different from Cancel
CHECK 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 = ‘ZSD_NFE_CMPLINF_BUKRS’

CHECK is_header-bukrs IS ON <lt_tvarvc-low values>

* Get existing text variables defined by parameters and their corresponding values
DATA: lt_varsubstitute
SELECT * FROM tvarvc INTO lt_varsubstitute WHERE

Version 21.0 152908-0562-20232 Page 102 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Name = ‘ZSD_NFE_VARTEXT_SUBSTITUTE’

IF sy-subrc IS INITIAL AND lt_varsubstitute IS NOT INITIAL


LOOP AT lt_varsubstitute INTO ls_varsubstitute
IF ls_varsubstitute-low IS NOT INITIAL AND ls_varsubstitute-high IS NOT INITIAL
* For the text string to be substituted, obtain the contents into the indicated variable
ls_contents = <Read contents of variable name provided by ls_varsubstitute-high>

IF sy-subrc IS INITIAL and ls_contents IS NOT INITIAL


ls_es_header-infcpl = es_header-infcpl
IF <ls_varsubstitute-high TYPE is DATE>
<Convert ls_contents to format DD.MM.YYYY>
ENDIF
<look for string value on ls_varsubstitute-low along text ls_es_header-infcpl and, everytime
found, substitute string per the contents of ls_contents>

ENDIF
ENDIF
ENDLOOP
ENDIF
(END – 14_UAT: Changes V2.0 – 25th Jul 2022)

(START – 15_UAT: Changes V2.0 – 17th Aug 2022)


3.20 BADI Requirement 22: Legal requirement in Brazil to have 0 quantity on items of “Nota
Fiscal Complementar” – no matter for price or tax complement.

Scope

Version 21.0 152908-0562-20232 Page 103 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding field.

Create Logic into SAP Enhancement EXIT_SAPLJ1BG_001, Include ZXJ1BU01.

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 NF is issuance, not booking


CHECK (SAPLJ1BG)wbaa-form IS NOT INITIAL
* Check NF Type is Complementary
CHECK (SAPLJ1BG)wbaa-doctyp EQ ‘2’
SELECT * FROM tvarvc INTO lt_zero_qty WHERE
Name = ‘ZSD_NFE_ZEROQTY_NFCOMPLEM’
IF sy-subrc IS INITIAL and lt_zero_qty IS NOT INITIAL
* Flag must be ACTIVE to force quantity to ZERO when NF Complementar
LOOP AT (SAPLJ1BG)wnflin INTO ls_nflin
ls_nflin-menge = 0
MODIFY (SAPLJ1BG)wnflin AS PERFROM ls_nflin
ENDLOOP
ENDIF
(END – 15_UAT: Changes V2.0 – 17th Aug 2022)

(START – 22_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)


3.21 BADI Requirement 23: NFe Item Additional Info for MM Automatic NF

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:

Version 21.0 152908-0562-20232 Page 104 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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’

Version 21.0 152908-0562-20232 Page 105 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

CHECK is_header-bukrs IS ON <lt_tvarvc-low values>

* 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’

IF sy-subrc IS NOT INITIAL OR lv_maxitmlen > 500 OR lv_maxitmlen IS INITIAL


lv_maxlenitm = 500
ENDIF
SELECT * FROM tvarvc INTO lt_sequence WHERE
Name = ‘ZMM_NFE_CMPLINF_ITMTXTSEQUENCE’

ENDIF

IF sy-subrc IS INITIAL AND lt_itm_sequence IS NOT INITIAL


SORT lt_itm_sequence BY name type numb ASCENDING
CLEAR: lv_appendtextitm
COPY et_item TO lt_item
LOOP AT lt_itm_sequence INTO ls_itm_sequence

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


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)

Version 21.0 152908-0562-20232 Page 106 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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_appendtextitm = ls_item-infadprod
(START – 39_ITC: RITM000002278935 Changes V4.0 – 14th Jun 2024)
CONCATENATE lv_appendtextitm // “ Base FCP:” // $q01 // “, % FCP:” // $r01 // “,
Valor FCP:” // $s01 INTO lv_appendtextitm
CONCATENATE lv_appendtextitm // “Base FCP:” // $q01 // “, % FCP:” // $r01 // “,
Valor FCP:” // $s01 INTO lv_appendtextitm
(END – 39_ITC: RITM000002278935 Changes V4.0 – 14th Jun 2024)
Where: $q01 = ls_nfstx-BASE
$r01 = ls_nfstx-RATE
$s01 = ls_nfstx-TAXVAL
ls_item-infadprod = lv_appendtextitm
MODIFY lt_item FROMUSING ls_item
EXIT (from LOOP lt_tvarvc > go to next it_nflin item)
ENDIF
ENDLOOP
ENDLOOP
ENDIF

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


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_appendtextitm = ls_item-infadprod
(START – 39_ITC: RITM000002278935 Changes V4.0 – 14th Jun 2024)
CONCATENATE lv_appendtextitm // “ Base FCP ST:” // $t01 // “, % FCP ST:” // $u01 //
“, Valor FCP ST:” // $v01 INTO lv_appendtextitm
CONCATENATE lv_appendtextitm // “Base FCP ST:” // $t01 // “, % FCP ST:” // $u01 //
“, Valor FCP ST:” // $v01 INTO lv_appendtextitm
(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_appendtextitm
MODIFY lt_item FROMUSING ls_item
EXIT (from LOOP lt_tvarvc > go to next it_nflin item)
ENDIF

Version 21.0 152908-0562-20232 Page 107 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

ENDLOOP
ENDLOOP
ENDIF

(Example FCP and FCP ST)

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:

Version 21.0 152908-0562-20232 Page 108 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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’

CHECK is_header-bukrs IS ON <lt_tvarvc-low values>

* 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’

IF sy-subrc IS NOT INITIAL OR lv_maxlen > 5000 OR lv_maxlen IS INITIAL


lv_maxlen = 5000
ENDIF

SELECT * FROM tvarvc INTO lt_sequence WHERE


Name = ‘ZMM_NFE_CMPLINF_J1B1ITMTXTSEQ’

Version 21.0 152908-0562-20232 Page 109 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

ENDIF

IF sy-subrc IS INITIAL AND lt_itm_sequence IS NOT INITIAL


SORT lt_itm_sequence BY name type numb ASCENDING
CLEAR: lv_appendtextj1itm
COPY et_item TO lt_item
LOOP AT lt_itm_sequence INTO ls_itm_sequence

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)

Where: $q01 = ls_nfstx-BASE


$r01 = ls_nfstx-RATE
$s01 = 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

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

Version 21.0 152908-0562-20232 Page 110 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

(Example FCP and FCP ST)

(END – 22_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)

(START – 26_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)


3.23 BADI Requirement 25: Fuels qTemp tag filling from automatic Transactions

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

Version 21.0 152908-0562-20232 Page 111 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

Create new implementation on BADI J_1BNF_ADD_DATA, Method ADD_DATA, including a


segregated Function Module or Include with the following functional 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.

* Check if it’s a new NF issuance (not booking)


CHECK is_header-form IS NOT INITIAL
* Check NF not manual (J1B1N)
CHECK is_header-manual IS INITIAL
* Only for items related to FUELS
CHECK et_fuel IS NOT INITIAL
* Copy internal structures to keep their integrity
CLEAR ls_nflin, lt_nflin, lt_fuel, ls_fuel, lt_tvarvc, ls_tvarvc, lt_vbrp, ls_vbrp, lt_rseg, lt_mseg,
lv_rule, ls_lipso2
COPY it_nflin TO lt_nflin
COPY et_fuel TO lt_fuel
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
Name = ‘ZSD_NFE_XMLTAG_QTEMP’
Low = iv_applic OR
Low = ‘**’

Version 21.0 152908-0562-20232 Page 112 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

* 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

IF lt_tvarvc IS NOT INITIAL


SORT lt_tvarvc BY name low numb ASCENDING

READ lt_tvarvc INTO ls_tvarvc WITH KEY


Name = ‘ZSD_NFE_XMLTAG_QTEMP’
Low = iv_applic
IF sy-subrc IS INITIAL AND ls_tvarvc-high IS NOT INITIAL
lv_rule = ls_tvarvc-high
ELSE
READ lt_tvarvc INTO ls_tvarvc WITH KEY
Name = ‘ZSD_NFE_XMLTAG_QTEMP’
Low = ‘**’
IF sy-subrc IS INITIAL AND ls_tvarvc-high IS NOT INITIAL
lv_rule = ls_tvarvc-high
ELSE
* No application or default rules were found: use default rule like “A”, that means
* ‘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.
lv_rule = ‘A’
ENDIF
ENDIF
ELSE
* No TVARVC records found: use default rule like “A”, that means
* ‘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.
lv_rule = ‘A’
ENDIF
* Loop on NF items Fuel info only
SORT lt_nflin BY docnum itmnum ASCENDING
LOOP lt_fuel INTO ls_fuel
* Loop on NF item related to Fuels info
READ lt_nflin INTO ls_nflin WITH KEY
docnum = ls_fuel-docnum

Version 21.0 152908-0562-20232 Page 113 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

Version 21.0 152908-0562-20232 Page 114 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

SELECT * FROM msego2 INTO ls_msego2 WHERE


BELNR = ls_nflin-refkey(10)
GJAHR = ls_nflin-refkey+10(4)
POSNR = ls_nflin-refitm
MSEHI = ls_nflin-meins
IF sy-subrc IS INITIAL AND ls_msego2-adqntp IS NOT INITIAL
AND ( ls_msego2-adqntp <> ls_nflin-menge )
ls_fuel-qtemp = ls_msego2-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 ‘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

Version 21.0 152908-0562-20232 Page 115 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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
ENDIF
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.
SELECT * FROM msego2 INTO ls_msego2 WHERE
BELNR = ls_nflin-refkey(10)
GJAHR = ls_nflin-refkey+10(4)
POSNR = ls_nflin-refitm
MSEHI = ls_nflin-meins
IF sy-subrc IS INITIAL AND ls_msego2-adqntp IS NOT INITIAL
AND ( ls_msego2-adqntp <> ls_nflin-menge )
ls_fuel-qtemp = ls_msego2-adqntp
MODIFY lt_fuel FROM ls_fuel
ENDIF
ENDIF

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

(END – 26_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)

(START – 29_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)


3.24 BADI Requirement 26: New ICMS Adrem (“Monofasico”) Fuels Tax amounts and “Fuel
Origin” NF-e tags

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.

(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)


The new ICMS Monophasic table to handle all necessary parameters to that Fuel Taxation was
designed to provide the “BR State of Origin” information required for corresponding XML MF-e
tag on “Fuel Origin” area of that document. For purchasing, that worked fine. However, for
Outbound, due to recent business need to include multiple Suppliers from distinct BR States
(Regions), that functionality was not enough as, on outbound, it’s necessary to identify the

Version 21.0 152908-0562-20232 Page 116 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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)

The tags to be accomplished by this topic are:

Scope
=> Only for Application automatic issued NF-e’s. For manual SAP NF Docs
(transaction J1B1N), user must provide information on corresponding fields.

Create new implementation on BADI J_1BNF_ADD_DATA, Method ADD_DATA, including a


segregated Function Module or Include with the following functional logic:

Version 21.0 152908-0562-20232 Page 117 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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).

(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)


The intention is to use Text block ZBxx (currently ZB05, available on Header Texts for BR
Document Types, but defined as parameter below to avoid hardcoding) to support the
information to be entered by user related to the reference NF-e(s) that must support the
corresponding outbound NF-e. Depending on the Business scenario (NF Item Type) and the
Grade being outbound, one or more lines on ZBxx will be necessary to support the required
information on NF-e:
 Sales or Shipment to Warehouse of Diesel A or Biodiesel: only one line on ZBxx
(following the expected format / rule) will be considered to represent the
related/referenced acquisition NF-e from where the Supplier BR State (region) will
be extracted to feed XML NF-e tag.
 Sales or Shipment to Warehouse of Diesel B: two lines will be required (one for
Diesel A and another for Biodiesel) to get the acquisition NF-e’s from where the
Suppliers BR States (regions) will be extracted to feed XML NF-e tags.
 Sales Return/Refusal or Sales Credit/Debit (‘NF Complementar’) memo: the original
ZB05 text informed on referenced Sales process will be used to derive the same
information for the corresponding Customer Return NF-e booking, Inbound NF-e
issuance for Refusal or ‘NF Complementar’ for Debit Memo.
With the implementation of this change, the “Fuel Origin” tags will behavior as per shown below
(some “practical” cases):

Version 21.0 152908-0562-20232 Page 118 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

(END – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 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. Special attention to ‘MODIFY’ and ‘INSERT’ as per considered
functional below but not necessarily correct from ABAP perspective.

* Check NF not manual (J1B1N)


CHECK is_header-manual IS INITIAL
* Only for items related to FUELS
CHECK et_fuel IS NOT INITIAL
* Copy internal structures to keep their integrity
CLEAR ls_nflin, lt_nflin, lt_fuel, ls_fuel, lt_fuelorigin, lt_tvarvc, ls_tvarvc, lt_vbrp, ls_vbrp, lt_rseg,
lt_mseg, lv_rule, ls_lipso2, lv_taxsit_out, lv_taxrg_partner, lv_kappl
COPY it_nflin TO lt_nflin
COPY et_fuel TO lt_fuel
COPY et_fuelorigin TO lt_fuelorigin
COPY it_partner TO lt_partner

* Check all NF items


LOOP AT it_nflin INTO ls_nflin
(START – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
* (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
CLEAR: ls_vbrp
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’

Version 21.0 152908-0562-20232 Page 119 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

READ TABLE it_vbrp INTO ls_vbrp USING


* Read Billing item by using NF item info
vbeln = ls-nflin-refkey
posnr = ls_nflin-refitm
ELSE
* If any error, use only item to read other structure (as by above FACT)
SORT it_vbrp BY vbeln posnr ASCENDING
READ TABLE it_vbrp INTO ls_vbrp WITH KEY
POSNR = ls_nflin-refitm
ENDIF
(END – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)

* Read NF item Fuel data


READ lt_fuel INTO ls_fuel WITH KEY ITMNUM = ls_nflin-itmnum
IF sy-subrc IS NOT INITIAL
* In case a non-fuel item, jump to next item
EXIT.
ELSE.
* Set price application area based on NF item application
IF iv_applic = ‘IV’ OR iv_applic = ‘LI’.
lv_kappl = ‘TX’
ELSEIF iv_applic = ‘BI’
lv_kappl = ‘V’
ENDIF

CALL FUNCTION ‘ZSD_BR_ICMS_ADREM_SEARCH’


EXPORTING
kappl = lv_kappl ** ‘V’ or ‘TX’
cst = ls_nflin-taxsit ** CST not converted
vat_code = ls_nflin-mwskz
pstyv = pricing_item-pstyv
plant = ls_nflin-werks
partyp = is_header-partyp
parid = is_header-parid
matnr = ls_nflin-matnr
valid_from = is_header-docdat
IMPORTING
e_icms_adrem = ls_icms_adrem_param
EXCEPTIONS
NO_RECORD_FOUND = 1
MATERIAL_INVALID = 2
INVALID_PLANT = 3
PARTNER_NOT_VALID = 4

IF sy-subrc EQ 0 AND ls_icms_adrem_param IS NOT INITIAL


* Convert Tax Situation on database (1 char) to official value (2 chars)
CALL FUNCTION 'CONVERSION_EXIT_TXSIT_OUTPUT'
EXPORTING
input = ls_icms_adrem_param-cst
IMPORTING
output = lv_taxsit_out.
* pBio indicator is active: fill corresponding field with mixture % to be moved to NF-e tag
IF ls_icms_adrem_param-pbio IS NOT INITIAL AND ls_icms_adrem_param-mixture IS NOT
INITIAL
ls_nffuel-pbio = ls_icms_adrem_param-mixture
MODIFY et_fuel FROM ls_fuel
ENDIF
* Fuel Origin indicator is active: create necessary record(s) in J_1BNFFUELORIGIN related
* structure to be further moved to NF-e tag
IF ls_icms_adrem_param-origcomb IS NOT INITIAL
SELECT * FROM tvarvc INTO lt_tvarvc_icmsadrem WHERE
( NAME LIKE 'ZSD#_ICMSADREM%' ESCAPE '#' )
LOW IS NOT INITIAL
(START – 43_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)
SORT lt_tvarvc_origcomb BY name low
SORT lt_tvarvc_origcomb BY name low high ASCENDING
(END – 43_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)

Version 21.0 152908-0562-20232 Page 120 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

IF sy-subrc EQ 0 AND lt_tvarvc_icmsadrem IS NOT INITIAL

(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)


* ENH026 will treat user access to fill ZBxx text into outbound delivery on the correct way and just
* for the document types enabled for it.
* Check if NF-e from Billing
IF iv_applic = ‘BI’ AND is_vbrk IS NOT INITIAL
* Check if BR Billing Type is relevant to functionality
Read parameter table lt_tvarvc_icmsadrem record in ls_tvarvc table using:
NAME = ‘ZSD_ICMSADREM_ORIG_UF_FKART’
LOW = is_vbrk-fkart
IF sy-subrc IS INITIAL
CLEAR: lv_delivery
* Perform specific logic for each NF Doctyp in scope
IF is_header-doctyp = ’1’
* A) DOCTYP = ‘1’-Normal NF-e
* For this scenario, ZBxx text is located on outbound delivery directly related to
* the Billing being created. Premise is 1:1 Delivery Document per Billing in BR.
READ TABLE it_vbrp INTO ls_vbrp INDEX 1
IF sy_subrc IS INITIAL AND ls_vbrp-vgbel IS NOT INITIAL AND ls_vbrp-vgtyp = ‘J’
lv_delivery = ls_vbrp-vgbel
ENDIF
ELSEIF is_header-doctyp = ’6’
* B) DOCTYP = ‘6’-Return
* For this scenario, ZBxx text is located on the original outbound delivery as per
* document flow
READ TABLE it_vbrp INTO ls_vbrp INDEX 1
IF sy_subrc IS INITIAL AND ls_vbrp-vgbel IS NOT INITIAL
SELECT * FROM vbfa INTO ls_vbfa WHERE
VBTYP_V = ‘J’
VBELN = ls_vbrp-vgbel
VBTYP_N = ls_vbrp-vgtyp
IF sy_subrc IS INITIAL AND ls_vbfa IS NOT INITIAL
lv_delivery = ls_vbfa-vbelv
ENDIF
ENDIF
ELSEIF is_header-doctyp = ’2’
* C) DOCTYP = ‘2’-Complementar
* For this scenario, ZBxx text is located on the referenced original outbound delivery as per
* ‘Differential Invoice’ design (IS-OIL)
READ TABLE it_vbrp INTO ls_vbrp INDEX 1
IF sy_subrc IS INITIAL AND ls_vbrp-vgbel IS NOT INITIAL AND ls_vbrp-vgtyp = ‘J’
lv_delivery = ls_vbrp-vgbel
ENDIF
ENDIF **NF doctyp

* Read Text Block ZBxx code - parameter


Read parameter table lt_tvarvc_icmsadrem record in ls_tvarvc table using criteria:
NAME = ZSD_ICMSADREM_ORIG_UF_TXTBLK
IF sy-subrc IS INITIAL lv_delivery IS NOT INITIAL AND ls_tvarvc-low IS NOT INITIAL
CALL FUNCTION Read_Text USING
ID = ls_tvarvc-low(4)
Language = PT
Name = lv_delivery
Object = “VBBK”
IF sy-subrc IS INITIAL and tdline 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>

Version 21.0 152908-0562-20232 Page 121 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

* 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: Maximum of two lines are expected depending on the grade
* Diesel A, Biodiesel => 1 line / NF-e reference
* Diesel B => 2 lines / NF-e references (1st line for Diesel A and 2nd for Biodiesel)

CLEAR: lv_docnum1, lv accesskey1, lv_docnum2, lv accesskey2, ls_nfdoc


* Get information from 1st line (if exists)
READ TABLE tdline INTO ls_tdline INDEX 1
IF sy_subrc IS INITIAL AND ls_tdline IS NOT INITIAL
Get ls_tdline and split string at character “;” into lv_docnum1, lv_accesskey1 but
respecting their maximum technical lengths: docnum (J_1BDOCNUM) = 10, accesskey
(J_1B_NFE_ACCESS_KEY_DTEL44) = 44
ENDIF
* Get information from 2nd line (if exists)
READ TABLE tdline INTO ls_tdline INDEX 2
IF sy_subrc IS INITIAL AND ls_tdline IS NOT INITIAL
Get ls_tdline and split string at character “;” into lv_docnum2, lv_accesskey2 but
respecting their maximum technical lengths: docnum (J_1BDOCNUM) = 10, accesskey
(J_1B_NFE_ACCESS_KEY_DTEL44) = 44
ENDIF

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)

SELECT docnum FROM j_1bnfe_active INTO lv_docnum1 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_docnum1
ENDIF
ENDIF
ELSE
SELECT * FROM j_1bnfdoc WHERE docnum = lv_docnum1 AND
cancel IS INITIAL AND
docstat = ‘1’
IF sy-subrc IS NOT INITIAL

Version 21.0 152908-0562-20232 Page 122 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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)

SELECT docnum FROM j_1bnfe_active INTO lv_docnum2 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_docnum2
ENDIF
ENDIF
ELSE
SELECT * FROM j_1bnfdoc INTO WHERE docnum = lv_docnum2 AND
cancel IS INITIAL AND
docstat = ‘1’
IF sy-subrc IS NOT INITIAL
CLEAR: lv_docnum2
ENDIF
ENDIF

CLEAR: ls_nfdoc, ls_tvarvc_nftyp, lv_brstate1


IF lv_docnum1 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_docnum1
SELECT * FROM tvarvc INTO ls_tvarvc_nftyp WHERE
name = ‘ZSD_NFE_USER_ADDINFOINP_NFTYPE’
low = ls_nfdoc-nftyp

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

Version 21.0 152908-0562-20232 Page 123 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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_brstate1 = ls_branch_address-regio
ENDIF
ENDIF
ENDIF
ENDIF

CLEAR: ls_nfdoc, ls_tvarvc_nftyp, lv_brstate2


IF lv_docnum2 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_docnum2
SELECT * FROM tvarvc INTO ls_tvarvc_nftyp WHERE
name = ‘ZSD_NFE_USER_ADDINFOINP_NFTYPE’
low = ls_nfdoc-nftyp

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

ENDIF ** TXTBLOCK exists on delivery AND tdline IS NOT INITIAL


ENDIF ** lv_delivery IS NOT INITIAL AND TXTBLOCK is defined
ENDIF ** FKART (Billing Type) is valid
ENDIF ** iv_applic = ‘BI’ AND is_vbrk IS NOT INITIAL
(END – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)

* Read per parameters if Material Origin indicates a 100% full origin or not (multiple origins)

Version 21.0 152908-0562-20232 Page 124 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

READ lt_tvarvc_icmsadrem WITH KEY


NAME = ‘ZSD_ICMSADREM_ORIGCOMB_100%’
LOW = ls_nflin-matorg

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

(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)


* If Material Origin indicates a full origin source, create just one record
* If Grade is a Diesel B one, always checks for TWO BR State differences (for Diesel A
* and for Biodiesel). For other “simple” Grades, check for JUST ONE reference BR State
* (if exists). If no BR State from referenced NF-e is found, use the BR State defined
* on Z Table for ICMS Monophasic record found.
CLEAR: lv_nfreflines
READ et_fuel INTO ls_fuel WITH KEY
DOCNUM = ls_nflin-docnum
ITEM = ls_nflin-itmnum
IF sy-subrc IS INITIAL AND ls_fuel-cprodanp IS NOT INITIAL
READ lt_tvarvc_icmsadrem-high INTO lv_nfreflines WITH KEY
DOCNUM = ‘ZSD_ICMSADREM_ORIG_UF_ANP’
LOW = ls_fuel-cprodanp
HIGH IS NOT INITIAL

Version 21.0 152908-0562-20232 Page 125 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

(END – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)


IF sy-subrc EQ 0
CLEAR ls_nffuelorigin
IF lv_orig100% = ‘X’
(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
* If Material Origin indicates a full origin source, create just one record
* If Grade is a Diesel B one, always checks for TWO BR State differences (for Diesel A
* and for Biodiesel). For other “simple” Grades, check for JUST ONE reference BR State
* (if exists). If no BR State from referenced NF-e is found, use the BR State defined
* on Z Table for ICMS Monophasic record found.
IF lv_nfreflines = ‘1’
* If, for Grade ANP Code, just 1 NF-e reference is expected (no blending)
(END – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
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’
(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)
IF lv_brstate1 IS NOT INITIAL
* Valid NF-e reference was provided: use BR state from there
ls_nffuelorigin-c_uf_origin = lv_brstate1
ELSE
* None valid NF-e reference was provided: use BR state from Z ICMS Table
(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
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’
(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
APPEND ls_nffuelorigin TO et_fuelorigin

Version 21.0 152908-0562-20232 Page 126 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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’

Version 21.0 152908-0562-20232 Page 127 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

IF lv_brstate1 IS NOT INITIAL


ls_nffuelorigin-c_uf_origin = lv_brstate1
ELSE
ls_nffuelorigin-c_uf_origin = ls_icms_adrem_param-uf
ENDIF
(START – 37_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
ls_nffuelorigin-p_origin = ( 100 – ls_icms_adrem_param-mixture )
APPEND ls_nffuelorigin TO et_fuelorigin
IF lv_brstate2 IS NOT INITIAL
ls_nffuelorigin-c_uf_origin = lv_brstate2
ELSE
ls_nffuelorigin-c_uf_origin = ls_icms_adrem_param-uf_aux
ENDIF
ls_nffuelorigin-p_origin = ls_icms_adrem_param-mixture
APPEND ls_nffuelorigin TO et_fuelorigin
IF lv_brstate2 IS NOT INITIAL
IF ( ls_nffuelorigin-c_uf_origin = lv_brstate2 )
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 = 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)
ELSEIF lv_origcom = ‘1’ ** Foreign 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 = ‘1’
IF lv_brstate1 IS NOT INITIAL
ls_nffuelorigin-c_uf_origin = lv_brstate1
ELSE
ls_nffuelorigin-c_uf_origin = ls_icms_adrem_param-uf
ENDIF
(START – 37_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
ls_nffuelorigin-p_origin = ( 100 – ls_icms_adrem_param-mixture )
APPEND ls_nffuelorigin TO et_fuelorigin
IF lv_brstate2 IS NOT INITIAL
ls_nffuelorigin-c_uf_origin = lv_brstate2
ELSE
ls_nffuelorigin-c_uf_origin = ls_icms_adrem_param-uf_aux
ENDIF
ls_nffuelorigin-p_origin = ls_icms_adrem_param-mixture
APPEND ls_nffuelorigin TO et_fuelorigin
IF lv_brstate2 IS NOT INITIAL
IF ( ls_nffuelorigin-c_uf_origin = lv_brstate2 )
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

Version 21.0 152908-0562-20232 Page 128 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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)

Version 21.0 152908-0562-20232 Page 129 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

(START – 34_CR: RITM000002135690 Changes V4.0 – 09th Feb 2024)


ELSEIF ls_tvarvc_icmsadrem-low = ‘1’
(START – 37_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
ELSEIF lv_origcom = ‘1’ ** Foreign origin
(END – 37_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
(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 = ‘1’
(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 = ‘0’
(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
(START – 37_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
ENDIF
(END – 37_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
ENDIF ** lv_orig100%
ENDIF
ENDIF ** ls_fuel-cprodanp IS NOT INITIAL
ENDIF ** lt_tvarvc_icmsadrem IS NOT INITAL
ENDIF ** origcmb IS NOT INITIAL

(START – 43_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)


* Fill value fields as per defined by Tax Authority documentation
******************************************************************************************************
* Special NFe Tags Treatment dependent on new Fuels CSTs (15, 53, 61)

* Check if BR NF Billing Doc Type is relevant to functionality


Read parameter table lt_tvarvc_icmsadrem record in ls_tvarvc table using:
NAME = ‘ZSD_ICMSADREM_CSTTAGS_FKART’
LOW = is_vbrk-fkart
LOW = lv_taxsit_out
IF sy-subrc IS INITIAL
(END – 43_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)

* CST ‘53’ (deferred)


IF lv_taxsit_out = ‘53’
READ lt_tvarvc_icmsadrem-low INTO lv_taxtyp_adrem WITH KEY
NAME = ‘ZSD_ICMSADREM_TAXTYP’
HIGH = ‘ADREM’
LOW IS NOT INITIAL

Version 21.0 152908-0562-20232 Page 130 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

Version 21.0 152908-0562-20232 Page 131 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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)

(START – 38_ITC: RITM000002278935 Changes V4.0 – 05th Jun 2024)


3.25 BADI Requirement 27: Calculate and feed XML tags for “ICMS Desonerado” and
controls its application (including “Motivo de Desoneração”)

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).

Version 21.0 152908-0562-20232 Page 132 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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).

Version 21.0 152908-0562-20232 Page 133 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

3.25.3[3.18.3] Functional Logic

Create new implementation on BADI J_1BNF_ADD_DATA, Method ADD_DATA, including a


segregated Function Module or Include with the following functional logic:

WARNING - CRITICAL LOGIC IMPLEMENTATION SEQUENCE DEPENDENCY: as the


next logic to be implemented will – if applicable – generate new information on NF Item(s) and
there is a dependency on other previous BADI_REQUIREMENT to include additional texts
based on this information, it’s mandatory to include the below new logic in BADI BEFORE all the
coding related to the following existing BADI_REQUIREMENT topics:
 BADI Requirement 05: Complementary information for O2C only
 BADI Requirement 07: Complementary information for P2P only
 BADI Requirement 18: NFe Item Additional Info for SD
 BADI Requirement 19: NFe Additional Header Info for Manually created NF-e’s (NF
Writer)
 BADI Requirement 20: Complementary information for P2P only
 BADI Requirement 23: NFe Item Additional Info for MM Automatic
 BADI Requirement 24: NFe Item Additional Info for NF Writer (Manually created)

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 not manual (J1B1N)
CHECK is_header-manual IS INITIAL
* Copy internal structures to keep their integrity
CLEAR ls_nflin, lt_nflin, ls_nfstx, lt_nfstx, lt_tvarvc, ls_tvarvc, lt_icmsdes,
lv_ufplant, lt_t001w, ls_t001w, lv_tabix, lt_et_item, ls_et_item
COPY it_nflin TO lt_nflin
COPY it_nfstx TO lt_nfstx
COPY et_item TO lt_et_item
Read parameter table (TVARVC) records in a table lt_tvarvc table using following criteria:
Name = ‘ZSD_NFE_STAT_ICMSDESON*’
Low IS NOT INITIAL
IF lt_tvarvc IS NOT INITIAL
SORT lt_tvarvc BY name low ASCENDING
READ lt_tvarvc INTO ls_tvarvc WITH KEY
Name = ‘ZSD_NFE_STAT_ICMSDESON_BUKRS’
Low = is_header-bukrs
IF sy-subrc IS INITIAL

Version 21.0 152908-0562-20232 Page 134 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

SELECT * FROM zsd_br_icms_desonera INTO lt_icmsdes


IF sy-subrc IS INITIAL AND lt_icmsdes IS NOT INITIAL
* CRITICAL: Sort internal structure accordingly: ‘Valid from’ DESCENDING to get correct valid record
depending on doc date
SORT lt_icmsdes BY UF Plant, CST, NF Doc Type, NF Type, CFOP ASCENDING AND
Valid From DESCENDING.
* Get Tax Regions from BR Plants
SELECT * INTO lt_t001w FROM t001W WHERE
LAND1 = ‘BR’ and
TXJCD IS NOT INITIAL and
J_1BBRANCH IS NOT INITIAL
SORT lt_nflin BY docnum itmnum ASCENDING
* Loop on NF items
LOOP lt_nflin INTO ls_nflin
READ TABLE lt_t001w INTO ls_t001w WITH KEY werks = ls_nflin-werks
IF sy-subrc IS INITIAL
lv_ufplant = ls_t001w-txjcd(3)
ENDIF

READ lt_icmsdes INTO ls_icmsdes WITH KEY


UF Plant = lv_uf
CST = ls_nflin-taxsit ** CST not converted
NF Doc Type = <null>
NF Type = is_header-nftype
CFOP = ls_nflin-cfop
Valid From LE is_header-docdat
IF sy-subrc IS NOT INITIAL.
READ lt_icmsdes INTO ls_icmsdes WITH KEY
UF Plant = lv_uf
CST = ls_nflin-taxsit ** CST not converted
NF Doc Type = is_header-doctyp
NF Type = <null>
CFOP = ls_nflin-cfop
Valid From LE is_header-docdat
IF sy-subrc IS NOT INITIAL.
READ lt_icmsdes INTO ls_icmsdes WITH KEY
UF Plant = lv_uf
CST = ls_nflin-taxsit ** CST not converted
NF Doc Type = <null>
NF Type = is_header-nftype
CFOP = <null>
Valid From LE is_header-docdat
IF sy-subrc IS NOT INITIAL.
READ lt_icmsdes INTO ls_icmsdes WITH KEY
UF Plant = lv_uf
CST = ls_nflin-taxsit ** CST not converted
NF Doc Type = is_header-doctyp
NF Type = <null>
CFOP = <null>
Valid From LE is_header-docdat
IF sy-subrc IS NOT INITIAL.
READ lt_icmsdes INTO ls_icmsdes WITH KEY
UF Plant = lv_uf
CST = ls_nflin-taxsit ** CST not converted
NF Doc Type = <null>
NF Type = <null>
CFOP = <null>
Valid From LE is_header-docdat
ENDIF
ENDIF.
ENDIF.

Version 21.0 152908-0562-20232 Page 135 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

lv_fp_calc5 = ROUND (lv_fp_calc4 - ls_nflin-nfnet ; 2)

lv_fp_calc5 = ROUND (( ls_nflin-nfnet * ( 1 - ( ls_nfstx-rate * ls_nfstx-


basered1 / 100 / 100 ) ) / ( 1 - ( ls_nfstx-rate / 100 ) ) ) - ls_nflin-nfnet; 2)
lv_fp_calc5 = ROUND (( ls_nflin-nfnet * ( 1 - ( lv_total_icms_rate * ls_nfstx-
basered1 / 100 / 100 ) ) / ( 1 - ( lv_total_icms_rate / 100 ) ) ) - ls_nflin-nfnet; 2)
IF lv_fp_calc5 GE 0 ** Final Exempt value
READ lt_et_item INTO ls_et_item WITH KEY
ITMNUM = ls_nflin-itmnum
IF sy-subrc IS INITIAL AND ls_et_item IS NOT INITIAL
lv_tabix = sy-tabix
IF ls_et_item-ststcl_vicmsdeson IS INITIAL
* If ICMS “Desonerado” value not yet exist, then update it
ls_et_item-ststcl_vicmsdeson = lv_calc5
IF ls_et_item-MOTDESICMS IS INITIAL

Version 21.0 152908-0562-20232 Page 136 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

* 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

ENDIF. ** lt_icmsdes IS NOT INITIAL


ENDIF ** sy-subrc IS INITIAL (BUKRS)
ENDIF ** lt_tvarvc IS NOT INITIAL

(END – 38_ITC: RITM000002278935 Changes V4.0 – 05th Jun 2024)

Version 21.0 152908-0562-20232 Page 137 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

4 DETAILED SAP CONFIGURATION – NFE BADI


Not applicable.
4.1 Configuration – NFe BADI

 Summary of required variants on TVARVC table described in previous section (Jun/24):

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

Version 21.0 152908-0562-20232 Page 138 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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_

Version 21.0 152908-0562-20232 Page 139 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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_GTIN_NULLTXT S 0 I EQ SEM GTIN


ZSD_NFE_ICMS60_BRANC
H_RULE S 0 I BT 9000 ZSD_NFE_ICMS60_RULE_SP
ZSD_NFE_ICMS60_MARDH
_STATUSES S 0 I BT UXQWBR
ZSD_NFE_ICMS60_MARDH
_STATUSES S 1 I BT 9001 UBR
ZSD_NFE_ICMS60_MAT_CF
OPCTG S 0 I EQ 51
ZSD_NFE_ICMS60_SLSORG
_DSTCHL S 0 I BT 5204 01
ZSD_NFE_ICMS60_TAXTYP
E S 0 I EQ ZSTR
ZSD_NFE_ICMS60_TESTRU
N S 0 I EQ X

ZSD_NFE_PAYM_METH_B S 0 I BT 15 BOLETO BANCARIO

ZSD_NFE_PAYM_METH_D S 0 I BT 15 BOLETO BANCÁRIO

ZSD_NFE_PAYM_METH_M S 0 I BT 15 BOLETO BANCÁRIO


TRANSFERENCIA BANCARIA,
ZSD_NFE_PAYM_METH_N S 0 I BT 18 CARTEIRA DIGITAL
TRANSFERENCIA BANCARIA,
ZSD_NFE_PAYM_METH_O S 0 I BT 18 CARTEIRA DIGITAL

ZSD_NFE_PAYM_METH_R S 0 I BT 15 BOLETO BANCÁRIO


TRANSFERENCIA BANCARIA,
ZSD_NFE_PAYM_METH_T S 0 I BT 18 CARTEIRA DIGITAL
TRANSFERENCIA BANCARIA,
ZSD_NFE_PAYM_METH_U S 0 I BT 18 CARTEIRA DIGITAL
TRANSFERENCIA BANCARIA,
ZSD_NFE_PAYM_METH_W S 0 I BT 18 CARTEIRA DIGITAL
TRANSFERENCIA BANCARIA,
ZSD_NFE_PAYM_METH_Y S 0 I BT 18 CARTEIRA DIGITAL
TRANSFERENCIA BANCARIA,
ZSD_NFE_PAYM_METH_Z S 0 I BT 18 CARTEIRA DIGITAL
ZSD_NFE_PRES_INDIC_BU
KRS S 0 I EQ BR0K
ZSD_NFE_PRES_INDIC_BU
KRS S 1 I EQ BR0L
ZSD_NFE_PRES_INDIC_BU
KRS S 2 I EQ BR0M
ZSD_NFE_PRES_INDIC_BU
KRS S 3 I EQ BR0N
ZSD_NFE_PRES_INDIC_NF
TYPE S 0 I BT ** 1
ZSD_NFE_PRES_INDIC_NF
TYPE S 1 I BT Z2 0
ZSD_NFE_SB_PARTNER_P
LANTS S 0 I BT 1070 0000128256
ZSD_NFE_SB_PARTNER_P
LANTS S 1 I BT B206 0000128256
ZSD_NFE_SB_PARTNER_P
LANTS S 2 I BT 2349 0000128256
ZSD_NFE_SB_PARTNER_P
LANTS S 3 I BT 1071 0000127964
ZSD_NFE_SB_PARTNER_P
LANTS S 4 I BT B207 0000127964
ZSD_NFE_SB_PARTNER_P
LANTS S 5 I BT 2350 0000127964
ZSD_NFE_SB_PARTNER_P
LANTS S 6 I BT 1072 0000128256
ZSD_NFE_SB_PARTNER_P
LANTS S 7 I BT B208 0000128256
ZSD_NFE_SB_PARTNER_P
LANTS S 8 I BT 2351 0000128256

Version 21.0 152908-0562-20232 Page 140 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

ZSD_NFE_XMLTAG_PST S 0 I BT ZBR3 A373


ZSD_NFE_XMLTAG_VBCST
DEST S 0 I BT ZBR4 A373
ZSD_NFE_XMLTAG_VBCST
RET S 0 I BT ZBR0 A373
ZSD_NFE_XMLTAG_VICMS
STDEST S 0 I BT ZBR5 A373
ZSD_NFE_XMLTAG_VICMS
STRET S 0 I BT ZBR1 A373
ZSD_NFE_XMLTAG_VICMS
SUBSTITUTO S 0 I BT ZBR2 A373
ZSD_NFE_ZEROQTY_NFCO
MPLEM S 0 I EQ X
ZSD_NFE_STAT_ICMSDES
ON_BUKRS S 0 I EQ BR0L
ZSD_NFE_STAT_ICMSDES
ON_BUKRS S 1 I EQ BR0N
ZSD_NFE_CMPLINF_HDTX_ S I BT STSTCL_VICMSDESON Valor Total ICMS Dispensado: ZSD_NFE_CMPLINF_HDTX
ICMSDESON _ICMSDESON
ZSD_NFE_CMPLINF_HDTX_ S 1 I BT MOTDESICMS Motivo(s) Desoneracao ICMS: ZSD_NFE_CMPLINF_HDTX
ICMSDESON _ICMSDESON
ZMM_NFE_CMPLINF_HDTX S I BT 9001 ZSD_NFE_PROCON_RJ
_PROCON
ZMM_NFE_CMPLINF_J1B1H S 3 I EQ ZMM_NFE_CMPLINF_HDTX
DRTXTSEQ _PROCON
ZMM_NFE_CMPLINF_TEXT S 4 I EQ ZMM_NFE_CMPLINF_HDTX
SEQUENCE _PROCON
ZSD_NFE_CMPLINF_HDTX_ S I BT 9001 ZSD_NFE_PROCON_RJ
PROCON
ZSD_NFE_CMPLINF_TEXTS S 14 I EQ ZSD_NFE_CMPLINF_HDTX_
EQUENCE PROCON

Version 21.0 152908-0562-20232 Page 141 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

 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.

Version 21.0 152908-0562-20232 Page 142 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

 Following configuration view (on SM30 transaction, J_1BMODFRETE_DET) related to


SAP Std Brazilian Localization will be necessary to provide information “MODFRETE”
for NF-e based on the Incoterms of the transaction.

(Current PRC values)

Version 21.0 152908-0562-20232 Page 143 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

 Following configuration flag on Brazilian branches is necessary in case the Method


ADD_DATA_J1B1N of new BADI J_1BNF_ADD_DATA must be used. If flag not active, then
the Method is not accessed even with the BADI activated.

4.2 Master Data – NFe BADI

Not applicable.
4.3 Enhancements – NFe BADI

Not applicable.

Version 21.0 152908-0562-20232 Page 144 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

4.4 Interfaces – NFe BADI

Not applicable.
4.5 Data Migration – NFe BADI

Not applicable.
4.5.1 Issue LogBehavioural Change – NFe BADI
Doc x-ref Description Notes Owner

4.5.2 Notes – NFe BADI


Doc x-ref Description Owner

5 TESTING REQUIREMENT – NFE BADI


5.1 Test cases / scenarios for O2C – NFe BADI

Test Step Step Description Expected Results


Condition
Create a sales order (order 01 Create a sales order Brazilian taxes are
type ZES) with: properly calculated in
Customer: end-consumer pricing procedure.
company
Material: energy material

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

5.2 Test cases / scenarios for P2P – NFe BADI

Test Step Step Description Expected Results


Condition
Find a PO create for 01 PO to do the return to vendor process The purchase order
consumption material, data is loaded
BR0L company code, plant automatically, and
H018, and have already since it is a total return,
had an invoice and nota you do not need to
fiscal posted with “I1” NF change the suggested
category quantity

T-Code: use ME2L

Version 21.0 152908-0562-20232 Page 145 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

T-Code: use MIRO


In the nota fiscal monitor, 03 Send the Nota Fiscal to get SEFAZ The nota fiscal was
select the nota fiscal approval approved and will be
created in the previous possible to print the
step, to send to SEFAZ DANFE to send the
T-Code: use J1BNFE good back to the
vendor
Check the PO history, and 04 PO history review User will be able to see
will be possible to see a that the Invoice PO
new line for the Credit History back to “zero”
Invoice, opening the PO (leaving the PO
quantity again to the new pending to receive the
nota fiscal that the vendor invoice and goods
will issue with the goods again)

Version 21.0 152908-0562-20232 Page 146 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

6 FUNCTIONAL DESIGN – DANFE AND PRINTING PROGRAM


6.1 As-Is Process – DanFe and Printing program:

The print program and smartform were already developed in the PRC system with DANF-e being
issued by that system.

Current PRC objects are:

Print Program: /BPBFL/O2C_FOUT_DANFE


Smartform: /BPBFL/O2C_FORM_OUT_DNFE

6.2 To-Be process – DanFe and Printing program:

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.

It is composed of two parts:


 An SAP Smartform that reflects one of the possible legal DANF-e formats made available by the
Tax Authority and chosen by BP as currently used in the PRC Production environment
(landscape).
 The print program report itself, that collects and processes all the necessary information to feed
DANF-e Form fields and text areas required to accomplish its legal issuance on operational
transactions.

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.

6.3 Security – DanFe and Printing program

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

7.1 Report – Print Program

Print program for DANFe is based on SAP Standard BR Localization J_1BNFPR.

Version 21.0 152908-0562-20232 Page 147 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

Version 21.0 152908-0562-20232 Page 148 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

#n1 Current page Current page All H 8 N/A


page
s
#nnn Total Pages Total Pages All H 8 N/A
page
s
#chavedeacessonfe Concatenate NF-e Access All H 8 N/A
GS_NFEACTIVE-REGIO Key (the one that page
/ GS_NFEACTIVE- composes the s
NFYEAR / DANF-e bar
GS_NFEACTIVE- code)
NFMONTH /
GS_NFEACTIVE-
STCD1 /
GS_NFEACTIVE-
MODEL /
GS_NFEACTIVE-SERIE
/ GS_NFEACTIVE-
NFNUM9 /
GS_NFEACTIVE-
DOCNUM9 /
GS_NFEACTIVE-CDV
#conteudovariavel1 "www.nfe.fazenda.gov.br SEFAZ Tax Only if the field J_1BPRNFHD-COUNTING is All H 8 N/A
/portal ou no site da Authority site initial page
Sefaz Autorizadora" when it's s
possible to
check NF-e
authenticity by
using Access
Key info
#naturezaoperacao J_1BPRNFHD-NATOP Nature of All H 8 N/A
operation page
description s
#protocoloautorizacao GS_NFEACTIVE- Authorization Format Date= DD/MM/YYYY and All H 8 N/A
AUTHCOD Protocol Code, Time=HH:MM:SS page
GS_NFEACTIVE- Date and Time, s
AUTHDATE issued by
GS_NFEACTIVE- SEFAZ Tax

Version 21.0 152908-0562-20232 Page 149 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

#cnpjempresa J_1BPRNFIS-CGC NF Issuer CNPJ All H 8 N/A


Federal page
Inscription s
#enderecoemp J_1BPRNFIS-STRAS Address All H 8 N/A
page
s
#bairroemp J_1BPRNFIS-ORT02 district All H 8 N/A
page
s
#cidadeemp J_1BPRNFIS-ORT01 City All H 8 N/A
page
s
#ufemp J_1BPRNFIS-TXJCD(2) State All H 8 N/A
page
s
#cepemp J_1BPRNFIS-PSTL2 Cep All H 8 N/A
page
s
#foneemp J_1BPRNFIS-TELF1 Telephone All H 8 N/A
page
s
#siteemp Blank Site All H 8 N/A
page
s
#BCCODE1281 Barcode Barcode code-128C based on field All H 8 N/A
#chavedeacessonfe page
s
#razaosocialdestinatario J_1BPRNFDE-NAME1 + NF-e recipient First H 8 N/A
J_1BPRNFDE-NAME2 + name page
J_1BPRNFDE-NAME3 + only
J_1BPRNFDE-NAME4
#cnpjdestinatario J_1BPRNFDE-CGC or NF-e recipient If J_1BPRNFDE-STKZN = ‘X’, CPF using First H 8 N/A
J_1BPRNFDE-CPF CNPJ/CPF format xxx.xxx.xxx-xx, otherwise CNPJ/CGC page
Federal using format xx.xxx.xxx/xxxx-xx only
Inscription

#dataemissao J_1BPRNFHD-DOCDAT NF-e Document Format DD/MM/AAAA First H 8 N/A


Date page
only

#enderecodestinatario If J_1BPRNFDE- NF-e recipient (START – 20_UAT: RITM000001588724 First H 8 N/A


XCPDK = 'X', address (street, Changes V3.0 – 15th Oct 2022) page
J_1BPRNFDE-STRAS number, Substitute ADDR_GET Function Module by or only
(Street and Number). complement) J_1B_NF_VENDOR_READ (IF gs_j1bprnfhd-
Else, Concatenate partyp = lv_ptypc) or
J_1BPRNFDE- J_1B_NF_CUSTOMER_READ (IF
STREET / gs_j1bprnfhd-partyp = lc_ptypc) Module
J_1BPRNFDE- Function, on all points of Method
HOUSE_NUM1 / PROCESS_FIRST:
J_1BPRNFDE- On CALL FUNCTION for J_1B Module
HOUSE_NUM2 Functions, use PARTNER_ID = gs_j1bprnfhd-
parid AND READ_ADDRESS = 'X'.
Fields provided by ADDRESS1 Import
structure on J_1B module functions are
exactly the same as the one on
ADDRESS_VALUE (feeding final variable
string ls_addval) returned by ADDR_GET
module function.
(END – 20_UAT: RITM000001588724
Changes V3.0 – 15th Oct 2022)
#bairrodestinatario J_1BPRNFDE-ORT02 District (START – 24_UAT: RITM000001588724 First H 8 N/A
Changes V3.0 – 15th Oct 2022) page
On Method PROCESS_FIRST of Report only
ZSD_O2C_FOUT_DANFE, change current
block below:

gs_firstsf-ort02 = gs_j1bprnfde-ort02.
gs_firstsf-pstlz = gs_j1bprnfde-pstlz.

IF gs_j1bprnfhd-pstdat IS NOT INITIAL.


gs_firstsf-pstdat = gs_j1bprnfhd-pstdat.
"dsaient.
ENDIF.

Version 21.0 152908-0562-20232 Page 150 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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
.…

To the following as expected per SEFAZ


Tax Authority rules on XML


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.

IF gs_j1bprnfhd-pstdat IS NOT INITIAL.


gs_firstsf-pstdat = gs_j1bprnfhd-pstdat.
"dsaient.
ENDIF.

gs_firstsf-ort01 = gs_j1bprnfde-ort01.

(END – 24_UAT: RITM000001588724
Changes V3.0 – 15th Oct 2022)

#cepdestinatario J_1BPRNFDE-PSTLZ ZIP Code First H 8 N/A


page
only

#dataentrega J_1BPRNFHD-DSAIENT Outbound or First H 8 N/A


Inbound ( From / page
To Plant) - only
generally the
NF-e approved
time
#cidadedestinatario J_1BPRNFDE-ORT01 NF-e recipient First H 8 N/A
City page
only

#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

#inscrestaddestinatario J_1BPRNFDE-STAINS NF Recipient - First H 8 N/A


State Inscription page
only

Version 21.0 152908-0562-20232 Page 151 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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:

Declare a custom variable LF_NPARC type


N length 1 (to work as a sequential
number)
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 structure LW_I_FAEDE
type FAEDE (used in function
DETERMINE_DUE_DATE)
Declare a custom structure LW_E_FAEDE
type FAEDE (used in function
DETERMINE_DUE_DATE)

Read field PARID from table J_1BNFNAD


where DOCNUM = J_1BPRNFHD-DOCNUM
and PARVW = ‘RG’ (Payer).
Create a custom variable called
LF_REF_NUMBER type J_1BINTERF-
XBLNR.
Use function module
J_1B_NF_NUMBER_CONDENSE sending
fields J_1BPRNFHD-SERIES,
J_1BPRNFHD-SUBSERIES and
J_1BPRNFHD-NFENUM as parameters and
receiving the result in custom variable
LF_REF_NUMBER.
After that select fields SHKZG, DMBTR,
ZFBDT, ZBD1T, ZBD1P and REBZG for all
entries in table BSID into your previously
declared table LT_BSID where BSID-
BUKRS = J_1BPRNFHD-BUKRS and BSID-
KUNNR = J_1BNFNAD-PARID and BSID-
GJAHR = year of field J_1BPRNFHD-
DOCDAT and BSID-XBLNR =
LF_REF_NUMBER and BSID-VBELN =
J_1BPRNFLI-REFKEY(10).
After retrieving data from table BSID (open
items) do the same search in table BSAD
(cleared items), appending the results in
the same internal table LT_BSID.
The processing logic for installments is
explained below:
Clear the variable LF_NPARC.

Loop the custom table LT_BSID. To each


record do:
Increase the variable LF_NPARC (add 1
to variable)
Clear the custom structures
LW_E_FAEDE and LW_I_FAEDE
Fill the custom structure LW_I_FAEDE
with the corresponding LT_BSID fields,
and field KOART with “D”.
Call the function module
DETERMINE_DUE_DATE sending the
structure LW_I_FAEDE.
After the call function, the complete
billing data information (installment) is:

Version 21.0 152908-0562-20232 Page 152 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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):

000562099-01 | 30/09/22 | 7.441,86


000562099-02 | 30/10/22 | 7.441,86

#vencfat1, #vencfat2, LW_E_FAEDE-NETDT VENCIMENTO LW_E_FAEDE-NETDT First H 8 N/A


#vencfat3, #vencfat4, (Installment J_1BNFTRADENOTES-DVENC page
#vencfat5, #vencfat6, Due Date) only
#vencfat7, #vencfat8
#vlfat1, #vlfat2, #vlfat3, LT_BSID-DMBTR VALOR LT_BSID-DMBTR First H 8 N/A
#vlfat4, #vlfat5, #vlfat6, (Installment J_1BNFTRADENOTES-VDUP page
#vlfat7, #vlfat8 Value) only

#vlbcicmsnota J_1BPRNFHD- BASE DE (START - 40_UAT: RITM000002278935 First H 8 N/A


ICMSBASE or SPACE CÁLCULO DO Changes V4.0 – 21st Jun 2024) page
ICMS (ICMS Tax ICMS Base Amount. Send only if only
Base) J_1BPRNFHD-ICMSVAL field> 0 (not null).
* Premise: For Tax Types NOT STATISTICAL
related to "ICMS" Tax Group, effective base
value is the summing up of 1st occurrence
with "normal base" value greater than zero for
each NF item. It's not expected that "normal
base" for ICMS should be composed /
summed up by multiple lines for the same NF
Item.
CLEAR: lv_base
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
base IS NOT INITAL AND stattx IS INITIAL
lv_base = lv_base + ls_nfstx-base
EXIT
ENDLOOP
ENDLOOP

NF Total ICMS Base = lv_base


(END – 40_UAT: RITM000002278935
Changes V4.0 – 21st Jun 2024)

#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

Version 21.0 152908-0562-20232 Page 153 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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)

#vlbcicmsstnota J_1BPRNFHD- Bill to - BASE First H 8 N/A


ICSTBASE DE CÁLCULO page
DO ICMS ST only

#vlicmsstnota J_1BPRNFHD-ICSTVAL VALOR DO First H 8 N/A


ICMS page
SUBSTITUTO only
(ICMS-ST Tax
Amout)
#vltotprod J_1BPRNFHD-NFNET VALOR TOTAL (v4.0 SYMBRET_CAT not used anymore) First H 8 N/A
or (J_1BPRNFHD- DOS Select the table of variant variables page
NFNET + PRODUTOS (TVARVC) table where TVARVC-SIGN = “I”, only
J_1BPRNFHD-NFDIS) (Total value of TVARVC_OPTI = “EQ” and TVARVC-NAME
Products) = SYMBRET_NFCAT. Get the value of
TVARVC-HIGH).

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."

#vlfretenota Blank VALOR DO First H 8 N/A


FRETE (Freight page
Value) only

#vlseguronota Blank VALOR DO First H 8 N/A


SEGURO page
(Insurance only
Value)
#vldescontonota Blank VALOR DO First H 8 N/A
DESCONTO page
(Discounts) only

#vldespesasnota J_1BPRNFHD-NFOTH OUTRAS First H 8 N/A


DESPESAS page
(Other only
Expenses)
#vlipinota J_1BPRNFHD-IPIVAL VALOR DO IPI First H 8 N/A
(IPI Tax page
Amount) only

#vltotnota J_1BPRNFHD-NFTOT VALOR TOTAL First H 8 N/A


DA NOTA (Total page
NF-e Value) only

#nometransp MY_CARRIER-NAME1 NOME / RAZÃO First H 8 N/A


+ MY_CARRIER- SOCIAL page
NAME2 + TRANSPORTA only
MY_CARRIER-NAME3 DORA (Carrier
+ MY_CARRIER- Name)
NAME4

Version 21.0 152908-0562-20232 Page 154 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

With the above, change existing


constants:
lc_idr1 TYPE string VALUE '1-
Destinatário/Remetente ' ‘1- Frete estipulado
pelo destinatario’,
lc_idr2 TYPE string VALUE '0-Emitente'
‘0- Frete estipulado pelo remetente’,

(START – 24_UAT: RITM000001588724


Changes V3.0 – 15th Oct 2022)

#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.

(START – 19_UAT: RITM000001588724


Changes V3.0 – 15th Oct 2022)

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
RNTC Code => if exists per line, is the 3rd
string after second ";" separator

Vehicles RNTC:
#rntc1 J_1BNFDOC-RNTC
#rntc2 J_1BNFTRAILER[1]-RNTC
#rntc3 J_1BNFTRAILER[2]-RNTC

(END – 19_UAT: RITM000001588724


Changes V3.0 – 15th Oct 2022)

Version 21.0 152908-0562-20232 Page 155 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

(START – 19_UAT: RITM000001588724


Changes V3.0 – 15th Oct 2022)

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 number => if exists per line, is the
1st string on line, before any separator

Plate numbers:
#placa1 J_1BNFDOC-PLACA
#placa2 J_1BNFTRAILER[1]-PLACA
#placa3 J_1BNFTRAILER[2]-PLACA

(END – 19_UAT: RITM000001588724


Changes V3.0 – 15th Oct 2022)

#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.

(START – 19_UAT: RITM000001588724


Changes V3.0 – 15th Oct 2022)

Version 21.0 152908-0562-20232 Page 156 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

(END – 19_UAT: RITM000001588724


Changes V3.0 – 15th Oct 2022)

#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

Version 21.0 152908-0562-20232 Page 157 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

(END – 22_UAT: RITM000001588724


Changes V3.0 – 15th Oct 2022)

#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

(END – 22_UAT: RITM000001588724


Changes V3.0 – 15th Oct 2022)

#numeracaovolume J_1BPRNFHD- NUMERO (START – 22_UAT: RITM000001588724 First H 8 N/A


SHPNUM(START – IDENTIFICAÇÃ Changes V3.0 – 15th Oct 2022) page
22_UAT: O (HU only
RITM000001588724 Numbers) Separated by " ;"
Changes V3.0 – 15th CREATE new GS_FIRST-NVOL CHAR36 to
Oct 2022) support this DANFe field (does not exist
currently)
Concatenation of CONCATENATE( J_1BNFTRANSVOL-
J_1BNFTRANSVOL- NVOL of all existing records, separated by
NVOL '/' into lv_nvol, truncating by field limit of
or 36 chars)
J_1BPRNFHD-SHPNUM IF lv_nvol IS NOT INITIAL
Use lv_nvol on GS_FIRST-NVOL
(END – 22_UAT: ELSEIF lv_nvol NOT INITIAL AND
RITM000001588724 J_1BPRNFHD-SHPNUM IS NOT INITIAL
Changes V3.0 – 15th Use J_1BPRNFHD-SHPNUM on
Oct 2022) GS_FIRST-NVOL
ENDIF

(END – 22_UAT: RITM000001588724


Changes V3.0 – 15th Oct 2022)

#pesobrutototal J_1BPRNFHD- PESO BRUTO (START – 22_UAT: RITM000001588724 First H 8 N/A


BRGEW(START – (Shipment Changes V3.0 – 15th Oct 2022) page
22_UAT: Gross weight) only
RITM000001588724 Get value using new specific
Changes V3.0 – 15th J_1BNFTRANSVOL:
Oct 2022) Read all records of table and sumup the
values on field PESOB
∑ J_1BNFTRANSVOL- IF ∑PESOB > 0
PESOB Use ∑PESOB on GS_FIRST-BRGEW
or ELSE
J_1BPRNFHD- Use J_1BPRNFHD-BRGEW on
BRGEW GS_FIRST-BRGEW
ENDIF
(END – 22_UAT:
RITM000001588724 (END – 22_UAT: RITM000001588724
Changes V3.0 – 15th Changes V3.0 – 15th Oct 2022)
Oct 2022)

#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

Version 21.0 152908-0562-20232 Page 158 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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)

$a01, $a02, $a03, $a04, MY_ITEMS-MATNR CÓDIGO Main H 8 N/A


$a05, $a06, $a07 (Material or detai
Service Code) l
$b01, $b02, $b03, $b04, MY_ITEMS-MAKTX or DESCRIÇÃO Description. Main H 8 N/A
$b05, $b06, $b07 MAKT-MAKTG (in PRODUTO/SER If J_1BPRNFLI-MATNR is initial then print detai
Brazilian Portuguese) VIÇO (Material J_1BPRNFLI-MAKTX otherwise read field l
or Service MAKTG from table MAKT where MAKT-
Description) MATNR = J_1BPRNFLI-MATNR and MAKT-
SPRAS = ‘(’ (PT Brazilian Portuguese).

$q01, $r01, $s01 TEXTO DE Item H 6 N/A


$t01, $u01, $v01 ITEM para FCP Deta
e/ou FCP ST il
(Item individual
texts for FCP
and/or FCP ST Text block already assembled with final
Taxes, if
values on BADI J_1BNF_ADD_DATA
applied, but
(previous section) during SAP NF Doc
on/off
creation. So get infAdProd text block
controlled by
ready for each NF item the following:
TVARVC)
$w01, $x01, $y01
READ_TEXT Using
ID = ‘0001’
TEXTO DE
LANGUAGE = ‘PT’
ITEM para
NAME = J_1BNFLIN-DOCNUM(10) //
ICMS-ST
J_1BNFLIN-ITMNUM(6)
“Repasse”
OBJECT = ‘J_1BNFLIN’
(CST 60)
(Item individual
texts for “ICMS
Repasse”, if
applied, but
on/off
controlled by
$z01 TVARVC)

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

OBS: On the above text block NO VALUES


must be informed or any variables must be
treated. This work is already performed by
the NF-e BADI when assembling the
complete text block during NF creation.

$c01, $c02, $c03, $c04, MY_ITEMS-NBM NCM (Tax Main H 8 N/A


$c05, $c06, $c07 Classification detai
Number for l
Material /
Service)
$d01, $d02, $d03, $d04, MY_ITEMS-MATORG + CST (Material Concatenate J_1BPRNFLI-MATORG and Main H 8 N/A
$d05, $d06, $d07 MY_ITEMS-TAXSIT Origin J_1BPRNFLI-TAXSIT without spaces. detai
concatenated Field J_1BPRNFLI-TAXSIT requires the l
with ICMS use of function module
Tributary CONVERSION_EXIT_TXSIT_OUTPUT to
Situation Code) format the output.

$e01, $e02, $e03, $e04, MY_ITEMS-CFOP(4) CFOP (Fiscal Main H 8 N/A


$e05, $e06, $e07 Code of the detai
Operation) l
$f01, $f02, $f03, $f04, MY_ITEMS-NFUNT UN (Unit of Main H 8 N/A
$f05, $f06, $f07 Measure for detai
Material or l

Version 21.0 152908-0562-20232 Page 159 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

#vlisstotal J_1BPRNFHD-ISSPVAL VALOR DO if J_1BPRNFHD-ISSPBASE are not null, First H 8 N/A


or J_1BPRNFHD- ISSQN (ISS Tax J_1BPRNFHD-ISSPVAL . page
ISSSVAL Amount) If J_1BPRNFHD-ISSSBASE are not null, only
J_1BPRNFHD-ISSSVAL.
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

Version 21.0 152908-0562-20232 Page 160 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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.

(v4.0 SYMBRET_CAT not used anymore)


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).

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:

=> Concatenate to already provided SAP


Standard BR Localization texts, a specific
customized BP Sales Order Header text
block, if exists, provided by TVARVC
variable ZSD_DANFE_NFTYP_ORDTXT
(see details at the end), using the following
logic:
if J_1BNFLIN-REFKEY (1st occurrence), go
to VBRP table where VBELN equal
J_1BNFLIN-REFKEY.
Use the funtion READ_TEXT with this
information, ID equal value provided by
TVARVC (if exists), Language equal PT,
Name equal VBRP-VGBEL, OBJECT equal
VBBK.
=> E-mail of customer master data, it is
necessary use the logic below:
Use field J_1BPRNFHD-J_1BPARID into
table KNA1 where KUNNR equal
J_1BPRNFHD-J_1BPARID. With field
ADRNR, select field SMTP_ADDR where
addrnumber equal KNA1-ADRNR,
PERSNUMBER equal blank, larger
DATE_FROM and FLGDEFAULT equal "X".

OBS: To avoid fixing the Text Block per NF


Type, please create the following logic
based on TVARVC entries for
‘ZSD_DANFE_NFTYP_ORDTXT’:
On counter, next counter value (multiple
entries)
On Low value, the NF Type (exp: ‘Z2’)
On High value, the Sls Order Hdr Text ID
(exp: 'Z002').

With the migration of the former


CL_NFE_PRINT BADI to the new
J_1BNFE_ADD_DATA, all the text blocks
are being treated in a way to compose the
unique “informações complementares”
text and save it on SAP NF tables
(persistence). With that said, it’s enough to
get J_1BNFFTX table records as described
in the beginning.

With last changes by SAP on NF Header


Texts by adoption of “Additional
Information” Header tab on NF Doc, all
BADI Texts are being collected and
assembled to the
“Addit.Inform(Company)” Text block

CALL FUNCTION READ_TEXT


EXPORTING
ID = ‘0002’
LANGUAGE = ‘PT’
NAME = J_1BNFDOC-DOCNUM (w/ 10

Version 21.0 152908-0562-20232 Page 161 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

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

(END – 10_UAT: Changes V2.0 – 29th Jun


2022)

#contingencia Blank RESERVADO First H 8 N/A


AO FISCO page
(Area Reserved only
to Fiscal Tax
Authority)
#homologacao1 NF-e emitida em If GS_NFEACTIVE-TPAMB equal 2, fix text First H 8 N/A
ambiente de "NF-e emitida em ambiente de page
homologação or blank homologação - SEM VALOR FISCAL". only

#homologacao2 First H 8 N/A


page
only

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

7.2.1 Form Main Requirements


Output type(s): PDF
Form Types: Smartform
Transmission medium: Network (LAN, WAN)
Legal requirements: Rules defined for DANF-e Landscape format as per NF-e
“Manual de Orientação ao Contribuinte”
Type of printer: Laser, Inkjet (Barcode will be printed on document)
Paper Size: A4

Version 21.0 152908-0562-20232 Page 162 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Orientation: Landscape
Special stationary to be used: N/A
Frequency and Timing On demand

7.2.2 Form Layout


SAP Standard BR Localization provides a DANF-e reference Smartform named J_1B_NF_SMARTFORMS
as shown below:

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):

Version 21.0 152908-0562-20232 Page 163 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

7.2.3 Page Break Requirement


DANF-e for BP is multipage: check layout contents details for differences between main and
subsequent pages.

7.2.4 Standard Texts (if SAPscript)


N/A
Description of Text Name Text ID Error Case
use
e.g. ADRS Describe the logic in case e.g. the standard
text in that language is missing.

7.2.5 Text Modules (if Smartforms)


Text Module name Original Translation Style name Error
language Case
Description of
use
Left side of sheet RECEBEMOS DE #razaosocialempresa OS PT H, 6 N/A
PRODUTOS CONSTANTES DA NOTA
FISCAL INDICADA AO LADO
Left side of sheet NF-e PT H, B, 8 N/A
Nº. #nrnota
SÉRIE #ser
Left side of sheet DATA DE RECEBIMENTO PT H, 6 N/A
Left side of sheet IDENTIFICAÇÃO E ASSINATURA DO PT H, 6 N/A
RECEBEDOR
Header Identificação do emitente PT H, B, 6 N/A
Header DANFE PT H, B, 10 N/A
Header DOCUMENTO AUXILIAR DA PT H, B, 6 N/A
NOTA FISCAL ELETRÔNICA
Header 0 – ENTRADA PT H, 8 N/A
1 – SAÍDA
Header Nº. #nrnota PT H, B, 8 N/A
Header – FL #n1 / #nnn PT H, 8 N/A

Version 21.0 152908-0562-20232 Page 164 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Header SÉRIE #ser PT H, B, 8 N/A


Header CHAVE DE ACESSO PT H, 6 N/A
Header Consulta de autenticidade no portal nacional PT H, 6 N/A
da NF-e
Header NATUREZA DA OPERAÇÃO PT H, 6 N/A
Header PROTOCOLO DE AUTORIZAÇÃO DE USO PT H, 6 N/A
Header INSCRIÇÃO ESTADUAL PT H, 6 N/A
Header INSCR. EST. SUBS. TRIBUTÁRIO PT H, 6 N/A
Header CNPJ PT H, 6 N/A
Main DESTINATÁRIO/REMETENTE PT H, B, 6 N/A
Main NOME / RAZÃO SOCIAL PT H, 6 N/A
Main CNPJ / CPF PT H, 6 N/A
Main DATA DA EMISSÃO PT H, 6 N/A
Main ENDEREÇO PT H, 6 N/A
Main BAIRRO / DISTRITO PT H, 6 N/A
Main CEP PT H, 6 N/A
Main DATA DA ENTRADA/SAÍDA PT H, 6 N/A
Main MUNICÍPIO PT H, 6 N/A
Main FONE / FAX PT H, 6 N/A
Main UF PT H, 6 N/A
Main INSCRIÇÃO ESTADUAL PT H, 6 N/A
Main HORA DE SAÍDA PT H, 6 N/A
Main FATURA/DUPLICATA PT H, B, 6 N/A
Main FATURA/DUPLICATA PT H, 6 N/A
Main VENCIMENTO PT H, 6 N/A
Main VALOR PT H, 6 N/A
Main CÁLCULO DO IMPOSTO PT H, B, 6 N/A
Main BASE DE CÁLCULO DO ICMS PT H, 6 N/A
Main VALOR DO ICMS PT H, 6 N/A
Main BASE DE CÁLCULO DO ICMS ST PT H, 6 N/A
Main VALOR DO ICMS SUBSTITUTO PT H, 6 N/A
Main VALOR TOTAL DOS PRODUTOS PT H, 6 N/A
Main VALOR DO FRETE PT H, 6 N/A
Main VALOR DO SEGURO PT H, 6 N/A
Main VALOR DO DESCONTO PT H, 6 N/A
Main OUTRAS DESPESAS PT H, 6 N/A
Main VALOR DO IPI PT H, 6 N/A
Main VALOR TOTAL DA NOTA PT H, 6 N/A
Main TRANSPORTADOR / VOLUMES PT H, B, 8 N/A
TRANSPORTADOS
Main NOME / RAZÃO SOCIAL PT H, 8 N/A
Main FRETE POR CONTA PT H, 8 N/A
Main CÓDIGO ANTT PT H, 8 N/A
Main PLACA DO VEÍCULO PT H, 8 N/A
Main UF PT H, 8 N/A
Main CNPJ PT H, 8 N/A
Main ENDEREÇO PT H, 8 N/A
Main MUNICÍPIO PT H, 8 N/A
Main UF PT H, 8 N/A
Main INSCRIÇÃO ESTADUAL PT H, 8 N/A
Main QUANTIDADE PT H, 8 N/A
Main ESPÉCIE PT H, 8 N/A
Main MARCA PT H, 8 N/A
Main NUMERO PT H, 8 N/A
Main PESO BRUTO PT H, 8 N/A
Main PESO LÍQUIDO PT H, 8 N/A
Main DADOS DOS PRODUTOS / SERVIÇOS PT H, B, 8 N/A
Main CÓDIGO PT H, 8 N/A
Main DESCRIÇÃO PRODUTO/SERVIÇO PT H, 8 N/A
Main NCM / SH PT H, 8 N/A
Main CST PT H, 8 N/A
Main CFOP PT H, 8 N/A
Main UN PT H, 8 N/A
Main QUANT. PT H, 8 N/A
Main VALORUNITÁRIO PT H, 8 N/A
Main VALORTOTAL PT H, 8 N/A
Main B. CALC. ICMS PT H, 8 N/A
Main B.CÁLC. ICMS ST PT H, 8 N/A
Main VALOR ICMS PT H, 8 N/A
Main VALOR ICMS ST PT H, 8 N/A
Main VALOR IPI PT H, 8 N/A
Main ALIQUOTAS PT H, 8 N/A
Main ICMS PT H, 8 N/A
Main IPI PT H, 8 N/A
Footer CÁLCULO DO ISSQN PT H, B, 8 N/A
Footer INSCRIÇÃO MUNICIPAL PT H, 8 N/A
Footer VALOR TOTAL DOS SERVIÇOS PT H, 8 N/A
Footer BASE DE CÁLCULO DO ISSQN PT H, 8 N/A
Footer VALOR DO ISSQN PT H, 8 N/A
Footer DADOS ADICIONAIS PT H, B, 8 N/A
Footer INFORMAÇÕES COMPLEMENTARES PT H, B, 8 N/A
Footer RESERVADO AO FISCO PT H, 8 N/A

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.

Version 21.0 152908-0562-20232 Page 165 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

Note C: This Style name will be defined in Smartforms and will contain the Paragraph and
character formats needed to output the text modules.

7.2.6 Layout Details – DanFe and Printing program


Macro position of the main window (details inside the macro window on topic 4.2)
Position of Left Margin 0,7 cm from left border
(Specify Unit)
Position of Right Margin 0,7 cm from left border
(Specify Unit)
Position of Logo 3,0cm from left border
(Specify Unit)
Position of Main Window (from top)
(Specify Unit)

8 DETAILED SAP CONFIGURATION – DANFE AND PRINTING PROGRAM


Not applicable.
8.1 Configuration – DanFe and Printing program

Output message type ZE01 review to change to new print program and smartform.

8.2 Master Data – DanFe and Printing program

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

Version 21.0 152908-0562-20232 Page 166 of 245


Functional Design
BTM-FTS_OTC_ENH010_BR__Nota Fiscal legal information - values_texts

9 TESTING REQUIREMENT – DANFE AND PRINTING PROGRAM


9.1 Test cases / scenarios – DanFe and Printing program

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

Version 21.0 152908-0562-20232 Page 167 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

10 FUNCTIONAL DESIGN - SEND EMAIL WITH DANFE/XML


10.1 As-Is Process - Send email with DANFE/XML:

Transaction /BPBFL/SD_NFE_MAIL Program /BPBFL/OTC_MAIL_SEND is the solution responsible to re-


create the DANF-e and XML files and attach them while assembling an email to be sent to the recipient of
each SAP NF Document approved by SEFAZ Tax Authority.

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.

10.2 To-Be process - Send email with DANFE/XML:

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.

It will be composed by five parts:

 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.

Version 5.0 29-03-2021 Page 168 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

Regarding the new four components, we have planned the following functional behaviors:

Version 5.0 29-03-2021 Page 169 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

Functional design of the new Z program for Output message


 Once output message starts processing (status = ‘pending’).
 Check if SAP NF Doc is CANCELLED or NF-e status is DENIED.
 If YES, set Output Message status to ‘processed’ (green) and log “NF-e XXXXXXXXX-SSS, Branch
BBBB cancelled or denied: not necessary to send e-mail.”. => FINISH.
 If NOT CANCELLED, check if NF-e status is still INITIAL or REJECTED.
 If YES (INITIAL or REJECTED), set Output Message status to ‘pending’ (yellow) => FINISH (will be
processed again on next job run).
 If NOT (INITIAL or REJECTED).
 Check if NF Partner code has a not blank e-mail e-mail(s) defined: get the one(s) set as
“Standard” and not linked to a Person with string “NFEXML” defined on besides “notes” field;
 If NOT, set Output Message status to ‘error’ (red) and log “<Customer / Vendor> XXXXXXXXXX has
no e-mail address defined. NF-e XXXXXXXXX-SSS, Branch BBBB was not sent. After corrections,
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 erro 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 and that partner also has a not
blank e-mail defined: get the one set as “Standard” and not linked to a Person e-mail(s)
defined: get the one(s) set with string “NFEXML” defined on besides “notes” field;
o If NOT, ADD to Output Message log <”Carrier XXXXXXXXXX has no e-mail address defined.
NF-e XXXXXXXXX-SSS, Branch BBBB was not sent to it. After corrections, for new attempt,
use transaction <new transaction code>” => FINISH.
 Check if there is an External Warehouse (‘SB’) Partner on SAP NF Doc and that
partner code is different from the main NF Partner:
 If YES, check that partner ‘SB’ has e-mail(s) defined and set with string
“NFEXML” defined on besides “notes” field.
o If NOT, ADD to Output Message log ”<External Warehouse
XXXXXXXXXX has no e-mail address defined. NF-e XXXXXXXXX-
SSS, Branch BBBB was not sent to it. After corrections, for new
attempt, use transaction <new transaction code>”.
o FINISH with status to ‘error’ (red) and just first cumulated log
 If YES (NF Partner has at least one NF-e e-mail inbox defined with “NFEXML” stamp), THEN
append the e-mail(s) on an internal table PARTNERS_EMAILS
o Read parameter table records in using following as criteria: NAME =
ZSD_EMAIL_DNFXML_PARTNERS_ERR

Version 5.0 29-03-2021 Page 170 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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);

(END – 17_UAT: Changes V2.0 – 22nd Aug 2022)

o If YES table PARTNERS_EMAILS is not empty


 Generate virtual DANF-e PDF file using print program.

Version 5.0 29-03-2021 Page 171 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

 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)

 Check if e-mail processing was OK


 If NOT, set Output Message status to ‘error’ (red) and log “E-mail NF-e
XXXXXXXXX-SSS, Branch BBBB, sending failed error <captured error> For another
attempt, use transaction <new transaction code>” => FINISH.
 If YES, set Output Message status to ‘processed’ (green) and log “E-mail(s) with
XML and DANF-e for NF-e XXXXXXXXX-SSS, Branch BBBB sent successfully to
Customer/Vendor XXXXXXXXXX e-mail [email protected], [email protected],
[email protected]”. => FINISH.

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);

Version 5.0 29-03-2021 Page 172 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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)

Version 5.0 29-03-2021 Page 173 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

 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

Functional design of the new requirement routine in NF output message procedure


 Once entering on requirement routine:
o Set return code = ‘fail’
o Read NAST messages tables using
Application = ‘NF’
Object key = <SAP NF Document number being processed>
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)
o If FOUND, exit (will not process routine)
o If NOT FOUND, set return code = ‘ok’. Then routine is free to be executed

Security
Transaction code
 The new Z transaction will require authorization objects for the following organization / transactional
elements:
o Company Code

Version 5.0 29-03-2021 Page 174 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

11 TECHNICAL DESIGN - SEND EMAIL WITH DANFE/XML


Basic technical sequence of table accesses for e-mail(s) address(es) defined as NF-e inbox(es) on Partners
(same for Vendors and Branches). This will be used on next subsections.
(SAP Customer Master Data)

(obs: “From” = execution date)

11.1 Report - Program for NF Output message

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.

Version 5.0 29-03-2021 Page 175 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

 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:

Version 5.0 29-03-2021 Page 176 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

(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
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>.
Check if lv_email_carrier lt_nfe_emails is found and it’s not blank IS INITIAL
If NOT lt_nfe_emails IS INITIAL, ADD to Output Message log “<”Carrier XXXXXXXXXX has
no e-mail address defined. NF-e XXXXXXXXX-SSS, Branch BBBB was not sent to anyone.
After corrections, for new attempt, use transaction <new transaction code>” => FINISH.
o Check if there is a Withdrawal Location / External Warehouse (‘SB’) Partner on SAP NF
Doc:
(SELECT parid INTO lv_extwh FROM J_1BNFNAD WHERE DOCNUM = J_1BNFDOC-
DOCNUM AND POSNR = ‘000000’ AND PARVW = ‘SB’)
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 = KNA1-ADRNR using KNA1-KUNNR = lv_extwh)
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
If lt_adrt IS NOT INITIAL
SELECT adr6 INTO lt_nfe_emails USING

Version 5.0 29-03-2021 Page 177 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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 lt_nfe_emails it’s blank
o If lt_nfe_emails IS INITIAL, ADD to Output Message log “<”External Warehouse
XXXXXXXXXX has no e-mail address defined. NF-e XXXXXXXXX-SSS, Branch BBBB was
not sent to anyone. After corrections, for new attempt, use transaction <new transaction
code>”
o FINISH processing with status to ‘error’ (red) and the current built log

 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

Version 5.0 29-03-2021 Page 178 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

If NOT lt_nfe_emails_tmp IS INITIAL AND lv_sp_flag IS NOT INITIAL,


ADD to Output Message log “<”Carrier XXXXXXXXXX has no e-mail address defined.
NF-e XXXXXXXXX-SSS, Branch BBBB was not sent to anyone. After corrections, for new
attempt, use transaction <new transaction code>”.
lv_error = ‘X’
Else
APPEND lt_nfe_emails_tmp INTO lt_nfe_emails
CLEAR lv_error
CLEAR lt_nfe_emails_tmp
Endif
o Check if there is a Withdrawal Location / External Warehouse (‘SB’) Partner on SAP NF
Doc:
(SELECT parid INTO lv_extwh FROM J_1BNFNAD WHERE DOCNUM = J_1BNFDOC-
DOCNUM AND POSNR = ‘000000’ AND PARVW = ‘SB’)
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 = KNA1-ADRNR using KNA1-KUNNR = lv_extwh)
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 lt_nfe_emails_tmp IS INITIAL
If lt_nfe_emails_tmp IS INITIAL AND lv_sb_flag IS NOT INITIAL,
ADD to Output Message log “<”Withdrawal Localtion / External Warehouse
XXXXXXXXXX has no e-mail address defined. NF-e XXXXXXXXX-SSS, Branch BBBB was
not sent to anyone. After corrections, for new attempt, use transaction <new transaction
code>”.
lv_error = ‘X’
Else
APPEND lt_nfe_emails_tmp INTO lt_nfe_emails
CLEAR lv_error

Version 5.0 29-03-2021 Page 179 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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

LOOP AT lt_tvarvc INTO ls_tvarvc WHERE low = J_1BNFDOC-BUKRS


LOOP AT lt_tvarvc INTO ls_tvarvc WHERE low = J_1BNFDOC-BUKRS AND NAME =
ZSD_EMAIL_DNFXML_BPINBOX
(END – 23_ELS: Changes V3.0 – 15th Oct 2022)
IF ls_tvarvc-high IS NOT INITIAL
APPEND ls_tvarvc-high INTO lt_bpinbox
ENDIF
ENDLOOP
IF lt_bpinbox IS INITIAL
(START – 23_ELS: Changes V3.0 – 15th Oct 2022)
LOOP AT lt_tvarvc INTO ls_tvarvc WHERE low = <blank>
LOOP AT lt_tvarvc INTO ls_tvarvc WHERE low = <blank> AND NAME =
ZSD_EMAIL_DNFXML_BPINBOX
(END – 23_ELS: Changes V3.0 – 15th Oct 2022)
IF ls_tvarvc-high IS NOT INITIAL
APPEND ls_tvarvc-high INTO lt_bpinbox
ENDIF
ENDLOOP
ENDIF
ENDIF
IF lt_bpinbox IS NOT INITIAL
APPEND lt_bpinbox INTO lt_nfe_emails
ENDIF
(START – 23_ELS: Changes V3.0 – 15th Oct 2022)
IF lt_bpinbox IS NOT INITIAL
APPEND ‘[email protected]’ INTO lt_nfe_emails
ENDIF

LOOP AT lt_tvarvc INTO ls_tvarvc WHERE low = J_1BNFDOC-BUKRS AND NAME =


ZSD_EMAIL_DNFXML_SENDER
IF ls_tvarvc-high IS NOT INITIAL

Version 5.0 29-03-2021 Page 180 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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

 Get RFC Destination


Please read RFC connection name from TVARVC variable
‘ZSD_EMAIL_DNFXML_RFC_DEST’
If NOT found or blank, set Output Message status to ‘pending’ (yellow NAST-
VSTAT = ‘0’) => FINISH (will be processed again on next job run).
 If found Generate virtual NF-e XML file by accessing GRC NF-e system via RFC.
For this part, suggest to use the same technical Methods GET_XML (that is
prepared to interact via RFC with current BP GRC environment) and PARSE_XML
(CLASS cl_/bpbfl/mail_send ), both developed inside report
/BPBFL/OTC_MAIL_SEND

Version 5.0 29-03-2021 Page 181 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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

 Convert necessary information to correct formats:


 J_1BNFDOC-CNPJ_BUPLA to CNPJ format with dots and / using Function
module CONVERSION_EXIT_CGCBR_OUTPUT
 J_1BNFDOC-CPF to CPF format with dots Function module
CONVERSION_EXIT_CPFBR_OUTPUT

Version 5.0 29-03-2021 Page 182 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

 J_1BNFDOC-SERIES removing leading zeroes by using


CONVERSION_EXIT_ALPHA_OUTPUT
 Generate virtual DANF-e PDF file using print program.
For this part, suggest to use the same technical Methods PROCESS_SSF and
TRIGGER_SSF (CLASS cl_/bpbfl/mail_send ) developed inside report
/BPBFL/OTC_MAIL_SEND. Send to the e-mail address(es) defined in lv_email
lt_nfe_emails

 Check if DANF-e generation was OK


 If NOT OK, set Output Message status to ‘error’ (red NAST-VSTAT = ‘2’) and log
“DANF-e generation error for NF-e <J_1BNFDOC-NFENUM>//”-“//<J_1BNFDOC-
SERIES>, Branch <J_1BNFDOC-BRANCH> <captured error, if possible>. For
another attempt, use transaction <new transaction code>” => FINISH.
 If OK Send e-mail(s) with generated virtual DANF-e PDF files..
For this part, suggest to use the same technical Method SEND_MAIL (CLASS
cl_/bpbfl/mail_send ) developed inside report /BPBFL/OTC_MAIL_SEND

(START – 23_ELS: Changes V3.0 – 15th Oct 2022)


 Use ‘lv_sender’ as the e-mail addres sender.
(END – 23_ELS: Changes V3.0 – 15th Oct 2022)

 Check if e-mail processing was OK


 If NOT, set Output Message status to ‘error’ (red NAST-VSTAT = ‘2’) and log “E-
mail for NF-e <J_1BNFDOC-NFENUM>//”-“//<J_1BNFDOC-SERIES>, Branch
<J_1BNFDOC-BRANCH> sending error <captured error>. For another attempt, use
transaction <new transaction code>” => FINISH.
 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> sent to <lv_email>,
<lv_email_carrier> successfully. successfully to: <lt_nfe_emails[1]-smtp-
addr>, <lt_nfe_emails[2]-smtp-addr>, <lt_nfe_emails[3]-smtp-addr>, …”. =>
FINISH.

Version 5.0 29-03-2021 Page 183 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

11.2 Z transaction / program for User Log Consulting or Re-submission of Messages

 Once entering the new Z transaction, the following selection screen is shown:

(v4.0) (Corresponding Technical fields)

Field name Select Option/Parameter Validation, Error Message and Comments

(Radio Button Select Selection Criteria Area 1 (per SAP Default option (set)
1) NF Document Numbers only)

(Radio Button Select Selection Criteria Area 1 (per


2) other indirect criteria to obtain SAP NF
Documents)
Document Select Option Inform directly the SAP NF Document(s) related to the NF-e(s) whose e-mail(s)
Number (Selection Criteria Area 1 – Field must be is(are) desired to be analysed or resent. Relationship among NF-e and SAP NF
closed if Radio Button 2 is selected) Document can be found via J1B3N matchcode (individually) or via J_1BNFDOC

Version 5.0 29-03-2021 Page 184 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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)

SELECT * FROM NAST INTO lt_nast WHERE


KAPPL = ‘NF’

Version 5.0 29-03-2021 Page 185 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

OBJKY = <lt_sapnfdocs>
KSCHL = <(TVARVC) ‘ZSD_EMAIL_DNFXML_OUTTYP’>
NACHA = <(TVARVC) ‘ZSD_EMAIL_DNFXML_TRXMED’>

SORT lt_nast by OBJKY ascending DATVR UHRVR descending


LOOP lt_sapnfdocs int ls_sapnfdoc
READ lt_nast USING
KAPPL = ‘NF’
OBJKY = ls_sapnfdoc
KSCHL = <(TVARVC) ‘ZSD_EMAIL_DNFXML_OUTTYP’>
NACHA = <(TVARVC) ‘ZSD_EMAIL_DNFXML_TRXMED’>
VSTAT = ‘0’ or VSTAT = ‘1’
IF sy-subrc = 0
DELETE ls_sapnfdoc FROM lt_sapnfdocs
ENDIF
ENDLOOP
(In example of image below unique register remaining is marked)

 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)

Version 5.0 29-03-2021 Page 186 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

(no visible screen: will run in background, called by the Z program)

 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)

Version 5.0 29-03-2021 Page 187 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

SELECT * FROM NAST INTO lt_nast WHERE


KAPPL = ‘NF’
OBJKY = <lt_sapnfdocs>
KSCHL = <(TVARVC) ‘ZSD_EMAIL_DNFXML_OUTTYP’>
NACHA = <(TVARVC) ‘ZSD_EMAIL_DNFXML_TRXMED’>

SORT lt_nast by OBJKY ascending DATVR UHRVR descending


LOOP lt_sapnfdocs int ls_sapnfdoc
READ lt_nast USING
KAPPL = ‘NF’
OBJKY = ls_sapnfdoc
KSCHL = <(TVARVC) ‘ZSD_EMAIL_DNFXML_OUTTYP’>
NACHA = <(TVARVC) ‘ZSD_EMAIL_DNFXML_TRXMED’>
VSTAT <>≠ ‘1’
IF sy-subrc = 0
DELETE ls_sapnfdoc FROM lt_sapnfdocs
ENDIF
ENDLOOP
(In example of image below, remaining registers are marked)

 For the found SAP NF Docs with previously successfully processed e-mail sent, call
RSNAST0D using the variant defined on parameter <Variant2>:
Application = ‘NF’

Version 5.0 29-03-2021 Page 188 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

Object key = <Selected SAP NF Documents from previous step>


Output Type = <(TVARVC) ‘ZSD_EMAIL_DNFXML_OUTTYP’>
Transmission medium = <(TVARVC) ‘ZSD_EMAIL_DNFXML_TRXMED’>
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:

11.3 Module Function in SLL-NFE to collect and send NF-e XML data

 Receive RFC ‘Access Key’ (44 positions) coming from ECC


 Read GUID from table /XNFE/OUTNFEHD using /XNFE/OUTNFEHD- ID = ‘Access Key’
 Read XMLSTRING from table /XNFE/OUTNFEXML
using GUID = /XNFE/OUTNFEHD-GUID and
TYPE = ‘1’
 If NOT found
o Return code 2 > End
 If found
o Call Function /XNFE/XML_XSTRING2STRING
Exporting inxstring = /XNFE/OUTNFEXML- XMLSTRING
Importing outstring = e_xml
o Return e_xml thru RFC

11.4 Requirement routine in NF output message procedure

 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 !):

Version 5.0 29-03-2021 Page 189 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

o Set return code = ‘fail’


o Read NAST messages table records using
Application = ‘NF’
Object key = <SAP NF Document number being processed>
Output Type = <(TVARVC) ‘ZSD_EMAIL_DNFXML_OUTTYP’>
Transmission medium = <(TVARVC) ‘ZSD_EMAIL_DNFXML_TRXMED’>
Processing status = ‘1’ (Processed Successfully) or ‘ ‘ (Pending)
o If FOUND, exit (will not process routine)
o If NOT FOUND, set return code = ‘ok’. Then routine is free to be executed

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

Version 5.0 29-03-2021 Page 190 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

IF SY-SUBRC EQ 0 AND lt_nast IS NOT INITIAL


* If records were found, then do not generate another message again
SY-SUBRC = ‘4’
ELSE
* If records not found, then permit generation of the first message
SY-SUBRC = ‘0’
ENDIF

12 DETAILED SAP CONFIGURATION - SEND EMAIL WITH DANFE/XML


Not applicable.
12.1 Configuration - Send email with DANFE/XML

TVARVC Variables / Parameters to Technical control

NAME TYPE NUMB SIGN OPTI LOW HIGH CLIE_INDEP

ZSD_EMAIL_DNFXML_BPINBOX S 0 I BT [email protected]

ZSD_EMAIL_DNFXML_BPINBOX S 1 I BT BR0K [email protected]

ZSD_EMAIL_DNFXML_BPINBOX S 2 I BT BR0L [email protected]

ZSD_EMAIL_DNFXML_BPINBOX S 3 I BT BR0M [email protected]

ZSD_EMAIL_DNFXML_BPINBOX S 4 I BT BR0N [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_SENDER S 1 I BT BR0K [email protected]

ZSD_EMAIL_DNFXML_SENDER S 2 I BT BR0L [email protected]

ZSD_EMAIL_DNFXML_SENDER S 3 I BT BR0M [email protected]

ZSD_EMAIL_DNFXML_SENDER S 4 I BT BR0N [email protected]

ZSD_EMAIL_DNFXML_TRXMED S 0 I EQ 5

New Output message type “ZEML – BR:Email w/DANFe+XML”

Version 5.0 29-03-2021 Page 191 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

12.2 Master Data - Send email with DANFE/XML

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.

13 TESTING REQUIREMENT - SEND EMAIL WITH DANFE/XML


13.1 Test cases / scenarios

Test Step Step Description Expected Results


Condition
Create DANF-e for an 01  (VA01) Create Sales order with NF-e should be
Energy sales invoicing w/ Energy item already created, with all Rejected by SEFAZ.
incorrect ICMS Tax Law to data ok except ICMS Tax Law. Both DANF-e
force NF-e Rejection 02  (VF01) Bill Sales Order. issuance and E-mail
03  (J1BNFE) Wait for SEFAZ return sending are not
04  (J1B3N) Try to issue DANF-e and E- possible (outputs
Mail but system will report ‘0 of 2 remain pending:
messages processed’. “yellow” statuses).
Cancel NF-e and Billing 01  (J1BNFE) Inutilize NF-e. Billing must Output must be finish
document from previous be automatically cancelled. with status OK and log
step 02  (SE38 – RSNAST00) Run ouput message “NF-e
message ZEML pending for SAP NF <J_1BNFDOC-
Doc of previous topic. NFENUM>//”-“//<J_1B
NFDOC-SERIES>,
Branch <J_1BNFDOC-
BRANCH> cancelled
or denied: not
necessary to send e-
mail.”
Back to Sales Order from 01  (VA02) Change Sales order with NF-e approved: output
the previous topics and Energy item correcting ICMS Tax Law message for DANF-e
correct ICMS Tax Law in ‘Country’ tab. and E-mail (ZEML)
 (VF01) Bill Sales Order again must be determined
02  (J1B3N) Once new NF-e is approved, and ran successfully
03 execute output message run (output message with
“green” status). Output
message log should
inform: “NF-e
<J_1BNFDOC-

Version 5.0 29-03-2021 Page 192 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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]

13.2 Functional Testing - for all functionalities:

Testing documents will be uploade in Team’s folder below after unit Test.
Unit Testing Evidences – under BR0K and BR0L

Version 5.0 29-03-2021 Page 193 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

14 FUNCTIONAL DESIGN - SLL-NFE & SAP PO


14.1 As-Is Process - SLL-NFE & SAP PO:

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.

15 TECHNICAL DESIGN - SLL-NFE & SAP PO


15.1 Communication Flow for Sending NF-es:

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:

Our landscape to NFe processes is:

 SAP ECC

Version 5.0 29-03-2021 Page 194 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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

 SAP Nota Fiscal Eletrônica – SLL-NFe


This is the messaging system between ECC->SEFAZ.
The SLL-NFe component contains the administration,settings and monitor workplaces for to manage the
communication with the Brazilian government. Here is set, for example, the states of Brazil, frequency to
check the status of SEFAZ service, CNPJS(tax numbers of the branches) and other information specific of BP
to the NFe processes.

 SAP NetWeaver Process Orchestation( SAP NetWeaver PO)


It is the application/plataform that allows to exchange the message between SLL-NFe and SEFAZ. This tool
will be responsible to send the NFe document through SOAP adapters(Web Services) to Brazilian
governement systems and receive the status(approval or rejection for those documents).

 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.

[15.3] Monitor NF-e Outbound - SLL-NFE & SAP PO:

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)

Version 5.0 29-03-2021 Page 195 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

 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.

Version 5.0 29-03-2021 Page 196 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

16 DETAILED SAP CONFIGURATION - SLL-NFE & SAP PO


 CNPJS(Tax numbers)
o Here are set the tax numbers of the BP company that will be allowed from SLL-NFe
perspective to send the NFe documents to SEFAZ, if some branch are not set here, the
communication with SEFAZ by this CNPJ will be no available:

 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:

Version 5.0 29-03-2021 Page 197 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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

Version 5.0 29-03-2021 Page 198 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

 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:

Version 5.0 29-03-2021 Page 199 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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.

How to address the correct authority system.

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

Version 5.0 29-03-2021 Page 200 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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:

Version 5.0 29-03-2021 Page 201 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

(START – 21_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)

17 FUNCTIONAL DESIGN – SLL-NFE & SAP-ECC – OTHER ENHANCEMENTS FOR NFE –


BP SPECIFIC REQUIREMENTS
17.1 As-Is Process – SLL-NFE & SAP-ECC Other Enhancements for NFe – bp Specific
Requirements:

17.1.1 ENHANCEMENT_REQUIREMENT_01: SEFAZ ERROR 858


On PRC design for GM RPTA Fuels, to solve issue for SEFAZ ERROR 858 (to intervein on NF-e ICMS Tax
tags area to assemble ICMSST block instead of ICMS60 one), two SAP Standard objects were changed:
o one in ECC (include LJ_1B_NFEF79): the aim was to force – is case of a CST ‘60’ - ICMS
Tax Type ‘ICM3’ be changed (on memory, as the database information was already created)
to ‘ICS3’ to make the next logic to get the corresponding tax group as ‘ICST’ and not ‘ICMS’,
which leads to further the assembling of an ICMSST block of tags. It is also necessary to
have variable corresponding to VBCSTRET not null (in fact, at the end, must be 0) to reach
the desired NF-e XML logic that ICMS60 assemlby does not accomplish. With that said, value
for VBCSTRET was forced to a “not possible but not null” 9999999999999.99.

.
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.

Version 5.0 29-03-2021 Page 202 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

17.1.2 ENHANCEMENT_REQUIREMENT_02: ICOS/NGRD COUNTERPARTIES – STREET x STREET2 INFO


On PRC, as that system had no direct integration with ICos/NGRD and so all counterparties were created
manually and following the necessary and expected by BR SAP Std NF requirements, the “Street” information
was fed on the Vendor’s and Customer’s Master Data ADRC-STREET. No enhancements or special
treatments were necessary.

17.1.3 ENHANCEMENT_REQUIREMENT_03: SEFAZ ERROR 362 – FUELS NFE MANDATORY CARRIER


On PRC, as no OTP integration exists, the Carrier was informed as supported by SAP Std Brazilian
Localization, that means, with the “Forward” agent (SP Partner) defined from the Customer Master Data (if
exists there) into the Order header or manually entered on it or directly on delivery header. With that (and
configured correctly), partner flows to Billing document and then to SAP NF Document.

17.1.4 ENHANCEMENT_REQUIREMENT_04: SPECIAL STOCK PARTNER FOR 3RD PARTY WH ON NF


On PRC, the business scenario for GM RPTA “outbound from External Contracted Warehouse” didn’t exist.
On first BTM Project Implementation, that approach was based entirely on SAP Special Stock functionality on
SD (using special stock “W-Consignment” and all related objects, including movement types). However, it was
an agreed premise on that Project, that OTP (“Oil Transaction Pipeline”) would not be able to handle this
“third-party stock possession control” and, as it was a specific BR requirement, the inventory control at OTP
would be at the Locations for bp Business Places only.

(START – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)

Version 5.0 29-03-2021 Page 203 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

17.1.5[16.1.2] ENHANCEMENT_REQUIREMENT_05: GM RPTA “Differential Invoice” treatment for BR Legal


Requirements (including “NF-e Complementar” when DEBIT)
On former PRC and previous PRI BTM Project, this business scenario for GM RPTA “Differential Invoice”
(debit or credit Customer due to original invoice price error) didn’t exist. It’s a specific IS-OIL design (under
OTP<>PRI Integration Standard Template design) and was not part of the scope for BR so far.
(END – 36_CR: RITM000002474916 Changes V4.0 – 26th May 2024)

(START – 44_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)


17.1.6[16.1.3] ENHANCEMENT_REQUIREMENT_06: SEFAZ ERROR 769 – ICMS CST 61
For GM RPTA “NF-e Complementar”, it’s a requirement to present the same ICMS CST 61 used on Sales but
with corresponding tags zeroed (qbcmonoret, vicmsmonoret, adremicmsret). However, as per SLL-NFE
current SAP Standard Logic, qbcmonoret is not filled when value from ECC is zeroed, causing the
suppression on such tag on final XML tag and, consequently, a SEFAZ error 769. To solve such issue it will
be necessary:
o SLL-NFE (Method FILL_NFE_DET_IMPOSTO_400,
Class /XNFE/CL_T2PROXY_NFE_400): Standard SAP does not move any value on
q_bcmono_ret variable, keeping the field EMPTY/BLANK, which leads to a final XML tag not
included on the file to be sent to tax authorities.

(END – 44_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)

17.2 To-Be process - SLL-NFE & SAP-ECC Other Enhancements for NFe – bp Specific
Requirements:

17.2.1 ENHANCEMENT_REQUIREMENT_01: SEFAZ ERROR 858


On PRI design for GM RPTA Fuels, to solve issue for SEFAZ ERROR 858 (to intervein on NF-e ICMS Tax
tags area to assemble ICMSST block instead of ICMS60 one), two SAP Standard objects are being changed,
but both in SLL-NFE:
o Function Module /XNFE/OUTNFE_CREATE_400 (Program
/XNFE/SAPLOUT_NFE_BACKEND Include /XNFE/LOUT_NFE_BACKENDU09): the aim is
to create an enhancement point at the beginning and a new Z Function call (of a new

Version 5.0 29-03-2021 Page 204 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

Function Group) having as Import parameters the internal table IT_NFE_PROD_COMB,


IT_NFE_DET_PROD, IT_NFE_IMPOSTO_COFINS and IT_NFE_IMPOSTO_ICMS. Inside
the Z Function Module, define 2 new Global Tables whose Types are similar to
IT_NFE_PROD_COMB, IT_NFE_DET_PROD, IT_NFE_IMPOSTO_COFINS and
IT_NFE_IMPOSTO_ICMS and then save the imported contents into those new Global Tables
inside context of new Function Group.

o Method FILL_NFE_DET_IMPOSTO_400, Class /XNFE/CL_T2PROXY_NFE_400): on this


point, the aim is to create a enhancement point at the end with a logic that starts with another
new Z Function call (of the same new Function Group of the previous Z Function Module)
having Export parameters similar to tables IT_NFE_PROD_COMB, IT_NFE_DET_PROD,
IT_NFE_IMPOSTO_COFINS and IT_NFE_IMPOSTO_ICMS. Inside the Z Function Module,
move the 2 new Global Tables contents to the Export parameters to make them available to
the context of the Method. Once the contents of original IT_NFE_PROD_COMB,
IT_NFE_DET_PROD, IT_NFE_IMPOSTO_COFINS and IT_NFE_IMPOSTO_ICMS are
available on Method enhancement, then use the contents to check if additional logic to
remove ICM60 Block and built a ICMSST one must be performed.

Version 5.0 29-03-2021 Page 205 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

17.2.2 ENHANCEMENT_REQUIREMENT_02: ICOS/NGRD COUNTERPARTIES – STREET x STREET2 INFO


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).

o Function Modules J_1B_NF_VENDOR_READ and J_1B_NF_CUSTOMER_READ: the aim


is to detect when the counterparty is a ICos/NGRD one (based on Account Groups defined
via parameter table) and the overwrites the ADRC-STREET info with ADRC-STR_SUPPL1
on all return (import) structures.

Version 5.0 29-03-2021 Page 206 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

17.2.3 ENHANCEMENT_REQUIREMENT_03: SEFAZ ERROR 362 – FUELS NFE MANDATORY CARRIER


On PRI, as we have integration with OTP for Fuels, no SP Carrier Partner is used on current integration
process. Due to that and to accomplish legal requirement at least for the transactions where freight is not
relevant (but Carrier is as per SEFAZ error 362), a new enhancement wil be created on a SAP Billing User
Exit RV60AFZD USEREXIT_NEWROLE_XVBPAK_AVBPAK. The aim is to check if the following is true:
 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
 The Billing is a Sales one (by list of valid CFOP codes)

Version 5.0 29-03-2021 Page 207 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

 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)

(START – 33_UAT: RITM000001897233 Changes V4.0 – 30th Oct 2023)


Due to UAT Defect 5746458: “Carrier information not flowing from OWB to SAP and so, to NF-e (that is
mandatory to be approved on Fuels”, it will be necessary to offer an alternative to inform BR Carrier
information on OWB side, once current “BOL Carrier” field (created by former Truck&Rail Project) seems
to be restricted to US only. With that, OWB “BOL #” field can be manually feed by user and info will be
migrated to corresponding SAP PRI ZZ Field.
(END – 33_UAT: RITM000001897233 Changes V4.0 – 30th Oct 2023)

(START – 28_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)


17.2.4 ENHANCEMENT_REQUIREMENT_04: SPECIAL STOCK PARTNER FOR 3RD PARTY WH ON NF
On BRD Project (for Diesel Distribution), new requirement to have Inventory control on Third Parties also on
OTP systems demanded OTP<>PRI integration and SAP current architectural design to remove SAP
‘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.
(END – 28_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)

(START – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)


17.2.5[16.1.4] ENHANCEMENT_REQUIREMENT_05: GM RPTA “Differential Invoice” treatment for BR Legal
Requirements (including “NF-e Complementar” when DEBIT)
On CR#14, “Differential Invoice” was requested as GM RPTA additional scope. “Differential Invoice/Billing” is
a native IS-OIL functionality to create Debit or Credit Memos for original Invoices that had price fluctuation (as
oil and fuels are worldwide known commodities characterized per market price fluctuation). On Brazil, no
matter the market reason for creating a Debit or Credit Memo over an original outbound (with NF-e), if it’s a
price/value adjust (not quantity!!), it’s necessary to handle requirements for NF-e registration: for DEBIT, a
specific “NF-e Complementar” legal document must be issued and, for CREDIT, a specific SAP BR
Localization record (not in fact a “legal” NF-e) to accomplish SAP logics and checks (otherwise error is
presented when saving the Differential Billing). Original IS-OIL design is to create the Differential
Invoice/Billing referencing the same Outbound Delivery for the original Sales.
(END – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)

Version 5.0 29-03-2021 Page 208 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

(START – 44_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)


17.2.6[16.1.5] ENHANCEMENT_REQUIREMENT_06: SEFAZ ERROR 769 – ICMS CST 61
On PRI design for GM RPTA Fuels, to solve issue for SEFAZ ERROR 769 (to intervein on NF-e ICMS Tax
tags area when assembling ICMS61), one SAP Standard object is being changed, but in SLL-NFE:

Method FILL_NFE_DET_IMPOSTO_400, Class /XNFE/CL_T2PROXY_NFE_400): the aim is to include new


additional logic on previously created enhancement point at the end of the Method. In resume, the functional
logic will be:
If ICMS CST is ’61, then check if field q_bcmono_ret is EMPTY/BLANK: if yes, move
qbcmonoret value from ECC (zeroed or not) to the field, avoiding it to be not present on final XML file.

(END – 44_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)

Version 5.0 29-03-2021 Page 209 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

18 TECHNICAL DESIGN - SLL-NFE & SAP-ECC – OTHER ENHANCEMENTS FOR NFE –


BP SPECIFIC REQUIREMENTS
For the technical details (functional perspective) related to the exposed Requirements, we have the
following next topics:

18.1 ENHANCEMENT_REQUIREMENT_01 – SEFAZ ERROR 858

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.

 Function Module /XNFE/OUTNFE_CREATE_400 (Program /XNFE/SAPLOUT_NFE_BACKEND


Include /XNFE/LOUT_NFE_BACKENDU09): the aim is to create an enhancement point at the
beginning and a new Z Function call (of a new Function Group) having as Import parameters the
internal table IT_NFE_PROD_COMB, IT_NFE_DET_PROD, IT_NFE_IMPOSTO_COFINS and
IT_NFE_IMPOSTO_ICMS. Inside the Z Function Module, define 2 new Global Tables whose Types
are similar tolike IT_NFE_PROD_COMB, IT_NFE_DET_PROD, IT_NFE_IMPOSTO_COFINS and
IT_NFE_IMPOSTO_ICMS and then save the imported contents into those new Global Tables inside
context of new Function Group.

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

Version 5.0 29-03-2021 Page 210 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

 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

o Create Enhancement Point at the end of Function Module /XNFE/OUTNFE_CREATE_400.


Then include:

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.

CALL FUNCTION zsd_xnfe_export_nf_global_info


Exporting
it_nfe_prod_comb = it_nfe_prod_comb
it_nfe_det_prod = it_nfe_det_prod
it_nfe_imposto_cofins = it_nfe_imposto_cofins
it_nfe_imposto_icms = it_nfe_imposto_icms

 Method FILL_NFE_DET_IMPOSTO_400, Class /XNFE/CL_T2PROXY_NFE_400): on this point, the


aim is to create a enhancement point at the end with a logic that starts with another new Z Function
call (of the same new Function Group of the previous Z Function Module) having Export parameters
similar to tables IT_NFE_PROD_COMB, IT_NFE_DET_PROD, IT_NFE_IMPOSTO_COFINS and
IT_NFE_IMPOSTO_ICMS. Inside the Z Function Module, move the 2 new Global Tables contents to
the Export parameters to make them available to the context of the Method. Once the contents of
original IT_NFE_PROD_COMB, IT_NFE_DET_PROD, IT_NFE_IMPOSTO_COFINS and
IT_NFE_IMPOSTO_ICMS are available on Method enhancement, then use the contents to check if
additional logic to remove ICM60 Block and built a ICMSST one must be performed.

Version 5.0 29-03-2021 Page 211 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

o Create Enhancement Point at the end of Method FILL_NFE_DET_IMPOSTO_400 (Class


/XNFE/CL_T2PROXY_NFE_400). Then include:

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.

DATA: 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
* Read Global Tables containing NF items info
CALL FUNCTION zsd_xnfe_import_nf_global_info
Importing
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
* Check if NFe Item(s) info is available
* Check if ICMS active Tax block of Tags per Tax Situation for current item is ICMS60 and
* if COFINS for Sales indicate rate per quantity (current scope just for Fuels)
IF lt_nfe_prod_comb IS NOT INITIAL AND lt_nfe_imposto_icms IS NOT INITIAL.
IF <CHOICE>-SEQUENCE-ICMS-CHOICE-SELECTION = ‘ICMS60’ AND <COFINS>-CHOICE-COFINSQTDE-CST = ’03’.

Version 5.0 29-03-2021 Page 212 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

* 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

Version 5.0 29-03-2021 Page 213 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

READ lt_tvarvc INTO ls_tvarvc USING


NAME = ‘ZXNFE_ENH010_SEFAZ_858_ECC_CLT’
LOW = sy-sysid
IF sy-subrc IS INITIAL AND ls_tvarvc-high IS NOT INITIAL
lv_eccclnt = ls_tvarvc(3)
* Check if Client from parameters is valid, If not, end processing
SELECT * FROM t000 USING mandt = lv_eccclnt
IF sy-subrc IS NOT INITIAL
CLEAR lv_eccclnt
EXIT
ENDIF
* Parameters related to RFC Connection
READ lt_tvarvc INTO ls_tvarvc USING
NAME = ‘ZXNFE_ENH010_SEFAZ_858_RFC_CNX’
LOW = sy-sysid
IF sy-subrc IS INITIAL AND ls_tvarvc-high IS NOT INITIAL
lv_rfccnx = ls_tvarvc-high
ENDIF
* 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 = <see schema image below>
fields = <see schema image below>
data = gt_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.

Version 5.0 29-03-2021 Page 214 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

IF sy-subrc IS INITIAL AND gt_temp IS NOT INITIAL


* ANP Entries from ECC found: check if ANP from NF item is valid
SORT gt_temp BY wa ASCENDING
READ gt_temp USING wa = ls_nfe_prod_comb-anp
IF sy-subrc IS INITIAL
* 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

* Change SELECTION from ICMS60 to ICMSST


<CHOICE>-SEQUENCE-ICMS-CHOICE-SELECTION = ‘ICMSST’

* 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

Version 5.0 29-03-2021 Page 215 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

<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

ENDIF **ANP code valid


ENDIF **gt_temp IS NOT INITIAL
ENDIF **ls_tvarvc-high (eccclnt) IS NOT INITIAL
ENDIF **lt_tvarvc IS NOT INITIAL
ENDIF **ls_nfe_prod_comb-anp IS NOT INITIAL
ENDIF **lv_item IS NOT INITIAL
ENDIF
ENDIF

18.2 ENHANCEMENT_REQUIREMENT_02 – ICOS/NGRD COUNTERPARTIES – STREET X


STREET2 INFO

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).

Version 5.0 29-03-2021 Page 216 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

o Function Modules J_1B_NF_VENDOR_READ and J_1B_NF_CUSTOMER_READ: the aim


is to detect when the counterparty is a ICos/NGRD one (based on Account Groups defined
via parameter table) and the overwrites the ADRC-STREET info with ADRC-STR_SUPPL1
on all return (import) structures.

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.

* Read parameter table


SELECT * tvarvc INTO lt_tvarvc WHERE
NAME = ZMM_NFE_VEND_ADDR_ICOS_ACCTGRP
IF sy-subrc IS NOT INITIAL AND lt_tvarvc IS NOT INITIAL
SORT lt_tvarvc BY name low ASCENDING
* Check if Vendor Account Group is related to a ICos/NGRD one
READ lt_tvarvc USING
NAME = ZMM_NFE_VEND_ADDR_ICOS_ACCTGRP
LOW = lfa1-ktokk
IF sy-subrc IS INITIAL
* It’s a ICos/NGRD Counterparty
* Street2 is the main field for “Street” info
* Must check if House Number1 is already contained on Street2
* If Yes, do not concatenate it. Otherwise do it.
<Check if exactly string on ADDRESS1-HOUSE_NUM1 is contained on ADDRESS1-STR_SUPPL1>
lv_stras = address1-str_suppl1
IF sy-subrc IS NOT INITIAL
lv_stras = CONCATENATE lv_stras address1-house_num1
ENDIF
IF address1-house_num2 IS NOT INITIAL
<Check if exactly string on ADDRESS1-HOUSE_NUM2 is contained on ADDRESS1-STR_SUPPL1>
IF sy-subrc IS NOT INITIAL
lv_stras = CONCATENATE lv_stras address1-house_num2
ENDIF
ENDIF
* Now adjust all necessary import variables
parnad-stras = lv_stras
parnad-street = address1-str_suppl1

Version 5.0 29-03-2021 Page 217 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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.

* Read parameter table


SELECT * tvarvc INTO lt_tvarvc WHERE
NAME = ZSD_NFE_CUST_ADDR_ICOS_ACCTGRP
IF sy-subrc IS NOT INITIAL AND lt_tvarvc IS NOT INITIAL
SORT lt_tvarvc BY name low ASCENDING
* Check if Customer Account Group is related to a ICos/NGRD one
READ lt_tvarvc USING
NAME = ZSD_NFE_CUST_ADDR_ICOS_ACCTGRP
LOW = kna1-ktokd
IF sy-subrc IS INITIAL
* It’s a ICos/NGRD Counterparty
* Street2 is the main field for “Street” info
* Must check if House Number1 is already contained on Street2
* If Yes, do not concatenate it. Otherwise do it.
<Check if exactly string on ADDRESS1-HOUSE_NUM1 is contained on ADDRESS1-STR_SUPPL1>
lv_stras = address1-str_suppl1
IF sy-subrc IS NOT INITIAL
lv_stras = CONCATENATE lv_stras address1-house_num1
ENDIF
IF address1-house_num2 IS NOT INITIAL
<Check if exactly string on ADDRESS1-HOUSE_NUM2 is contained on ADDRESS1-STR_SUPPL1>
IF sy-subrc IS NOT INITIAL
lv_stras = CONCATENATE lv_stras address1-house_num2
ENDIF
ENDIF
* Now adjust all necessary import variables
parnad-stras = lv_stras
parnad-street = address1-str_suppl1
address-stras = lv_stras

Version 5.0 29-03-2021 Page 218 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

address1-street = address1-str_suppl1
ENDIF
ENDIF

18.3 ENHANCEMENT_REQUIREMENT_03 – CARRIER ON FUELS SALES NF-E (SEFAZ ERROR


362)

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)

• The Billing is a Sales one (by list of valid CFOP codes)


• 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 ‘9-No freight’ (info derived from Incoterm);

(START – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)


In case the new clauses related to the topics above (*) ARE not true, that means, Carrier partner is
found and it’s valid, then no “default” Carrier code from parameter will be taken.
(END – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 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.

Version 5.0 29-03-2021 Page 219 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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)

CALL FUNCTION 'J_1BSA_COMPONENT_ACTIVE'


EXPORTING
bukrs = vbrk-bukrs
component = 'BR'
EXCEPTIONS
COMPONENT_NOT_ACTIVE =1
OTHERS = 2.

CHECK sy-subrc IS INITIAL


* This means that it's Brazil comp code and so
* SAP BR Std BR Localization logics will be active (for tax and NFe)
* Check if it’s a BR NF relevant Billing document
CHECK tvfk-fkart IS NOT INITIAL AND tvfk-j_1bnfrel IS NOT INITIAL
* Check if Billing is being created from Delivery
(START – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
* Check if Billing is NOT an IS-OIL Differential Invoice:
* In this case, no Carrier must be informed
IF tvfk-oic_diffin IS INITIAL
(END – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
IF alips IS NOT INITIAL
* Check NF Type is assigned to the Order Type
IF tvak-j_1bnftype IS NOT INITIAL
* Read on database if NF Type is ‘1-Normal’:
SELECT * FROM j_1baa INTO ls_j1baa WHERE
NFTYPE = tvak-j_1bnftype
IF sy-subrc IS INITIAL AND ( ls_j_1baa-doctyp = ‘1’ OR ls_j_1baa-doctyp = ‘6’ )
* Check that NO Carrier Partner ‘SP’ already exists
READ xvbpak USING
POSNR = ‘000000’
PARVW = ‘SP’
IF sy-subrc IS NOT INITIAL
* Read necessary parameters from TVARVC (transaction STVARV)
SELECT * FROM tvarvc INTO lt_tvarvc WHERE

Version 5.0 29-03-2021 Page 220 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

( name LIKE ‘ZSD#_NFE#_SEFAZ#_362#_%’ ESCAPE ‘#’ )


IF lt_tvarvc IS NOT INITIAL
SORT lt_tvarvc BY name low ASCENDING
COPY alips TO lt_lips
* Read ANP Codes (if exist) from Delivery items Master Data
SELECT matnr anp FROM mara INTO lt_mara
FOR ALL ENTRIES OF lt_lips WHERE MATNR = lt_lips-matnr
SORT lt_mara BY matnr ASCENDING
CLEAR: lv_flag
* Loop on Delivery items to find at least one that is relevant for generating
* SEFAZ ERROR 382 and so, a Transportation provider must be checked and
* present on the Billing document being created
LOOP AT lt_lips INTO ls_lips
READ lt_mara INTO ls_mara USING
MATNR = ls_lips-matnr
IF sy-subrc IS INITIAL AND ls_mara-anp IS NOT INITIAL
* Delivery item has ANP Code: check if on List for SEFAZ ANP
* codes required to indicate Transportation provider
READ lt_tvarvc USING
NAME = ‘ZSD_NFE_SEFAZ_362_ANP’
LOW = ls_mara-anp
IF sy-subrc IS INITIAL
* Confirm that CFOP is a Fuel Sales one
READ lt_tvarvc USING
NAME = ‘ZSD_NFE_SEFAZ_362_CFOP’
LOW = ls_lips-j_1bcfop(4)
IF sy-subrc IS INITIAL
* At least one item is relevant: set flag and end loop
lv_flag = ‘X’
EXIT
ENDIF
ENDIF
ENDIF
ENDLOOP
IF lv_flag IS NOT INITIAL
(START – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
* At least one Fuel item is relevant and no Carrier partner assigned so far.
* Look for possible carrier info came from OTP/OWB and use it in case ok.
* Premise: each GM RPTA has only one item for a Physical shipment or, at least
* multiple items on a same SAP Delivery will be handled by the same Carrier
CLEAR: lv_carrier
IF vbap-zzcarrierfein IS NOT INITIAL
SELECT * FROM zsd_carriertab INTO ls_carriertab WHERE
zzcarrierfein = vbap-zzcarrierfein
IF sy-subrc IS INITIAL AND ls_carriertab-zzcarriername 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 lt_tvarvc INTO lt_ktokk USING
NAME = ‘ZSD_NFE_SEFAZ_362_KTOKK’
LOW = <IS NOT INITIAL>

SELECT * FROM lfa1 INTO ls_lfa1 WHERE


NAME4 = ls_carriertab-zzcarriername

Version 5.0 29-03-2021 Page 221 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

KTOKK = <lt_ktokk-low for all lt_ktokk lines>

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

(END – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)


read_address = 'X'
IMPORTING
parnad = ls_partner
address = ls_address
address1 = ls_address1
EXCEPTIONS
partner_not_found =1
address_not_found =2
others = 3.

Version 5.0 29-03-2021 Page 222 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

(START – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)

IF sy-subrc IS INITIAL AND ls_tvarvc-high IS NOT INITIAL


DATA: ls_xvbpak LINE OF xvbpak
ls_xvbpak-mandt = sy-mandt
ls_xvbpak-posnr = ‘000000’
ls_xvbpak-parvw = ‘SP’
ls_xvbpak-lifnr = ls_tvarvc-high (with 0’s on the left to complete 10 positions)
ls_xvbpak-adrnr = ls_address-adrnr (with 0’s on the left to complete 10 positions)
ls_xvbpak-adrda = ‘D’
ls_xvbpak-name1 = ls_address-name1
ls_xvbpak-nrart = ‘LI’
ls_xvbpak-spras = ls_address-spras(1)
ls_xvbpak-stcd1 = ls_partner-cgc
ls_xvbpak-stcd2 = ls_partner-cpf
ls_xvbpak-stcd3 = ls_partner-stains
ls_xvbpak-stcd4 = ls_partner-munis

IF sy-subrc IS INITIAL AND lv_carrier IS NOT INITIAL


DATA: ls_xvbpak LINE OF xvbpak
ls_xvbpak-mandt = sy-mandt
ls_xvbpak-posnr = ‘000000’
ls_xvbpak-parvw = ‘SP’
ls_xvbpak-lifnr = lv_carrier (with 0’s on the left to complete 10 positions)
ls_xvbpak-adrnr = ls_address-adrnr (with 0’s on the left to complete 10 positions)
ls_xvbpak-adrda = ‘D’
ls_xvbpak-name1 = ls_address-name1
ls_xvbpak-nrart = ‘LI’
ls_xvbpak-spras = ls_address-spras(1)
ls_xvbpak-stcd1 = ls_partner-cgc
ls_xvbpak-stcd2 = ls_partner-cpf
ls_xvbpak-stcd3 = ls_partner-stains
ls_xvbpak-stcd4 = ls_partner-munis
(END – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)

APPEND ls_xvbpak INTO xvbpak


ENDIF
(START – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
ENDIF
ENDIF
ENDIF
(END – 27_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)
ENDIF
ENDIF ** tvak-j_1bnftype IS NOT INITIAL
ENDIF **alips IS NOT INITIAL
(START – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)
ENDIF **tvfk-oic-diffin IS INITIAL
(END – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)

Version 5.0 29-03-2021 Page 223 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

(START – 28_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)


18.4 ENHANCEMENT_REQUIREMENT_04 – SPECIAL STOCK PARTNER FOR 3RD PARTY WH ON
NF

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)
**********************************************************************************

Version 5.0 29-03-2021 Page 224 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

* 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)

CALL FUNCTION 'J_1BSA_COMPONENT_ACTIVE'


EXPORTING
bukrs = vbrk-bukrs
component = 'BR'
EXCEPTIONS
COMPONENT_NOT_ACTIVE =1
OTHERS = 2.

CHECK sy-subrc IS INITIAL


* This means that it's Brazil comp code and so
* SAP BR Std BR Localization logics will be active (for tax and NFe)
* Check if it’s a BR NF relevant Billing document
CHECK tvfk-fkart IS NOT INITIAL AND tvfk-j_1bnfrel IS NOT INITIAL
* Check if Billing is being created from Delivery
CHECK alips IS NOT INITIAL
* Check NF Type is assigned to the Order Type
CHECK tvak-j_1bnftype IS NOT INITIAL
* Read on database if NF Type is ‘1-Normal’ or ‘6-Return’ or ‘2-Complementar’:
SELECT * FROM j_1baa INTO ls_j1baa WHERE
NFTYPE = tvak-j_1bnftype
IF sy-subrc IS INITIAL AND ( ls_j_1baa-doctyp = ‘1’ OR ls_j_1baa-doctyp = ‘6’ OR ls_j_1baa-doctyp = ‘2’ )
* Check that NO Special Stock ‘SB’ already exists at header level
READ xvbpak USING
POSNR = ‘000000’
PARVW = ‘SB’
CHECK sy-subrc IS NOT INITIAL
* Read necessary parameters from TVARVC (transaction STVARV)
SELECT * FROM tvarvc INTO lt_tvarvc WHERE
name = ‘ZSD_NFE_SB_PARTNER_PLANTS’

IF lt_tvarvc IS NOT INITIAL


SORT lt_tvarvc BY name low ASCENDING
* Premise: all Billing items are from the same Plant

Version 5.0 29-03-2021 Page 225 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

* So, just first will be checked


READ lt_tvarvc INTO ls_tvarvc USING
NAME = ‘ZSD_NFE_SB_PARTNER_PLANTS’
LOW = vbrp-werks

IF sy-subrc IS INITIAL AND ls_tvarvc-high IS NOT INITIAL


* A record with Billing item Plant was found on parameters
* Try to read info from the “potential” associated SAP Customer Code

CALL FUNCTION ‘j_1b_nf_customer_read’


EXPORTING
partner_id = ls_tvarvc-high
read_address = 'X'
IMPORTING
parnad = ls_partner
address = ls_address
address1 = ls_address1
EXCEPTIONS
partner_not_found =1
address_not_found =2
others = 3.

IF sy-subrc IS INITIAL AND ls_address1 IS NOT INITIAL


DATA: ls_xvbpak LINE OF xvbpak
ls_xvbpak-mandt = sy-mandt
ls_xvbpak-posnr = ‘000000’
ls_xvbpak-parvw = ‘SB’
ls_xvbpak-kunnr = ls_tvarvc-high (with 0’s on the left to complete 10 positions)
ls_xvbpak-adrnr = ls_address-adrnr (with 0’s on the left to complete 10 positions)
ls_xvbpak-adrda = ‘D’
ls_xvbpak-name1 = ls_address-name1
ls_xvbpak-nrart = ‘KU’
ls_xvbpak-spras = ls_address-spras(1)
ls_xvbpak-stcd1 = ls_partner-cgc
ls_xvbpak-stcd2 = ls_partner-cpf
ls_xvbpak-stcd3 = ls_partner-stains
ls_xvbpak-stcd4 = ls_partner-munis

APPEND ls_xvbpak INTO xvbpak


ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
(END – 28_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)

(START – 33_UAT: RITM000001897233 Changes V4.0 – 30th Oct 2023)


(INCLUDE zsd_br_nfe_carrier)
************************************************************************
* PROGRAM ID : ZSD_BR_NFE_CARRIER *
* PROGRAM TITLE : NA *
* Enhancement *
* AUTHOR : Prasenjit Ghosh *

Version 5.0 29-03-2021 Page 226 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

* DATE : 28th Oct, 2022 *


* GLOBAL/LOCAL : Brazil *
* DEVELOPMENT ID : ENH010 *
* CHANGE REQUEST (CTS) : PDIK943434 *
* AUTHORIZATION OBJECT : NA *
* DESCRIPTION : Enhancement for Carrier for NFE *
*----------------------------------------------------------------------*
* COPIED FROM : NA *
* TITLE : NA *
* OTHER RELATED OBJ : NA *
************************************************************************
* CHANGE HISTORY LOG *
************************************************************************
* MOD. NO.| DATE | NAME |CORRECTION NUMBER| CHANGE *
* REFERENCE#*
*----------------------------------------------------------------------*
* Initial | 26-10-2022 | Prasenjit Ghosh |RITM000001588724 |PDIK943434 *
*----------------------------------------------------------------------*
* Mod-001 | 21-07-2023 | Prasenjit Ghosh |RITM000001897233 |PDIK946211 *
* 27_RTM | | | | *
*----------------------------------------------------------------------*
* Mod-002 | 21-07-2023 | Prasenjit Ghosh |RITM000001897233 |PDIK946211 *
* 28_RTM | | | | *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Include ZSD_BR_NFE_CARRIER
*&---------------------------------------------------------------------*


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.

Version 5.0 29-03-2021 Page 227 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

*End of Mod-001


(END – 33_UAT: RITM000001897233 Changes V4.0 – 30th Oct 2023)

(END – 28_RTM: RITM000001897233 Changes V4.0 – 15th May 2023)

(START – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)


18.5[16.2] ENHANCEMENT_REQUIREMENT_05 – GM RPTA “Differential Invoice” treatment for BR
Legal Requirements (including “NF-e Complementar” when DEBIT)

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)”

The following must be accomplished by the solution:


• Correct NF Type must be assigned depending on if the Differential Invoice to be created is for
Debit or Credit the Customer (the same Billing Type is used for both scenarios and
referencing same Delivery document of the original Sales Outbound): to be possible to
identify the scenario, the total net value of the document (header – field NETWR) will be
used:
 In case NETWR carries a ZERO or NEGATIVE value, then nothing or a Credit to
Customer is being provided: with that, the NF Type will be one with Type “Correction”
(exp: Z3).
 In case NETWR carries a POSITIVE value, then a Debit to Customer is being provided:
with that, the NF Type will be one with Type “Complementary” (exp: Z2).
• With the recent regulation for ICMS Monophasic and the PIS/COFINS for Fuels, both
taxations are based on QUANTITY and not on PERCENTAGE RATES anymore: with that
defined, the DEBIT and CREDIT scenarios must not calculate those taxes, while the item on
Differential Billing maintaining the same item quantity from the referenced Delivery document.
To have correct identification for those scenarios and to be possible to map them on J1BTAX
cockpit tables (Fiscal data), new SD Tax Codes will be created (with codes mimic from
existing VAT Codes).
• Necessary objects will not be hard-coded (NF Types, SD Tax Codes, etc) but based on
parameters defined on TVARVC table.

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.

Please create user exit routine zzusroih_j1b as per indicated below.

Version 5.0 29-03-2021 Page 228 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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 zzusroih_j1b USING.


t_ctvfk
t_wvbrk
t_wvbrp
t_rvbak
t_rvbap
t_rvbap
t_l_nftyp
**********************************************************************************
* BR Fuels Sales NF-e: Define NF Type for Differential Invoice
* Billing (Z1), other than ‘N2’ fixed on code by SAP
**********************************************************************************
* Correct NF Type must be assigned depending on if the Differential Invoice to be created
* is for Debit or Credit the Customer (the same Billing Type is used for both scenarios and
* referencing same Delivery document of the original Sales Outbound): to be possible to
* identify the scenario, the total net value of the document (header – field NETWR) will be used:
* => In case NETWR carries a ZERO or NEGATIVE value, then nothing or a Credit to
* Customer is being provided: with that, NF Type will be one with Type “Correction” (exp: Z3).
* => In case NETWR carries a POSITIVE value, then a Debit to Customer is being provided:
* with that, the NF Type will be one with Type “Complementary” (exp: Z2).

* Check if a NF Type is already assigned (relevant for BR)


CHECK t_l_nftype IS NOT INITIAL
* Check if it’s a BR NF relevant Billing document
CHECK t_wvbrk-fkart IS NOT INITIAL AND t_ctvfk-j_1bnfrel IS NOT INITIAL
* Check if IS-OIL Differential Invoice is being processed
CHECK t_ctvfk-oic_diffin IS NOT INITIAL
CHECK (SAPLV60A)TVFK-OIC_DIFFIN IS NOT INITIAL
* Check Billing Document header is being created
CHECK t_wvbrk-updkz = ‘I’
* Read necessary parameters from TVARVC (transaction STVARV)
SELECT * FROM tvarvc INTO lt_tvarvc WHERE
( name LIKE 'ZSD_NFE_DIFFERINV_#%' ESCAPE '#' )

IF sy-subrc IS INITIAL AND lt_tvarvc IS NOT INITIAL


SORT lt_tvarvc BY name low ASCENDING
* Check if resulting document is a Credit or a Debit Note
IF t_wvbrk-netwr > 0
* Total document net is greater than zero: DEBIT NOTE
READ lt_tvarvc INTO ls_tvarvc USING
NAME = ‘ZSD_NFE_DIFFERINV_NFTYPE_DEBI’
LOW = t_wvbrk-fkart
IF sy-subrc IS INITIAL AND ls_tvarvc-high IS NOT INITIAL

Version 5.0 29-03-2021 Page 229 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

* 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)

(START – 44_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)


18.6[16.3] ENHANCEMENT_REQUIREMENT_06 – SEFAZ ERROR 769 – ICMS CST 61

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.

Method FILL_NFE_DET_IMPOSTO_400, Class /XNFE/CL_T2PROXY_NFE_400): the aim is to include new


additional logic on previously created enhancement point at the end of the Method. In resume, the functional
logic will be:
If ICMS CST is ’61, then check if field q_bcmono_ret is EMPTY/BLANK: if yes, move
qbcmonoret value from ECC (zeroed or not) to the field, avoiding it to be not present on final XML file.

Version 5.0 29-03-2021 Page 230 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

o Change Enhancement Point at the end of Method FILL_NFE_DET_IMPOSTO_400 (Class


/XNFE/CL_T2PROXY_NFE_400). Then include:

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.

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Class /XNFE/CL_T2PROXY_NFE_400, Method FILL_NFE_DET_IMPOSTO_400,


End A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 ZSD_NFE_DET_IMPOSTO_400. "active version
************************************************************************
* PROGRAM ID : ZSD_NFE_DET_IMPOSTO_400 *
* PROGRAM TITLE : NA *
* Enhancement *
* AUTHOR : Prasenjit Ghosh *
* DATE : 26th Oct, 2022 *
* GLOBAL/LOCAL : Brazil *
* DEVELOPMENT ID : ENH010 *
* CHANGE REQUEST (CTS) : PDIK943434 *
* AUTHORIZATION OBJECT : NA *
* DESCRIPTION : Enhancement for Importing data for NFE *
*----------------------------------------------------------------------*
* COPIED FROM : NA *
* TITLE : NA *
* OTHER RELATED OBJ : NA *
************************************************************************
* CHANGE HISTORY LOG *
************************************************************************
* MOD. NO.| DATE | NAME |CORRECTION NUMBER| CHANGE *
* REFERENCE#*
*----------------------------------------------------------------------*
* Initial | 26-10-2022 | Prasenjit Ghosh |RITM000001588724 |PDIK943434 *
*----------------------------------------------------------------------*

* 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.

DATA: lt_nfe_prod_comb TYPE /xnfe/if_nfe_prod_comb_400_t,


lt_nfe_det_prod TYPE /xnfe/if_nfe_det_prod_400_t,
lt_nfe_imposto_cofins TYPE /xnfe/if_nfe_imposto_cofins_t,
lt_nfe_imposto_icms TYPE /xnfe/if_nfe_imposto_icms_400t,
lt_options TYPE STANDARD TABLE OF rfc_db_opt,
ls_options TYPE rfc_db_opt,
lt_fields TYPE STANDARD TABLE OF rfc_db_fld,
ls_fields TYPE rfc_db_fld,
lt_temp TYPE STANDARD TABLE OF tab512.

Version 5.0 29-03-2021 Page 231 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

DATA: lv_item TYPE /xnfe/lineid,


lv_eccclnt TYPE mandt,
lv_rfccnx TYPE char20.

* Read Global Tables containing NF items info


CALL FUNCTION 'ZSD_XNFE_IMPORT_NF_GLOBAL_INFO'
IMPORTING
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.

* Check if NFe Item(s) info is available


* Check if ICMS active Tax block of Tags per Tax Situation for current item is ICMS60 and
* if COFINS for Sales indicate rate per quantity (current scope just for Fuels)
IF lt_nfe_prod_comb IS NOT INITIAL AND lt_nfe_imposto_icms IS NOT INITIAL.
IF <choice>-sequence-icms-choice-selection = 'ICMS60' AND <cofins>-choice-cofinsqtde-cst = '03'.
* Use COFINS and ICMS info to help finding WHICH NF item is being processed
CLEAR: lv_item, lv_eccclnt, lv_rfccnx.
LOOP AT lt_nfe_imposto_cofins INTO DATA(ls_nfe_imposto_cofins1) WHERE cst = <cofins>-choice-cofinsqtde-cst
AND v_cofins = <cofins>-choice-cofinsqtde-v_cofins
AND q_bcprod = <cofins>-choice-cofinsqtde-q_bcprod
AND v_aliq_prod = <cofins>-choice-cofinsqtde-v_aliq_prod.

READ TABLE lt_nfe_imposto_icms INTO DATA(ls_nfe_imposto_icms1) WITH KEY ID = ls_nfe_imposto_cofins1-id.


IF sy-subrc EQ 0.
IF ls_nfe_imposto_icms1-orig = <choice>-sequence-icms-choice-icms60-orig AND
ls_nfe_imposto_icms1-cst = <choice>-sequence-icms-choice-icms60-cst AND
ls_nfe_imposto_icms1-v_bcstret = <choice>-sequence-icms-choice-icms60-sequence-v_bcstret AND
ls_nfe_imposto_icms1-v_icmsstret = <choice>-sequence-icms-choice-icms60-sequence-v_icmsstret AND
ls_nfe_imposto_icms1-p_st = <choice>-sequence-icms-choice-icms60-sequence-p_st AND
ls_nfe_imposto_icms1-v_icmssubstituto = <choice>-sequence-icms-choice-icms60-sequence-v_icmssubstituto.
lv_item = ls_nfe_imposto_icms1-id.
EXIT.
ENDIF.
ENDIF .
ENDLOOP.

IF lv_item IS NOT INITIAL.


* By available info, NF item was found
READ TABLE lt_nfe_prod_comb INTO DATA(ls_nfe_prod_comb) WITH KEY ID = lv_item.
IF sy-subrc EQ 0 AND ls_nfe_prod_comb-c_prod_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 TABLE @DATA(lt_tvarvc) WHERE ( name LIKE 'ZXNFE#_ENH010#_SEFAZ#_858%' ESCAPE '#' ).
IF sy-subrc EQ 0 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 numb ASCENDING.
* Parameters related to ECC Client
READ TABLE lt_tvarvc INTO DATA(ls_tvarvc) WITH KEY name = 'ZXNFE_ENH010_SEFAZ_858_ECC_CLT'
low = sy-sysid.
IF sy-subrc EQ 0 AND ls_tvarvc-high IS NOT INITIAL.
lv_eccclnt = ls_tvarvc-high(3).
* Check if Client from parameters is valid, If not, end processing
SELECT SINGLE mandt FROM t000 INTO @DATA(lv_mandt) WHERE mandt = @lv_eccclnt.
IF sy-subrc NE 0.
CLEAR lv_eccclnt.
EXIT.
ENDIF.
* Parameters related to RFC Connection
READ TABLE lt_tvarvc INTO ls_tvarvc WITH KEY name = 'ZXNFE_ENH010_SEFAZ_858_RFC_CNX'
low = sy-sysid.
IF sy-subrc EQ 0 AND ls_tvarvc-high IS NOT INITIAL.
lv_rfccnx = ls_tvarvc-high.
ENDIF.

CLEAR: lt_options[], ls_options, lt_fields[], ls_fields, lt_temp[].


ls_options-text = |MANDT = '| && lv_eccclnt && |'| && | AND NAME = 'ZSD_XNFE_ANP_SEFAZ_858'|.
APPEND ls_options TO lt_options.
ls_fields-fieldname = 'LOW'.
ls_fields-length = '000009'.
APPEND ls_fields TO lt_fields.

* 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.

Version 5.0 29-03-2021 Page 232 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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.

* Change SELECTION from ICMS60 to ICMSST


<choice>-sequence-icms-choice-selection = 'ICMSST'.
* Build ICMSST
<choice>-sequence-icms-choice-icmsst-orig = ls_nfe_imposto_icms1-orig.
<choice>-sequence-icms-choice-icmsst-cst = ls_nfe_imposto_icms1-cst.
<choice>-sequence-icms-choice-icmsst-v_bcstret = ls_nfe_imposto_icms1-v_bcstret.
<choice>-sequence-icms-choice-icmsst-p_st = ls_nfe_imposto_icms1-p_st.
<choice>-sequence-icms-choice-icmsst-v_icmssubstituto = ls_nfe_imposto_icms1-v_icmssubstituto.
<choice>-sequence-icms-choice-icmsst-v_icmsstret = ls_nfe_imposto_icms1-v_icmsstret.
<choice>-sequence-icms-choice-icmsst-v_bcstdest = ls_nfe_imposto_icms1-v_bcstdest.
<choice>-sequence-icms-choice-icmsst-v_icmsstdest = ls_nfe_imposto_icms1-v_icmsstdest.

IF ls_nfe_imposto_icms1-v_bcfcpstret IS NOT INITIAL.


<choice>-sequence-icms-choice-icmsst-sequence-v_bcfcpstret = ls_nfe_imposto_icms1-v_bcfcpstret.
ENDIF.
IF ls_nfe_imposto_icms1-p_fcpstret IS NOT INITIAL.
<choice>-sequence-icms-choice-icmsst-sequence-p_fcpstret = ls_nfe_imposto_icms1-p_fcpstret.
ENDIF.
IF ls_nfe_imposto_icms1-v_fcpstret IS NOT INITIAL.
<choice>-sequence-icms-choice-icmsst-sequence-v_fcpstret = ls_nfe_imposto_icms1-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_icms1-v_bcefet IS NOT INITIAL.
<choice>-sequence-icms-choice-icmsst-sequence1-v_bcefet = ls_nfe_imposto_icms1-v_bcefet.
ENDIF.
IF ls_nfe_imposto_icms1-p_icmsefet IS NOT INITIAL.
<choice>-sequence-icms-choice-icmsst-sequence1-p_icmsefet = ls_nfe_imposto_icms1-p_icmsefet.
ENDIF.
IF ls_nfe_imposto_icms1-v_icmsefet IS NOT INITIAL.
<choice>-sequence-icms-choice-icmsst-sequence1-v_icmsefet = ls_nfe_imposto_icms1-v_icmsefet.
ENDIF.

ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.

ENDIF.
ENDIF.

(START – 44_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)


****************************************************************************
* SEFAZ Error 769: In case CST61 (Fuels) is present, guarantee that tag
* qbcmonoret (quantity related to withheld ICMS Monophasic) will be on final
* XML file no matter it’s zeroed or not.
IF lt_nfe_prod_comb IS NOT INITIAL AND <choice>-sequence-icms-choice-selection = 'ICMS61'.
IF <choice>-sequence-icms-choice-icms61-q_bcmono_ret IS EMPTY/BLANK.
* If ICMS61 section exists but the qbcmonoret is EMPTY/BLANK, move
* ECC value to the tag
<choice>-sequence-icms-choice-icms61-q_bcmono_ret = ls_nfe_imposto_icms-q_bcmono_ret.
ENDIF
ENDIF
(END – 44_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)

ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*
(END – 44_CR: RITM000002474916 Changes V4.0 – 12th Aug 2024)

Version 5.0 29-03-2021 Page 233 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

19 DETAILED SAP CONFIGURATION - SLL-NFE & SAP-ECC – OTHER ENHANCEMENTS


FOR NFE – BP SPECIFIC REQUIREMENTS
Not applicable.
19.1 Configuration

 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

Version 5.0 29-03-2021 Page 234 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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)

Version 5.0 29-03-2021 Page 235 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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

Version 5.0 29-03-2021 Page 236 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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

Version 5.0 29-03-2021 Page 237 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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_ANP S 100 I EQ 820101019

ZSD_NFE_SEFAZ_362_ANP S 101 I EQ 820101020

ZSD_NFE_SEFAZ_362_ANP S 102 I EQ 820101021

ZSD_NFE_SEFAZ_362_ANP S 103 I EQ 820101022

ZSD_NFE_SEFAZ_362_ANP S 104 I EQ 820101025

ZSD_NFE_SEFAZ_362_ANP S 105 I EQ 820101026

ZSD_NFE_SEFAZ_362_ANP S 106 I EQ 820101027

ZSD_NFE_SEFAZ_362_ANP S 107 I EQ 820101028

ZSD_NFE_SEFAZ_362_ANP S 108 I EQ 820101029

ZSD_NFE_SEFAZ_362_ANP S 109 I EQ 820101030

ZSD_NFE_SEFAZ_362_ANP S 110 I EQ 820101031

ZSD_NFE_SEFAZ_362_ANP S 111 I EQ 820101032

ZSD_NFE_SEFAZ_362_ANP S 112 I EQ 820101033

ZSD_NFE_SEFAZ_362_ANP S 113 I EQ 820101034

Version 5.0 29-03-2021 Page 238 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

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

 TVARVC Variables / Parameters to Technical control on SLL-NFE Client

Variable Name Selection type Number INCL/EXCL Option Field Value Field Value CHAR01 data element for SYST

ZXNFE_ENH010_SEFAZ_858_ECC_CLT S 0 I BT PDI 201

ZXNFE_ENH010_SEFAZ_858_ECC_CLT S 1 I BT PYI 200

ZXNFE_ENH010_SEFAZ_858_ECC_CLT S 2 I BT PQI 200

ZXNFE_ENH010_SEFAZ_858_ECC_CLT S 3 I BT PSI 200

ZXNFE_ENH010_SEFAZ_858_ECC_CLT S 4 I BT PFI 200

ZXNFE_ENH010_SEFAZ_858_ECC_CLT S 5 I BT PRI 200

ZXNFE_ENH010_SEFAZ_858_RFC_CNX S 0 I BT PDI

ZXNFE_ENH010_SEFAZ_858_RFC_CNX S 1 I BT PYI NFE_TO_ECC

ZXNFE_ENH010_SEFAZ_858_RFC_CNX S 2 I BT PQI NFE_TO_ECC

ZXNFE_ENH010_SEFAZ_858_RFC_CNX S 3 I BT PSI

ZXNFE_ENH010_SEFAZ_858_RFC_CNX S 4 I BT PFI NFE_TO_ECC

ZXNFE_ENH010_SEFAZ_858_RFC_CNX S 5 I BT PRI NFE_TO_ECC

 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

(START – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)


 TVARVC Parameters for Differential Invoice Control to associate relevant NF Parameters information:
Variable Name Selection type Number INCL/EXCL Option Field Value Field Value CHAR01 data element for SYST
ZSD_BR_ENH011_DIFFINV_FKART S I EQ Z1

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

(END – 36_CR: RITM000002474916 Changes V4.0 – 24th May 2024)

Version 5.0 29-03-2021 Page 239 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

19.2 Master Data

N/A

20 TESTING REQUIREMENT - SLL-NFE & SAP-ECC – OTHER ENHANCEMENTS FOR NFE


– BP SPECIFIC REQUIREMENTS
20.1 Test cases / scenarios

Test Step Step Description Expected Results


Condition
‍ 

‍ 

‍ 

‍ 

20.2 Functional Testing - for all functionalities:

Testing documents will be uploaded in Team’s folder below after unit Test.
Unit Testing Evidence – under BR0M

(END – 21_UAT: RITM000001588724 Changes V3.0 – 15th Oct 2022)

Version 5.0 29-03-2021 Page 240 of 244


Functional Design
SL - DEL22-New Sale and Purchase Processes

Version 5.0 29-03-2021 Page 241 of 243


Functional Design
SL - DEL22-New Sale and Purchase Processes

21 APPENDIX
21.1[16.4] SEFAZ Technical Notes

This appendix subsection aims to register SEFAZ Technical Notes applied:


[16.4.1] (Version 11.0 – Brazil Trading Migration Project – 2022)
Technical Note Version High level description Explanation Availability Migration
date solution

“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

Version 5.0 29-03-2021 Page 242 of 243


Functional Design
SL - DEL22-New Sale and Purchase Processes

“NT2021.003 - 1.00 New As from discussed during BR02 (N/A)


Regras de validation Workshop on November 22nd, 2021, this
Validação rules for is not relevant to bp PRI (no products
cEAN” cEAN e with EAN code)
cEANTrib
na NF-
“NT2021.004 - 1.30 New Included in Scope by approved Change Apr
Regras de validation Request #6. 15th ,
Validação e rules for 2022
Novos Carrier
Campos” area,
new
fields for
FCT-ST

21.1.1 (Version 2.0 – Brazil Diesel Distribution Project – 2023)


Technical Note Version High level Explanation Availability date Migration solution
description

“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).

21.1.2 (Version 4.0 – Brazil Rio de Janeiro Office Project – 2024)


Technical Note Version High level Explanation Availability date Migration solution
description

“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”

Version 5.0 29-03-2021 Page 243 of 243

You might also like