Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

IDoc Extension Creation

Former Member
0 Kudos

Hi,

Can somebody please give me the answer for the following questions?

1.How do we extend IDocs? (Ex: SHPMNT04)

2. What code needs to be inserted in the IDoc function module?

3. How do we configure the Segments when additional fields are to be added?

Please provide the detailed procedure with step by step examples and T-Codes.

Thanks,

John.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi John,

Go through this info.

Enhancement of IDoc Type

Usually enhancement takes place when the content in IDocs provided by SAP are not sufficient for the business process. IDoc extension can take place whenever dictionary table has a new structure appended required by the business process.

In brief IDoc extension takes place when extra fields are required for the business process.

Let us take a scenario and understand the process of IDoc extension.

In this scenario say visitor is different from the actual customer who has came to the sales office in behalf of the customer to obtain the quotation or inquiry etc. Or an authorized agent qualified by the actual customer to order for items. So a field by name NAMEVI (Visitor) is added to Customer master data. As there is no provision given by SAP to handle this, we need to extend an IDoc.

The standard message type and IDoc type provided by SAP are DEBMAS and DEBMAS05.

Consider the data in the table below for extending the IDoc. These details can be understood in different sections in the process of extending it.

Basic IDoc type DEBMAS05

Version 4.7

IDoc extension DEBMASEXT

Custom segment Z1KNA1

Fields in Custom Segment Visitor

Parent of Custom Segment E1KNA11

Outbound process

Step1. Customize kna1 table by appending a structure provided by SAP (ZAKNA1)

Component Component Type

VISITOR NAMEVI

Step2: Write a module pool program to update some existing customers to add data for Visitor.

Step3: Create a custom segment

Transaction Code: WE31

Segment type: Z1KNA11 Click (create). Provide short text

Field Name Data element

VISITOR NAMEVI

Save

Step4: Create IDoc extension

Transaction WE30

Object Name DEBMASEXT

Choose Extension

Click and it leads to next screen.

Linked basic type: DEBMAS05

Provide description and enter

Observe all the segments to be copied into your IDoc extension from linked basic

type.

Select E1KNA11 and click (create segment) to obtain a popup window

Provide the required values and observe child segment Z1KNA11 to be added to

parent segment E1KNA11.

Step5: Release segment and IDoc extension

Transaction: WE31

Segment type: Z1KNA11

Path: Edit à Set release

Step6: Assign Basic type to extension / messages

Transaction: WE82

Click , then

Select DEBMAS message type against DEBMAS06 basic type

Click provide the information

Message Type Basic Type Extension Version

DEBMAS DEBMAS06 DEBMASEXT 4.7

Delete the earlier one from which it was copied.

Save.

Observe the result as follows

Step 7: Check and Transport IDoc extension

Transaction: WE30

Object name: DEBMASEXT

Path: Development object à Check

Ensure that there are no errors or warnings

Now transport

Path: Development à Transport

Step8: Find suitable user exit for writing code to support IDoc extension

Transaction: SE84.

Click Enhancements

In short text provide customer

Find suitable enhancement to be VSV00001

Alternative way

Transaction: SMOD

Click F4 help for Enhancement

Path: F4help à SAP Applications à Logistics general à Logistics Basic Data à

Business partners à Vendor Master.

Find the enhancement as VSV00002, which is an approximate user exit.

Now search for different extensions like VSV00001. Then see for its components.

Identify the appropriate user exit to be ‘EXIT_SAPLVV01_001’ (Create Export of

Additional Customer Master Segments). This user exit can be used in outbound ALE

process, meant for filling the data into custom segments.

You have to identify here another user exit as ‘EXIT_SAPLVV02_001’, which is

helpful for inbound ALE process. This user exit can be used to read the segments

and post it to Application repository.

Step9: Develop a project to encapsulate enhancements and components.

Transaction: CMOD.

Enhancement: custex and click Create to provide attributes.

Click Enhancement Assignments.

Provide VSV00001, short text and save.

From the initial screen of the transaction, select components and click change.

Find 4 components to be added.

Activate them.

Select user exit EXIT_SAPLVV01_001 for outbound process and double click it. It leads to function builder.

Double click on provided include program ZXVSVU01 and press enter.

Now, write supporting code for IDoc extension, i.e., populating custom segments in IDoc.

Check the code and activate.

Code in ZXVSVU01

*&----


*& Include ZXVSVU01 *

*&----


*In this scenario, the E1KNA11 has been extended to accommodate

*User-defined fields in the customer table kna1. The name of the

*extended

*segment is z1kna11. There is one custom field: visitor

*&----


*Data declarations

DATA: kna1m like e1kna1m,

kna11 like e1kna11,

z1kna11 like z1kna11,

w_kna1 like kna1.

  • make sure you are processing correct message type

check message_type eq 'DEBMAS'.

  • make sure data is added after the correct segment

check segment_name eq 'E1KNA1M'.

  • since customer number is not passed in this user exit, you need to go

  • through the data records to find the customer number

loop at idoc_data.

case idoc_data-segnam.

when 'E1KNA1M'.

move idoc_data-sdata to kna1m.

when 'E1KNA11'.

move idoc_data-sdata to kna11.

endcase. " case idoc_data-segname.

endloop. " loop at idoc_data.

  • select data from the user-defined fields in kna11.

select single *

from kna1 " Customer master table

into w_kna1

where kunnr = kna1m-kunnr.

if sy-subrc eq 0.

  • set the idoc extension name for control record

idoc_cimtype = 'DEBMASEX'.

  • clear custom fields from kna1 to extended segment

clear z1kna11.

  • copy custom fields from kna1 to extended segment

move-corresponding w_kna1 to z1kna11. " field name must be same

  • condense all fields of extended segment

condense: z1kna11-visitor.

  • populate segment name in the data record, copy data contents into it

  • and append the data record to existing data records in

move 'Z1KNA11' TO IDOC_data-segnam. " administrative section

move z1kna11 to idoc_data-sdata. " data section

append idoc_data.

endif. " if sy-subrc eq 0.

Step 10:

Define Logical System

Assign client to Logical System

Maintain RFC Destination

Maintain Customer Distribution Model

Generate Partner Profiles

Distribute Customer Distribution Model

INBOUND PROCESS

Step 11: Append the custom structure to the table KNA1 similar to the process done

in outbound process.

Step 12.

Define Logical System

Assign client to Logical System

Generate Partner Profiles

Step 13. Execute the transaction to ‘Send Customers’ from Outbound system.

Step 14. Now in the Inbound system, create the project in the similar way as done at

outbound side.

In the user exit EXIT_SAPLVV02_001, find include ‘ZXVSVU02’. Write the code to

support IDoc extension.

Code in ZXVSVU02

*&----


*& Include ZXVSVU02 *

*&----


data: kna1m like e1kna1m,

kna11 like e1kna11,

z1kna11 like z1kna11.

data fs_kna1 type kna1.

message i000(0) with 'INBOUND PROCESS CALLED'.

LOOP AT IDOC_data.

case idoc_data-segnam.

when 'E1KNA1M'.

kna1m = idoc_data-sdata.

when 'E1KNA11'.

kna11 = idoc_data-sdata.

when 'Z1KNA11'.

z1kna11 = idoc_data-sdata.

select single *

from kna1

into fs_kna1

where kunnr = kna1m-kunnr.

if sy-subrc eq 0.

update kna1

set visitor = z1kna11-visitor

where kunnr = kna1m-kunnr.

else.

idoc_status-docnum = idoc_control-docnum.

idoc_status-status = '51'.

idoc_status-msgty = 'E'.

idoc_status-msgid = 'ZE'.

idoc_status-msgno = '005'.

idoc_status-msgv1 = kna1m-kunnr.

append idoc_status.

endif. " if sy-subrc eq 0.

endcase. " case idoc_data-segnam.

endloop. " LOOP AT IDOC_data.

Step 15. Assign FM to extension/Message type

Transaction: WE57

Path: Change à New Entries

Select ‘IDOC_INPUT_DEBITOR’ against DEBMAS06 basic type, to fill extra

information as shown below.

Function Module Basic Type Message Type Extension

IDOC_INPUT_DEBITOR DEBMAS06 DEBMAS DEBMASEXT

Step 16. Execute the transaction to ‘Get Customers’.

And observe that records with extra data are saved in database.

Rewords some points .

rgds,

P.Naganjana Reddy

5 REPLIES 5

Former Member
0 Kudos

Hi John,

Go through this info.

Enhancement of IDoc Type

Usually enhancement takes place when the content in IDocs provided by SAP are not sufficient for the business process. IDoc extension can take place whenever dictionary table has a new structure appended required by the business process.

In brief IDoc extension takes place when extra fields are required for the business process.

Let us take a scenario and understand the process of IDoc extension.

In this scenario say visitor is different from the actual customer who has came to the sales office in behalf of the customer to obtain the quotation or inquiry etc. Or an authorized agent qualified by the actual customer to order for items. So a field by name NAMEVI (Visitor) is added to Customer master data. As there is no provision given by SAP to handle this, we need to extend an IDoc.

The standard message type and IDoc type provided by SAP are DEBMAS and DEBMAS05.

Consider the data in the table below for extending the IDoc. These details can be understood in different sections in the process of extending it.

Basic IDoc type DEBMAS05

Version 4.7

IDoc extension DEBMASEXT

Custom segment Z1KNA1

Fields in Custom Segment Visitor

Parent of Custom Segment E1KNA11

Outbound process

Step1. Customize kna1 table by appending a structure provided by SAP (ZAKNA1)

Component Component Type

VISITOR NAMEVI

Step2: Write a module pool program to update some existing customers to add data for Visitor.

Step3: Create a custom segment

Transaction Code: WE31

Segment type: Z1KNA11 Click (create). Provide short text

Field Name Data element

VISITOR NAMEVI

Save

Step4: Create IDoc extension

Transaction WE30

Object Name DEBMASEXT

Choose Extension

Click and it leads to next screen.

Linked basic type: DEBMAS05

Provide description and enter

Observe all the segments to be copied into your IDoc extension from linked basic

type.

Select E1KNA11 and click (create segment) to obtain a popup window

Provide the required values and observe child segment Z1KNA11 to be added to

parent segment E1KNA11.

Step5: Release segment and IDoc extension

Transaction: WE31

Segment type: Z1KNA11

Path: Edit à Set release

Step6: Assign Basic type to extension / messages

Transaction: WE82

Click , then

Select DEBMAS message type against DEBMAS06 basic type

Click provide the information

Message Type Basic Type Extension Version

DEBMAS DEBMAS06 DEBMASEXT 4.7

Delete the earlier one from which it was copied.

Save.

Observe the result as follows

Step 7: Check and Transport IDoc extension

Transaction: WE30

Object name: DEBMASEXT

Path: Development object à Check

Ensure that there are no errors or warnings

Now transport

Path: Development à Transport

Step8: Find suitable user exit for writing code to support IDoc extension

Transaction: SE84.

Click Enhancements

In short text provide customer

Find suitable enhancement to be VSV00001

Alternative way

Transaction: SMOD

Click F4 help for Enhancement

Path: F4help à SAP Applications à Logistics general à Logistics Basic Data à

Business partners à Vendor Master.

Find the enhancement as VSV00002, which is an approximate user exit.

Now search for different extensions like VSV00001. Then see for its components.

Identify the appropriate user exit to be ‘EXIT_SAPLVV01_001’ (Create Export of

Additional Customer Master Segments). This user exit can be used in outbound ALE

process, meant for filling the data into custom segments.

You have to identify here another user exit as ‘EXIT_SAPLVV02_001’, which is

helpful for inbound ALE process. This user exit can be used to read the segments

and post it to Application repository.

Step9: Develop a project to encapsulate enhancements and components.

Transaction: CMOD.

Enhancement: custex and click Create to provide attributes.

Click Enhancement Assignments.

Provide VSV00001, short text and save.

From the initial screen of the transaction, select components and click change.

Find 4 components to be added.

Activate them.

Select user exit EXIT_SAPLVV01_001 for outbound process and double click it. It leads to function builder.

Double click on provided include program ZXVSVU01 and press enter.

Now, write supporting code for IDoc extension, i.e., populating custom segments in IDoc.

Check the code and activate.

Code in ZXVSVU01

*&----


*& Include ZXVSVU01 *

*&----


*In this scenario, the E1KNA11 has been extended to accommodate

*User-defined fields in the customer table kna1. The name of the

*extended

*segment is z1kna11. There is one custom field: visitor

*&----


*Data declarations

DATA: kna1m like e1kna1m,

kna11 like e1kna11,

z1kna11 like z1kna11,

w_kna1 like kna1.

  • make sure you are processing correct message type

check message_type eq 'DEBMAS'.

  • make sure data is added after the correct segment

check segment_name eq 'E1KNA1M'.

  • since customer number is not passed in this user exit, you need to go

  • through the data records to find the customer number

loop at idoc_data.

case idoc_data-segnam.

when 'E1KNA1M'.

move idoc_data-sdata to kna1m.

when 'E1KNA11'.

move idoc_data-sdata to kna11.

endcase. " case idoc_data-segname.

endloop. " loop at idoc_data.

  • select data from the user-defined fields in kna11.

select single *

from kna1 " Customer master table

into w_kna1

where kunnr = kna1m-kunnr.

if sy-subrc eq 0.

  • set the idoc extension name for control record

idoc_cimtype = 'DEBMASEX'.

  • clear custom fields from kna1 to extended segment

clear z1kna11.

  • copy custom fields from kna1 to extended segment

move-corresponding w_kna1 to z1kna11. " field name must be same

  • condense all fields of extended segment

condense: z1kna11-visitor.

  • populate segment name in the data record, copy data contents into it

  • and append the data record to existing data records in

move 'Z1KNA11' TO IDOC_data-segnam. " administrative section

move z1kna11 to idoc_data-sdata. " data section

append idoc_data.

endif. " if sy-subrc eq 0.

Step 10:

Define Logical System

Assign client to Logical System

Maintain RFC Destination

Maintain Customer Distribution Model

Generate Partner Profiles

Distribute Customer Distribution Model

INBOUND PROCESS

Step 11: Append the custom structure to the table KNA1 similar to the process done

in outbound process.

Step 12.

Define Logical System

Assign client to Logical System

Generate Partner Profiles

Step 13. Execute the transaction to ‘Send Customers’ from Outbound system.

Step 14. Now in the Inbound system, create the project in the similar way as done at

outbound side.

In the user exit EXIT_SAPLVV02_001, find include ‘ZXVSVU02’. Write the code to

support IDoc extension.

Code in ZXVSVU02

*&----


*& Include ZXVSVU02 *

*&----


data: kna1m like e1kna1m,

kna11 like e1kna11,

z1kna11 like z1kna11.

data fs_kna1 type kna1.

message i000(0) with 'INBOUND PROCESS CALLED'.

LOOP AT IDOC_data.

case idoc_data-segnam.

when 'E1KNA1M'.

kna1m = idoc_data-sdata.

when 'E1KNA11'.

kna11 = idoc_data-sdata.

when 'Z1KNA11'.

z1kna11 = idoc_data-sdata.

select single *

from kna1

into fs_kna1

where kunnr = kna1m-kunnr.

if sy-subrc eq 0.

update kna1

set visitor = z1kna11-visitor

where kunnr = kna1m-kunnr.

else.

idoc_status-docnum = idoc_control-docnum.

idoc_status-status = '51'.

idoc_status-msgty = 'E'.

idoc_status-msgid = 'ZE'.

idoc_status-msgno = '005'.

idoc_status-msgv1 = kna1m-kunnr.

append idoc_status.

endif. " if sy-subrc eq 0.

endcase. " case idoc_data-segnam.

endloop. " LOOP AT IDOC_data.

Step 15. Assign FM to extension/Message type

Transaction: WE57

Path: Change à New Entries

Select ‘IDOC_INPUT_DEBITOR’ against DEBMAS06 basic type, to fill extra

information as shown below.

Function Module Basic Type Message Type Extension

IDOC_INPUT_DEBITOR DEBMAS06 DEBMAS DEBMASEXT

Step 16. Execute the transaction to ‘Get Customers’.

And observe that records with extra data are saved in database.

Rewords some points .

rgds,

P.Naganjana Reddy

0 Kudos

Hi,

That was a great answer. That almost solved my problem. But, Could you please let me know if the same procedure can be followed for an Outbound IDoc? or is there any other procedure?

Thanks,

John.

Former Member
0 Kudos

Hi John,

This is for posting program.

FUNCTION zidoc_input_btmatmas.

*"----


""Local interface:

*" IMPORTING

*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD

*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC

*" VALUE(NO_APPLICATION_LOG) LIKE SY-DATAR OPTIONAL

*" VALUE(MASSSAVEINFOS) LIKE MASSSAVINF STRUCTURE MASSSAVINF

*" OPTIONAL

*" EXPORTING

*" VALUE(WORKFLOW_RESULT) LIKE BDWF_PARAM-RESULT

*" VALUE(APPLICATION_VARIABLE) LIKE BDWF_PARAM-APPL_VAR

*" VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK

*" VALUE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS

*" TABLES

*" IDOC_CONTRL STRUCTURE EDIDC

*" IDOC_DATA STRUCTURE EDIDD

*" IDOC_STATUS STRUCTURE BDIDOCSTAT

*" RETURN_VARIABLES STRUCTURE BDWFRETVAR

*" SERIALIZATION_INFO STRUCTURE BDI_SER

*" EXCEPTIONS

*" WRONG_FUNCTION_CALLED

*"----


DATA:wa_mara TYPE z1marm,

wa_makt TYPE e1maktm.

DATA: st_mara TYPE mara,

st_makt TYPE makt.

LOOP AT idoc_contrl.

LOOP AT idoc_data WHERE docnum = idoc_contrl-docnum.

CASE idoc_data-segnam.

WHEN 'Z1MARM'.

wa_mara = idoc_data-sdata.

MOVE-CORRESPONDING wa_mara TO st_mara.

INSERT mara FROM st_mara.

IF sy-subrc = 0.

COMMIT WORK.

ENDIF.

WHEN 'E1MAKTM'.

wa_makt = idoc_data-sdata.

MOVE-CORRESPONDING wa_makt TO st_makt.

INSERT makt FROM st_makt.

IF sy-subrc = 0.

COMMIT WORK.

ENDIF.

ENDCASE.

ENDLOOP.

ENDLOOP.

IF sy-subrc = 0.

return_variables-wf_param = 'Processed IDOCs'.

return_variables-doc_number = idoc_contrl-docnum.

return_variables-wf_param = 'Appl_objects'.

  • return_variables-doc_number = fs_app_empdet-ssn.

APPEND return_variables.

idoc_status-docnum = idoc_contrl-docnum.

idoc_status-status = 53.

idoc_status-msgty = 'I'.

idoc_status-msgid = 'ZE'.

idoc_status-msgno = '006'.

APPEND idoc_status.

ENDIF.

ENDFUNCTION.

Rewords some points.

Rgds,

P.Naganjana Reddy

0 Kudos

Hi,

Thats great. But I wanted to know the Outbound Idoc Extension Code. Please revert back asap.

Thanks,

John.

Former Member
0 Kudos

Hi John ,

Good morning,

Extension means in we82 u will proivde the basic type and idoctype there only the extension and the release options are there.

You giving the extension name what ur giving the name that name u have to replace it in basic type.

Rewords some points.

Rgds,

P.Naganjana Reddy