Showing posts with label idoc. Show all posts
Showing posts with label idoc. Show all posts

Saturday, October 10, 2020

What is an IDOC Structure in SAP.

IDOC Structure.

  


Each IDOC has 3 records I.             Control Record:

Ø  It contains IDOC type & Message type information, Partner information such as partner system number, Port number of the sender & receiver system.

Ø  It is also contain technical & address information of sender & recipients.

 

     II.      Data Record:

Ø  These are collection of segments. The data record of an IDOC contains segment.

Ø  Segment is collection of fields which can be distributed the data between the systems.

 

III.         Status record:

Ø  It contains the status of the processed IDOC to know where an IDOC has been successful/failed.

Ø  The standard table EDIDC contains an IDOC information such as control records, different statuses etc.

  Note:

Ø  The Sender/Source system is also called as ‘Outbound system’.

Ø  The Receiver/Target system is also called as ‘Inbound system’.

Ø  The T-code ‘WE30’ is used to maintain different types of IDOC’s such as Basic IDOC, Extended IDOC.

Ø  The T-codes WE02/WE05 are used to list out the generated IDOC’s.

Ø  The T-code ‘WE19’ is used to test/check the IDOC.

Custom Segments:

Ø  The custom segments are starts with Z*/Y* & they are maintained by technical & functional consultants

Standard Segment:

Ø  These are system provided segments

Ø  The T-code : WE31 is used to maintain the segments

 

Message Types:

Ø  These are identifiers of the application data to be distributed between the systems

Ø  The T-code WE81 is used to create & WE82 is to assign the message types to the IDOC (Data carrier)

Ø  The standard table EDIDC contains all available message type

System provided standard message types?

Message Type

Description

MATMAS

Material Master

DEBMAS

Customer Master

CREMAS

Vendor Master

 

Partner Profiles:

Ø  These are used to maintain the partner system details with which data to be distributed such as partner number, Partner type & Message type of outbound parameters. Ø The T-code WE20 is used to maintain partner profiles

Ports:

Ø  These are used to specify the way in which data to be distributed through an IDOC

Ø  The system generates one unique port number

Ø  The T-code WE21 is used to maintain ports for IDOC process

Customer Distribution Model:

Ø  It is used to define data distribution model to exchange the messages between two logical systems (SAP – SAP/SAP – non SAP)

Ø  The T-code BD64 is used to define/maintain customer distribution model

Process codes;

Ø  It is used to identify type of the data to be distributed through an IDOC interface.

Ø  The T-code WE41/WE42 is used to work with the process code 


Friday, October 9, 2020

How to check the IDOCs in SAP.

How to check the IDOCs?

Check the IDOCs in SAP.

Ans :- WE19 is the T-code to check the IDOC’s.

1.   Execute WE02/WE05

2.   Provide the Message type: CREMAS (Logical Sys), Partner no: LS810 & Click on Execute             3. After we get the status code 03, if we want to know the IDOC is reached to destination or                 not then we execute RBDMOIND standard program.

4.  The status of an IDOC (3) use in Green color (turn 10 to12) means it is delivered   

               Successfully. Yellow traffic light indicates/the status code remains same, IDOC is in                   Progress or in the Transaction RFC & Red traffic light/the status code turns 10 to 11                 indicates the Error/the IDOC is damaged.   

5.  Expand the Data Records folder & click on each segment to see the data to be distributed.    

Sunday, September 27, 2020

Generates an IDOC for Customer Master, Sales Master and Sales item table in SAP ABAP.

Generates an IDOC for Customer Master, Sales Master  and Sales item table in SAP ABAP.



IDOC Report Details.

 &---------------------------------------------------------------------*

*& Report  ZRZ_ORDER_IDOC                                              *                                                                     *

*&---------------------------------------------------------------------*

 REPORT  ZRZ_ORDER_IDOC                          .

 ***********************************************************************

* PURPOSE OF REPORT *

***********************************************************************

* Generats an Idoc for Customer Master, Sales Master

* and Sales item table.

***********************************************************************

TABLES : ZCUSTOMERS, "Cutomer Header

         ZSOHEADERS, "Sales Header

         ZSOITEMS. "Sales Items

DATA : S_CTRL_REC LIKE EDIDC, "Idoc Control Record

       S_ZRZSEG1 LIKE ZRZSEG1, "CUSTOMER Header Data

       S_ZRZSEG2 LIKE ZRZSEG2, "SALES HEADER Data

       S_ZRZSEG3 LIKE ZRZSEG3. "SALES Detail Data

DATA : T_ZCUSTOMERS LIKE ZCUSTOMERS OCCURS 0 WITH HEADER LINE.

DATA : T_ZSOHEADERS LIKE ZSOHEADERS OCCURS 0 WITH HEADER LINE.

DATA : T_ZSOITEMS LIKE ZSOITEMS OCCURS 0 WITH HEADER LINE.

DATA : T_EDIDD LIKE EDIDD OCCURS 0 WITH HEADER LINE."Data Records

DATA : T_COMM_IDOC LIKE EDIDC OCCURS 0 WITH HEADER LINE.

"Generated Communication IDOc

CONSTANTS :

C_ZRZSEG1 LIKE EDIDD-SEGNAM VALUE 'ZRZSEG1',

C_ZRZSEG2 LIKE EDIDD-SEGNAM VALUE 'ZRZSEG2',

C_ZRZSEG3 LIKE EDIDD-SEGNAM VALUE 'ZRZSEG3'.

 

CONSTANTS: C_IDOCTP LIKE EDIDC-IDOCTP VALUE 'ZRZORDER'.

*** Selection Screen

SELECT-OPTIONS : S_KUNNR FOR ZCUSTOMERS-KUNNR OBLIGATORY,

                 S_VBELN FOR ZSOHEADERS-VBELN.

PARAMETERS :  C_MESTYP LIKE EDIDC-MESTYP DEFAULT 'ZRZSO_MT',

              "Message Type

              C_RCVPRT LIKE EDIDC-RCVPRT DEFAULT 'LS',

              "Partner type of receiver

              C_LOGSYS LIKE EDIDC-RCVPRN DEFAULT 'Y901',

              C_RCVPOR LIKE EDIDC-RCVPOR DEFAULT 'A000000226',

              C_SNDPRN LIKE EDIDC-SNDPRN DEFAULT 'LSSENDS',

              C_SNDPRT LIKE EDIDC-SNDPRT DEFAULT 'LS'.

"Destination System

 

***START-OF-SELECTION

START-OF-SELECTION.

  PERFORM GENERATE_DATA_RECORDS.

  PERFORM GENERATE_CONTROL_RECORD.

  PERFORM SEND_IDOC.

 ***********************************************************************

*&---------------------------------------------------------------------*

*&      Form  generate_data_records

*&---------------------------------------------------------------------*

FORM GENERATE_DATA_RECORDS .

  PERFORM FETCH_ZCUSTOMERS.

  PERFORM FETCH_ZSOHEADERS.

  PERFORM FETCH_ZSOITEMS.

  PERFORM ARRANGE_DATA_RECORDS.

ENDFORM.                    " generate_data_records

*&---------------------------------------------------------------------*

*&      Form  fetch_zcustomers

*&---------------------------------------------------------------------*

FORM FETCH_ZCUSTOMERS.

  SELECT *

  FROM ZCUSTOMERS

  INTO TABLE T_ZCUSTOMERS

  WHERE KUNNR IN S_KUNNR.

  IF SY-SUBRC NE 0.

    MESSAGE E398(00) WITH 'No Customers Found'.

  ENDIF.

ENDFORM.                    " fetch_zcustomers

*&---------------------------------------------------------------------*

*&      Form  fetch_zsoheaders

*&---------------------------------------------------------------------*

FORM FETCH_ZSOHEADERS.

  SELECT *

  FROM ZSOHEADERS

  INTO TABLE T_ZSOHEADERS

  WHERE VBELN IN S_VBELN

    AND KUNNR IN S_KUNNR.

  IF SY-SUBRC NE 0.

    MESSAGE I398(00) WITH 'No Sales orders found'.

  ENDIF.

ENDFORM.                    " fetch_zsoheaders

*&---------------------------------------------------------------------*

*&      Form  fetch_zsoitems

*&---------------------------------------------------------------------*

FORM FETCH_ZSOITEMS.

  IF NOT T_ZSOHEADERS[] IS INITIAL.

    SELECT *

    FROM ZSOITEMS

    INTO TABLE T_ZSOITEMS

    FOR ALL ENTRIES IN T_ZSOHEADERS

    WHERE VBELN = T_ZSOHEADERS-VBELN.

    IF SY-SUBRC NE 0.

      MESSAGE I398(00) WITH 'No Sales order items found'.

    ENDIF.

  ENDIF.

ENDFORM.                    " fetch_zsoitems

 *&---------------------------------------------------------------------*

*&      Form  generate_control_record

*&---------------------------------------------------------------------*

FORM GENERATE_CONTROL_RECORD .

  S_CTRL_REC-RCVPOR = C_RCVPOR. "Receiver Port

  S_CTRL_REC-MESTYP = C_MESTYP. "Message type

  S_CTRL_REC-IDOCTP = C_IDOCTP. "Basic IDOC type

  S_CTRL_REC-RCVPRT = C_RCVPRT. "Partner type of receiver

  S_CTRL_REC-RCVPRN = C_LOGSYS. "Partner number of receiver

 

  S_CTRL_REC-SNDPRT = C_SNDPRT. "Sender Partner type

  S_CTRL_REC-SNDPRN = C_SNDPRN. "Sender Partner Number

ENDFORM.                    " generate_control_record

 

*&---------------------------------------------------------------------*

*&      Form  send_idoc

*&---------------------------------------------------------------------*

FORM SEND_IDOC.

  CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

    EXPORTING

      MASTER_IDOC_CONTROL            = S_CTRL_REC

    TABLES

      COMMUNICATION_IDOC_CONTROL     = T_COMM_IDOC

      MASTER_IDOC_DATA               = T_EDIDD

    EXCEPTIONS

      ERROR_IN_IDOC_CONTROL          = 1

      ERROR_WRITING_IDOC_STATUS      = 2

      ERROR_IN_IDOC_DATA             = 3

      SENDING_LOGICAL_SYSTEM_UNKNOWN = 4

      OTHERS                         = 5.

  IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ELSE.

    COMMIT WORK.

    LOOP AT T_COMM_IDOC.

      WRITE:/ 'IDoc Generated - ', T_COMM_IDOC-DOCNUM.

    ENDLOOP.

  ENDIF.

ENDFORM.                    " send_idoc

 *&---------------------------------------------------------------------*

*&      Form  arrange_data_records

*&---------------------------------------------------------------------*

FORM ARRANGE_DATA_RECORDS .

  DATA: W_INDEX1 LIKE SY-TABIX,

        W_INDEX2 LIKE SY-TABIX.

  SORT T_ZCUSTOMERS BY KUNNR.

  SORT T_ZSOHEADERS BY KUNNR VBELN.

  SORT T_ZSOITEMS BY VBELN POSNR.

 

  LOOP AT T_ZCUSTOMERS.

    S_ZRZSEG1-KUNNR = T_ZCUSTOMERS-KUNNR.

    S_ZRZSEG1-NAME1 = T_ZCUSTOMERS-NAME1.

    S_ZRZSEG1-ORT01 = T_ZCUSTOMERS-ORT01.

    S_ZRZSEG1-LAND1 = T_ZCUSTOMERS-LAND1.

    T_EDIDD-SEGNAM = C_ZRZSEG1.

    T_EDIDD-SDATA = S_ZRZSEG1.

    APPEND T_EDIDD.

    CLEAR T_EDIDD.

 

    CLEAR W_INDEX1.

    READ TABLE T_ZSOHEADERS WITH KEY KUNNR = T_ZCUSTOMERS-KUNNR BINARY SEARCH.

 

    IF SY-SUBRC = 0.

      W_INDEX1 = SY-TABIX.

      LOOP AT T_ZSOHEADERS FROM W_INDEX1.

        IF T_ZSOHEADERS-KUNNR NE T_ZCUSTOMERS-KUNNR.

          EXIT.

        ENDIF.

        S_ZRZSEG2-VBELN = T_ZSOHEADERS-VBELN.

        S_ZRZSEG2-KUNNR = T_ZSOHEADERS-KUNNR.

        T_EDIDD-SEGNAM = C_ZRZSEG2.

        T_EDIDD-SDATA = S_ZRZSEG2.

        APPEND T_EDIDD.

        CLEAR T_EDIDD.

 

        CLEAR W_INDEX2.

        READ TABLE T_ZSOITEMS WITH KEY VBELN = T_ZSOHEADERS-VBELN BINARY SEARCH.

        IF SY-SUBRC = 0.

          W_INDEX2 = SY-TABIX.

          LOOP AT T_ZSOITEMS FROM SY-TABIX.

            IF T_ZSOITEMS-VBELN NE T_ZSOHEADERS-VBELN.

              EXIT.

            ENDIF.

            S_ZRZSEG3-VBELN = T_ZSOITEMS-VBELN.

            S_ZRZSEG3-POSNR = T_ZSOITEMS-POSNR.

            S_ZRZSEG3-MATNR = T_ZSOITEMS-MATNR.

            S_ZRZSEG3-NETWR = T_ZSOITEMS-NETWR.

            S_ZRZSEG3-ZMENG = T_ZSOITEMS-ZMENG.

            T_EDIDD-SEGNAM = C_ZRZSEG3.

            T_EDIDD-SDATA = S_ZRZSEG3.

            APPEND T_EDIDD.

            CLEAR T_EDIDD.

          ENDLOOP.

        ENDIF.

      ENDLOOP.

    ENDIF.

  ENDLOOP.

ENDFORM.                    " arrange_data_records