04-18-2008 12:42 PM
Hi everybody,
I want some configuration details regardign IDOC creation. The requirement is, once i create a purchase order in one system, the details should automatciaclly transfer to other system through IDOC. could any one suggest any document or detailed procedure to accomplish the task. Thanks in advance,
Santosh.
04-18-2008 6:27 PM
hi santosh kumar,
Creating an IDoc Segment WE31:
The segment defines the structure of the records in an IDoc. They are defined with transaction WE31.
We will define a structure to send a text from the text database.
Transaction WE31 calls the IDoc segment editor. The editor defines the fields of a
single segment structure. The thus defined IDoc segment is then created as a data
dictionary structure. You can view the created structure with SE11 and use it in an
ABAP as any TABLES declaration.
To demonstrate the use of the IDoc segment editor we will set up an example, which
allows you to send a single text from the text pool (tables STXH and STXL) as an
IDoc. These are the texts that you can see with SO10 or edit from within many
applications.
We will show the steps to define an IDoc segment YAXX_THEAD with the DDic
structure of THEAD.
To facilitate our work, we will use the "copy-from-template-tool", which reads the
definition of a DDIC structure and inserts the field and the matching definitions as
rows in the IDoc editor. You could, of course, define the structure completely
manually, but using the template makes it easier.
The tool in release 4.0b lets you use both DDIC structures or another IDoc segment
definition as a template.
The thus created structure can be edited any time. When saving, it will create a data
dictionary structure based on the definition in WE31. The DDIC structure will retain
the same name. You can view the structure as a table definition with SE11 and use it
in an ABAP the same way.
Defining the Message Type (EDMSG)
The message type defines the context under which an IDoc is transferred to its destination. It allows for using the same IDoc file format for several different applications.
Imagine the situation of sending a purchase order to a supplier. When the IDoc with
the purchase order reaches the supplier, it will be interpreted as a sales order
received from a customer, namely you.
Simultaneously you want to send the IDoc data to the supplier's warehouse to inform
it that a purchase order has been issued and is on the way.
Both IDoc receivers will receive the same IDoc format; however, the IDoc will be
tagged with a different message type. While the IDoc to the supplier will be flagged
as a purchase order (in SAP R/3 standard: message type = ORDERS), the same IDoc
sent to the warehouse should be flagged differently, so that the warehouse can
recognize the order as a mere informational copy and process it differently than a
true purchase order.
The message type together with the IDoc type determine the processing function.
The message types are stored in table EDMSG.
Defining the message type can be done from the transaction WEDI
EDMSG: Defining the message type (1)
The entry is only a base entry which tells the system that the message type is
allowed. Other transactions will use that table as a check table to validate the entry.
IT is as shown .
EDMSG: Defining the message type (1):
The entry is only a base entry which tells the system that the message type is
allowed. Other transactions will use that table as a check table to validate the entry.
Sales Orders are being created through inbound IDocs using FM 'EDI_DATA_INCOMING'. Now a Report is required to check the status of these Inbound IDocs along with Sales Orders generated against customer Purchase Orders.
Requirement:
Sales Orders are being created through inbound IDocs using FM 'EDI_DATA_INCOMING'. Now a Report is required to check the status of these Inbound IDocs along with Sales Orders generated against customer Purchase Orders.
-
Processing:
The report selects, 'ORDERS' IDoc numbers & status, generated between given time range, from table EDIDC. Further, it calls Function Module 'IDOC_READ_COMPLETELY' to get the IDoc details. Then required information is extracted by reading relevant field data of IDoc segments.
-
sampl code:
REPORT Z_EDI_FILE_LOAD_STATUS_REPORT .
*----
Staus Report for Inbound IDOCs ( Sales Orders )
*----
Program : Z_EDI_FILE_LOAD_STATUS_REPORT
Presented By : www.rmtiwari.com
*----
TABLES : EDIDC.
*----
ALV stuff
TYPE-POOLS: SLIS.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA : BEGIN OF T_REPORT OCCURS 0,
IDOC_NO TYPE EDI_DOCNUM,
IDOC_DATE TYPE SY-DATUM,
IDOC_TIME TYPE SY-UZEIT,
SORDER_NO TYPE VBELN,
STP_NO TYPE KNA1-KUNNR,
STP_NAME(35) TYPE C,
STP_PHONE(12) TYPE C,
PO_NO(15) TYPE C,
STATUS TYPE C,
S_TEXT(70) TYPE C,
ERROR(70) TYPE C,
END OF T_REPORT.
--
selection-screen begin of block date with frame title TEXT-S01.
select-options: UDATE for EDIDC-UPDDAT
default SY-datum obligatory, "Changed On
UTIME for EDIDC-UPDTIM . "Changed Time
selection-screen end of block date.
----
INITIALIZATION.
START-OF-SELECTION.
PERFORM SHOW_STATUS_REPORT.
&----
*& Form alv_grid
&----
text
----
--> p1 text
< -- p2 text
----
FORM ALV_GRID.
IF GT_FIELDCAT[] IS INITIAL.
PERFORM FIELDCAT_INIT.
PERFORM LAYOUT_INIT.
PERFORM SORT_INIT.
ENDIF.
PERFORM GRID_DISPLAY.
ENDFORM. "alv_grid
&----
*& Form layout_init
&----
FORM LAYOUT_INIT.
GS_LAYOUT-ZEBRA = 'X'.
GS_LAYOUT-CELL_MERGE = 'X'.
GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GS_LAYOUT-NO_VLINE = ' '.
GS_LAYOUT-TOTALS_BEFORE_ITEMS = ' '.
ENDFORM. " layout_init
&----
*& Form fieldcat_init
&----
FORM FIELDCAT_INIT.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'IDOC_NO'.
LS_FIELDCAT-KEY = 'X'.
LS_FIELDCAT-REPTEXT_DDIC = 'IDOC'.
LS_FIELDCAT-OUTPUTLEN = 10.
Fix for ALV print bug, which puts 'N/A' over last digit
Set inttype to 'N' to stop corruption of printed ALV cell.
LS_FIELDCAT-INTTYPE = 'N'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'IDOC_DATE'.
LS_FIELDCAT-REPTEXT_DDIC = 'Creation Date'.
LS_FIELDCAT-OUTPUTLEN = 10.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'IDOC_TIME'.
LS_FIELDCAT-REPTEXT_DDIC = 'Creation Time'.
LS_FIELDCAT-OUTPUTLEN = 8.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'STATUS'.
LS_FIELDCAT-REPTEXT_DDIC = 'St'.
LS_FIELDCAT-OUTPUTLEN = 2.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'ERROR'.
LS_FIELDCAT-REPTEXT_DDIC = 'Message'.
LS_FIELDCAT-OUTPUTLEN = 70.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'STP_NO'.
LS_FIELDCAT-REPTEXT_DDIC = 'S.T.Party No'.
LS_FIELDCAT-OUTPUTLEN = 10.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'STP_NAME'.
LS_FIELDCAT-REPTEXT_DDIC = 'Sold to Party Name'.
LS_FIELDCAT-OUTPUTLEN = 35.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'PO_NO'.
LS_FIELDCAT-REPTEXT_DDIC = 'Purch Order'.
LS_FIELDCAT-OUTPUTLEN = 15.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'STP_PHONE'.
LS_FIELDCAT-REPTEXT_DDIC = 'S.T.Party Phone'.
LS_FIELDCAT-OUTPUTLEN = 15.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
ENDFORM. "fieldcat_init
&----
*& Form sort_init
&----
FORM SORT_INIT.
DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
*
CLEAR LS_SORT.
LS_SORT-FIELDNAME = 'IDOC_DATE'.
LS_SORT-SPOS = 1.
LS_SORT-UP = 'X'.
APPEND LS_SORT TO GT_SORT.
CLEAR LS_SORT.
LS_SORT-FIELDNAME = 'IDOC_TIME'.
LS_SORT-SPOS = 2.
LS_SORT-UP = 'X'.
APPEND LS_SORT TO GT_SORT.
CLEAR LS_SORT.
LS_SORT-FIELDNAME = 'STATUS'.
LS_SORT-SPOS = 3.
LS_SORT-UP = 'X'.
APPEND LS_SORT TO GT_SORT.
CLEAR LS_SORT.
LS_SORT-FIELDNAME = 'IDOC_NO'.
LS_SORT-SPOS = 4.
LS_SORT-UP = 'X'.
APPEND LS_SORT TO GT_SORT.
ENDFORM. "sort_init
&----
*& Form grid_display
&----
FORM GRID_DISPLAY.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = GT_FIELDCAT
IT_SORT = GT_SORT
i_callback_program = SY-REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_DEFAULT = ' '
I_SAVE = 'X'
TABLES
T_OUTTAB = T_REPORT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. "grid_display
&----
*& Form COMMENT_BUILD
&----
Processing of listheader
----
FORM COMMENT_BUILD USING P_FK_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
REFRESH P_FK_LIST_TOP_OF_PAGE.
List Heading : Typ H
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = 'Sales Order Interface: Z_EDI_FILE_LOAD'.
APPEND LS_LINE TO P_FK_LIST_TOP_OF_PAGE.
List : Typ S
clear LS_LINE.
LS_LINE-typ = 'S'.
LS_LINE-key = 'Date Range:'.
LS_LINE-info = UDATE-low.
if not UDATE-high is initial.
write ' To ' to LS_LINE-info+30.
LS_LINE-info+36 = UDATE-high.
endif.
APPEND LS_LINE TO P_FK_LIST_TOP_OF_PAGE.
ENDFORM. " COMMENT_BUILD
----
FORM TOP_OF_PAGE *
----
Ereigniss TOP_OF_PAGE *
event TOP_OF_PAGE
----
FORM TOP_OF_PAGE.
PERFORM COMMENT_BUILD USING gt_LIST_TOP_OF_PAGE[].
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
ENDFORM. "TOP_OF_PAGE
&----
*& Form show_status_report
&----
FORM SHOW_STATUS_REPORT .
Report to show status.
DATA: BEGIN OF T_TEDS2 OCCURS 0.
INCLUDE STRUCTURE TEDS2.
DATA: END OF T_TEDS2.
DATA: BEGIN OF T_IDOC_CONTROL_TMP OCCURS 0.
INCLUDE STRUCTURE EDIDC.
DATA: END OF T_IDOC_CONTROL_TMP.
CONSTANTS: C_STATUS_IN_IDOC_POSTED LIKE EDIDC-STATUS VALUE '53'.
DATA : T_EDIDS TYPE STANDARD TABLE OF EDIDS WITH HEADER LINE.
DATA : T_EDIDD TYPE STANDARD TABLE OF EDIDD WITH HEADER LINE.
DATA : GV_PARTNER_SEG TYPE E1EDKA1,
GV_PO_REF_SEG TYPE E2EDK02.
Get text for status values
SELECT * FROM TEDS2 INTO TABLE T_TEDS2 WHERE LANGUA = SY-LANGU.
Read the IDoc's status after processing
SELECT * FROM EDIDC
INTO TABLE T_IDOC_CONTROL_TMP
WHERE UPDDAT IN UDATE
AND UPDTIM IN UTIME
AND MESTYP = 'ORDERS'.
LOOP AT T_IDOC_CONTROL_TMP.
IDoc has been processed, since control record changed.
READ TABLE T_TEDS2 WITH KEY STATUS = T_IDOC_CONTROL_TMP-STATUS.
T_REPORT-IDOC_NO = T_IDOC_CONTROL_TMP-DOCNUM.
T_REPORT-IDOC_DATE = T_IDOC_CONTROL_TMP-CREDAT.
T_REPORT-IDOC_TIME = T_IDOC_CONTROL_TMP-CRETIM.
T_REPORT-S_TEXT = T_TEDS2-DESCRP.
IF T_IDOC_CONTROL_TMP-STATUS = C_STATUS_IN_IDOC_POSTED.
ok status
T_REPORT-STATUS = 'S'.
ELSE.
error status
T_REPORT-STATUS = 'E'.
ENDIF.
Get IDoc details.
CALL FUNCTION 'IDOC_READ_COMPLETELY'
EXPORTING
DOCUMENT_NUMBER = T_REPORT-IDOC_NO
TABLES
INT_EDIDS = T_EDIDS
INT_EDIDD = T_EDIDD
EXCEPTIONS
DOCUMENT_NOT_EXIST = 1
DOCUMENT_NUMBER_INVALID = 2
OTHERS = 3.
Get Error status
READ TABLE T_EDIDS WITH KEY STATUS = T_IDOC_CONTROL_TMP-STATUS.
IF SY-SUBRC EQ 0.
REPLACE FIRST OCCURRENCE OF '&1' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA1.
REPLACE FIRST OCCURRENCE OF '&2' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA2.
REPLACE FIRST OCCURRENCE OF '&3' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA3.
REPLACE FIRST OCCURRENCE OF '&4' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA4.
REPLACE FIRST OCCURRENCE OF '&' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA1.
REPLACE FIRST OCCURRENCE OF '&' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA2.
REPLACE FIRST OCCURRENCE OF '&' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA3.
REPLACE FIRST OCCURRENCE OF '&' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA4.
T_REPORT-ERROR = T_EDIDS-STATXT.
ENDIF.
LOOP AT T_EDIDD.
CASE T_EDIDD-SEGNAM.
WHEN 'E1EDKA1'.
GV_PARTNER_SEG = T_EDIDD-SDATA.
CLEAR : T_REPORT-STP_NAME.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = GV_PARTNER_SEG-PARTN
IMPORTING
OUTPUT = T_REPORT-STP_NO.
SELECT SINGLE NAME1 TELF1
INTO (T_REPORT-STP_NAME,T_REPORT-STP_PHONE)
FROM KNA1
WHERE KUNNR = T_REPORT-STP_NO.
WHEN 'E1EDK02'.
GV_PO_REF_SEG = T_EDIDD-SDATA.
T_REPORT-PO_NO = GV_PO_REF_SEG-BELNR.
ENDCASE.
ENDLOOP.
APPEND T_REPORT.
ENDLOOP .
SORT T_REPORT BY STATUS IDOC_NO.
Show Report
PERFORM ALV_GRID.
ENDFORM. " show_status_report
thanks
karthik
reward me points if usefull.
04-18-2008 10:09 PM
Hi Santhose,
to send purchase order details from sender to reciever you will use PORDCR message type.
you have two approaches for sending idocs from sender to receiver.one is using tcodes.if you use this you have to manually send using tcodes.second approach is using change pointers.if you use this when you create a purchase order in in sender that is automatically created in receiver.
how to use change pointers is explained below.
The Change Pointer Technique
Enable Change Pointers Globally
TCode: BD 61
Path: From the ALE Customizing in IMG,choose Modeling and Implemantation Business
Process, MAster Data distribution, Replication of Modified Data, Activate
Change Pointers
Enable Change Pointers Globally
TCode: BD 50
Path: From the ALE Customizing in IMG,choose Modeling and Implemantation Business
Process, MAster Data distribution, Replication of Modified Data, Activate
Change Pointers for Message Type
Specify the Fields for which Change Pointers are to be written
TCode: BD 52
Path: From the ALE main Menu, Choose ALE Development, IDOCs, Change , Define
Change-Relevant Fields
if you have any doubts let me know.
please reward points if helpful.