11

How to add an user-defined segment to an IDoc

 1 year ago
source link: https://blogs.sap.com/2023/06/05/how-to-add-an-user-defined-segment-to-an-idoc-2/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
June 5, 2023 2 minute read

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

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

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

IDOC_page-0001-scaled.jpg
IDOC_page-0002-scaled.jpg
IDOC_page-0003-scaled.jpg
IDOC_page-0004-scaled.jpg
IDOC_page-0005-scaled.jpg
IDOC_page-0006-scaled.jpg
IDOC_page-0007-scaled.jpg
IDOC_page-0008-scaled.jpg
IDOC_page-0009-scaled.jpg

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK