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: 

how to create idoc

Former Member
0 Kudos

how to create idoc?

what is idoc?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Anil,

IDOC is a intermediate document to exchange data between two SAP Systems.

IDOC types are templates for specific message types depending on what is the business document, you want to exchange.

WE30 - you can create a IDOC type.

An IDOC with data, will have to be triggered by the application that is trying to send out the data.

FOr testing you can use WE19.

Regards,

Ravi

5 REPLIES 5

Former Member
0 Kudos

Anil,

IDOC is a intermediate document to exchange data between two SAP Systems.

IDOC types are templates for specific message types depending on what is the business document, you want to exchange.

WE30 - you can create a IDOC type.

An IDOC with data, will have to be triggered by the application that is trying to send out the data.

FOr testing you can use WE19.

Regards,

Ravi

Former Member
0 Kudos

Hi Anil,

<b>**what is idoc?</b>

*IDocs are structured ASCII files (or a virtual equivalent).

*Electronic Interchange Document

*They are the file format used by SAP R/3 to exchange data with foreign systems.

*Data Is transmitted in ASCII format, i.e. human readable form

*IDocs exchange messages

*IDocs are used like classical interface files

<b>how to create idoc?</b>

*WE30 - you can create a IDOC type

For more information in details on the same along with the examples can be viewed on:

http://www.netweaverguru.com/EDI/HTML/IDocBook.htm#_Toc8400404

Hope this will help you.

If ur satisfied then please close this thread by rewarding appropraite points to the helpful answers.

Cheers

Sunny

Former Member
0 Kudos

Hai anil,

1.To Create Idoc we need to follow these steps:

Create Segment ( WE31)

Create Idoc Type ( WE30)

Create Message Type ( WE81)

Assign Idoc Type to Message Type ( WE82)

2.What is an IDoc

An IDoc is simply a data container that is used to exchange information between any two processes that can understand the syntax and semantics of the data.IDoc is not a process.

IDOCs are stored in the database. In the SAP system, IDOCs are stored in database tables.

IDOCs are independent of the sending and receiving systems.

IDOCs are independent of the direction of data exchange.

The two available process for IDOCs are

*Outbound Process

*Inbound Process

hope this might be helpful

regards,

praba.

Former Member
0 Kudos

Hi Anil,

This example tell u how to create an idoc.

FUNCTION·MASTER_IDOC_CREATE_XAMPLE.

*"----

-


*"

*"Local·interface:

*"·······IMPORTING

*"·············VALUE(APPL_HEADER)·LIKE·XHEAD·STRUCTURE··XHEAD

*"·······TABLES

*"··············APPL_ITEM·STRUCTURE··XITEM

*"----

-


*·variables·of·general·interest

··DATA:

*·······control·record·for·the·IDoc

········IDOC_CONTROL·LIKE·EDIDC,

*·······data·records·for·the·IDoc

········T_IDOC_DATA·LIKE·EDIDD·OCCURS·0·WITH·HEADER·LINE,

*·······table·for·the·IDocs·created·by·MASTER_IDOC_CONTROL

········T_COMM_CONTROL·LIKE·EDIDC·OCCURS·0·WITH·HEADER·LINE,

*·······partner·type·for·logical·system

········C_PARTNER_TYPE_LOGICAL_SYSTEM·LIKE·EDIDC-RCVPRT,

*·······help·variable·for·the·check·if·an·IDoc·has·to·be·created

········H_CREATE_IDOC.

*·variables·specific·for·this·example

··DATA:

*·······field·strings·with·IDoc·segment·structure

········E1XHEAD·LIKE·E1XHEAD,

········E1XITEM·LIKE·E1XITEM,

*·······data·to·be·put·to·the·control·record

········C_MESSAGE_TYPE·LIKE·EDIDC-MESTYP·VALUE·'XAMPLE',

········C_BASE_IDOC_TYPE·LIKE·EDIDC-IDOCTP·VALUE·'XAMPLE01',

*·······segment·types·to·be·put·to·the·data·record·table

········C_HEADER_SEGTYP·LIKE·EDIDD-SEGNAM·VALUE·'E1XHEAD',

········C_ITEM_SEGTYP·LIKE·EDIDD-SEGNAM·VALUE·'E1XITEM'.

*·check·if·an·IDoc·has·to·be·created,·read·the·distribution·model

··CALL·FUNCTION·'ALE_MODEL_DETERMINE_IF_TO_SEND'

·······EXPORTING

············MESSAGE_TYPE···········=·C_MESSAGE_TYPE

*·········SENDING_SYSTEM·········=·'·'

*·········RECEIVING_SYSTEM·······=·'·'

*·········VALIDDATE··············=·SY-DATUM

·······IMPORTING

············IDOC_MUST_BE_SENT······=·H_CREATE_IDOC.

*····exceptions

*·········own_system_not_defined·=·1

*·········others·················=·2.

··IF·H_CREATE_IDOC·IS·INITIAL.

*···no·message·flow·maintained·in·the·model,·nothing·to·do

····EXIT.

··ENDIF.

*·put·the·application·header·record·to·the·IDoc

··MOVE-CORRESPONDING·APPL_HEADER·TO·E1XHEAD.

*·convert·SAP·codes·to·ISO·codes

··PERFORM·E1XHEAD_CODES_SAP_TO_ISO

····USING

······APPL_HEADER

····CHANGING

······E1XHEAD.

*·append·record·to·IDoc·data·table

··T_IDOC_DATA-SEGNAM·=·C_HEADER_SEGTYP.

··T_IDOC_DATA-SDATA·=·E1XHEAD.

··APPEND·T_IDOC_DATA.

··LOOP·AT·APPL_ITEM.

*···put·the·application·item·record·to·the·IDoc·segment

····MOVE-CORRESPONDING·APPL_ITEM·TO·E1XITEM.

*···convert·currency·amounts·from·SAP·internal·to·neutral·format

····PERFORM·E1XITEM_CURRENCY_SAP_TO_IDOC

······USING

········APPL_HEADER-CURRENCY

······CHANGING

········E1XITEM.

*···convert·SAP·codes·to·ISO·codes

····PERFORM·E1XITEM_CODES_SAP_TO_ISO

······USING

········APPL_ITEM

······CHANGING

········E1XITEM.

*···left·justify·all·non·character·fields

····PERFORM·E1XITEM_CONDENSE

······CHANGING

········E1XITEM.

*···append·record·to·IDoc·data·table

····T_IDOC_DATA-SEGNAM·=·C_ITEM_SEGTYP.

····T_IDOC_DATA-SDATA·=·E1XITEM.

····APPEND·T_IDOC_DATA.

··ENDLOOP.

··CALL·FUNCTION·'MASTER_IDOC_DISTRIBUTE'

*·in·update·task···"if·application·document·is·posted·in·update·task

·······EXPORTING

············MASTER_IDOC_CONTROL············=·IDOC_CONTROL

·······TABLES

············COMMUNICATION_IDOC_CONTROL·····=·T_COMM_CONTROL

············MASTER_IDOC_DATA···············=·T_IDOC_DATA.

*······exceptions

*···········error_in_idoc_control··········=·1

*···········error_writing_idoc_status······=·2

*···········error_in_idoc_data·············=·3

*···········sending_logical_system_unknown·=·4

*···········others·························=·5.

*·A·commit·work·has·to·be·done.·It·could·also·be·done·in·the·calling

*·application.

··COMMIT·WORK.

··READ·TABLE·T_COMM_CONTROL·INDEX·1.

··IF·SY-SUBRC·<>·0.

*·no·IDoc·was·created,·you·can·react·here,·if·neccessary

··ENDIF.

ENDFUNCTION.

*&----


*

*&······Form··E1XITEM_CONDENSE

*&----


*

·······text···························································

*----


*

*··-->··p1········text

*··<--··p2········text

*----


*

FORM·E1XITEM_CONDENSE

··CHANGING

····IDOC_SEGMENT·LIKE·E1XITEM.

*·left·justify·all·non·character·fields

··CONDENSE:·IDOC_SEGMENT-QUANTITY,

············IDOC_SEGMENT-VALUE.

ENDFORM.·······························"·E1XITEM_CONDENSE

*&----


*

*&······Form··E1XITEM_CURRENCY_SAP_TO_IDOC

*&----


*

·······text···························································

*----


*

*··-->··p1········text

*··<--··p2········text

*----


*

FORM·E1XITEM_CURRENCY_SAP_TO_IDOC

··USING

····CURRENCY_CODE·LIKE·TCURC-WAERS

··CHANGING

····IDOC_SEGMENT·LIKE·E1XITEM.

··CALL·FUNCTION·'CURRENCY_AMOUNT_SAP_TO_IDOC'

·······EXPORTING

············CURRENCY····=·CURRENCY_CODE

············SAP_AMOUNT··=·IDOC_SEGMENT-VALUE

·······IMPORTING

············IDOC_AMOUNT·=·IDOC_SEGMENT-VALUE.

*······exceptions

*···········others······=·1.

ENDFORM.·······························"·E1XITEM_CURRENCY_SAP_TO_IDOC

*&----


*

*&······Form··E1XHEAD_CODES_SAP_TO_ISO

*&----


*

·······text···························································

*----


*

*··-->··p1········text

*··<--··p2········text

*----


*

FORM·E1XHEAD_CODES_SAP_TO_ISO

··USING

····APPL_DATA·LIKE·XHEAD

··CHANGING

····IDOC_SEGMENT·LIKE·E1XHEAD.

*·convert·a·currency·code·from·SAP·code·to·ISO·code

··IF·NOT·APPL_DATA-CURRENCY·IS·INITIAL.

····CALL·FUNCTION·'CURRENCY_CODE_SAP_TO_ISO'

·········EXPORTING

··············SAP_CODE·=·APPL_DATA-CURRENCY

·········IMPORTING

··············ISO_CODE·=·IDOC_SEGMENT-CURRENCY.

*······exceptions

*···········not_found·=·1

*···········others····=·2.

··ELSE.

····IDOC_SEGMENT-CURRENCY·=·APPL_DATA-CURRENCY.

··ENDIF.

*·convert·a·country·from·SAP·code·to·ISO·code

··IF·NOT·APPL_DATA-COUNTRY·IS·INITIAL.

····CALL·FUNCTION·'COUNTRY_CODE_SAP_TO_ISO'

·········EXPORTING

··············SAP_CODE·=·APPL_DATA-COUNTRY

·········IMPORTING

··············ISO_CODE·=·IDOC_SEGMENT-COUNTRY.

*······exceptions

*···········not_found·=·1

*···········others····=·2.

··ELSE.

····IDOC_SEGMENT-COUNTRY·=·APPL_DATA-COUNTRY.

··ENDIF.

ENDFORM.·······························"·E1XHEAD_CODES_SAP_TO_ISO

*&----


*

*&······Form··E1XITEM_CODES_SAP_TO_ISO

*&----


*

·······text···························································

*----


*

*··-->··p1········text

*··<--··p2········text

*----


*

FORM·E1XITEM_CODES_SAP_TO_ISO

··USING

····APPL_DATA·LIKE·XITEM

··CHANGING

····IDOC_SEGMENT·LIKE·E1XITEM.

*·convert·a·unit·of·measure·from·SAP·code·to·ISO·code

··IF·NOT·APPL_DATA-UNIT·IS·INITIAL.

····CALL·FUNCTION·'UNIT_OF_MEASURE_SAP_TO_ISO'

·········EXPORTING

··············SAP_CODE·=·APPL_DATA-UNIT

·········IMPORTING

··············ISO_CODE·=·IDOC_SEGMENT-UNIT.

*······exceptions

*···········not_found···=·1

*···········no_iso_code·=·2

*···········others······=·3.

··ELSE.

····IDOC_SEGMENT-UNIT·=·APPL_DATA-UNIT.

··ENDIF.

*·convert·a·package·type·from·SAP·code·to·ISO·code

··IF·NOT·APPL_DATA-SHIP_INST·IS·INITIAL.

····CALL·FUNCTION·'SAP_TO_ISO_PACKAGE_TYPE_CODE'

·········EXPORTING

··············SAP_CODE·=·APPL_DATA-SHIP_INST

·········IMPORTING

··············ISO_CODE·=·IDOC_SEGMENT-SHIP_INST.

*······exceptions

*···········not_found·=·1

*···········others····=·2.

··ELSE.

····IDOC_SEGMENT-SHIP_INST·=·APPL_DATA-SHIP_INST.

··ENDIF.

ENDFORM.·······························"·E1XITEM_CODES_SAP_TO_ISO

http://help.sap.com/saphelp_nw04/helpdata/en/0b/2a6cdd507d11d18ee90000e8366fc2/plain.htm

reward points if it helps.

with regards,

Manikandan R