Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 13

NF-e - Decouple RFC from DB Update

Problem
During the implementation / go live from certain customers problems in the communication
between the involved IT systems are discovered. Major parts are:
 Numbering gaps
 Update Task delay
 Locked documents when update in ERP is triggered via RFC from messaging system
 Validation in GRC xNFe
 NF-e at Sefaz but not posted in ERP

A solution to get rid of this problems is to decouple the RFC call from the data base update.
The solution for the decouple provides 3 possible ways to number and send the NF-e to
SEFAZ.
1. via the monitor report
2. a mix of 1 and 3 where the numbering is done in the monitor report and the sending in
the batch report.
3. via a periodically scheduled batch report. The time interval for scheduling the job
must be decided based on the data volume.

For high data volume solution 1 may lead to performance problems because the data base
update must be completed before the data are send. For such situation solution 2 should be
preferred.

The indicator for the decision is inserted in the output determination tables (se description
below).

New coding objects


New function modules

Create the new functions in the sequence as described with transaction SE37

1. J_1B_NFE_OUT_OK_NORFC
Function Group: J_1B_NFE
Short text: Processed when NFE is OK -> calls update functions but not the RFC

Tab Attributes
Mark Normal Function Module

Tab Import
Parameter Typing Associated Type Default Value Optional Pass Value
I_REFTYP TYPE J_1BREFTYP SPACE X
I_VBELN TYPE VBELN_VF X

Tab Changing
Parameter Typing Associated Type Default Value Optional Pass Value
CS_HEADER TYPE J_1BNFDOC
CS_ACTTAB TYPE J_1BNFE_ACTIVE

Tab Tables
Parameter Typing Associated Type Default Value Optional Pass Value
IT_NFLIN LIKE J_1BNFLIN
IT_NFNAD LIKE J_1BNFNAD
IT_NFSTX LIKE J_1BNFSTX
IT_NFFTX LIKE J_1BNFFTX
IT_NFREF LIKE J_1BNFREF
IT_NFCPD LIKE J_1BNFCPD X
IT_VBFA LIKE VBFAVB X

Tab Exception
Exception Short Text
WRONG_NUMBER_RANGE Error by numbering
RFC_FAILURE Error when RFC is called

2. J_1B_NFE_SET_NUMBER
Function Group: J_1B_NFE
Short text: Processed NF-e: Determine NF-e number and send a NF-e

Tab Attributes
Mark Normal Function Module

Tab Import
Parameter Typing Associated Type Default Value Optional Pass Value
IV_DOCNUM TYPE J_1BDOCNUM
IV_BATCH TYPE FLAG SPACE

Tab Export
Parameter Typing Associated Type Pass Value
ES_ACTIVE_MOD TYPE J_1BNFE_ACTIVE
CS_ACTTAB TYPE J_1BNFE_ACTIVE

Tab Exception
Exception Short Text
NUMBERING_NOT_POSSIBLE Numbering not possible
LOCK_ERROR_NFDOC Nf header is locked
LOCK_ERROR_ACTIVE NF-e Active is locked
ALREADY_NUMBERED NF-e is already numbered

3. J_1B_NFE_RFCBATCH_DELETE
Function Group: J_1B_NFE
Short text: Delete table entries J_1BNFERFCBATCH
Tab Attributes
Mark Update Module and Start immed.

Tab Import
Parameter Typing Associated Type Default Value Optional Pass Value
I_DOCNUM TYPE J_1BDOCNUM X

New report J_BNFECALLRFC


Create the report with transaction SE38
Maintain the attributes:
Type: Executable Program
Status: SAP Standard Program
Application: Cross Application
Package: J1BA
New Messages
Create new messages with transaction SE91
Number Short text Self-
explanatory
93 NF-e number &1 already given. Numbering and send to SEFAZ not X
allowed.
94 Contingency for NF-e without number not allowed X
95 Send NF-e without number not allowed X
96 Numbering not possible without an assigned Form X
97 NF-e is cancelled - Numbering not allowed X
98 DB-Error by deletion J_1BNFERFCBATCH X
99 Numbering in Monitor for RFC call &1 not allowed X

Changed coding objects


Change function module J_1B_NFE_UPDATE_ACTIVE
Add new Import parameter I_TRACE
Type spec.: TYPE
Associated Type: CHAR1
Default value: SPACE
Pass value: X

New DDIC objects


Create new objects with transaction SE11

Domain J_1BNFERFCCALL
Short text: Control for NF-e Numbering and RFC call to messaging system
Package: J1BA
Type: CHAR
No. of Characters: 1
Value Range:
Space – Numbering, RFC call and data base update in the same LUW
1 Numbering & RFC is triggered via the Monitor Report( J1BNFE)
2 Numbering in Monitor Report - RFC via batch report
3 Numbering and RFC are triggered in the batch report J_1BRFCBATCH

Data element J_1BNFERFCCALL


Short text: Control for NF-e Numbering and RFC call to messaging system
Package: J1BA
Domain: J_1BNFECALLRFC
Field labels
Length Field Label
Short 10 RFC Call
Medium 15 RFC Call
Long 20 RFC Call
Heading 03 RFC

Documentation:
Definition
The field controls how the NF-e numbering and the RFC call for creation of the XML file
is executed from ERP backend.
Use
Before the availability of the field the numbering and RFC call was in the same LUW as
the data base update of the NF-e. Thiss functionality is kept with the default setting
"SPACE".
Example
Possible values
SPACE - is the default. Numbering, RFC call and data base update in the same LUW
1 - Numbering and RFC are triggered from the Monitor Report (Transaction J1BNFE)
2 - Numbering in Monitor Report - RFC via batch report
3 - Numbering and RFC call are triggered in the batch report

Transparent Table J_1BNFERFCBATCH


Short text: NF-e documents to be send via Report J_1BRFCBATCH
Package: J1BA
Delivery Class. A
Table View Maintenance: Allowed with restrictions
Enhancement Category: Can not be enhanced

Field Key Init Data Element


MANDT X X MANDT
DOCNUM X X J_1BDOCNUM

Technical settings:
Data Class: APPL1
Size Category: 3
Buffering not allowed

Change DDIC
Use transaction SE11

Domain J_1BNFE_ACTION_REQUIRED
In the Tab Value Range Add new values
Value Short description:
9 Set NF-e number and send to SEFAZ
0 Set NF-e number and send to SEFAZ via Batch report
A Numbering is done in batch - no manual action required
B Send to SEFAZ via Batch report - no manual action required

Tables: J_1BB2, J_1BB2DYNAMIC, J_1BNFE_ACTIVE, J_1BNFE_HISTORY

In all tables add new field CALLRFC at the end of the field list.
Data element is J_1BNFERFCCALL

In table J_1BNFE_HISTORY add after CALLRFC additionally


Field NFNUM9 with data element J_1BNFNUM9

View J_1BB2V
In the TAB View Fields push the button Table fields, double-click on J_1BB2, and mark the
field:
CALLRFC
Change the maintenance screen for the view with transaction SE54. Insert view name
J_1BB2V. Mark Generated Objects and push CHANGE. Double click on screen 281. Select
LAYOUT.
Choose Dictionary/program fields window (F6). Insert J_1BB2V as table name.
For field J_1BB2V-CALLRFC mark short text (length 10).
Select field J_1BB2V-CALLRFC and insert it into frame NF-e behind Numbering Conting..
Set Do not convert in the shown popup

Insert in the flow logic in the PAI the yellow marked line:

FIELD J_1BB2V-BUKRS .
FIELD J_1BB2V-BRANCH .
FIELD J_1BB2V-FORM .
FIELD J_1BB2V-SUBOBJ .
FIELD J_1BB2V-TOTLIH .
FIELD J_1BB2V-TOTLIL .
FIELD J_1BB2V-FATURA .
FIELD J_1BB2V-SERIES .
FIELD J_1BB2V-SUBSER .
FIELD J_1BB2V-NUMBERRANGE .
FIELD J_1BB2V-FIELDNAME .
FIELD J_1BB2V-PRNTER .
FIELD J_1BB2V-PRNTERCONT .
FIELD J_1BB2V-LASSERPRINTER.
FIELD J_1BB2V-NFENRNR.
FIELD J_1BB2V-CALLRFC.

Leave the screen maintenance. In the maintenance dialog, push F7.


In the shown popup, mark New Field/sec.table in Structure.
In the next popup, mark Normal field.

View J_1BB2DYNAMICV
In the TAB View Fields push the button Table fields, double-click on J_1BB2DYNAMICV, and
mark the field:
CALLRFC
Change the maintenance screen for the view with transaction SE54. Insert view name
J_1BB2DYNAMICV Mark Generated Objects and push CHANGE. Double click on screen
283. Select LAYOUT.
Choose Dictionary/program fields window (F6). Insert J_1BB2DYNAMICV V as table name.

For field J_1BB2DYNAMICV-CALLRFC mark short text (length 10).


Select field J_1BB2DYNAMICV V-CALLRFC and insert it into frame NF-e behind Numbering
Conting..
Set Do not convert in the shown popup

Insert in the flow logic in the PAI the yellow marked line:

FIELD j_1bb2dynamicv-series .
FIELD j_1bb2dynamicv-subser .
FIELD j_1bb2dynamicv-prnter .
FIELD j_1bb2dynamicv-prntercont .
FIELD j_1bb2dynamicv-nfenrnr.
FIELD J_1BB2dynamicV-LASSERPRINTER.
FIELD J_1BB2dynamicV-CALLRFC.

Leave the screen maintenance. In the maintenance dialog, push F7.


In the shown popup, mark New Field/sec.table in Structure.
In the next popup, mark Normal field.
Change GUI Status for report J_1BNFE_MONITOR
Use transaction SE41
Program: J_1BNFE_MONITOR
Status: SCREEN_100

In section Function Keys


Assign Function Code SET_NUM to Function Key: CTRL + F6
Function Text: Set NF-e number
Icon Name: ICON_RELEASE
Icon Text: Set Nf-e number
Info Text Set Nf-e number

Double click on the marked line to get the following popup


Insert the function key into the application toolbar
Insert the function key into the menu bar
The function key appears in the monitor report and allows to number and send NF-es with the
RCFcall status 1 derived from the output configuration to SEFAZ when the user decides that
they are completed.
For status 2 the NF-e are only numbered and scheduled for send with the next batch run.
NF-es with RFC call status 3 can not be numbered and send with the monitor report.
Activation of the new functionality
The new functionality is activated when in the output configuration the indicator for RFC call
(see red frame in the picture below) is set to 1, 2 or 3. For initial value (SPACE) the existing
functionality with on LUW for data base update and RFC call remains.

IMG: Cross-Application Components -> General Application Functions -> Nota fiscal ->
Output -> Assign Numbering and Printing Parameters

The setting can be done in General Printing Parameters and/or Key-Specific Printing
Parameters

BADI for changing print configuration


The field CALLRFC in the printer configuration can be manipulated in the BADI
J_1B_RANGE_NUMBER in method PRINT_CONFIGURATION. Only values 1,2 and 3 are
allowed. The value derived from the BADI overrules the customizing settings.

Insert in the method line


PRINT_CONF-CALLRFC = <value>.

Schedule a batch job


For sending NF-es with RFC call status 2 and 3 to SEFAZ a batch job for Report
J_BNFECALLRFC must be scheduled periodically.

You might also like