You are on page 1of 27

How to add an user-defined segment to an IDoc

Description:

This document will show you how to create a new Segment and append it to a NEW IDoc type.

Scenario:

You have to transfer some custom data via IDoc ZPINVOICBE for Invoice. You need to implement the below
steps to achieve it:

1. Create a new Zsegment


2. Add segment for an Idoc type
3. Maintain Output Types and Assignment to IDoc Types in WE82
4. Maintain Partner Profile in WE20
5. Write the code in USER EXIT

1. Create a new Z-Segment (Tcode WE31)

MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
1
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
2
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
3
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
4
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
5
Then set it released by press F3, Go to Menu->Edit->Set Release

2. Copy Basic Type INVOIC02 (Tcode WE30) to ZPINVOICBE and add new segment

MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
6
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
7
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
8
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
9
3. Maintain Output Types and Assignment to IDoc Types in WE82 (Tcode WE82)

MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
10
WE81

MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
11
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
12
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
13
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
14
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
15
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
16
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
17
4.Maintain Partner Profile in WE20 (Tcode WE20)

MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
18
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
19
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
20
5.Write the code in USER EXIT LXEDFU01 User_Exit Control Data IDoc_Output_Invoic

MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
21
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
22
* P516 VAT Registration Number / VAT TEXT
CLEAR : LS_EDIDD, LV_STCEG_L, LV_LAND1, LS_ZE1EDK29.
READ TABLE CT_INT_EDIDD INTO LS_EDIDD WITH KEY SEGNAM = 'ZE1EDK29'.
IF SY-SUBRC NE 0.
READ TABLE CT_INT_EDIDD INTO LS_EDIDD WITH KEY SEGNAM = 'E1EDK01'.
CLEAR LS_E1EDK01.
LS_E1EDK01 = LS_EDIDD-SDATA.
SELECT SINGLE STCEG_L LAND1 FROM VBRK INTO (LV_STCEG_L, LV_LAND1)
WHERE VBELN = LS_E1EDK01-BELNR.
IF LV_STCEG_L = 'BE'.
LS_EDIDD-SEGNAM = 'ZE1EDK29'.
LS_ZE1EDK29-STCEG = TEXT-004.
CASE LV_LAND1.
WHEN 'LU'.
LS_ZE1EDK29-BEZEI100 = TEXT-001.
WHEN 'BE'.
LS_ZE1EDK29-BEZEI100 = TEXT-002.
WHEN OTHERS.
LS_ZE1EDK29-BEZEI100 = TEXT-003.
ENDCASE.
LS_EDIDD-SDATA = LS_ZE1EDK29.
APPEND LS_EDIDD TO CT_INT_EDIDD.
ENDIF.
ENDIF. Then we check the Zsegment is existing or not and Append or Insert corresponding.

MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
23
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
24
Finally, the values of Zsegment will come through into IDoc.

MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
25
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
26
MICKAEL QUESNOT🎯🇪🇺
Directeur BU SAP SCM & CONCUR
https://www.linkedin.com/in/mickaelquesnot/
27

You might also like