Skip to Content
Product Information
Author's profile photo Quesnot Mickaël

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)

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

3. Maintain Output Types and Assignment to IDoc Types in WE82 (Tcode WE82)
WE81

We82

4.Maintain Partner Profile in WE20 (Tcode WE20)

5.Write the code in USER EXIT LXEDFU01 User_Exit Control Data IDoc_Output_Invoic

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.

TEST
VF02

VF31

Finally, the values of Zsegment will come through into IDoc.
WE05

BD87

 

 

 

 

 

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Dominik Tylczynski
      Dominik Tylczynski

      That is a really interesting topic but such a lousy piece of writing:

      1. You don't copy a basic IDoc type to a Z-type to add a custom segment. Instead you create an IDoc enhancement. You could have explained the concept.
      2. You missed assignment of ALE message type to the IDoc enhancement.
      3. The source code is not formatted or explained. Literals are used in the code without explanation what they are and how they relate to IDoc enhancement. Text ids are used without providing their content.
      4. Screenshots are not readable and not aligned with the text. They are just dumped at the end of the article.

      What value does this article add?

      Author's profile photo Mickael QUESNOT
      Mickael QUESNOT

      Screenshots readable  here https://www.linkedin.com/feed/update/urn:li:activity:7070164968733618176/