Functional Specification Document
BHU 27268 – India e-invoice
New Z-table and logic at invoice user exit
Document Modification Log:
Version Date Description of Change Author
1.0 17.12.2019 Invoice user exit changes Santhosh Shenoy
2.0 14.01.2020 ZTEWAYBILL table added Santhosh Shenoy
3.0 21.01.2020 ZTINVTYPE_DETER table for decision Santhosh Shenoy
flag
1
APPLE IS&T INTERNAL TO APPLE
Functional Specification Document
TABLE OF CONTENTS
1. INTRODUCTION...........................................................................................................
2.ORGANISATIONALSTRUCTURE……………………………………………………...3
3.DEFINITION OF BUSINESS NEED…………………………………………………….3
3.1 AS-IS BUSINESS SCENARIO.............................................................................
3.2 TO-BE BUSINESS SOLUTION.............................................................................
4. SCOPE..........................................................................................................................
5. REASON FOR DEVELOPMENT...................................................................................
6. PROCESSING LOGIC...................................................................................................
2
APPLE IS&T INTERNAL TO APPLE
Functional Specification Document
1. INTRODUCTION
The GST Council has approved introduction of ‘E-invoicing’ or ‘electronic invoicing’ in a phased
manner for reporting of business to business (B2B) invoices to GST System, starting from 1st January
2020 on voluntary basis. The main objective is to enable interoperability across the entire GST eco-
system i.e. an e-invoice generated by one software should be capable of being read by any other
software.
At Apple this project is kick started to go live and be compliant by April 2020. This functional spec
pertains to changes envisaged at invoice create user exit. At invoice creation stage we plan to identify
the scenario’s applicability for e-invoice and generate xml file and pass it to Govt. system for approval.
2.ORGANISATIONAL STRUCTURE
Company Code : 0062
Sales Orgs : 1320 , 1325
3.DEFINITION OF BUSINESS NEED
3.1 AS-IS BUSINESS SCENARIO
Today there is no e-invoicing solution for India and therefore customer invoice gets created in the
system and the Rover outputs – ZRIB, ZRIS and ZRIT are sent to respective recipient’s in the
business transaction.
3.2 TO-BE BUSINESS SOLUTION
At the stage of Invoice generation, we need to have a mechanism to derive if e-invoice is required for
this case or not. Post this, need to drive the logic to generate the xml file with required IRN (invoice
reference number) and other additional fields and transmit to Govt system. Once response is
received, it has to be updated back in SAP and dependent actions have to be performed.
4. SCOPE
Scoping India business cases only. Therefore, all invoicing scenarios to be taken into account to
finalise design elements. This FS includes changes related to invoice creation user exit and z-table
creations/ changes.
3
APPLE IS&T INTERNAL TO APPLE
Functional Specification Document
5. REASON FOR DEVELOPMENT
Apple business in India has to be compliant with local regulations related to e-invoicing , GST reports
and taxation rules.
6 . PROCESSING LOGIC
At invoice creation stage we will go through existing z-table ZTINVTYPE_DETER table to fetch if e-
invoice/ e-Waybill is required or not.
Z-table: ZTINVTYP_DETER (existing table modification)
Add 2 new fields e-invoice flag, e-waybill flag to this table (non-key fields). This is 911-
maintainable table and both the new fields should have Y/N as the possible values.
Existing table ZTEWAYBILL modification
6 new IRN related fields ( in yellow) have to be added to existing ztewaybill table.
4
APPLE IS&T INTERNAL TO APPLE
Functional Specification Document
5
APPLE IS&T INTERNAL TO APPLE
Functional Specification Document
Technical object : RV60AFZZ , USEREXIT_ SAVE_DOCUMENT_PREPARE
SECTION 1 (Derive e-inv, eWb required or not decision flag)
E-invoice / E-waybill decision flag is required at multiple stages in the e-invoice functionality
during following stages.
- Invoice creation user exit
- Output requirement routine 845 to control new o/p ZXML
- Rover driver program to build dependency of IRN applicability and IRN response for
successfully processing ZRIB, ZRIT and ZRIS invoice outputs.
Proposal is to modularise this logic for deriving the flags into a abap method and call this
object wherever required.
Check if the invoice is getting created for India sales org by validating VBRK-VKORG with
TVARVC Z_INDIA_GST_VKORG. If yes, then progress further to derive e-invoice, e-waybill
decision flag.
** Customer group and Sales district control **
Check following with ZTDEFAULT (new) entry: Z_INDEINV_CUSTGRP_EXCL
If VBRK-KDGRP= parameter 1 and VBRK-BZIRK = parameter 2 or if ZTDEFAULT values
are blank
then do the table read for ZTINVTYP_DETER
If No, then exit the e-invoice flag logic.
There is existing abap include ZILV_DETERMINE_TAX_BOS called to derive invoice type
field at invoice creation stage.
Copy following read sequence which is already existing there
6
APPLE IS&T INTERNAL TO APPLE
Functional Specification Document
• Company code,Sales org, Notification type, Priority, BillingType,Order Reason and
item category,
• Company code,Sales org, Notification type, BillingType, OrderReason and item
category,
• SalesOrg, BillingType, OrderType, OrderReason & Intrastate,
• SalesOrg, BillingType, OrderType & OrderReason,
• SalesOrg, BillingType, OrderType, OrderReason & WrntyCode,
• SalesOrg, BillingType & OrderType,
• SalesOrg & BillingType,
For successful entry found, fetch e-invoice and e-Waybill table flag entries (Y/N)
**No IRN required for invoices without GST**
Check if VBRK-ZZINVTYPE = 999 (new TVARVC variable)
If yes , then exit the IRN logic.
SECTION 2 ( Write entry in ZTEWAYBILL table based on e-inv, eWb required or not
decision flag)
If e-invoice flag & e-waybill flag is checked from decision table , then write an entry in
ZTEWAYBILL with below details.
Billing document VBRK-VBELN
Sequence no. = 001
Tax invoice number = VBRK- ZZTAX_INVNO
IRN = IRN number (blank).
IRN status = A (Details in status management section)
7
APPLE IS&T INTERNAL TO APPLE
Functional Specification Document
E-way bill number = blank
E-way bill status = A
E-way bill creation date = blank
E-way bill creation time = blank
E-way bill validity date = blank (not used today)
E-way bill validity time = blank (not used today)
E-invoice validated date = Date received in the IRN response
E-invoice validated time = Time received in the IRN response
Comments = blank
E-invoice IRN = blank
E-invoice IRN status = A
QR code = blank
E-invoice validated date = blank
Acknowledgement number = blank
IRN comments = blank
Changed date = sys date of updating the entry
Changed time = sys time of updating the entry
If e-invoice flag is checked and no e-way bill required decision table , then write an entry
in z-table ZTEWAYBILL same as above except the statuses
E-way bill status = N
E-invoice IRN status = A
If e-invoice flag is not checked and e-way bill required from decision table , then write an
entry in z-table ZTEWAYBILL same as above except the statuses
E-way bill status = 1 (will be routed via legacy solution)
E-invoice IRN status = N
IRN Status list
IRN status field gets updated in the ZTEWAYBILL table at following stages
8
APPLE IS&T INTERNAL TO APPLE
Functional Specification Document
Stages Status Description
While writing entry in ZTEWAYBILL table at invoice N E-invoice not required
creation
While writing entry in ZTEWAYBILL table at invoice A Not yet sent to IRP
creation
ZXML o/p processing- Data issue B Data issue
IRP response received- Success D IRN approved
IRP response received- Rejected E IRN rejected- PRTNR
IRP response received- Rejected F IRN rejected- IRP
IRP Response update in ZTEWAYBILL table T Timeout
Manual status update via ZSEWAYBILL R Reprocess
Created Manually Q Updated Manually
e-Waybill Status
eWaybill status field gets updated in the ZTEWAYBILL table at following stages
Stages Status Description
While writing entry in ZTEWAYBILL table at invoice N e-Waybill not required
creation
While writing entry in ZTEWAYBILL table at invoice A e-Waybill via ZXML o/p
creation
ZXML o/p processing - Data issue 2 Data issue
ZXML o/p successfully processed 3 Despatched to IRP
IRP response – Rejected 4 Despatched with Error-GSP
IRP response received- Rejected 5 Despatched with Error-EWB
IRP response received- Success 6 EWB Received Successfully
Manual status update via ZSEWAYBILL 7 EWB Cancelled
Important points to note in this FS:
A process inventory ( list of india business scenario) is prepared and business have agreed to
uniquely identify the e-invoice , e-waybill applicability based on the fields listed in the new
decision table ZTEINV_CNTRL.
ZTEWAYBILL table is existing in PD2 today for eWB solution. Same will be enhanced for e-
invoicing as well.
IRN & e-Waybill response from Govt system (IRP) will be updated back into ZTEWAYBILL table
entry . HTTP call FM Z_XML_OVER_HTTP_CLIENT
Currently leagcy e-way bill solution is live in SAP. If only e-way bill is required for a scenario then
it will be routed via legacy solution by managing eWB statuses in ZTEWAYBILL TABLE.
With reference to recent FAQ from Indian Govt its decided that IRN number will be issued from
IRP in response message from Govt.
9
APPLE IS&T INTERNAL TO APPLE
Functional Specification Document
7. Functional test plan
Validate all the field in decision table ZTINVTYP_DETER
Duplicate entry check in decision table ZTINVTYP_DETER
Validate all the fields in Storage table ZTEWAYBILL for all 3 cases – eWB only required, einvoice
only required , eWB +einv required
Execute India scenarios after decision table update and check if ZTEWAYBILL table entries are
being written successfully based on eWB & Einv applicability.
10
APPLE IS&T INTERNAL TO APPLE