Sie sind auf Seite 1von 5

Idoc INVOIC02 Structure

SAP INVOICE IDoc Basic Type Structure


The main segments of INVOIC02 are:

E1EDK01 for IDoc: Document header general data


E1EDKA1 for IDoc: Document Header Partner Information
E1EDKT1 for IDoc: Document Header Text Identification
E1EDKT2 for IDoc: Document Header Texts Lines
E1EDK14 for IDoc: Document Header Organizational Data
E1EDP01 for IDoc: Document Item General Data
The full INVOIC02 Basic Type is:

The full documentation can be found here Inbound Processing of IDocs Received.

XML Schema for Invoice IDoc


This link contains the Idoc INVOIC02 XML Schema.
( For obvious security reason, I put the document in Zipped format).

User Exit and BADI for Idoc INVOIC02


User Exit for SAP Invoice Idoc
EXIT_SAPLVEDF_001 (ZXEDFU01)

This User Exit offers to make additionnal Control Data IDoc_Output_Invoice.


The parameters of this User Exist are:

1
2
3
4
5
6
7
8
9
1
0
1
1
1
2
1
3
1
4

*"*"Globale Schnittstelle:
*" IMPORTING
*"
VALUE(CONTROL_RECORD_OUT) LIKE EDIDC STRUCTURE EDIDC
*"
VALUE(DVBDKR) LIKE VBDKR STRUCTURE VBDKR OPTIONAL
*"
VALUE(DOBJECT) LIKE NAST STRUCTURE NAST OPTIONAL
*" EXPORTING
*"
VALUE(CONTROL_RECORD_OUT) LIKE EDIDC STRUCTURE EDIDC
*" TABLES
*"
DXVBPA STRUCTURE VBPA OPTIONAL
*"
DTVBDPR STRUCTURE VBDPR OPTIONAL
*" EXCEPTIONS
*"
ERROR_MESSAGE_RECEIVED
*"
DATA_NOT_RELEVANT_FOR_SENDING
*"----------------------------------------------------------------------

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 BY SEGMENT.
The following Code is an example of ABAP implementation of the user exit ZXEDFU02

1
2
3
4
5
6
7
8
9
1
0
1
1
1
2
1

DATA: ls_E1EDKA1 LIKE e1edka1,


ls_edidd LIKE edidd.
DATA: lv_index TYPE I.
READ TABLE int_edidd INTO ls_edidd index lv_index.
CHECK ls_edidd-segnam EQ 'E1EDKA1' AND
ls_edidd-sdata(2) EQ 'WE'.
ls_E1EDKA1-parvw = 'AG'.
ls_edidd-sdata = ls_E1EDKA1.
APPEND ls_edidd TO int_edidd.

BADI for SAP Invoice Idoc


SD_INVOICE_IDOC_OUTPUT_INT: Internal BADI for
IDOC output processing
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: Item Data
RBKP,Document Header: Invoice Receipt

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/pasten the activing ).
The main BAPI used to generate an outbound Idoc INVOIC02 for Invoice is the
BAPI IDOC_OUTPUT_INVOIC. 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.
2.

Generate EDIDD tables for INVOICES with IDOC_OUTPUT_INVOIC


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 AndCOMMIT WORK.
IDOC_OUTPUT_INVOIC
ABAP

1 DATA : ls_nast
2
ls_ctrl_in
3
ls_ctrl_out

TYPE nast,
TYPE edidc,
TYPE edidc.

4
5
6
7
8
9
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
3
1
3
2
3
3
3
4
3
5
3
6
3

DATA
DATA
DATA
DATA

:
:
:
:

lt_idoc_data
TYPE TABLE OF edidd.
ls_idoc_header
TYPE edidc.
lt_comm_idoc_control TYPE TABLE OF edidc.
lt_created_comm_idocs TYPE TABLE OF edidc.

CLEAR ls_nast.
ls_nast-mandt = sy-mandt.
ls_nast-objky = lv_invoicekey. " @Change with Invoice number
clear ls_ctrl_in.
ls_ctrl_in-IDOCTP = 'INVOIC02'.
ls_ctrl_in-MESTYP = 'INVOIC'. " @ You can put your extension
CLEAR lt_idoc_data[].
CALL FUNCTION 'IDOC_OUTPUT_INVOIC'
EXPORTING
object
= ls_nast
control_record_in
= ls_ctrl_in
IMPORTING
control_record_out
= ls_ctrl_out
* OBJECT_TYPE
=
TABLES
int_edidd
= lt_idoc_data[]
EXCEPTIONS
error_message_received
=1
data_not_relevant_for_sending = 2
OTHERS
= 3.
CLEAR lt_comm_idoc_control[].
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control
= ls_idoc_header
TABLES
communication_idoc_control
= lt_comm_idoc_control
master_idoc_data
= lt_idoc_data
EXCEPTIONS
error_in_idoc_control
= 01
error_writing_idoc_status
= 02
error_in_idoc_data
= 03
sending_logical_system_unknown = 04.
IF sy-subrc EQ 0.
CALL FUNCTION 'DB_COMMIT'.
COMMIT WORK.
ENDIF.

7
3
8
3
9
4
0
4
1
4
2
4
3
4
4
4
5
4
6
4
7
4
8
4
9

Das könnte Ihnen auch gefallen