SAP Invoice IDoc INVOIC02 - Structure, User-Exit and BADI

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8
At a glance
Powered by AI
The article discusses the structure of an INVOIC02 IDoc in SAP, including its main segments. It also describes ways to enhance an INVOIC02 IDoc through user exits and BADIs.

An INVOIC02 IDoc has a basic type structure consisting of segments like E1EDK01, E1EDKA1, E1EDKT1, E1EDKT2, E1EDK14, and E1EDP01.

The main segments in an INVOIC02 IDoc are: E1EDK01 for document header general data, E1EDKA1 for document header partner information, E1EDKT1 for document header text identification, and E1EDP01 for document item general data.

22.2.

2021 SAP Invoice IDoc INVOIC02 - Structure, User-Exit And BADI

SAP TABLES SAP TCODES SAP BAPI ABAP SNIPPETS TOP SAP COURSES

TOP SAP BOOKS

SAP4TECH
SAP and ABAP Tutorials

SAP TECHNICAL  SAP FUNCTIONAL  SAP FIORI SAP HANA SAP BW

SAP CRM SAP SRM SAP4TECH 

SAP4TECH » SAP Invoice IDoc INVOIC02 – Structure,


User-Exit and BADI

SAP Invoice IDoc SEARCH ON


SAP4TECH
INVOIC02 – Structure,
User-Exit and BADI
 By John  September 14, 2015  SAP IDOC, Search
ABAP Tutorials

Idoc INVOIC02: This article will introduce you to outbound


IDoc for Invoice/Billing document in SAP.
THE MOST
It will cover the IDoc Invoic02 structures, XML Schema, POPULARS
Enhancement for INVOICE Idoc and ABAP Code to
generate INVOICE Idoc with BAPI
The Most
Idoc INVOIC02 Structure Important
User Exit and BADI for Idoc INVOIC02 SAP ISU
Generate Invoice IDoc with BAPI Tables

This website uses cookies to improve your experience. We'll assume you accept this policy as X
Table of Contents
long as you
 are using this website Accept View Policy

https://sap4tech.net/idoc-invoic02-sap-invoice-idoc/ 1/8
22.2.2021 SAP Invoice IDoc INVOIC02 - Structure, User-Exit And BADI

SAP Users
Tables (for
Idoc INVOIC02 Structure Personal,
Logon,

SAP INVOICE IDoc Basic Type Structure and


Address
First at all, let’s detail the main segments of INVOIC02 : Data)

E1EDK01 for IDoc: Document header general data


E1EDKA1 for IDoc: Document Header Partner SAP
Information Purchase

E1EDKT1 for IDoc: Document Header Text Order


Identification Tables:
E1EDKT2 for IDoc: Document Header Texts Lines Main PO

E1EDK14 for IDoc: Document Header Organizational tables in


Data SAP MM –

E1EDP01 for IDoc: Document Item General Data SAP PO


Tables

SAP Good
Movement
Types –
Full list of
SAP
Movement
Types

The Main
SAP G/L
Account
Tcodes &
SAP GL
The full INVOIC02 Basic Type is:
Account
This website uses cookies to improve your experience. We'll assume you accept this policy as
Tables X
In Order to go further, you can check the full
long as you are using this website Accept View Policy
documentation on how to manage Inbound Processing of
https://sap4tech.net/idoc-invoic02-sap-invoice-idoc/ 2/8
22.2.2021 SAP Invoice IDoc INVOIC02 - Structure, User-Exit And BADI

IDocs Received.
SAP BOM
Tables for
XML Schema for Invoice IDoc BOM
Header,
This link contains the Idoc INVOIC02 XML Schema.( For
Items and
obvious security reason, I put the document in Zipped
components
format).
and
Category
User Exit and BADI for Idoc
INVOIC02

SAP TUTORIALS
User Exit for SAP Invoice Idoc
BY TOPICS

EXIT_SAPLVEDF_001 (ZXEDFU01) SAP Tables


SAP Tcodes
This User Exit offers to make additional Control Data SAP BAPI
IDoc_Output_Invoice.
ABAP Snippets
So the parameters of this User Exist are:
Top SAP Courses
1 *"  IMPORTING Top SAP Books
2 *"     VALUE(CONTROL_RECORD_OUT) LIKE  EDIDC STRUCTURE
3 *"     VALUE(DVBDKR) LIKE  VBDKR STRUCTURE  VBDKR OPTI
4 *"     VALUE(DOBJECT) LIKE  NAST STRUCTURE  NAST OPTIO
5 *"  EXPORTING
6 *"     VALUE(CONTROL_RECORD_OUT) LIKE  EDIDC STRUCTURE
7 *"  TABLES
8 *"      DXVBPA STRUCTURE  VBPA OPTIONAL
9 *"      DTVBDPR STRUCTURE  VBDPR OPTIONAL
10 *"  EXCEPTIONS
11 *"      ERROR_MESSAGE_RECEIVED
12 *"      DATA_NOT_RELEVANT_FOR_SENDING
13 *"----------------------------------------------------

User Exit EXIT_SAPLVEDF_002 (ZXEDFU02)

This User Exist allows Customer Enhancement in Data


Segments when generating Billing Document Output.

It called when generating the INVOIC02 Idoc SEGMENT


This website uses cookies to improve your experience. We'll assume you accept this policy as X
BY SEGMENT.
long as you are using this website Accept View Policy

https://sap4tech.net/idoc-invoic02-sap-invoice-idoc/ 3/8
22.2.2021 SAP Invoice IDoc INVOIC02 - Structure, User-Exit And BADI

The following Code is an example of ABAP implementation


of the user exit ZXEDFU02

1   DATA: ls_E1EDKA1  LIKE e1edka1,


2         ls_edidd    LIKE edidd.
3   DATA: lv_index    TYPE I.
4         
5   READ TABLE int_edidd INTO ls_edidd index lv_index.
6  
7   CHECK ls_edidd-segnam EQ 'E1EDKA1'  AND
8         ls_edidd-sdata(2) EQ 'WE'.
9  
10   ls_E1EDKA1-parvw = 'AG'.
11  
12   ls_edidd-sdata = ls_E1EDKA1.
13   APPEND ls_edidd TO int_edidd.

BADI for SAP Invoice Idoc INVOICE02

SD_INVOICE_IDOC_OUTPUT_INT: Internal BADI


for IDOC output processing

Hence, This BADI has 4 methods:

CONTROL_RECORD_OUT_PREPARE: check and


modify EDIDD ( Idoc Data Table )
IDOC_DATA_APPEND: allows to add more data
segment for IDoc
INVOICE_READ helps read the SAP Invoice.
PACKAGING_DATA_READ reads the packaging Data.

SAP Invoice Tables

In order to fill the enhancement of INVOIC02, you can rely


on the most important tables for SAP Invoice

VBRP,Billing Document: Item Data


VBRK,Billing Document: Header Data
VBFK,Invoice: header Data
VBFP,Invoice:
This website Item Data
uses cookies to improve your experience. We'll assume you accept this policy as X
RBKP,Document Header:
long as Invoice
you are using Receipt
this website Accept View Policy

https://sap4tech.net/idoc-invoic02-sap-invoice-idoc/ 4/8
22.2.2021 SAP Invoice IDoc INVOIC02 - Structure, User-Exit And BADI

Generate Invoice IDoc with BAPI


With the following ABAP Program Snippet, you can
generate an Idoc INVOIC.INVOIC02 in less than a couple
of minutes ( between creating of ABAP program/function,
copy/paste the activation ).

The main BAPI used to generate an outbound Idoc


INVOIC02 for Invoice is the
BAPI IDOC_OUTPUT_INVOIC.

Also This BAPI will fill the prepare the Idoc and fill the
segments required for INVOIC02 Idoc ( and even
extension if user exist or BADI are implemented ).

To explain the following ABAP Coden here the steps:

1. Generate EDIDD tables for INVOICES with


IDOC_OUTPUT_INVOIC
2. Distribute the IDoc, So a IDoc number is generated
with standard BAPI MASTER_IDOC_DISTRIBUTE
3. If no error occurs when creating the IDoc, we call a
commit work with both DB_COMMIT BAPI And
COMMIT WORK.

1 DATA : ls_nast                 TYPE nast,


2        ls_ctrl_in              TYPE edidc,
3        ls_ctrl_out             TYPE edidc.
4  
5 DATA : lt_idoc_data            TYPE TABLE OF edidd,
6        ls_idoc_header          TYPE edidc,
7        lt_comm_idoc_control    TYPE TABLE OF edidc,
8        lt_created_comm_idocs   TYPE TABLE OF edidc.
9  
10 CLEAR ls_nast.
11 ls_nast-mandt = sy-mandt.
12 ls_nast-objky = lv_invoicekey. " @Change with Invoice
13  
14 clear ls_ctrl_in.
15 ls_ctrl_in-IDOCTP = 'INVOIC02'.
16 ls_ctrl_in-MESTYP = 'INVOIC'. " @ You can put your ext
17  
18 CLEAR lt_idoc_data[].
19 CALL FUNCTION 'IDOC_OUTPUT_INVOIC'
20   EXPORTING
This
21
website uses cookies to improve your experience. We'll assume you accept
    object                        = ls_nast
this policy as X
22 long as you are using =this
    control_record_in             website Accept View Policy
ls_ctrl_in
23   IMPORTING
https://sap4tech.net/idoc-invoic02-sap-invoice-idoc/ 5/8
22.2.2021 SAP Invoice IDoc INVOIC02 - Structure, User-Exit And BADI
24     control_record_out            = ls_ctrl_out
25 *   OBJECT_TYPE                   =
26   TABLES
27     int_edidd                     = lt_idoc_data[]
28   EXCEPTIONS
29     error_message_received        = 1
30     data_not_relevant_for_sending = 2
31     OTHERS                        = 3.
32  
33 CLEAR lt_comm_idoc_control[].
34  
35 CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
36   EXPORTING
37     master_idoc_control            = ls_idoc_header
38   TABLES
39     communication_idoc_control     = lt_comm_idoc_cont
40     master_idoc_data               = lt_idoc_data
41   EXCEPTIONS
42     error_in_idoc_control          = 01
43     error_writing_idoc_status      = 02
44     error_in_idoc_data             = 03
45     sending_logical_system_unknown = 04.
46 IF sy-subrc EQ 0.
47   CALL FUNCTION 'DB_COMMIT'.
48   COMMIT WORK.
49 ENDIF.

Tags: Exit, INVOICE, SAP BADI, SAP IDOC, SAP Tabes

Related Posts

ABAP PopUp: Convert JSON to Top 18 SAP


Types and ABAP Internal Common ABAP
Samples codes Table and ABAP Dumps in ST22 &
Data to JSON Troubleshooting
Format
This website uses cookies to improve your experience. We'll assume you accept this policy as X
long as you are using this website Accept View Policy

https://sap4tech.net/idoc-invoic02-sap-invoice-idoc/ 6/8
22.2.2021 SAP Invoice IDoc INVOIC02 - Structure, User-Exit And BADI

TRENDING POSTS THE MOST RECENT NAVIGATE TO

The Most Important SAP SAP Tables


The Most Important SAP
ISU Tables SAP Tcodes
ISU Tables
SAP Fiori 3 UX and SAP BAPI
Design of SAP Fiori Apps
SAP Users Tables (for ABAP Snippets
for SAP S/4HANA, SAP
Personal, Logon, and TechEd Lecture Top SAP Courses
Address Data) The Main SAP Dunning Top SAP Books
Transaction Codes
SAP Purchase Order SAP Accounts Payable
BY SAP TOPICS
Tables: Main PO tables in Tcodes & Accounts
SAP MM – SAP PO Tables Receivable Tcodes ( SAP
Select Category
AP Tcodes & SAP AR
SAP Good Movement Types Tcodes)

– Full list of SAP Movement The Most Important SAP


Types Payment Terms Tables
(ZTERM, Text…)

The Main SAP G/L Account The most Important SAP


Work Center Tables in
Tcodes & SAP GL Account
SAP PP
Tables
The Main SAP G/L
Account Tcodes & SAP
SAP BOM Tables for BOM
GL Account Tables
Header, Items and
The Full list of SAP
components and Category
S4/HANA TCodes
The Most Useful SAP
Fiori Tcodes List and SAP
Fiori Launch Pad Tcode

This website uses cookies to improve your experience.


SAP4TECH We'll assume you accept this policy as X
Copyright © 2021.
All Rights Reserved. SAP and SAP logo are registered trademarks of SAP AG. SAP4TECH.net is not associated with SAP
long as you are using this website Accept View Policy
AG. We have made every effort to make sure provide relevant search results, use the content on this site at your own risk.
https://sap4tech.net/idoc-invoic02-sap-invoice-idoc/ 7/8
22.2.2021 SAP Invoice IDoc INVOIC02 - Structure, User-Exit And BADI

Back to Top ↑

This website uses cookies to improve your experience. We'll assume you accept this policy as X
long as you are using this website Accept View Policy

https://sap4tech.net/idoc-invoic02-sap-invoice-idoc/ 8/8

You might also like