Distribution of IDOC

hi,
plz help me i have to distribute material master data. in that i have to distribute only sales view only. how can i do this .
regards
ranga

Hi
Have to configure all the related settings of ALE
and use the Tcode BD10 for distributing/sending the Material data
<b>Reward points for useful Answers</b>
Regards
Anji

Similar Messages

  • WBS data distribution for IDOC-PI-JDBC with system status 'CRTD' not working.

    Hello Experts,
    I am busy with a project where the PS project creation and updates should be transfered to the external legacy system through IDOC-PI-JDBC scenario.
    I am using the BAPI_PROJECT_MAINTAIN for this process. This scenario is working fine with the projects system status released (REL).
    If the system status is Created (CRTD) then no idoc creation happening therefor no data distribution of work breakdown structure(WBS) to the legacy system.
    Can anybody give me some suggestion of make it happening.
    Thanks in advance.
    Regards,
    Antony.

    Hello all,
    I did it with the help of my abap developer.
    We implemented a BADI, and from the BADI we created the idoc.
    When the idoc is there the legacy system receive the data.
    Regards,
    Antony.

  • Central contract distribution trough IDOC - including new partner

    Hi,
    I created a partner in SRM for use with a specific central contract that I am distributing the ECC through an IDOC, the contract in backend is configured with this partner as mandatory, but if I process manually the data in the IDOC in ECC, document is not created, message error is that new partner missing.
    Any ideas how can I add a partner in this process?
    I'm working with SRM 7.0 and ECC 6.0
    Regards,
    José Luis D.

    To trace where your issue might be, it is helpful to find out the following:
    1) in table BBP_BACKEND_DEST, get the SYS_TYPE value for your backend system (LOGSYS = your backend system)
    2) in table BBP_FUNCTION_MAP, get the function name for OBJECT = BUS2000113 and METHOD = TransferFromData and TYPE = <your value from step 1>
    If you are going through IDOC processing, likely the Function would be "B46B_CTR_TRANSFER". In that case, set a session breakpoint in that function module. Then test run FM BBP_PD_CTR_TRANSFER with your contract GUID as input parameter and IV_SAVE_DB = "X". Execute until the breakpoint and start tracing the problem. This should help you identify the source of the error.

  • Is it Possible to import an IDoc type from R/3 into APO system

    Hi Gurus ,
    Could you please guide if we can import an IDoc type from R/3 system to APO system ?? If yes , can you please give the guidelines / step - by - step procedure for this.
    Thanks in advance ,
    Roseline

    hi
    yes u can export an idoc from r/3 to a legacy system.
    the brief outline is as follows:
    1. set up an rfc connection. it has to be 'T' type in t-code sm59
    configure the saprfc.ini file if on windows based os. if on unix based os configure rfcexec.c to have the login details of apo system.
    2.set up logical systems( at least 1 each for r/3 and apo) using T-code SALE.
    3.assign clients to the logical sytems using T-code SALE..
    4.create ports using tcode we20.
    5. create idoc segments using we30 and release.
    6. create idoc type using we31.
    7. create message type using we81.
    8. assign message to idoc using we82.
    9.build a customer model using tcode bd64.
    10. create an outbound process code usint tcode we41.
    it will help if you specify your idoc that you want to use- for vendor, customer and material there are predefined distributions and idocs.
    Thanks.

  • Want to transfer data via idocs from one  R/3 to different R/3

    Hi!!
    May i hav nay step by step pdf which gives the complete flow of how to transfer idocs from from one  R/3 to different R/3.
    Though i have the basics steps but some where I m stuck.
    Also I have two doubts::
    1.Is thr Any relation bw port name and Logical System name?Can they be same.??I  hav kept Logical System name as SAPE60 AND PORT name also as SAPE60(in e60) and  SAPEI6(in ei6) servers respectively.
    2.Should the Logical System names be maintained same in both the servers??
    Kindly respond .
    Helpful answers will be rewarded points!!!

    Hi Deepika ,
    See the Example scenarios
    MASTER DATA TRANSFERMATION BETWEEN 2 DIFF CLIENTS
    •     For this scenario Client 800 is the Sender and 810 is the receiving system
    1. Creating Logical Systems
    o     Login using 800 client
    o     Go to T. Code SALE
    o     Expand Sending and Receiving Systems
    o     Expand Logical Systems
    o     Click on Define Logical System
    o     Click on New Entries
    o     Create STUD_S, STUD_R Logical Systems
    o     Save and come back
    o     Assign the STUD_S Logical System to client 800
    o     Assign the STUD_R Logical System to client 810
    2. Creating the RFCs
    o     Go to T. Code SM59
    o     Expand R/3 Connections
    o     Enter RFC Name as STUD_S
    o     Connection Type as 3
    o     Language as EN
    o     Client as 800
    o     User as  SAPUSER
    o     PWD as abap
    o     Target host as sap
    o     Click on Remote logon button to test the RFC
    o     Enter RFC Name as STUD_R
    o     Connection Type as 3
    o     Language as EN
    o     Client as 800
    o     User as  SATISH
    o     PWD as abap
    o     Target host as sap
    o     Click on Remote logon button to test the RFC
    3. Creating the Message Type
    o     Go to T. Code WE81
    o     Click on change, continue
    o     Click on New Entries button
    o     Give message type as ZBAPI_STUD_MAS and description
    o     Save and back
    4. Creating the Segment
    o     Go to T. Code WE31
    o     Give segment name as ZBAPI_STUD_SEG
    o     Enter Short Text
    o     Enter the Field Name and Data Element in the text boxes
    o     Save, continue,
    o     Click on Edit -> Set Release.
    5. Creating the Basic IDOC Object
    o     Go to T. code WE30
    o     Give obj. name as ZBAPI_STUD_IDOC
    o     Click on create
    o     Select create new radio button, give description and continue
    o     Select the IDOC obj name and click on create button
    o     Enter the segment name which is create earlier
    o     Select the check box if you want to make the segment mandatory
    o     Enter 1 in minimum number 99999 in maximum number, continue
    o     Save and back
    o     Click on Edit -> Set Release
    6. Creating Customer Distribution Model
    o     Go to T. Code BD64
    o     Click on change and Create model view button
    o     Enter the short text and Technical name as ZSTUDENT
    o     Select the model and click on Add Message Type Button
    o     Give the Sender as STUD_S,
    o                    Receiver as STUD_R,
    o                    Message Type as ZBAPI_STUD_MAS
    o     Select the model view & click on Environment -> Generate Partner Profiles
    o     Select Transfer IDOC Immediately and Trigger Immediately radio buttons
    o     Click on Execute
    o     You should get a list in green color which means it executed successfully.
    o     Back to main screen, select the model view
    o     Click Edit->Model view->Distribute
    o     Click on continue
    o     You should get a list saying model view is distributed successfully.
    7. Checking the Port
    o     Go to T. Code WE21
    o     Expand Transactional RFC
    o     Find the port from the list which is created using BD64 for STUD_R (Receiving system) RFC Destination.
    8. Checking the Partner Profiles.
    o     Go to T. Code WE20
    o     Expand Partner Type LS
    o     Select the Partner profile STUD_R
    o     Double click on Message Type ZBAPI_STUD_MAS in Outbound parmtrs.
    o     Check Receiver Port is assigned correctly
    o     Check the Basic type as your Basic IDOC object.
    9. Assigning the Message Type to Basic IDOC Object
    o     Go to T. Code WE82
    o     Click on Change & continue, New Entries button
    o     Give the Message type as ZBAPI_STUD_MAS
    o     Give Basic Type as ZBAPI_STUD_IDOC
    o     Release as 46C
    o     Save and back
    10. Creating Inbound Function Module (Posting Program)
    o     Go to T. Code SE37
    o     Create a function Module IDOC_INPUT_ZBAPI_STUD_MAS
    o     Set the Processing type as Remote Enabled Module and mode as start immed, in Attributes Tab.
    o     Import Parameters
    INPUT_METHOD                 LIKE     BDWFAP_PAR-INPUTMETHD
    MASS_PROCESSING     LIKE     BDWFAP_PAR-MASS_PROC
    NO_APPLICATION_LOG     LIKE     SY-DATAR
    MASSSAVEINFOS                 LIKE     MASSSAVINF
    o     Export Parameters
    WORKFLOW_RESULT          LIKE     BDWF_PARAM-RESULT
    APPLICATION_VARIABLE     LIKE     BDWF_PARAM-APPL_VAR
    IN_UPDATE_TASK          LIKE     BDWFAP_PAR-UPDATETASK
    CALL_TRANSACTION_DONE  LIKE     BDWFAP_PAR-CALLTRANS
    o     Tables
    IDOC_CONTRL     LIKE     EDIDC
    IDOC_DATA          LIKE     EDIDD
    IDOC_STATUS     LIKE     BDIDOCSTAT
    RETURN_VARIABLES     LIKE     BDWFRETVAR
    SERIALIZATION_INFO     LIKE     BDI_SER
    o     Exceptions
    WRONG_FUNCTION_CALLED
    o     Source Code
    DATA: FIRST_TRANC LIKE MARA_UEB-TRANC,
          ZBAPI_STUD_SEG like zbapi_stud.
    DATA: ZBAPI_STUD LIKE ZBAPI_STUD.
      DATA: I_ZBAPI_STUD LIKE ZBAPI_STUD.
      DATA: C_TRUE                         VALUE 'X'.
      DATA: C_FALSE                        VALUE ' '.
    DATA: BEGIN OF T_IDOC_ROLLNO OCCURS 0,
            DOCNUM LIKE EDIDC-DOCNUM,
            ROLLNO LIKE ZBAPI_STUD-ROLLNO,
          END   OF T_IDOC_ROLLNO.
      DEFINE APPEND_RESFIELDS.
        PERFORM APPEND_RES_FIELDS TABLES T_MFIELDRES
                                         T_RES_FIELDS
                                  USING  &1
                                         COUNTER-D_IND.
      END-OF-DEFINITION.
      DATA: I_MARA_UEB LIKE MARA_UEB.
      DATA: I_ZSTUD_UEB LIKE ZBAPI_STUD.
      DATA: I_MAKT_UEB LIKE MAKT_UEB.
      DATA: I_MARC_UEB LIKE MARC_UEB.
      DATA: I_MARD_UEB LIKE MARD_UEB.
      DATA: I_MFHM_UEB LIKE MFHM_UEB.
      DATA: I_MARM_UEB LIKE MARM_UEB.
      DATA: I_MEAN_UEB LIKE MEA1_UEB.
      DATA: I_MBEW_UEB LIKE MBEW_UEB.
      DATA: I_STEU_UEB LIKE STEU_UEB.
      DATA: I_STEUMM_UEB LIKE STEUMM_UEB.
      DATA: I_MLGN_UEB LIKE MLGN_UEB.
      DATA: I_MLGT_UEB LIKE MLGT_UEB.      " //br010797 neu zu 4.0
      DATA: I_MPGD_UEB LIKE MPGD_UEB.
      DATA: I_MPOP_UEB LIKE MPOP_UEB.
      DATA: I_MVEG_UEB LIKE MVEG_UEB.
      DATA: I_MVEU_UEB LIKE MVEU_UEB.
      DATA: I_MVKE_UEB LIKE MVKE_UEB.
      DATA: I_MPRW_UEB LIKE MPRW_UEB.
      DATA: I_LTX1_UEB LIKE LTX1_UEB.
      DATA: HELP_MARC_UEB LIKE MARC_UEB.
      DATA: T_MARA_UEB LIKE MARA_UEB OCCURS 0.
      DATA: T_MAKT_UEB LIKE MAKT_UEB OCCURS 0.
      DATA: T_MARC_UEB LIKE MARC_UEB OCCURS 0.
      DATA: T_MARD_UEB LIKE MARD_UEB OCCURS 0.
      DATA: T_MFHM_UEB LIKE MFHM_UEB OCCURS 0.
      DATA: T_MARM_UEB LIKE MARM_UEB OCCURS 0.
      DATA: T_MEAN_UEB LIKE MEA1_UEB OCCURS 0.
      DATA: T_MBEW_UEB LIKE MBEW_UEB OCCURS 0.
      DATA: T_STEU_UEB LIKE STEU_UEB OCCURS 0.
      DATA: T_STEUMM_UEB LIKE STEUMM_UEB OCCURS 0.
      DATA: T_MLGN_UEB LIKE MLGN_UEB OCCURS 0.
      DATA: T_MLGT_UEB LIKE MLGT_UEB OCCURS 0.    " //br010797 neu zu 4.0
      DATA: T_MPGD_UEB LIKE MPGD_UEB OCCURS 0.
      DATA: T_MPOP_UEB LIKE MPOP_UEB OCCURS 0.
      DATA: T_MVEG_UEB LIKE MVEG_UEB OCCURS 0.
      DATA: T_MVEU_UEB LIKE MVEU_UEB OCCURS 0.
      DATA: T_MVKE_UEB LIKE MVKE_UEB OCCURS 0.
      DATA: T_MPRW_UEB LIKE MPRW_UEB OCCURS 0.
      DATA: T_LTX1_UEB LIKE LTX1_UEB OCCURS 0.
    Internal fields/ tables
    DATA: FLAG_ERROR_HAPPENED.
    DATA: flag_material_exists. "//br210397 zu 4.0 keine Verwendung mehr
      DATA: FLAG_EXIT_TO_BE_DONE.
      DATA: HELP_TABIX LIKE SY-TABIX.
      DATA: HELP_TRANC LIKE MARA_UEB-TRANC.
      DATA: HELP_ALAND LIKE STEU_UEB-ALAND.
      DATA: HELP_VKORG LIKE MVKE-VKORG.
      DATA: HELP_WERKS LIKE T001W-WERKS.
      DATA: HELP_LFDNR LIKE STEU_UEB-LFDNR.
      DATA: LAST_MARC_TRANC LIKE MARA_UEB-TRANC.
      DATA: LAST_MLGN_TRANC LIKE MARA_UEB-TRANC.    " //br010797 neu zu 4.0
      DATA: LAST_TEXT_TRANC LIKE MARA_UEB-TRANC.
      DATA: CURRENT_TABIX LIKE SY-TABIX.
      DATA: GENERAL_SUBRC LIKE SY-SUBRC.
      DATA: HELP_FACTOR TYPE P DECIMALS 3.
      DATA: USER_SEGMENTS LIKE EDIDD OCCURS 0 WITH HEADER LINE.  " insert
      DATA: CUST_SEGMENT LIKE EDIDD.
      DATA: I_MFIELDRES LIKE MFIELDRES.
    DATA: I_MERRDAT LIKE MERRDAT.
      DATA: I_EDIDD LIKE EDIDD.
                                           " //br neu zu 3.1g
      DATA: T_RES_FIELDS LIKE DELFIELDS OCCURS 0 WITH HEADER LINE.
      DATA: T_MFIELDRES LIKE MFIELDRES OCCURS 0.
      DATA: T_MERRDAT LIKE MERRDAT OCCURS 0.
      DATA: T_EDIDD LIKE EDIDD OCCURS 0.
    DATA: BEGIN OF t_matnr OCCURS 0, "//br210397 zu 4.0
            matnr LIKE mara-matnr,   " wird nicht mehr verwendet
          END OF t_matnr.            "
      DATA: BEGIN OF COUNTER,
              TRANC LIKE MARA_UEB-TRANC,
              D_IND LIKE MARA_UEB-D_IND,
            END OF COUNTER.
    DATA: BEGIN OF t_idoc_tranc OCCURS 0,                          " 4.0
            docnum LIKE edidc-docnum,                              "
            tranc  LIKE mara_ueb-tranc,                            "
          END OF t_idoc_tranc.                                     "
      DATA T_IDOC_TRANC LIKE MATIDOCTRANC OCCURS 0 WITH HEADER LINE."
      DATA: FLAG_FITS.
      DATA: APPLICATION_SUBRC LIKE SY-SUBRC.
      DATA FLAG_MUSS_PRUEFEN LIKE SY-DATAR.
      DATA MAX_ERRORS LIKE T130S-ANZUM.    " 4.0
    note 419281
      DATA : FLG_MASS.
      CLEAR : FLG_MASS.
      FIELD-SYMBOLS: .            " 4.0
    ALE-distribution unity : IDOC status set by locking      "note0361838
      data:                                                     "note0361838
        it_dsp_idocstat like bdidocstat                         "note0361838
          occurs 0 with header line.                            "note0361838
    Initialize data - general
      REFRESH T_MFIELDRES.
      REFRESH T_IDOC_TRANC.
      REFRESH T_IDOC_TRANC.                "JH/02.02.98/4.0C  KPr100004993
    REFRESH t_idoc_tranc_segment.   " //br 40 : unnötig
    REFRESH matnr_tranc.            "    -"-
    REFRESH t_matnr.
      COUNTER-TRANC = 1.
      COUNTER-D_IND = 1.
      REFRESH T_MARA_UEB.
      REFRESH T_MAKT_UEB.
      REFRESH T_MARC_UEB.
      REFRESH T_MARD_UEB.
      REFRESH T_MFHM_UEB.
      REFRESH T_MARM_UEB.
      REFRESH T_MEAN_UEB.
      REFRESH T_MBEW_UEB.
      REFRESH T_STEU_UEB.
      REFRESH T_STEUMM_UEB.
      REFRESH T_MLGN_UEB.
      REFRESH T_MLGT_UEB.                  " //br010797 neu zu 4.0
      REFRESH T_MPGD_UEB.
      REFRESH T_MPOP_UEB.
      REFRESH T_MVEG_UEB.
      REFRESH T_MVEU_UEB.
      REFRESH T_MVKE_UEB.
      REFRESH T_MPRW_UEB.
    REFRESH VKORG_ALAND.
    REFRESH WERKS_ALAND.
      CLEAR APPLICATION_SUBRC.
      REFRESH T_MERRDAT.
    Check if right function is called
      READ TABLE IDOC_CONTRL INDEX 1.
      IF SY-SUBRC <> 0.
        EXIT.
      ELSE.
        IF  IDOC_CONTRL-IDOCTP <> 'ZBAPI_STUD_IDOC'.
          RAISE WRONG_FUNCTION_CALLED.
        ENDIF.
      ENDIF.
      LOOP AT IDOC_CONTRL.
      Initialize data - per IDOC
      t_idoc_tranc-docnum = counter-tranc.
        T_IDOC_TRANC-DOCNUM = IDOC_CONTRL-DOCNUM.
        T_IDOC_TRANC-FIRST_TRANC_IDOC = COUNTER-TRANC + 2.
        APPEND T_IDOC_TRANC.
      Select segments which belong to IDOC
        REFRESH T_EDIDD.
        LOOP AT IDOC_DATA WHERE DOCNUM = IDOC_CONTRL-DOCNUM.
          APPEND IDOC_DATA TO T_EDIDD.
        ENDLOOP.
       BUSINESS TRANSACTION EVENT (header / data)         "note0388000
         call function 'OPEN_FI_PERFORM_MGV00200_E'         "note0388000
              exporting                                     "note0388000
                  idoc_header       = idoc_contrl           "note0388000
                  FLG_APPEND_STATUS = 'X'                   "note0388000
              tables                                        "note0388000
    (DEL)       idoc_data         = idoc_data "note0388000 note0418561
                  idoc_data         = t_edidd               "note0418561
                  idoc_status       = idoc_status           "note0388000
              exceptions                                    "note0388000
                  others       = 1.                         "note0388000
         if sy-subrc = 1.                                   "note0388000
            continue.                                       "note0388000
         endif.                                             "note0388000
      Within one IDOC: loop through data segments:
      Prepare internal tables for the current material
        LOOP AT T_EDIDD INTO IDOC_DATA.
        Transform from CoreData to Normal Data if necesary
          CASE IDOC_DATA-SEGNAM.
           WHEN 'E1MARAC'.
    *--COMMENTED BY SATISH
             PERFORM MOVE_E1MARAC_TO_E1MARAM USING IDOC_DATA.
           WHEN 'E1MAKTC'.
             PERFORM MOVE_E1MAKTC_TO_E1MAKTM USING IDOC_DATA.
    *--COMMENTES ENDED BY SATISH
             WHEN 'ZBAPI_STUD_SEG'.
              PERFORM MOVE_E1MARAC_TO_E1MARAM USING IDOC_DATA.
                CLEAR I_ZBAPI_STUD.
    Second: Move E1MARAC into E1MARAM
                I_ZBAPI_STUD = IDOC_DATA-SDATA.
    Third: Move E1MARAM back into IDOC-line
                IDOC_DATA-SDATA =  I_ZBAPI_STUD.
                IDOC_DATA-SEGNAM = 'ZBAPI_STUD_SEG'.
          ENDCASE.
          CURRENT_TABIX = SY-TABIX.
          COUNTER-D_IND = COUNTER-D_IND + 1.
          COUNTER-TRANC = COUNTER-TRANC + 2.
          CASE IDOC_DATA-SEGNAM.
             WHEN 'ZBAPI_STUD_SEG'.
            Initialize data - per material
              COUNTER-D_IND = 1.
              FIRST_TRANC = COUNTER-TRANC.
            interpret segment
              ZBAPI_STUD_SEG = IDOC_DATA-SDATA.
              MOVE-CORRESPONDING ZBAPI_STUD TO I_ZSTUD_UEB.
              T_IDOC_ROLLNO-DOCNUM  = IDOC_CONTRL-DOCNUM.
              T_IDOC_ROLLNO-ROLLNO  = I_ZSTUD_UEB-ROLLNO.
              APPEND T_IDOC_ROLLNO.
           ENDCASE.
                if not ZBAPI_STUD_SEG is initial.
                 ZBAPI_STUD-MANDT  = ZBAPI_STUD_SEG-MANDT.
                 ZBAPI_STUD-ROLLNO = ZBAPI_STUD_SEG-ROLLNO.
                 ZBAPI_STUD-FNAME  = ZBAPI_STUD_SEG-FNAME.
                 ZBAPI_STUD-LNAME  = ZBAPI_STUD_SEG-LNAME.
                  INSERT ZBAPI_STUD FROM ZBAPI_STUD_SEG.
                  COMMIT WORK.
                ENDIF.
    *-- ALE ditribution unity : update IDOC status                "note03618
          LOOP AT it_dsp_idocstat.                                  "note036
             LOOP AT IDOC_STATUS WHERE DOCNUM = it_dsp_idocstat.    "note036
                DELETE idoc_status INDEX sy-tabix.                  "note036
             ENDLOOP.                                               "note036
             APPEND it_dsp_idocstat TO idoc_status.                 "note036
          ENDLOOP.                                                  "note036
    *--GENERATING THE IDOC STATUS
      PERFORM HANDLE_ERROR_EXT             " //br40
                  TABLES                                        "
                     IDOC_CONTRL                                "
                     IDOC_STATUS                                "
                     RETURN_VARIABLES                           "
                     T_MERRDAT                                  "
                     T_IDOC_TRANC                               "
                     T_IDOC_ROLLNO          "JH/4.0C/KPr100004993
                  USING                                         "
                     GENERAL_SUBRC                              "
                     NO_APPLICATION_LOG                         "
                     MASSSAVEINFOS         "wk/40c
                  CHANGING                                      "
                     WORKFLOW_RESULT.                           "
                  PERFORM HANDLE_ERROR
                              TABLES
                                 IDOC_CONTRL
                                 IDOC_STATUS
                                 RETURN_VARIABLES
                                 T_MERRDAT
                                 T_IDOC_ROLLNO     "JH/4.0C/KPr100004993
                              USING
                                 APPLICATION_SUBRC
                              CHANGING
                                 WORKFLOW_RESULT.
      SORT T_IDOC_ROLLNO BY ROLLNO. "note 315124
    React on general error
      DATA: I_MERRDAT LIKE MERRDAT.
      IF GENERAL_SUBRC <> 0.
        I_MERRDAT-MSGTY = 'E'.
        I_MERRDAT-MSGID = SY-MSGID.
        I_MERRDAT-MSGNO = SY-MSGNO.
        I_MERRDAT-MSGV1 = SY-MSGV1.
        I_MERRDAT-MSGV2 = SY-MSGV2.
        I_MERRDAT-MSGV3 = SY-MSGV3.
        I_MERRDAT-MSGV4 = SY-MSGV4.
        APPEND I_MERRDAT TO T_MERRDAT.
      ENDIF.
      LOOP AT T_MERRDAT INTO  I_MERRDAT
                        WHERE MSGTY = 'S'  "success
                        OR    MSGTY = 'D'  "dummy
                        OR    MSGTY = 'I'  "Information " //br011097 zu 3.1I
                        OR    MSGTY = 'H'  "dummy       " 4.0
                        OR    MSGTY = 'W'. "warning
        DELETE T_MERRDAT.
      ENDLOOP.
        ENDLOOP.
      ENDLOOP.
    ENDFUNCTION.
    *&      Form  handle_error_ext
    FORM HANDLE_ERROR_EXT
            TABLES
               IDOC_CONTRL                   STRUCTURE EDIDC
               IDOC_STATUS                   STRUCTURE BDIDOCSTAT
               RETURN_VARIABLES              STRUCTURE BDWFRETVAR
               T_MERRDAT                     STRUCTURE MERRDAT
               IDOC_TRANC                    STRUCTURE MATIDOCTRANC
    JH/02.02.98/4.0C  KPr100004993 (Anfang)
               T_IDOC_ROLLNO                 STRUCTURE T_IDOC_ROLLNO
    JH/02.02.98/4.0C  KPr100004993 (Ende)
            USING
               GENERAL_SUBRC                 LIKE SY-SUBRC
               NO_APPLICATION_LOG            LIKE SY-DATAR
               MASSSAVEINFOS                 LIKE MASSSAVINF
            CHANGING
               WORKFLOW_RESULT               LIKE BDWF_PARAM-RESULT.
      DATA FLAG_ERROR_HAPPENED.
      DATA I_MERRDAT LIKE MERRDAT.
      DATA IDOC_INDEX_2_SUBRC LIKE SY-SUBRC.
      DATA AL_HANDLES TYPE BAL_T_LOGH. "//br99
      SORT T_IDOC_ROLLNO BY ROLLNO.                        "note 315124
    React on general error
      IF GENERAL_SUBRC <> 0.
        REFRESH T_MERRDAT.
      i_merrdat-tranc = 0.                              " //br261197
        READ TABLE IDOC_TRANC INDEX 1.     " zu 40b
        I_MERRDAT-TRANC = IDOC_TRANC-FIRST_TRANC_IDOC.          "
        I_MERRDAT-MSGTY = 'E'.
        I_MERRDAT-MSGID = SY-MSGID.
        I_MERRDAT-MSGNO = SY-MSGNO.
        I_MERRDAT-MSGV1 = SY-MSGV1. I_MERRDAT-MSGV2 = SY-MSGV2.
        I_MERRDAT-MSGV3 = SY-MSGV3. I_MERRDAT-MSGV4 = SY-MSGV4.
        APPEND I_MERRDAT TO T_MERRDAT.
      ENDIF.
    DATA: C_TRUE,
          C_FALSE VALUE 'X'.
    If error happened ==> Rollback whole work....
      LOOP AT T_MERRDAT INTO I_MERRDAT WHERE MSGTY NA 'SDHWI'.
        EXIT.
      ENDLOOP.
      IF SY-SUBRC = 0.
        FLAG_ERROR_HAPPENED = C_TRUE.
        ROLLBACK WORK.
      ELSE.
        FLAG_ERROR_HAPPENED = C_FALSE.
      ENDIF.
    Set IDOC status
    two cases:
    single IDOC-processing: ==> error can be written in IDOC status
    package processing ==> anononymous "package error" for all IDOCs
      READ TABLE IDOC_CONTRL INDEX 2.
      IDOC_INDEX_2_SUBRC = SY-SUBRC.
      IF SY-SUBRC = 0.
        IF 1 = 2.                          "//br40
          MESSAGE E051(B1).                                     "
        ENDIF.                                                  "
        CLEAR I_MERRDAT.
        I_MERRDAT-MSGID = 'B1'.
        I_MERRDAT-MSGTY = 'E'.
        I_MERRDAT-MSGNO = '051'.
      ENDIF.
      IF IDOC_INDEX_2_SUBRC NE 0 OR FLAG_ERROR_HAPPENED = C_FALSE.
      Nur in diesen Fällen wird Application Log geschrieben
      Delete all Successes and Dummy records from t_merrdat
      DELETE t_merrdat WHERE msgty = 'S'  "success         " testweise
                       OR    msgty = 'D'. "dummy           "
        LOOP AT T_MERRDAT INTO I_MERRDAT WHERE MSGTY = 'D'.     "
          I_MERRDAT-MSGTY = 'S'.                                "
          MODIFY T_MERRDAT FROM I_MERRDAT.                      "
        ENDLOOP.                                                "
      ENDIF.
      WORKFLOW_RESULT = 0.
      LOOP AT IDOC_CONTRL.
      Set IDOC status
        CLEAR IDOC_STATUS.
        IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
        IF FLAG_ERROR_HAPPENED = C_FALSE.
    Application log
          PERFORM WRITE_APPL_LOG TABLES IDOC_TRANC
                                        T_MERRDAT
                                        IDOC_STATUS
                                 USING  IDOC_CONTRL
                                        FLAG_ERROR_HAPPENED
                                        NO_APPLICATION_LOG
                                        MASSSAVEINFOS
                                        AL_HANDLES.
        idoc_status-status = '53'.       "OK!
        APPEND idoc_status.
    JH/02.02.98/4.0C  KPr100004993 (Anfang)
        Fill Return variables
          CLEAR RETURN_VARIABLES.
          RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
          RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'.
          APPEND RETURN_VARIABLES.
        Verknüpfungseintrag anlegen
          READ TABLE T_IDOC_ROLLNO WITH KEY ROLLNO = IDOC_CONTRL-DOCNUM
                                  BINARY SEARCH.
          IF SY-SUBRC = 0.
            RETURN_VARIABLES-DOC_NUMBER = T_IDOC_ROLLNO-ROLLNO.
            RETURN_VARIABLES-WF_PARAM = 'Appl_Objects'.
            APPEND RETURN_VARIABLES.
          ENDIF.
    JH/02.02.98/4.0C  KPr100004993 (Ende)
        ELSE.
          IF IDOC_INDEX_2_SUBRC NE 0.
    Application Log
            PERFORM WRITE_APPL_LOG TABLES IDOC_TRANC
                                          T_MERRDAT
                                          IDOC_STATUS
                                   USING  IDOC_CONTRL
                                          FLAG_ERROR_HAPPENED
                                          NO_APPLICATION_LOG
                                          MASSSAVEINFOS
                                          AL_HANDLES.
          ELSE.
            IDOC_STATUS-MSGID = I_MERRDAT-MSGID.
            IDOC_STATUS-MSGTY = I_MERRDAT-MSGTY.
            IDOC_STATUS-MSGNO = I_MERRDAT-MSGNO.
            IDOC_STATUS-MSGV1 = I_MERRDAT-MSGV1.
            IDOC_STATUS-MSGV2 = I_MERRDAT-MSGV2.
            IDOC_STATUS-MSGV3 = I_MERRDAT-MSGV3.
            IDOC_STATUS-MSGV4 = I_MERRDAT-MSGV4.
            IDOC_STATUS-STATUS = '51'.     "ERROR!
            APPEND IDOC_STATUS.
          ENDIF.
        Fill Return variables
          CLEAR RETURN_VARIABLES.
          RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
        return_variables-wf_param = c_wf_par_processed_idocs.
          RETURN_VARIABLES-WF_PARAM = 'Error_IDOCs'.
          APPEND RETURN_VARIABLES.
          WORKFLOW_RESULT = 99999.
        ENDIF.
      APPEND idoc_status.
      ENDLOOP.
      IF NO_APPLICATION_LOG IS INITIAL.
        CALL FUNCTION 'BAL_DB_SAVE'                           "//br99
             EXPORTING
                  I_IN_UPDATE_TASK = ' '
                  I_SAVE_ALL       = ' '
                  I_T_LOG_HANDLE   = AL_HANDLES.
           EXCEPTIONS
                LOG_NOT_FOUND    = 1
                SAVE_NOT_ALLOWED = 2
                NUMBERING_ERROR  = 3
                OTHERS           = 4.
        CALL FUNCTION 'BAL_GLB_MEMORY_REFRESH'                "//br99
             EXPORTING
                I_AUTHORIZATION          =
                  I_REFRESH_ALL            = ' '
                  I_T_LOGS_TO_BE_REFRESHED = AL_HANDLES.
           EXCEPTIONS
                NOT_AUTHORIZED           = 1
                OTHERS                   = 2
      ENDIF.
    ENDFORM.                               " handle_error
    Save, check and activate
    11. Assigning the Inbound Function Module to Basic Type & Message Type
    o     Go to T. Code WE57
    o     Click on change, continue, continue and New Entries Button
    o     Enter the Module as IDOC_INPUT_ZBAPI_STUD_MAS
    o     Type as “F”
    o     Basic Type as ZBAPI_STUD_IDOC
    o     Message Type as ZBAPI_STUD_MAS.
    o     Direction as 2
    o     Save and back
    Now Login in 810 client
    12. Assigning the Inbound Function Module in ALE Table
    o     Go to T. Code BD51
    o     Click on continue, New Entries button
    o     Give the Inbound Function Module IDOC_INPUT_ZBAPI_STUD_MAS
    o     Give Input t. as 0 (zero)
    o     Save and back
    13. Creating Process Code
    o     Go to T. Code WE42
    o     Click on Change, New Entries Button
    o     Give Process Code name as ZSTUD, give Description & Save
    o     Select Processing with ALE Services Radio button
    o     Select Processing by Function Module Radio button
    o     Click the ALE Table (arrow Icon) in Identification
    o     Give the Function Module Name ZIDOC_INPUT_ZBAPI_STUD_MAS
    o     Give maximum number of repeats 0
    o     Save and back, back
    o     Select the process code from the list & click on Logical Messages Icon
    o     Give the Message Type as ZBAPI_STUD_MAS
    o     Save & Back, Save & Back, Save & Back
    14. Changing the Customer Distribution model in Receiving system
    o     Go to T. Code BD64
    o     Click on change and Create model view button
    o     Select the model view & click on Environment -> Generate Partner Profiles
    o     Select Transfer IDOC Immediately and Trigger Immediately radio buttons
    o     Click on Execute
    o     You should get a list in green color which means it executed successfully.
    15. Assigning the Process Code to Message Type in Receiving System
    o     Go to T. Code WE20
    o     Expand Partner Type LS
    o     Select the Partner Profile STUD_S
    o     Double click on Message Type ZBAPI_STUD_MAS in Inbound parmtrs.
    o     Give the Process Code as ZSTUD
    o     Click on Trigger Immediately Radio button
    o     Save & Back
    o     Save & Back
    16. Creating the Selection Program (Outbound Program)
    •     Login in client 800.
    •     Go to T. Code SE38
    •     Create a Report Program as   ZSTUD_SEND with the following code
    REPORT ZSTUD_SEND
           NO STANDARD PAGE HEADING.
    TABLES: ZBAPI_STUD.
    DATA: IT_STUD LIKE ZBAPI_STUD OCCURS 0 WITH HEADER LINE.
    SELECTION-SCREEN:BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
    SELECT-OPTIONS: S_ROLLNO FOR ZBAPI_STUD-ROLLNO.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN:BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-H02.
    PARAMETERS:  P_MESTYP LIKE EDIDC-MESTYP,
                 P_RCVPRN LIKE TBDLST-LOGSYS.
    SELECTION-SCREEN:END OF BLOCK B2.
    SELECTION-SCREEN:END OF BLOCK B1.
    START-OF-SELECTION.
      PERFORM CREATE_STUDENT.
      PERFORM CREATE_IDOC.
    *&      Form  CREATE_STUDENT
          sending student
    FORM CREATE_STUDENT.
    SELECT * FROM ZBAPI_STUD
       INTO TABLE IT_STUD
       WHERE ROLLNO IN S_ROLLNO.
    ENDFORM.                    " CREATE_STUDENT
    *&      Form  CREATE_IDOC
          IDOC Creation
    FORM CREATE_IDOC.
    DATA : IMAS_DATA LIKE EDIDD OCCURS 10 WITH HEADER LINE,
           IMAS_CON LIKE EDIDC OCCURS 10 WITH HEADER LINE,
           ICOM_CON LIKE EDIDC OCCURS 10 WITH HEADER LINE.
    IMAS_CON-RCVPRT = 'LS'.
    IMAS_CON-RCVPRN = P_RCVPRN.
    IMAS_CON-IDOCTP = 'ZBAPI_STUD_IDOC'.
    IMAS_CON-MESTYP = P_MESTYP.
    IMAS_CON-DIRECT = 1.
    APPEND IMAS_CON.
    LOOP AT IT_STUD.
      IMAS_DATA-SEGNAM = 'ZBAPI_STUD_SEG'.
      IMAS_DATA-SDATA = IT_STUD.
      APPEND IMAS_DATA.
    ENDLOOP.
    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
         EXPORTING
              MASTER_IDOC_CONTROL            = IMAS_CON
            OBJ_TYPE                       = ''
            CHNUM                          = ''
         TABLES
              COMMUNICATION_IDOC_CONTROL     = ICOM_CON
              MASTER_IDOC_DATA               = IMAS_DATA
       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.
    ENDIF.
    COMMIT WORK.
    LOOP AT  ICOM_CON.
      WRITE :/ 'IDOC: ', ICOM_CON-DOCNUM, 'CREATED SUCCESSFULLY'.
    ENDLOOP.
    ENDFORM.                    " CREATE_IDOC
    17. Transferring the student records from 800 to 810 client
    •     Execute Report Program   ZSTUD_SEND
    •     Give the Range of Roll Nos to Transfer
    •     Give Message Type as    ZBAPI_STUD_MAS
    •     Give Receiver Logical system as   STUD_R
    •     Execute
    •     You should get the IDOC Number
    •     Take the IDOC Number and go to T. Code WE05 & Execute
    •     In Outbox you can see the IDOC Status
    •     Select the status record in left side window
    •     Double click on the Status record in right side window
    •     You can see the Control Record, Data Record and Status Records for that IDOC
    •     If the ICON is green and the status code is 3, it means the IDOC is passed to PORT Successfully.
    Now Login in 810 client
    •     Go to T. Code WE05 & Execute
    •     You can see the status record in left side window
    •     If the status no is 53 and color is green, it means the IDOC is Posted to Application successfully.
    •     You can see the Log Information by double clicking on the status record in right side window.
    •     Now in left side window, you can see the Control Record, Data Record & Status Record of the IDOC
    •     Now go to T. Code SE16
    •     Give the table name ZBAPI_STUD & press F7
    •     See the contents of the table
    •     The table is updated with the students records transferred from 800 client with our selection program.
    Reward if useful
    Thanks
    Jagadeesh.G

  • QM Usage decision posting transmitting via IDoc MBGMCR

    Dear QM gurus,
    I have a question related to UD distribution respectively distribution of material document created once UD is recorded; the distribution is IDoc-based (message MBGMCR). My idea is to create output message (e.g. ZUDD) for ALE trans. medium and logical system LS but don´t know what processing program / routine should be used. The distinction of material document created from UD is a transaction / even key WQ. The IDoc handling will be done via XI, so how to trigger output message from R/3? The purpose is to distribute information of stock posting (from initial QI to UU or BL) to external WMS system.
    Thanks for your thoughts and comments.
    Best regards,
    Pavel

    As moderator I deleted several replies to this message.  We are going to have a do over here.
    First -  a reminder to all that bumping up a discussion is typically frowned upon.  If the issue is still a problem, add a comment indicating what you have done, what further research you have tried, what things you have ruled out, etc... We assume that if this is a current, ongoing problem, you are working daily to resolve it so there must be something to add.
    Pavel - you may not have gotten any responses because maybe the question wasn't clear.  It could also be that there is no one here with experience in the area you are looking at.  I'm not that familiar with the integration of QM to external WMS.
    Out of everything you wrote, I gather that your real question is "The IDoc handling will be done via XI, so how to trigger output message from R/3? ".
    That really wouldn't be a QM question but more a development or BASIS question I think.  That part of the process is pretty much totally outside of the QM module I think.  But maybe I'm not getting your question.
    Craig

  • ALEREQ idoc type from PI system

    Hi,
         I have to change the vendor data from Inbound idoc which will be coming from PI system.
    but, to get the inbound idoc for vendor we have idoc type as CREMAS05 and message type as CREFET
    But,at PI side to send the vendor data, they see the idoc type as ALEREQ01 for message type as CREFET.
    Kindly provide me the resolution.
    Thanks in Advance.

    hi
    yes u can export an idoc from r/3 to a legacy system.
    the brief outline is as follows:
    1. set up an rfc connection. it has to be 'T' type in t-code sm59
    configure the saprfc.ini file if on windows based os. if on unix based os configure rfcexec.c to have the login details of apo system.
    2.set up logical systems( at least 1 each for r/3 and apo) using T-code SALE.
    3.assign clients to the logical sytems using T-code SALE..
    4.create ports using tcode we20.
    5. create idoc segments using we30 and release.
    6. create idoc type using we31.
    7. create message type using we81.
    8. assign message to idoc using we82.
    9.build a customer model using tcode bd64.
    10. create an outbound process code usint tcode we41.
    it will help if you specify your idoc that you want to use- for vendor, customer and material there are predefined distributions and idocs.
    Thanks.

  • Ale / Idoc between two different servers

    Hi All,
    In my scenario i am working on two different servers in which distribution of idoc is carrying out.
    (Before this i have worked on same server scenarios with different clients.)
    But present scenario i am working with two diferent servers,
    like,
    i am having 100 client in server A (sender system) and 700 client in server B(receiver system),
    i have created all the basic steps like logical systems in both systems,
    Assign logical systems to clients in consecutive servers,
    RFC's and ports.
    while creating message type under model view in server A client 100(sender system ) i can find only 100 client's logical system name, i cannot find the 700 clients logical system name.
    due to both clients are in different ip address , does we need to transfer the logical system assign ment transport request to other client.
    regards,
    Mohd.

    Hello abdul  ,
    When you configure a logical system for example the same system with a different client (700) it should be configured in the source system (Client 100).
    In this way when you can send the relevant IDOCs via the ALE according the model view (BD64) ,the source system (100) knows that the target is the  system with the client 700 .
    (There is a generic RFC in the background process : INBOUND_IDOC_PROCESS).
    Sender :  system_100
    Receiver:system_700
    Message type : MATMAS
    Also in order to accept the relevant Idocs in the system with client 700,you must configure a partner profile that will contain in inbound parameters the relevant message type (MATMAS).
    I hope it is more understood .
    Thank you,
    Boaz

  • How to extend an existing IDOC!

    tell me the steps to extend the existing IDOC !
                                                                   Thanks

    1>we31(create new segments with fields u want to populate)
    2>we30(create an extension idoc type).in we30 u will get to radio buttons.1>basic type 2>extension.click on the extension and then copy the basic type.Now will get all the segmnts .Now add the new segments under the parent segement which needs to be extended.
    3>attach the extended idoc type to basic type and message type to tcode WE82.
    4>Now u have to search for an exit where u have to write ur code in order to populate the fields which u have extended.Basically u will write in the Function module.Make sure u r writing in the correct exit.Evry messagetype will have a function module.
    5>create a project in cmod and activate the function exit.
    IDOC EXTENSIONS
    Letâs first look at the concept of IDOC extension. SAP delivers Basic IDOC types such as DEBMAS02, MATMAS02, ORDERS02, and WMMBID01. By extending the Basic IDOC type, you are actually creating a new IDOC type. You create a new segment with the additional fields. This new segment has to be associated with one of the existing Basic IDOC segments. Then you create a new extension type, which is associated with the Basic IDOC type. This results in a new IDOC type. In order for ALE function modules to relate to this new IDOC type, the IDOC type is linked to the corresponding message type. Note that you should not add fields to existing segments but should create a new segment and associate it with an existing segment. This, in a nutshell, is the process of creating IDOC extensions.
    In our example, the Basic IDOC type DEBMAS02 is used to communicate Customer Master data to the SAP Customer Master application. Even though the application has a screen to enter and store a contact personâs business address (see Figure 1), DEBMAS02 does not have a segment or fields that communicate the contact personâs business address. If your business requires that this business address be communicated to the other system through the ALE interface for Customer Master, then you have to extend the DEBMAS02 IDOC type, and enhance the corresponding ALE function module.
    In DEBMAS02 the contact person fields are present in segment E1KNVKM and the business address of the contact person is stored on the SADR SAP table. You need to create a new segment, Z1SADRX, that is associated with E1KNVKM. This will be done in the process of creating an extension type ZDEBMASX. This extension type will then be associated with a new IDOC type, ZDEBMASZ. IDOC type ZDEBMASZ will be linked to message type DEBMAS for Customer Master. The final step in the IDOC extension process is to check the new objects. This check also verifies the structural integrity of the IDOC type. Letâs look at each of these steps in more detail.
    1. Create an Extension Type and a New Segment.
    First, letâs determine the fields on table SADR that you are going to provide for in the new segment Z1SADRX. You need fields for name, street, city, region, and country to give the business address of the contact person. You also need fields for the address number. ADRNR is a field in SAP tables such as SADR that uniquely identifies the address of an entity. This field is cross-referenced from other tables to the SADR table to obtain the full description of the address. Because this is an IDOC type for master data, the first field of the new segment will be MSGFN. The message function field informs the receiving system of the action to be taken for that particular segment. In the code that you write for populating the new segment, the value of the message function is the same as that of the parent segment E1KNVKM. In all, you will have 12 fields in segment Z1SADRX (see Table 1).
    To create an extension type and new segment:
    •     Use transaction WE30 or from WEDI go to Development -> IDOC types.
    •     Enter ZDEBMASX for Object Name.
    •     Choose Extension Type.
    •     Click on Create.
    •     You will see a pop-up screen. Choose Create New, and enter a description. For version 4.x, enter DEBMAS02 in the Linked Basic Type field. Enter.
    •     You will see a screen with ZDEBMASX and its description in the first line. Click on this line, and press Create. For version 4.x, expand the tree of segments, and place the cursor on E1KNVKM.
    •     You will see a pop-up screen. Enter E1KNVKM as the reference segment. Enter.
    •     For 4.x, press Create after placing the cursor on segment E1KNVKM.
    •     You will see a line appear with E1KNVKM hierarchically below ZDEBMASX, with a description "Customer Master contact person (KNVK)."
    •     Click on this line and press Create. You will receive a message indicating that the new segment being created will be a child segment of E1KNVKM. Enter. A pop-up box appears for the new segment.
    •     Enter Z1SADRX as the segment type, 1 for Minimum, 1 for Maximum. Leave Mandatory segment unchecked. These entries imply that there is only one Z1SADRX segment for every occurrence of the E1KNVKM segment, and also that this segment is not mandatory. Note that if the parent segment is not mandatory, then the child segment should not be mandatory, because this could result in a syntax error during the creation or processing of the IDOC.
    •     For 4.x, you must first create the IDOC segment Z1SADRX (Iâll explain why in a moment) from the menu path WEDI -> IDOC -> Development -> IDOC Segment.
    •     Click on Segment Editor.
    •     On the next screen, click on Create.
    •     Enter a development class for the object. Enter.
    •     This will take you to the screen for segment definition. Enter a description for the segment. Enter the field name, data element, and the data element documentation name. In most cases, all three fields may have the same values. If you are using a field in the segment that is not present in the ABAP/4 data dictionary, you must first create the domain, data element, field, and appropriate documentation before using it in the new segment.
    •     Enter these three columns for all 12 fields. Save.
    •     Click on Generate/Activate, F3 to step back.
    •     From screen Maintain Segment, go to Segment Type -> Release. A checkbox now appears beside the segment definition Z1SADRX (see Figure 2). Check this box. Save.
    •     Save again to store the descriptions of the segment, F3 to step back.
    •     Save the extension type.
    It is possible to have several new segments with relevant Basic IDOC type parent segments in a single extension type. However, you can form only one IDOC type based on a single extension type.
    2. Create an IDOC Type.
    The next step is to create an IDOC type by associating the extension type that you created with the Basic IDOC type. This is a simple process:
    •     From transaction WE30 or WEDI go to Development -> IDOC Types.
    •     Enter ZDEBMASZ for Object Name.
    •     Click on IDOC Type.
    •     Click on Create.
    •     Enter DEBMAS02 for Basic IDOC type.
    •     Enter ZDEBMASX for extension type.
    •     Enter a description.
    •     Enter.
    •     You will see a display of the composite IDOC type with all segments, including Z1SADRX (see Figure 3).
    It is possible to associate only one extension type with a Basic IDOC type for a given IDOC type. However, you can have multiple new segments in an extension type.
    3. Link IDOC Type to Message Type.
    The next step is to link the new IDOC type to its corresponding message type. This is important, because this relationship is referenced in the partner profile parameters where you specify the message type and IDOC type to be used for that particular representative system. To link the message type:
    •     Use transaction WE82, or from WE30, go to Environment -> IDOC Type / Message Type, or from WEDI go to Development -> IDOC Type -> Environment Î IDOC Type / Message Type.
    •     Click on Display <-> Change.
    •     Click on New Entries.
    •     Enter DEBMAS for message type.
    •     Enter DEBMAS02 for Basic IDOC type.
    •     Enter ZDEBMASX for extension type.
    •     Enter your SAP R/3 release number for Release.
    •     Save.
    This data is stored on the EDIMSG table and is accessed by several ALE processes to relate the message type to the IDOC type.
    4. Check the IDOC Type.
    Before checking the IDOC type for consistency, it is important to perform another step that releases the extension type to the IDOC type:
    •     From WEDI go to Development -> IDOC Types -> Extras -> Release Type, or from transaction WE30 go to Extras -> Release Type.
    •     For the Object Name ZDEBMASX and radio button Extension Type, click Yes.
    •     The extension type has now been "released."
    You canât edit the extension type once itâs released. To cancel the release for further editing or deactivation, go to WE30 Î Extras Î Cancel release. The final step in the IDOC extension process is checking the validity of the IDOC type:
    •     From transaction WE30 or WEDI go to Development -> IDOC types.
    •     Enter ZDEBMASX for Object name.
    •     Click on Extension Type.
    •     From the Development Object menu select Check.
    •     Repeat the operation for IDOC type ZDEBMASZ.
    •     A check log will be generated for each run with details of correctness or errors (see Figure 4).
    In some situations it is possible to receive errors during the check process, especially segment length errors. The incorrect IDOC segment can be repaired and corrected by executing program RSEREPSG. This program checks the formal consistency and repairs incorrect segments. In test mode it will generate a log of formal correctness for the specified segment only. For the program to repair segments in normal mode, the underlying IDOC structures (DDIC structures) must be active. This program rectifies the lengths of the DDIC structures and not the fields themselves. RSEREPSG can also be used to change the person responsible for the object and the release flag.
    Menu paths may vary slightly depending on the release/version of SAP R/3, but the procedures and the principles are the same.
    ALE FUNCTION MODULE ENHANCEMENTS
    Having extended the IDOC type to contain additional fields for an inbound or outbound application, you now want to enhance ALE function modules for populating the additional segment on the outbound or applying the additional segment data on the inbound application. It may be necessary to enhance an ALE function module even in situations where an IDOC extension has not been performed if the IDOC data being passed to and from the application requires modifications. The following approach applies to both situations.
    The core working code for ALE processes for a given application area is always encapsulated in ABAP/4 function modules. These function modules are associated with such control information as message types and process codes. So the ALE process checks this control information and derives the name of the function module to invoke for that particular IDOC processing from certain database tables. These function modules contain objects known as customer functions, which can be considered SAP Enhanced user exits. A function module is called at a particular point during the processing of the main program or function module, and it can be used to influence data processing at that point by adding code to the customer function. The customer function behaves like a normal function module and has import and export parameters, tables (internal tables) statement, and exception processing. Unlike a conventional user exit, customer functions give you the ability to modify only data available to you by the function moduleâs parameters and internal tables. While most ALE/EDI function modules are supported by customer functions, there are ALE/EDI processes that still use conventional user exits. There are a few ways to determine which function module to enhance for a given message type/process code:
    •     For master data distribution, from SALE go to Extensions -> Master data distribution -> Setup additional data for message types. Search for message type DEBMAS in this example. You see an entry for DEBMAS associated with function module MASTERIDOC_CREATE_SMD_DEBMAS. This data is stored on table TBDME. The function module names for all master data message types follow this pattern: MASTERIDOC_CREATE_SMD_messagetype. This function module calls another function module of name MASTERIDOC_CREATE_DEBMAS or MASTERIDOC_CREATE_messagetype. Search for the words customer function, and you find several hits that can be used to add code to the function module.
    •     From WEDI got to Control -> Inbound process codes -> Inbound with ALE service -> Processing by function module (transaction WE42), or from WEDI go to Control -> Outbound process codes -> Outbound with ALE service -> With function module (transaction WE41). There will be function modules associated with the process codes. For inbound, the function modules usually follow this pattern: IDOC_INPUT_messagetype: for example, IDOC_INPUT_CHRMAS for inbound characteristics master.
    •     Use transaction WE57 or from WEDI go to Development -> Message/Application Object. The entries list the function module, Business Object, message type, and IDOC type that are used for inbound ALE/EDI interfaces.
    Customer functions are not specific only to ALE and EDI but also to all programs/modules in SAP R/3. Customer function is a SAP enhancement component; the other two types are menu and screen enhancements.
    All customer function exits are maintained in SAP enhancements and are found by using transaction SMOD. After executing transaction SMOD, pull down (F4) on the enhancement name field, and execute again. This provides you with a list of all SAP enhancements available. SAP enhancements are grouped by development class pertaining to an application area. Choose Application development R/3 SD master data distribution for development class VSV to lead to a screen that lists VSV00001 as an enhancement (see Figure 5). Press Component +/- to display its function exit components. There are four possible components listed, all of which are function exits (and are function modules) that are called from the ALE function modules in the form Call Customer Function Î001â. This is a special occurrence of the ABAP statement Call. Go to item Exit_SAPLVV01_ 001, which you need to enhance for the Customer Master outbound example of an IDOC extension. In the ALE-function module MASTERIDOC_CREATE_DEBMAS, the statement CALL Customer Function 001 is translated in the background to call component EXIT_SAPLVV01_001. Although this function exit can be edited using transaction SE37, you will use a simpler approach.
    When you use SAP enhancements and their components, you manage them with an SAP object known as a project, which is like an envelope containing the selected enhancements and their components. A project can be used to control the execution of components and to transport them to other clients and instances in SAP. Basically, the process involves creating a project, including enhancements and components that are to be enhanced, editing the components, and then activating the project. The following process creates a project for our example Customer Master IDOC extension:
    •     Execute transaction CMOD.
    •     Enter name of project, say CSTMAST1.
    •     Click on Create.
    •     Enter a description of the project.
    •     Save.
    •     Click on SAP Enhancements.
    •     Enter VSV00001 for Enhancement.
    •     Save.
    Once youâve created the project, edit the function exit components and activate the project. Remember that the code in the function exit enhancement will execute only if the project is activated. In fact, this is a convenient SAP enhancements feature, whereby the work in progress (developing code in the customer function) will not affect users of that application. When the code is completed, the project can be activated so the enhanced functionality takes effect. It can also be deactivated for maintenance.
    As mentioned earlier, customer functions (function exits) are embedded in ALE function modules and can be used to influence the creation and modification of IDOC data on an outbound application or to post additional or modified IDOC data to an inbound R/3 application. Function exits are similar to regular function modules, with import/export parameters, tables (internal tables), and exceptions.
    The two important factors to consider while developing the customer function are:
    1.     The point in the ALE function module where the function exit occurs
    2.     The data made available by the customer function that can be modified or posted to the R/3 application, based on the direction.
    Because some function modules have several customer functions, it is critical to choose the function exit best suited for that particular enhancement. Do not attempt to perform activities that the function exit is not designed for. The importance of this point is illustrated by the following description of enhancing function modules for outbound and inbound ALE interfaces.
    Outbound interfaces. In an outbound ALE interface you use function exits (customer functions) to populate additional segments created by an IDOC extension or to modify the existing IDOC data segments as per business requirements. Previously, you identified that enhancement VSV00001 has a component EXIT_SAPLVV01_001 (function exit), which can be used for populating the additional data segment Z1SADRX that you created in the IDOC extension ZDEBMASX (IDOC type ZDEBMASZ, based on Basic IDOC type DEBMAS02). You also learned that the ALE function module that calls this function exit is MASTERIDOC_CREATE_DEBMAS, which has a statement Call Customer Function 001.
    Browse the function module MASTERIDOC_CREATE_DEBMAS using transaction SE37. You will find that this customer function is invoked for every segment of IDOC type DEBMAS02. In fact, the function exit is called soon after the creation of an existing segment has been populated with data and appended to the IDOC data table (internal table). Also, the function exit is exporting the message type, IDOC type, and the segment name and is importing the IDOC extension type. It is also passing the IDOC data internal table. This indicates that the ALE function module is allowing you to populate additional segments for every existing segment and modify the existing segmentâs data.
    Letâs write ABAP/4 code to accomplish the task of populating IDOC segment Z1SADRX with a contact personâs business address:
    •     From SE37, display function module MASTERIDOC_CREATE_ DEBMAS.
    •     Find Customer Function 001.
    •     Double-click on 001.
    •     The function EXIT_SAPLVV01_001 will be displayed.
    •     Double-click on INCLUDE ZXVSVU01.
    •     You will be asked to create a new include object. Proceed as desired.
    •     Enter code (as in Listing 1).
    •     Be sure to perform a main program check (Function Module -> Check -> main program) and extended program check (Function module -> Check -> Extended check).
    Now that you have extended the IDOC and enhanced the ALE function module based on the requirements for the contact personâs business address on the Customer Master, letâs test the interface. You should create a logical system and define a port for this interface. You should also configure the Customer Distribution Model to indicate that message type DEBMAS is being distributed to this logical system. The only difference in configuration between a regular outbound ALE interface and an enhanced one is the partner profile definition. While maintaining the outbound parameters of the partner profile, make sure the IDOC type is ZDEBMASZ. The fields for Basic IDOC type and extension type are automatically populated with DEBMAS02 and ZDEBMASX, respectively.
    To maintain the contact personâs business address of a customer:
    •     Use transaction BD12 or from BALE go to Master Data ->Customer -> Send and send that Customer Master record by executing the transaction after filling in the relevant fields such as customer number, message type, and logical system.
    •     Use transaction WE02 or WE05 to verify the IDOC created. You should see the new segment Z1SADRX populated with the correct data.
    With SAP releases below 4.5B, you cannot capture changes to business address through change pointers because a change document object is not available for capturing business address changes, and also earlier releases have not been configured to write change documents for a contact personâs business address. If you would like this functionality, you can either create change document objects, generate function modules to create change documents, and perform ALE configuration to tie it in, or make a cosmetic change to the contact person screen data while changing the contact personâs business address so that it gets captured as a change to the Customer Master. Subsequently, the ALE enhancement that you performed captures the contact personâs business address.
    Inbound interfaces. The process for enhancing inbound ALE interfaces is similar for outbound, with a few exceptions; specifically in the coding of customer functions (function exits) for the ALE/EDI function modules.
    The first step is to create an IDOC extension for the specific Basic IDOC type by adding new segments at the appropriate hierarchy level: that is, associated to the relevant existing segment. Populate the data fields on the new segments with application data by the translator or external system/program before importing them into the R/3 System. Then, find the ALE function module that is invoked by the inbound processing. By browsing through the code or reading the documentation on the function exit enhancements using the SMOD transaction, identify the function exit in which you should place your code. The technique used in the code to post the additional or modified IDOC data to the application can vary based on the application rules and requirements, the data available at that point in processing, and the application function modules available to update the application tables. It is important to search first for application modules that process the data and see if they can be called within the function exit. If the additional data in the extended segments in specific to a custom table or resides in nonkey fields of a single or small set of tables, you may be able to update it directly by SQL statements in the function exit. This approach should be carefully evaluated and is certainly not highly recommended.
    Another option is to use Call Transaction from within the function exit to process the additional data. For example, in the case of message type WMMBXY for inbound goods movements from a warehouse management system, the standard interface creates batches for materials, but does not update its characteristics. In such a case, you can use Call Transaction MSC1 to create the batch and assign characteristic values to it from within the function exit provided.
    Error handling is a very important consideration when making enhancements to inbound ALE/EDI objects. In ALE and EDI inbound processing, workflow is used for handling errors at different levels such as technical and application. If workflow has been configured for the interface, the error messages and workflow items flow to the inbox of the named recipient(s).
    It is also critical to enhance the workflow that handles notifications of the inbound ALE/EDI process. In most scenarios this is not a very difficult task because SAP lets you influence the workflow parameters and messages in function exits (customer functions). You typically do this using flags and message codes to trigger certain workflow actions. If you conform to the status codes and flags stipulated for workflow processing, the enhancement could be error-free and seamless. In the case of an inbound IDOC with an extension, you should populate the EDIDC fields IDOCTYP (new IDOC type) and CIMTYP (extension type) accordingly.
    IDOC REDUCTIONS
    When distributing or communicating master data to other systems, the volumes of data transmitted over communication lines may be large, resulting in performance problems and/or excessive usage of resources such as disk space and bandwidth. Careful scrutiny of the master data Basic IDOC type may reveal that many of the segments are redundant or are simply not being used. If this is true, then the basic IDOC type is a candidate for a technique known as IDOC reduction. The R/3 System provides the ability to eliminate unused segments and irrelevant segment fields from the Basic IDOC type. This procedure is relatively simple and easy to implement. IDOC reduction is available for only a few message types such as DEBMAS, CREMAS, GLMAST, MATMAS, and certain POS messages.
    When performing an IDOC reduction, a new message type is created based on an existing message type. The IDOC segments associated with that message type are proposed for editing. Mandatory segments of the IDOC type canât be excluded. By default optional segments are excluded, but you can choose to include an optional segment and only certain fields in the optional segment. If you have extended the Basic IDOC type and created a new IDOC type associated with a corresponding message type and you are creating a new message type (view) based on it for purposes of IDOC reduction, then the enhanced IDOC type is presented for editing along with the additional segments.
    Letâs use the Vendor Master IDOC type CREMAS01 as an example to demonstrate IDOC reduction. Message type CREMAS is used for communicating Vendor Master data to other R/3 or external systems. If you browse the IDOC type CREMAS01 youâll see that it has 10 segments, with E1LFA1M being a mandatory segment (see Figure 6). To reduce this IDOC type:
    •     Use transaction BD53 or from SALE go to Distribution scenarios -> Master data distribution -> Reduce IDOC type for master data.
    •     Enter ZCREMS for View (message type).
    •     Click on Create.
    •     You will see a pop-up box. Enter CREMAS in the Derived From field. Enter.
    •     Enter a description. Enter.
    •     You will see a list display with segment E1LFA1M in green and a * symbol. The symbols used in IDOC reduction are: * for mandatory, 1 for selected, - for deselected, x for core selected, and the Î.â for core not selected. The corresponding elements are highlighted in green, white, red, violet, and gray, respectively.
    •     Expand all trees. You will see nine other segments in red.
    •     Place your cursor on the E1LFB1M segment for company code data and click on Select. It turns white with a 1 symbol.
    •     Double-clicking on it will display a list of fields. You can select fields that you require (see Figure 7).
    •     Note that if a child segment is selected, its parent is also selected automatically in order to maintain the hierarchical integrity.
    •     After youâve selected the segments required and its fields, save.
    •     From the main screen, click on Activate.
    Activating the new message type ZCREMS will turn on the message type change pointer generation on a particular client. While creating a reduced IDOC type message is a client-independent activity, activation is client-dependent. An entry is created in table TBDA2 for a specific message type in a specific client and is activated. To delete this message type, you need to deactivate it from all clients on that instance. These message types are transportable.
    Now that weâve created a new message type for a reduced IDOC type, letâs build the rest of the ALE configuration to work the interface with the following steps:
    •     Define a logical system to represent the other R/3 or external system.
    •     Configure the Customer Distribution Model to send message ZCREMS to this logical system.
    •     Define a port, if needed, for this system.
    •     Define a partner profile based on the logical system and maintain its outbound parameters. Make sure to use ZCREMS as the message type and CREMAS01 as the IDOC type.
    •     Use transaction BD14 or execute program RBDSECRE or from BALE go to Master Data -> Vendors -> Send. Then, to specify a vendor or range of vendors and enter message type, go to ZCREMS and its target logical system.
    •     Execute.
    You can also capture changes to Vendor Master data and create IDOCs by executing transaction BD21 or program RBDMIDOC. Use transaction WE02 or WE05 to view the IDOCs created as a result of the preceding test. Notice the segments populated and the basic segments that are absent due to the reduction. You will find that the fields deselected from the segments have a value of /. This is equivalent to a null value. Eliminating segments may result in saving resources, while eliminating fields may not, unless the data is compressed. Also, if you look at the master data ALE function modules for these few message types, youâll see that a function module IDOC_REDUCTION_FIELD_REDUCE is called for every segment being populated. This in itself may be an overhead. It is important to weigh the pros and cons before implementing IDOC reduction. Of course, in certain cases, it may be a necessity for adjustment of data.
    Enhancing ALE/EDI and IDOC extensions and conducting IDOC reductions is fairly simple. However, before proceeding with these tasks, you must carefully research the many options available in ALE and develop the best design for your business scenario.
    IMPLEMENTING BAPI WITH ALE: A SAMPLE SCENARIO
    Business application programming interfaces (BAPIs) provide an interface to Business Objects in the R/3 System. Business Objects are based on object-oriented technologies and represent an application objects, such as an address or a sales order. This next section prototypes an ALE interface that incorporates BAPI methods. When weâve finished, you should have a good idea of how easy it is to incorporate BAPIs with ALE and of how beneficial leveraging the 1000+ BAPIs available in the R/3 System can be when you want to interface with R/3 application objects.
    Letâs start with a brief overview of SAP Business Objects and BAPIs.
    SAP Business Objects. An SAP Business Object envelopes R/3 data and business processes while making the details of data structure and access methods transparent to a user interfacing with it. It consists of four layers: kernel, integrity layer, interface layer, and access layer. The kernel represents the R/3 data and its attributes. The integrity layer represents the business logic of the object and contains the business rules that govern the values of the kernel. The interface layer describes the interface mechanisms to external applications. BAPIs belong to the interface layer. The access layer represents communication methods, such as COM/DCOM, RFC, and CORBA.
    SAP Business Objects and their details are stored in the Business Object Repository in the R/3 System.
    BAPIs. BAPIs are "methods" of SAP Business Objects and represent their interface layer. BAPIs are essentially function modules in the R/3 System that are capable of invoking remote function calls (RFCs) for the purpose of communicating data through the function moduleâs import/export parameters and internal tables. BAPIs do not invoke screen dialogs. Like blackbox technology, BAPIs do not require the programmer or user to know the coding and implementation details of the interface to the Business Object. The user simply invokes the BAPI with its appropriate parameters and values in order to accomplish a task such as getting a list of materials from an external system or sending a list of contact person details to another system.
    BAPIs can be executed synchronously or asynchronously while using the ALE communication layer for exchanging data. Typically, with asynchronous BAPI communications, an ALE IDOC is used to distribute the data. As we will learn in the following prototype, the ALE distribution model has to be configured in order to use the appropriate BAPI methods for the RFC destination that provides a gateway to the external system (R/3 or other). For this type of communication, an ALE IDOC interface must exist. If a particular BAPI (SAP-delivered or user-written) does not have an ALE IDOC interface, the interface can be generated using certain R/3 tools and procedures.
    BAPIs are fast becoming the communication standard for exchanging data between business systems (including R/3). SAP Business Objects conform to Open Application Group (OAG) standards, and BAPIs support the COM/DCOM and CORBA guidelines. ALE and BAPIs is the strategic direction for all SAP interface technologies and will replace SAPâs traditional techniques in the future.
    A BAPI/ALE PROTOTYPE ÷ CONTACT PERSON DETAILS
    In the previous section, we learned how to enhance ALE functionality using the example of Customer Contact Person details. We extended the IDOC and enhanced a customer function with a few lines of ABAP code to achieve the additional functionality of distributing contact person details. While this was an exercise to learn IDOC extensions and customer-function enhancements, we can prototype a BAPI/ALE interface in this section that accomplishes the same purpose ÷ the distribution of contact person details. In release 4.5 of the R/3 System, message type ADR3MAS and IDOC type ADR3MAS01 have been provided to distribute contact person details with the aid of a BAPI method. The steps weâll walk through in a moment will illustrate the ease with which we can integrate BAPIs with ALE to get an interface up and running for many standard business scenarios or specialized cases that were not supported by ALE prior to the advent of BAPIs.
    The ADR3MAS is considered to be a master data message type because it complements business master data, such as customer and vendor master. It is now supported by change document functionality, implying that change pointer mechanisms can be used to capture and then distribute changes occurring to contact person data using ALE IDOCs. The function module that accesses the R/3 data is a BAPI. In the R/3 System, contact person address is a business object. If we search the Business Object Repository (via transaction SWO1) with the keyword "address," for example, we will find business object BUS4003 under Cross-Application Components -> General Application Functions -> Address Management -> BUS4003: Address of a person in a company. This is the business object that pertains to our scenario, and a drill down on it reveals the details of the object, including its methods (see Figure 8). The method that would be of interest to us is "AddressContPart.SaveReplica." For your information, the corresponding BAPI function module is BAPI_ADDRCONTPART_ SAVEREPLICA in the function group SZAM.
    Having gathered this information, Letâs build the outbound interface:
    •     Create a logical system (via transaction SALE) to represent the receiver system.
    •     Configure the distribution model. From transaction SALE, use option Maintain Distribution Model to create a model view for this scenario. Specify the sender system (the base logical system for the client you are working in, such as the logical system that has been assigned to that client) and the receiver system (the logical system). After positioning the cursor on the receiver system, click on Method and enter AddressContPart in the Object Name field on the panel that pops up. Also enter SaveReplica in the Method field on the pop-up panel. Enter and save the Distribution Model (see Figure 9).
    •     From transaction WE20, create a partner profile based on the logical system for the interface. Use message type ADR3MAS and IDOC type ADR3MAS01, with an appropriate port.
    •     Activate the change pointer for message type ADR3MAS. From SALE go to Set up Data Distribution -> Master Data Distribution -> Activate Change Pointers. Ensure that change pointer generation is active at the general level as well.
    Now that weâve completed the configuration, letâs test the interface. The purpose of this test is only to create outbound IDOCs. Appropriate settings, such as port definitions and RFC destinations, can be made as required for purposes of communicating the IDOCs to the external system (or other R/3 system).
    From the Customer Master or Vendor Master screens, create or make changes to contact person address. This should result in the creation of change pointers. (Check table BDCPS for change pointer entries with message type ADR3MAS.) After this, from transaction BALE go to Periodic Processing -> Process Change Pointers, enter ADR3MAS as the message type, and execute the transaction. This should result in a message indicating the number of master IDOCs created. Use transaction WE05 to display the IDOCs.
    THE ALE AUDIT
    In this section letâs take a look at the prototyping of the ALE Audit. ALE Audit is a powerful mechanism for verifying the success of ALE transactions/messages sent to another system. As you will see, implementing ALE Audit is not only easy but also very beneficial, because it facilitates the monitoring and tracking of transactions across systems while providing an entry point into error handling.
    Program RBDSTATE is used for audit confirmation of ALE transactions between two R/3 systems; in other words, it indicates the success or failure of the ALE transaction on the target system. The program reports the status of the transaction on the target system back to the sending system. This process also serves as an interface itself from the target system to the sender system, facilitated by message type ALEAUD. In the following section, weâll look at the various steps needed to set up ALEAUD and execute program RBDSTATE.
    SETTING UP ALEAUD and EXECUTING PROGRAM RDBSTATE
    Letâs consider two different R/3 systems with base logical systems BK1CLNT010 (sender system) and BK2CLNT020 (target system). Assume that you are distributing characteristics master (message type CHRMAS) from BK1CLNT010 to BK2CLNT020. When you send CHRMAS02 IDOCs from BK1CLNT010, their status is 03 (data passed to port OK) if they were successfully externalized from the sender system. If the IDOCs were received and processed successfully on the target system, the status of those IDOCs on the target system is 53 (application data posted). Remember that you have to create a partner profile for BK1CLNT010 on the target system in order to receive the CHRMAS messages. The inbound parameters of BK1CLNT010 partner on the target system have CHRMAS as the message type and CHRM as the process code.
    You now need to configure BK2CLNT020 to send ALEAUD messages to BK1CLNT010, the sender system. And you also need to configure BK1CLNT010 to receive those messages in order to update the status of CHRMAS IDOCs sent to the target system:
    •     On the target system BK2CLNT020, configure the distribution of message flow of type ALEAUD to logical system BK1CLNT010.
    •     Create filter object using object type MESTYP with a value of the message type for which you need audit confirmation. This message type must flow from the sender, BK1CLNT010 to BK2CLNT020. In this example, the value of the filter object type MESTYP is CHRMAS, message type for characteristics master. Save the distribution model. Use transaction BD64 to do this.
    •     On target system BK2CLNT020, create an RFC destination with name BK1CLNT010. Choose the relevant connection type and enter the logon parameters and password for the R/3 system on which BK1CLNT010 resides. Use transaction SM59 to do this.
    •     On target system BK2CLNT020, generate partner profile and port definition using transaction SALE, go to Communications -> Generate partner profile. Specify the customer model as described. Check the partner profile to ensure outbound parameter entries for message types ALEAUD and SYNCH.
    •     On sender system BK1CLNT010, create a logical system for BK2CLNT020. Create a partner profile for logical system BK2CLNT020 with inbound parameters for message type ALEAUD, with process code AUD1.
    •     Distribution of customer model on BK2CLNT020 to BK1CLNT010 is not necessary.
    TESTING THE ALE CONFIRMATION PROCESS
    Now you are ready to test the ALE audit confirmation process:
    •     From the sender system, BK1CLNT010, send a couple of CHRMAS02 (characteristics master) IDOCs down to the target system, BK2CLNT020. Make sure that the status of the IDOCs is 03 (data passed to port).
    •     Check the target system for receipt of these IDOCs. Make sure that they are in a status of 53 (application data posted).
    •     Execute program RBDSTATE with appropriate parameters. Specify BK1CLNT010 for Confirm to System, CHRMAS for Message type, and date, if necessary.
    •     Upon successful execution, informational messages will be issued indicating the IDOC number and status of the ALEAUD IDOC. (Note that a single ALEAUD audit IDOC can contain audit messages for multiple application IDOCs. This capability reduces the traffic of IDOCs between the two systems and keeps the overhead of audit confirmations at a minimum.)
    •     Check the sender system for the receipt of the ALEAUD message. The status of the CHRMAS IDOCs that you sent to the target system must be changed to 41 (application document created in target system).
    This completes the test of ALE audit confirmations (see Figure 10 and Figure 11 for IDOC display of target and sender system).
    Audit confirmations can play a significant role in the reporting and monitoring of production systems. You can schedule program RBDSTATE periodically on target systems to report back to sender systems. Keep in mind that you need to maintain a sufficient time lag between the sending of application IDOCs to the target system and the execution of this audit program because the application documents need to be posted on the target system. This program can also be accessed from BALE using Periodic work -> Audit confirmation.

  • Steps for Idoc to EDI Subsystem

    Hi all,
    Can anyone tell me the steps that i have to worry about to send an idoc immediately to EDI Subsystem
    I mean what all things i have to specify while creating ports and partner profiles etc
    Thanks

    Sending Order Confirmations by EDI (SD-SLS) 
    Use
    By setting up and using the Electronic Data Interchange functions in the R/3 System, you eliminate the need to print documents and send them through the standard mail system. Instead, you send the information electronically. This method is more practical, convenient, and allows you and your customer to process data faster.
    In this EDI scenario, you process and send order confirmations to a customer's R/3 Purchasing system.
    Prerequisites
    Application
    Customizing
    To process outbound order confirmations, you need to make all of the necessary EDI settings in Customizing for Basis. You make settings for output control in Customizing for Sales and Distribution.
    Output Control
    The standard SD condition components are:
    Condition component     Value
    Sales document type     AA
    Output determination procedure     V10000
    Condition type     BA00
    Transmission medium     6 (EDI)
    Access sequence     0001
    Processing subroutine     Program RSNASTED, form routine EDI_PROCESSING
    Partner function     SP (sold-to party)
    Application     V1
    Condition records for outbound order confirmations are maintained in Customizing for Sales and Distribution. Choose Basic Functions  Output Control  Output Determination  Output Determination Using the Condition Technique  Maintain Output Determination for Sales Documents.
    IDoc Interface
    Define the EDI partner profile for your partner (transaction WE20) by entering the following data for the outbound parameters for partner profiles and the additional profiles for message control:
    Field     Value
    Message type     ORDRSP
    Partner type     KU (customer)
    Partner function     SP (sold-to party)
    Receiver port     e.g. SUBSYSTEM
    Output mode     e.g. Transfer IDoc immediately
    Basic type     ORDERS04
    Process code     SD10
    Activities
    Create an order. When you save the document, the system uses your settings in output control to find the appropriate condition record and send confirmation of the order by EDI. To review and maintain output data in the document, choose Extras  Output  Header.
    Receiving Acknowledgments via EDI (MM-PUR-GF-CON) 
    Use
    You have arranged with your vendor that that latter is to send you acknowledgments in respect of purchase orders or outline agreements received from your company. (Note: both kinds of acknowledgment are generally referred to as "order acknowledgments" in the system. The corresponding EDIFACT term is "order response" (ORDRSP).)
    You have the option of working exclusively with acknowledgments. The acknowledgment is then purely informative in nature, since only the acknowledgment number is recorded in the system.
    If you wish to receive different kinds of vendor confirmation, such as both order acknowledgments and shipping notifications (also known as advance shipping notices - ASNs), it is possible for quantities and dates to be entered in the system automatically).
    For more information on this topic, refer to the MM Purchasing documentation ( Confirmations from the Purchasing Viewpoint and Receiving Confirmations via EDI).
    Prerequisites
    Application
    To work with several categories of vendor confirmation, you must:
    u2022     Enter a confirmation control key on the item detail screen
    u2022     Set up the confirmation control facility in Customizing for Purchasing (Purchasing  Confirmations  Set up Confirmation Control). There you can specify the order in which you expect confirmations from your vendors, for example.
    Under Confirmation sequence, you can:
    u2022     Specify tolerances for date and price checks
    u2022     Allow vendor material changes (VMat indicator)
    u2022     Adopt vendor price changes (Price indicator)
    Do not use a confirmation control key if you work exclusively with acknowledgments.
    IDoc Interface
    You have made the following settings for your EDI vendors in Customizing for Purchasing (Purchasing  Messages  EDI  Set up Partner Profile):
    Parameters for Inbound Messages     
    Field     Value
    Partner type     LI
    Partner role     LF
    Message category     ORDRSP
    Process code     ORDR
    Processing     Initiate immediately or process via background program
    Activities
    When an acknowledgment is received in the form of an incoming EDI message, the system checks whether a confirmation control key has been entered in the relevant PO or outline purchase agreement.
    u2022     If there is no confirmation control key, only the acknowledgment number is entered on the item detail screen.
    u2022     If there is a confirmation control key, the system updates the confirmation overview. That is to say, the dates and quantities set out in the acknowledgment that has just been received are recorded and taken into account in the overview. To view acknowledgments that have been received, choose Item  Confirmations  Overview from the item overview. Column C (creation indicator) contains the value 3, meaning that the acknowledgment was received via EDI. The system also enters the IDoc number in the External document column.
    An IDoc can always acknowledge one purchase order only. The acknowledgment relates to the PO item, not to any individual schedule lines.
    Exceptions
    When an acknowledgment is received via EDI, the system automatically checks quantities, prices, and dates. In checking quantities, it applies the over- and underdelivery tolerances set for the item. You can set tolerances for prices and delivery dates in Customizing for Purchasing under Set up Confirmation Control.
    The tolerances you define apply to all vendors. Using the enhancement MM06E001 provided by SAP, you can specify that the tolerances do not apply to certain vendors.
    If the acknowledged quantities, prices, and dates vary from those set out in the PO or purchase agreement, the system issues a warning message. In this case, the purchasing document is not updated.
    For more information on this topic, refer to the section Error Correction (Receiving Confirmations via EDI) of the MM Purchasing documentation.
    Sending PO Change Notices via EDI (MM-PUR-PO) 
    Use
    This section describes how to transmit a change notice relating to a purchase order that has already been sent to a vendor.
    The function corresponds to the transmission of a purchase order via EDI.
    Prerequisites
    Application
    You have already successfully transmitted the original purchase order to the vendor via EDI.
    Message Control
    You have created message condition records for your EDI vendors (Purchasing  Master data  Messages  Purchase order  Create).
    Use the message type NEU to transmit PO change notices.
    IDoc Interface
    You have made the following settings for your EDI vendors in Customizing for Purchasing (Purchasing  Messages  Set up Partner Profile):
    Parameters for Outbound Messages     
    Field     Value
    Application     EF ( Purchasing: purchase order)
    Message category     ORDCHG
    IDoc type     ORDERS02 or ORDERS04
    Process code     ME 11 (ORDCHG: PO change notice)
    If you wish to transmit PO conditions or texts to your vendor, you must create an IDoc view. For more information on this topic, see Sending a Purchase Order via EDI.
    Activities
    Change an existing purchase order via Purchasing  Purchase order  Change. Make the necessary changes and save the PO.
    The new message is compared with the last successfully transmitted message. PO change notices indicate whether any new items have been added to the PO, and/or whether any already transmitted items have been changed.
    When the message is transmitted, only those changes that are simultaneously new and print-relevant are included. The system sets the change indicator for the new message. To check the change indicator, choose Header  Messages in the PO item overview.
    See also:
    MM Purchasing: Creating a Purchase Order
    Cross-Application Components:  Customizing Message Control in Purchasing (MM): Example: Purchase Order
    Receiving Order Changes by EDI (SD-SLS) 
    Use
    In this EDI scenario, you receive and process order changes sent by a customer from an R/3 Purchasing system.
    Prerequisites
    Application
    General
    You can receive and process order changes in your system only on the basis of an existing order.
    Customizing
    To process incoming order changes, you need to make all of the necessary settings in Customizing for Basis. There are no special settings for Sales and Distribution.
    IDoc Interface
    Define the EDI partner profile for your partner (transaction WE20) by entering the following data in the header and detail screen for inbound parameters:
    Parameter     Value
    Partner type     KU (customer); if the IDoc is sent from an R/3 system via tRFC (in a typical case with ALE scenarios), enter LS for logical system!
    Message type     ORDCHG
    Process code     ORDC
    Processing     Process immediately
    Allowed Agents     Enter an R/3 user or an organizational unit, for example.
    Activities
    Inbound Processing
    The IDoc interface receives the IDoc and reviews its control record. According to this record and the corresponding partner profile, the IDoc is transferred to the function module IDOC_INPUT_ORDCHG in Sales and Distribution. The ALE services are called.
    The system processes the IDoc in the background, using the data records in the IDoc to determine the relevant order.
    If processing is successful, the system updates the sales order. The IDoc is sent back to the IDoc interface which updates the status records in the IDoc.
    Exception Handling
    If it cannot determine an order, or if an error occurs in processing, the system determines the relevant agent(s) and sends a workitem to the integrated inbox(es). An agent can pick up the workitem to process the IDoc or simply end processing.
    To display an IDoc for order changes, choose Environment  Display facsimiles in the order. The system displays a dialog box of object links where you can choose Linked IDocs.

  • EDI - IDoc Help

    Hi ABAP and EDI experts,
    I have a request, I am a trainer. I am working on a Training Software, not real time. Is there any way that i can create and IDoc and see. Kindly provide me any such.
    Help will be surely rewarded.
    Thanks
    Chinna

    Hi Chinna,
    See the example scenario  material
    MASTER DATA TRANSFERMATION BETWEEN 2 DIFF CLIENTS
    u2022     For this scenario Client 800 is the Sender and 810 is the receiving system
    1. Creating Logical Systems
    o     Login using 800 client
    o     Go to T. Code SALE
    o     Expand Sending and Receiving Systems
    o     Expand Logical Systems
    o     Click on Define Logical System
    o     Click on New Entries
    o     Create STUD_S, STUD_R Logical Systems
    o     Save and come back
    o     Assign the STUD_S Logical System to client 800
    o     Assign the STUD_R Logical System to client 810
    2. Creating the RFCs
    o     Go to T. Code SM59
    o     Expand R/3 Connections
    o     Enter RFC Name as STUD_S
    o     Connection Type as 3
    o     Language as EN
    o     Client as 800
    o     User as  SAPUSER
    o     PWD as abap
    o     Target host as sap
    o     Click on Remote logon button to test the RFC
    o     Enter RFC Name as STUD_R
    o     Connection Type as 3
    o     Language as EN
    o     Client as 800
    o     User as  SATISH
    o     PWD as abap
    o     Target host as sap
    o     Click on Remote logon button to test the RFC
    3. Creating the Message Type
    o     Go to T. Code WE81
    o     Click on change, continue
    o     Click on New Entries button
    o     Give message type as ZBAPI_STUD_MAS and description
    o     Save and back
    4. Creating the Segment
    o     Go to T. Code WE31
    o     Give segment name as ZBAPI_STUD_SEG
    o     Enter Short Text
    o     Enter the Field Name and Data Element in the text boxes
    o     Save, continue,
    o     Click on Edit -> Set Release.
    5. Creating the Basic IDOC Object
    o     Go to T. code WE30
    o     Give obj. name as ZBAPI_STUD_IDOC
    o     Click on create
    o     Select create new radio button, give description and continue
    o     Select the IDOC obj name and click on create button
    o     Enter the segment name which is create earlier
    o     Select the check box if you want to make the segment mandatory
    o     Enter 1 in minimum number 99999 in maximum number, continue
    o     Save and back
    o     Click on Edit -> Set Release
    6. Creating Customer Distribution Model
    o     Go to T. Code BD64
    o     Click on change and Create model view button
    o     Enter the short text and Technical name as ZSTUDENT
    o     Select the model and click on Add Message Type Button
    o     Give the Sender as STUD_S,
    o                    Receiver as STUD_R,
    o                    Message Type as ZBAPI_STUD_MAS
    o     Select the model view & click on Environment -> Generate Partner Profiles
    o     Select Transfer IDOC Immediately and Trigger Immediately radio buttons
    o     Click on Execute
    o     You should get a list in green color which means it executed successfully.
    o     Back to main screen, select the model view
    o     Click Edit->Model view->Distribute
    o     Click on continue
    o     You should get a list saying model view is distributed successfully.
    7. Checking the Port
    o     Go to T. Code WE21
    o     Expand Transactional RFC
    o     Find the port from the list which is created using BD64 for STUD_R (Receiving system) RFC Destination.
    8. Checking the Partner Profiles.
    o     Go to T. Code WE20
    o     Expand Partner Type LS
    o     Select the Partner profile STUD_R
    o     Double click on Message Type ZBAPI_STUD_MAS in Outbound parmtrs.
    o     Check Receiver Port is assigned correctly
    o     Check the Basic type as your Basic IDOC object.
    9. Assigning the Message Type to Basic IDOC Object
    o     Go to T. Code WE82
    o     Click on Change & continue, New Entries button
    o     Give the Message type as ZBAPI_STUD_MAS
    o     Give Basic Type as ZBAPI_STUD_IDOC
    o     Release as 46C
    o     Save and back
    10. Creating Inbound Function Module (Posting Program)
    o     Go to T. Code SE37
    o     Create a function Module IDOC_INPUT_ZBAPI_STUD_MAS
    o     Set the Processing type as Remote Enabled Module and mode as start immed, in Attributes Tab.
    o     Import Parameters
    INPUT_METHOD                 LIKE     BDWFAP_PAR-INPUTMETHD
    MASS_PROCESSING     LIKE     BDWFAP_PAR-MASS_PROC
    NO_APPLICATION_LOG     LIKE     SY-DATAR
    MASSSAVEINFOS                 LIKE     MASSSAVINF
    o     Export Parameters
    WORKFLOW_RESULT          LIKE     BDWF_PARAM-RESULT
    APPLICATION_VARIABLE     LIKE     BDWF_PARAM-APPL_VAR
    IN_UPDATE_TASK          LIKE     BDWFAP_PAR-UPDATETASK
    CALL_TRANSACTION_DONE  LIKE     BDWFAP_PAR-CALLTRANS
    o     Tables
    IDOC_CONTRL     LIKE     EDIDC
    IDOC_DATA          LIKE     EDIDD
    IDOC_STATUS     LIKE     BDIDOCSTAT
    RETURN_VARIABLES     LIKE     BDWFRETVAR
    SERIALIZATION_INFO     LIKE     BDI_SER
    o     Exceptions
    WRONG_FUNCTION_CALLED
    o     Source Code
    DATA: FIRST_TRANC LIKE MARA_UEB-TRANC,
          ZBAPI_STUD_SEG like zbapi_stud.
    DATA: ZBAPI_STUD LIKE ZBAPI_STUD.
      DATA: I_ZBAPI_STUD LIKE ZBAPI_STUD.
      DATA: C_TRUE                         VALUE 'X'.
      DATA: C_FALSE                        VALUE ' '.
    DATA: BEGIN OF T_IDOC_ROLLNO OCCURS 0,
            DOCNUM LIKE EDIDC-DOCNUM,
            ROLLNO LIKE ZBAPI_STUD-ROLLNO,
          END   OF T_IDOC_ROLLNO.
      DEFINE APPEND_RESFIELDS.
        PERFORM APPEND_RES_FIELDS TABLES T_MFIELDRES
                                         T_RES_FIELDS
                                  USING  &1
                                         COUNTER-D_IND.
      END-OF-DEFINITION.
      DATA: I_MARA_UEB LIKE MARA_UEB.
      DATA: I_ZSTUD_UEB LIKE ZBAPI_STUD.
      DATA: I_MAKT_UEB LIKE MAKT_UEB.
      DATA: I_MARC_UEB LIKE MARC_UEB.
      DATA: I_MARD_UEB LIKE MARD_UEB.
      DATA: I_MFHM_UEB LIKE MFHM_UEB.
      DATA: I_MARM_UEB LIKE MARM_UEB.
      DATA: I_MEAN_UEB LIKE MEA1_UEB.
      DATA: I_MBEW_UEB LIKE MBEW_UEB.
      DATA: I_STEU_UEB LIKE STEU_UEB.
      DATA: I_STEUMM_UEB LIKE STEUMM_UEB.
      DATA: I_MLGN_UEB LIKE MLGN_UEB.
      DATA: I_MLGT_UEB LIKE MLGT_UEB.      " //br010797 neu zu 4.0
      DATA: I_MPGD_UEB LIKE MPGD_UEB.
      DATA: I_MPOP_UEB LIKE MPOP_UEB.
      DATA: I_MVEG_UEB LIKE MVEG_UEB.
      DATA: I_MVEU_UEB LIKE MVEU_UEB.
      DATA: I_MVKE_UEB LIKE MVKE_UEB.
      DATA: I_MPRW_UEB LIKE MPRW_UEB.
      DATA: I_LTX1_UEB LIKE LTX1_UEB.
      DATA: HELP_MARC_UEB LIKE MARC_UEB.
      DATA: T_MARA_UEB LIKE MARA_UEB OCCURS 0.
      DATA: T_MAKT_UEB LIKE MAKT_UEB OCCURS 0.
      DATA: T_MARC_UEB LIKE MARC_UEB OCCURS 0.
      DATA: T_MARD_UEB LIKE MARD_UEB OCCURS 0.
      DATA: T_MFHM_UEB LIKE MFHM_UEB OCCURS 0.
      DATA: T_MARM_UEB LIKE MARM_UEB OCCURS 0.
      DATA: T_MEAN_UEB LIKE MEA1_UEB OCCURS 0.
      DATA: T_MBEW_UEB LIKE MBEW_UEB OCCURS 0.
      DATA: T_STEU_UEB LIKE STEU_UEB OCCURS 0.
      DATA: T_STEUMM_UEB LIKE STEUMM_UEB OCCURS 0.
      DATA: T_MLGN_UEB LIKE MLGN_UEB OCCURS 0.
      DATA: T_MLGT_UEB LIKE MLGT_UEB OCCURS 0.    " //br010797 neu zu 4.0
      DATA: T_MPGD_UEB LIKE MPGD_UEB OCCURS 0.
      DATA: T_MPOP_UEB LIKE MPOP_UEB OCCURS 0.
      DATA: T_MVEG_UEB LIKE MVEG_UEB OCCURS 0.
      DATA: T_MVEU_UEB LIKE MVEU_UEB OCCURS 0.
      DATA: T_MVKE_UEB LIKE MVKE_UEB OCCURS 0.
      DATA: T_MPRW_UEB LIKE MPRW_UEB OCCURS 0.
      DATA: T_LTX1_UEB LIKE LTX1_UEB OCCURS 0.
    Internal fields/ tables
    DATA: FLAG_ERROR_HAPPENED.
    DATA: flag_material_exists. "//br210397 zu 4.0 keine Verwendung mehr
      DATA: FLAG_EXIT_TO_BE_DONE.
      DATA: HELP_TABIX LIKE SY-TABIX.
      DATA: HELP_TRANC LIKE MARA_UEB-TRANC.
      DATA: HELP_ALAND LIKE STEU_UEB-ALAND.
      DATA: HELP_VKORG LIKE MVKE-VKORG.
      DATA: HELP_WERKS LIKE T001W-WERKS.
      DATA: HELP_LFDNR LIKE STEU_UEB-LFDNR.
      DATA: LAST_MARC_TRANC LIKE MARA_UEB-TRANC.
      DATA: LAST_MLGN_TRANC LIKE MARA_UEB-TRANC.    " //br010797 neu zu 4.0
      DATA: LAST_TEXT_TRANC LIKE MARA_UEB-TRANC.
      DATA: CURRENT_TABIX LIKE SY-TABIX.
      DATA: GENERAL_SUBRC LIKE SY-SUBRC.
      DATA: HELP_FACTOR TYPE P DECIMALS 3.
      DATA: USER_SEGMENTS LIKE EDIDD OCCURS 0 WITH HEADER LINE.  " insert
      DATA: CUST_SEGMENT LIKE EDIDD.
      DATA: I_MFIELDRES LIKE MFIELDRES.
    DATA: I_MERRDAT LIKE MERRDAT.
      DATA: I_EDIDD LIKE EDIDD.
                                           " //br neu zu 3.1g
      DATA: T_RES_FIELDS LIKE DELFIELDS OCCURS 0 WITH HEADER LINE.
      DATA: T_MFIELDRES LIKE MFIELDRES OCCURS 0.
      DATA: T_MERRDAT LIKE MERRDAT OCCURS 0.
      DATA: T_EDIDD LIKE EDIDD OCCURS 0.
    DATA: BEGIN OF t_matnr OCCURS 0, "//br210397 zu 4.0
            matnr LIKE mara-matnr,   " wird nicht mehr verwendet                                               
          END OF t_matnr.            "
      DATA: BEGIN OF COUNTER,
              TRANC LIKE MARA_UEB-TRANC,
              D_IND LIKE MARA_UEB-D_IND,
            END OF COUNTER.
    DATA: BEGIN OF t_idoc_tranc OCCURS 0,                          " 4.0
            docnum LIKE edidc-docnum,                              "
            tranc  LIKE mara_ueb-tranc,                            "
          END OF t_idoc_tranc.                                     "
      DATA T_IDOC_TRANC LIKE MATIDOCTRANC OCCURS 0 WITH HEADER LINE."
      DATA: FLAG_FITS.
      DATA: APPLICATION_SUBRC LIKE SY-SUBRC.
      DATA FLAG_MUSS_PRUEFEN LIKE SY-DATAR.
      DATA MAX_ERRORS LIKE T130S-ANZUM.    " 4.0
    note 419281
      DATA : FLG_MASS.
      CLEAR : FLG_MASS.
      FIELD-SYMBOLS: .            " 4.0
    ALE-distribution unity : IDOC status set by locking      "note0361838
      data:                                                     "note0361838
        it_dsp_idocstat like bdidocstat                         "note0361838
          occurs 0 with header line.                            "note0361838
    Initialize data - general
      REFRESH T_MFIELDRES.
      REFRESH T_IDOC_TRANC.
      REFRESH T_IDOC_TRANC.                "JH/02.02.98/4.0C  KPr100004993
    REFRESH t_idoc_tranc_segment.   " //br 40 : unnötig
    REFRESH matnr_tranc.            "    -"-
    REFRESH t_matnr.
      COUNTER-TRANC = 1.
      COUNTER-D_IND = 1.
      REFRESH T_MARA_UEB.
      REFRESH T_MAKT_UEB.
      REFRESH T_MARC_UEB.
      REFRESH T_MARD_UEB.
      REFRESH T_MFHM_UEB.
      REFRESH T_MARM_UEB.
      REFRESH T_MEAN_UEB.
      REFRESH T_MBEW_UEB.
      REFRESH T_STEU_UEB.
      REFRESH T_STEUMM_UEB.
      REFRESH T_MLGN_UEB.
      REFRESH T_MLGT_UEB.                  " //br010797 neu zu 4.0
      REFRESH T_MPGD_UEB.
      REFRESH T_MPOP_UEB.
      REFRESH T_MVEG_UEB.
      REFRESH T_MVEU_UEB.
      REFRESH T_MVKE_UEB.
      REFRESH T_MPRW_UEB.
    REFRESH VKORG_ALAND.
    REFRESH WERKS_ALAND.
      CLEAR APPLICATION_SUBRC.
      REFRESH T_MERRDAT.
    Check if right function is called
      READ TABLE IDOC_CONTRL INDEX 1.
      IF SY-SUBRC <> 0.
        EXIT.
      ELSE.
        IF  IDOC_CONTRL-IDOCTP <> 'ZBAPI_STUD_IDOC'.
          RAISE WRONG_FUNCTION_CALLED.
        ENDIF.
      ENDIF.
      LOOP AT IDOC_CONTRL.
      Initialize data - per IDOC
      t_idoc_tranc-docnum = counter-tranc.
        T_IDOC_TRANC-DOCNUM = IDOC_CONTRL-DOCNUM.
        T_IDOC_TRANC-FIRST_TRANC_IDOC = COUNTER-TRANC + 2.
        APPEND T_IDOC_TRANC.
      Select segments which belong to IDOC
        REFRESH T_EDIDD.
        LOOP AT IDOC_DATA WHERE DOCNUM = IDOC_CONTRL-DOCNUM.
          APPEND IDOC_DATA TO T_EDIDD.
        ENDLOOP.
       BUSINESS TRANSACTION EVENT (header / data)         "note0388000
         call function 'OPEN_FI_PERFORM_MGV00200_E'         "note0388000
              exporting                                     "note0388000
                  idoc_header       = idoc_contrl           "note0388000
                  FLG_APPEND_STATUS = 'X'                   "note0388000
              tables                                        "note0388000
    (DEL)       idoc_data         = idoc_data "note0388000 note0418561
                  idoc_data         = t_edidd               "note0418561
                  idoc_status       = idoc_status           "note0388000
              exceptions                                    "note0388000
                  others       = 1.                         "note0388000
         if sy-subrc = 1.                                   "note0388000
            continue.                                       "note0388000
         endif.                                             "note0388000
      Within one IDOC: loop through data segments:
      Prepare internal tables for the current material
        LOOP AT T_EDIDD INTO IDOC_DATA.
        Transform from CoreData to Normal Data if necesary
          CASE IDOC_DATA-SEGNAM.
           WHEN 'E1MARAC'.
    *--COMMENTED BY SATISH
             PERFORM MOVE_E1MARAC_TO_E1MARAM USING IDOC_DATA.
           WHEN 'E1MAKTC'.
             PERFORM MOVE_E1MAKTC_TO_E1MAKTM USING IDOC_DATA.
    *--COMMENTES ENDED BY SATISH
             WHEN 'ZBAPI_STUD_SEG'.
              PERFORM MOVE_E1MARAC_TO_E1MARAM USING IDOC_DATA.
                CLEAR I_ZBAPI_STUD.
    Second: Move E1MARAC into E1MARAM
                I_ZBAPI_STUD = IDOC_DATA-SDATA.
    Third: Move E1MARAM back into IDOC-line
                IDOC_DATA-SDATA =  I_ZBAPI_STUD.
                IDOC_DATA-SEGNAM = 'ZBAPI_STUD_SEG'.
          ENDCASE.
          CURRENT_TABIX = SY-TABIX.
          COUNTER-D_IND = COUNTER-D_IND + 1.
          COUNTER-TRANC = COUNTER-TRANC + 2.
          CASE IDOC_DATA-SEGNAM.
             WHEN 'ZBAPI_STUD_SEG'.
            Initialize data - per material
              COUNTER-D_IND = 1.
              FIRST_TRANC = COUNTER-TRANC.
            interpret segment
              ZBAPI_STUD_SEG = IDOC_DATA-SDATA.
              MOVE-CORRESPONDING ZBAPI_STUD TO I_ZSTUD_UEB.
              T_IDOC_ROLLNO-DOCNUM  = IDOC_CONTRL-DOCNUM.
              T_IDOC_ROLLNO-ROLLNO  = I_ZSTUD_UEB-ROLLNO.
              APPEND T_IDOC_ROLLNO.
           ENDCASE.
                if not ZBAPI_STUD_SEG is initial.
                 ZBAPI_STUD-MANDT  = ZBAPI_STUD_SEG-MANDT.
                 ZBAPI_STUD-ROLLNO = ZBAPI_STUD_SEG-ROLLNO.
                 ZBAPI_STUD-FNAME  = ZBAPI_STUD_SEG-FNAME.
                 ZBAPI_STUD-LNAME  = ZBAPI_STUD_SEG-LNAME.
                  INSERT ZBAPI_STUD FROM ZBAPI_STUD_SEG.
                  COMMIT WORK.
                ENDIF.
    *-- ALE ditribution unity : update IDOC status                "note03618
          LOOP AT it_dsp_idocstat.                                  "note036
             LOOP AT IDOC_STATUS WHERE DOCNUM = it_dsp_idocstat.    "note036
                DELETE idoc_status INDEX sy-tabix.                  "note036
             ENDLOOP.                                               "note036
             APPEND it_dsp_idocstat TO idoc_status.                 "note036
          ENDLOOP.                                                  "note036
    *--GENERATING THE IDOC STATUS
      PERFORM HANDLE_ERROR_EXT             " //br40
                  TABLES                                        "
                     IDOC_CONTRL                                "
                     IDOC_STATUS                                "
                     RETURN_VARIABLES                           "
                     T_MERRDAT                                  "
                     T_IDOC_TRANC                               "
                     T_IDOC_ROLLNO          "JH/4.0C/KPr100004993
                  USING                                         "
                     GENERAL_SUBRC                              "
                     NO_APPLICATION_LOG                         "
                     MASSSAVEINFOS         "wk/40c
                  CHANGING                                      "
                     WORKFLOW_RESULT.                           "
                  PERFORM HANDLE_ERROR
                              TABLES
                                 IDOC_CONTRL
                                 IDOC_STATUS
                                 RETURN_VARIABLES
                                 T_MERRDAT
                                 T_IDOC_ROLLNO     "JH/4.0C/KPr100004993
                              USING
                                 APPLICATION_SUBRC
                              CHANGING
                                 WORKFLOW_RESULT.
      SORT T_IDOC_ROLLNO BY ROLLNO. "note 315124
    React on general error
      DATA: I_MERRDAT LIKE MERRDAT.
      IF GENERAL_SUBRC <> 0.
        I_MERRDAT-MSGTY = 'E'.
        I_MERRDAT-MSGID = SY-MSGID.
        I_MERRDAT-MSGNO = SY-MSGNO.
        I_MERRDAT-MSGV1 = SY-MSGV1.
        I_MERRDAT-MSGV2 = SY-MSGV2.
        I_MERRDAT-MSGV3 = SY-MSGV3.
        I_MERRDAT-MSGV4 = SY-MSGV4.
        APPEND I_MERRDAT TO T_MERRDAT.
      ENDIF.
      LOOP AT T_MERRDAT INTO  I_MERRDAT
                        WHERE MSGTY = 'S'  "success
                        OR    MSGTY = 'D'  "dummy
                        OR    MSGTY = 'I'  "Information " //br011097 zu 3.1I
                        OR    MSGTY = 'H'  "dummy       " 4.0
                        OR    MSGTY = 'W'. "warning
        DELETE T_MERRDAT.
      ENDLOOP.
        ENDLOOP.
      ENDLOOP.
    ENDFUNCTION.
    *&      Form  handle_error_ext
    FORM HANDLE_ERROR_EXT
            TABLES
               IDOC_CONTRL                   STRUCTURE EDIDC
               IDOC_STATUS                   STRUCTURE BDIDOCSTAT
               RETURN_VARIABLES              STRUCTURE BDWFRETVAR
               T_MERRDAT                     STRUCTURE MERRDAT
               IDOC_TRANC                    STRUCTURE MATIDOCTRANC
    JH/02.02.98/4.0C  KPr100004993 (Anfang)
               T_IDOC_ROLLNO                 STRUCTURE T_IDOC_ROLLNO
    JH/02.02.98/4.0C  KPr100004993 (Ende)
            USING
               GENERAL_SUBRC                 LIKE SY-SUBRC
               NO_APPLICATION_LOG            LIKE SY-DATAR
               MASSSAVEINFOS                 LIKE MASSSAVINF
            CHANGING
               WORKFLOW_RESULT               LIKE BDWF_PARAM-RESULT.
      DATA FLAG_ERROR_HAPPENED.
      DATA I_MERRDAT LIKE MERRDAT.
      DATA IDOC_INDEX_2_SUBRC LIKE SY-SUBRC.
      DATA AL_HANDLES TYPE BAL_T_LOGH. "//br99
      SORT T_IDOC_ROLLNO BY ROLLNO.                        "note 315124
    React on general error
      IF GENERAL_SUBRC <> 0.
        REFRESH T_MERRDAT.
      i_merrdat-tranc = 0.                              " //br261197
        READ TABLE IDOC_TRANC INDEX 1.     " zu 40b
        I_MERRDAT-TRANC = IDOC_TRANC-FIRST_TRANC_IDOC.          "
        I_MERRDAT-MSGTY = 'E'.
        I_MERRDAT-MSGID = SY-MSGID.
        I_MERRDAT-MSGNO = SY-MSGNO.
        I_MERRDAT-MSGV1 = SY-MSGV1. I_MERRDAT-MSGV2 = SY-MSGV2.
        I_MERRDAT-MSGV3 = SY-MSGV3. I_MERRDAT-MSGV4 = SY-MSGV4.
        APPEND I_MERRDAT TO T_MERRDAT.
      ENDIF.
    DATA: C_TRUE,
          C_FALSE VALUE 'X'.
    If error happened ==> Rollback whole work....
      LOOP AT T_MERRDAT INTO I_MERRDAT WHERE MSGTY NA 'SDHWI'.
        EXIT.
      ENDLOOP.
      IF SY-SUBRC = 0.
        FLAG_ERROR_HAPPENED = C_TRUE.
        ROLLBACK WORK.
      ELSE.
        FLAG_ERROR_HAPPENED = C_FALSE.
      ENDIF.
    Set IDOC status
    two cases:
    single IDOC-processing: ==> error can be written in IDOC status
    package processing ==> anononymous "package error" for all IDOCs
      READ TABLE IDOC_CONTRL INDEX 2.
      IDOC_INDEX_2_SUBRC = SY-SUBRC.
      IF SY-SUBRC = 0.
        IF 1 = 2.                          "//br40
          MESSAGE E051(B1).                                     "
        ENDIF.                                                  "
        CLEAR I_MERRDAT.
        I_MERRDAT-MSGID = 'B1'.
        I_MERRDAT-MSGTY = 'E'.
        I_MERRDAT-MSGNO = '051'.
      ENDIF.
      IF IDOC_INDEX_2_SUBRC NE 0 OR FLAG_ERROR_HAPPENED = C_FALSE.
      Nur in diesen Fällen wird Application Log geschrieben
      Delete all Successes and Dummy records from t_merrdat
      DELETE t_merrdat WHERE msgty = 'S'  "success         " testweise
                       OR    msgty = 'D'. "dummy           "
        LOOP AT T_MERRDAT INTO I_MERRDAT WHERE MSGTY = 'D'.     "
          I_MERRDAT-MSGTY = 'S'.                                "
          MODIFY T_MERRDAT FROM I_MERRDAT.                      "
        ENDLOOP.                                                "
      ENDIF.
      WORKFLOW_RESULT = 0.
      LOOP AT IDOC_CONTRL.
      Set IDOC status
        CLEAR IDOC_STATUS.
        IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
        IF FLAG_ERROR_HAPPENED = C_FALSE.
    Application log
          PERFORM WRITE_APPL_LOG TABLES IDOC_TRANC
                                        T_MERRDAT
                                        IDOC_STATUS
                                 USING  IDOC_CONTRL
                                        FLAG_ERROR_HAPPENED
                                        NO_APPLICATION_LOG
                                        MASSSAVEINFOS
                                        AL_HANDLES.
        idoc_status-status = '53'.       "OK!
        APPEND idoc_status.
    JH/02.02.98/4.0C  KPr100004993 (Anfang)
        Fill Return variables
          CLEAR RETURN_VARIABLES.
          RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
          RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'.
          APPEND RETURN_VARIABLES.
        Verknüpfungseintrag anlegen
          READ TABLE T_IDOC_ROLLNO WITH KEY ROLLNO = IDOC_CONTRL-DOCNUM
                                  BINARY SEARCH.
          IF SY-SUBRC = 0.
            RETURN_VARIABLES-DOC_NUMBER = T_IDOC_ROLLNO-ROLLNO.
            RETURN_VARIABLES-WF_PARAM = 'Appl_Objects'.
            APPEND RETURN_VARIABLES.
          ENDIF.
    JH/02.02.98/4.0C  KPr100004993 (Ende)
        ELSE.
          IF IDOC_INDEX_2_SUBRC NE 0.
    Application Log
            PERFORM WRITE_APPL_LOG TABLES IDOC_TRANC
                                          T_MERRDAT
                                          IDOC_STATUS
                                   USING  IDOC_CONTRL
                                          FLAG_ERROR_HAPPENED
                                          NO_APPLICATION_LOG
                                          MASSSAVEINFOS
                                          AL_HANDLES.
          ELSE.
            IDOC_STATUS-MSGID = I_MERRDAT-MSGID.
            IDOC_STATUS-MSGTY = I_MERRDAT-MSGTY.
            IDOC_STATUS-MSGNO = I_MERRDAT-MSGNO.
            IDOC_STATUS-MSGV1 = I_MERRDAT-MSGV1.
            IDOC_STATUS-MSGV2 = I_MERRDAT-MSGV2.
            IDOC_STATUS-MSGV3 = I_MERRDAT-MSGV3.
            IDOC_STATUS-MSGV4 = I_MERRDAT-MSGV4.
            IDOC_STATUS-STATUS = '51'.     "ERROR!
            APPEND IDOC_STATUS.
          ENDIF.
        Fill Return variables
          CLEAR RETURN_VARIABLES.
          RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
        return_variables-wf_param = c_wf_par_processed_idocs.
          RETURN_VARIABLES-WF_PARAM = 'Error_IDOCs'.
          APPEND RETURN_VARIABLES.
          WORKFLOW_RESULT = 99999.
        ENDIF.
      APPEND idoc_status.
      ENDLOOP.
      IF NO_APPLICATION_LOG IS INITIAL.
        CALL FUNCTION 'BAL_DB_SAVE'                           "//br99
             EXPORTING
                  I_IN_UPDATE_TASK = ' '
                  I_SAVE_ALL       = ' '
                  I_T_LOG_HANDLE   = AL_HANDLES.
           EXCEPTIONS
                LOG_NOT_FOUND    = 1
                SAVE_NOT_ALLOWED = 2
                NUMBERING_ERROR  = 3
                OTHERS           = 4.
        CALL FUNCTION 'BAL_GLB_MEMORY_REFRESH'                "//br99
             EXPORTING
                I_AUTHORIZATION          =
                  I_REFRESH_ALL            = ' '
                  I_T_LOGS_TO_BE_REFRESHED = AL_HANDLES.
           EXCEPTIONS
                NOT_AUTHORIZED           = 1
                OTHERS                   = 2
      ENDIF.
    ENDFORM.                               " handle_error
    Save, check and activate
    11. Assigning the Inbound Function Module to Basic Type & Message Type
    o     Go to T. Code WE57
    o     Click on change, continue, continue and New Entries Button
    o     Enter the Module as IDOC_INPUT_ZBAPI_STUD_MAS
    o     Type as u201CFu201D
    o     Basic Type as ZBAPI_STUD_IDOC
    o     Message Type as ZBAPI_STUD_MAS.
    o     Direction as 2
    o     Save and back
    Now Login in 810 client
    12. Assigning the Inbound Function Module in ALE Table
    o     Go to T. Code BD51
    o     Click on continue, New Entries button
    o     Give the Inbound Function Module IDOC_INPUT_ZBAPI_STUD_MAS
    o     Give Input t. as 0 (zero)
    o     Save and back
    13. Creating Process Code
    o     Go to T. Code WE42
    o     Click on Change, New Entries Button
    o     Give Process Code name as ZSTUD, give Description & Save
    o     Select Processing with ALE Services Radio button
    o     Select Processing by Function Module Radio button
    o     Click the ALE Table (arrow Icon) in Identification
    o     Give the Function Module Name ZIDOC_INPUT_ZBAPI_STUD_MAS
    o     Give maximum number of repeats 0
    o     Save and back, back
    o     Select the process code from the list & click on Logical Messages Icon
    o     Give the Message Type as ZBAPI_STUD_MAS
    o     Save & Back, Save & Back, Save & Back
    14. Changing the Customer Distribution model in Receiving system
    o     Go to T. Code BD64
    o     Click on change and Create model view button
    o     Select the model view & click on Environment -> Generate Partner Profiles
    o     Select Transfer IDOC Immediately and Trigger Immediately radio buttons
    o     Click on Execute
    o     You should get a list in green color which means it executed successfully.
    15. Assigning the Process Code to Message Type in Receiving System
    o     Go to T. Code WE20
    o     Expand Partner Type LS
    o     Select the Partner Profile STUD_S
    o     Double click on Message Type ZBAPI_STUD_MAS in Inbound parmtrs.
    o     Give the Process Code as ZSTUD
    o     Click on Trigger Immediately Radio button
    o     Save & Back
    o     Save & Back
    16. Creating the Selection Program (Outbound Program)
    u2022     Login in client 800.
    u2022     Go to T. Code SE38
    u2022     Create a Report Program as   ZSTUD_SEND with the following code
    REPORT ZSTUD_SEND
           NO STANDARD PAGE HEADING.
    TABLES: ZBAPI_STUD.
    DATA: IT_STUD LIKE ZBAPI_STUD OCCURS 0 WITH HEADER LINE.
    SELECTION-SCREEN:BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
    SELECT-OPTIONS: S_ROLLNO FOR ZBAPI_STUD-ROLLNO.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN:BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-H02.
    PARAMETERS:  P_MESTYP LIKE EDIDC-MESTYP,
                 P_RCVPRN LIKE TBDLST-LOGSYS.
    SELECTION-SCREEN:END OF BLOCK B2.
    SELECTION-SCREEN:END OF BLOCK B1.
    START-OF-SELECTION.
      PERFORM CREATE_STUDENT.
      PERFORM CREATE_IDOC.
    *&      Form  CREATE_STUDENT
          sending student
    FORM CREATE_STUDENT.
    SELECT * FROM ZBAPI_STUD
       INTO TABLE IT_STUD
       WHERE ROLLNO IN S_ROLLNO.
    ENDFORM.                    " CREATE_STUDENT
    *&      Form  CREATE_IDOC
          IDOC Creation
    FORM CREATE_IDOC.
    DATA : IMAS_DATA LIKE EDIDD OCCURS 10 WITH HEADER LINE,
           IMAS_CON LIKE EDIDC OCCURS 10 WITH HEADER LINE,
           ICOM_CON LIKE EDIDC OCCURS 10 WITH HEADER LINE.
    IMAS_CON-RCVPRT = 'LS'.
    IMAS_CON-RCVPRN = P_RCVPRN.
    IMAS_CON-IDOCTP = 'ZBAPI_STUD_IDOC'.
    IMAS_CON-MESTYP = P_MESTYP.
    IMAS_CON-DIRECT = 1.
    APPEND IMAS_CON.
    LOOP AT IT_STUD.
      IMAS_DATA-SEGNAM = 'ZBAPI_STUD_SEG'.
      IMAS_DATA-SDATA = IT_STUD.
      APPEND IMAS_DATA.
    ENDLOOP.
    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
         EXPORTING
              MASTER_IDOC_CONTROL            = IMAS_CON
            OBJ_TYPE                       = ''
            CHNUM                          = ''
         TABLES
              COMMUNICATION_IDOC_CONTROL     = ICOM_CON
              MASTER_IDOC_DATA               = IMAS_DATA
       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.
    ENDIF.
    COMMIT WORK.
    LOOP AT  ICOM_CON.
      WRITE :/ 'IDOC: ', ICOM_CON-DOCNUM, 'CREATED SUCCESSFULLY'.
    ENDLOOP.
    ENDFORM.                    " CREATE_IDOC
    17. Transferring the student records from 800 to 810 client
    u2022     Execute Report Program   ZSTUD_SEND
    u2022     Give the Range of Roll Nos to Transfer
    u2022     Give Message Type as    ZBAPI_STUD_MAS
    u2022     Give Receiver Logical system as   STUD_R
    u2022     Execute
    u2022     You should get the IDOC Number
    u2022     Take the IDOC Number and go to T. Code WE05 & Execute
    u2022     In Outbox you can see the IDOC Status
    u2022     Select the status record in left side window
    u2022     Double click on the Status record in right side window
    u2022     You can see the Control Record, Data Record and Status Records for that IDOC
    u2022     If the ICON is green and the status code is 3, it means the IDOC is passed to PORT Successfully.
    Now Login in 810 client
    u2022     Go to T. Code WE05 & Execute
    u2022     You can see the status record in left side window
    u2022     If the status no is 53 and color is green, it means the IDOC is Posted to Application successfully.
    u2022     You can see the Log Information by double clicking on the status record in right side window.
    u2022     Now in left side window, you can see the Control Record, Data Record & Status Record of the IDOC
    u2022     Now go to T. Code SE16
    u2022     Give the table name ZBAPI_STUD & press F7
    u2022     See the contents of the table
    u2022     The table is updated with the students records transferred from 800 client with our selection program.
    Reward if helpful
    Thanks
    Jagadesh.G

  • IDOC fields suppressing

    hi all
    my idoc contains so many fields..i want to send only recquired fields..how to suppress remaining fields or segments
    regards
    shankar

    hi
    Use transaction BD53 or from SALE go to Distribution scenarios -> Master data distribution -> Reduce IDOC type for master data.
    Enter ZCREMS for View (message type).
    Click on Create.
    You will see a pop-up box. Enter CREMAS in the Derived From field. Enter.
    Enter a description. Enter.
    You will see a list display with segment E1LFA1M in green and a * symbol. The symbols used in IDOC reduction are: * for mandatory, 1 for selected, - for deselected, x for core selected, and the Î.â for core not selected. The corresponding elements are highlighted in green, white, red, violet, and gray, respectively.
    Expand all trees. You will see nine other segments in red.
    Place your cursor on the E1LFB1M segment for company code data and click on Select. It turns white with a 1 symbol.
    Double-clicking on it will display a list of fields. You can select fields that you require (see Figure 7).
    Note that if a child segment is selected, its parent is also selected automatically in order to maintain the hierarchical integrity.
    After youâve selected the segments required and its fields, save.
    From the main screen, click on Activate.
    Ramesh.

  • ALE/IDOC configurations?

    Hi Experts,
    Suppose i've two R/3 systems let say R1(Source system) and R2 (Target System). Now i want to send MATMAS05 IDOC from R1 to R2. Can anyone tell wht are ALE configuration's need to b done on both systems......plz give all Tcodes which are required at both systems with descriptions....
    Pts will b rewarded to approraite answers
    Regards
    Faisal

    Hi Friend ,
    Please the process in steps .
    MASTER DATA TRANSFERMATION BETWEEN 2 DIFF CLIENTS
    •     For this scenario Client 800 is the Sender and 810 is the receiving system
    1. Creating Logical Systems
    o     Login using 800 client
    o     Go to T. Code SALE
    o     Expand Sending and Receiving Systems
    o     Expand Logical Systems
    o     Click on Define Logical System
    o     Click on New Entries
    o     Create STUD_S, STUD_R Logical Systems
    o     Save and come back
    o     Assign the STUD_S Logical System to client 800
    o     Assign the STUD_R Logical System to client 810
    2. Creating the RFCs
    o     Go to T. Code SM59
    o     Expand R/3 Connections
    o     Enter RFC Name as STUD_S
    o     Connection Type as 3
    o     Language as EN
    o     Client as 800
    o     User as  SAPUSER
    o     PWD as abap
    o     Target host as sap
    o     Click on Remote logon button to test the RFC
    o     Enter RFC Name as STUD_R
    o     Connection Type as 3
    o     Language as EN
    o     Client as 800
    o     User as  SATISH
    o     PWD as abap
    o     Target host as sap
    o     Click on Remote logon button to test the RFC
    3. Creating the Message Type
    o     Go to T. Code WE81
    o     Click on change, continue
    o     Click on New Entries button
    o     Give message type as ZBAPI_STUD_MAS and description
    o     Save and back
    4. Creating the Segment
    o     Go to T. Code WE31
    o     Give segment name as ZBAPI_STUD_SEG
    o     Enter Short Text
    o     Enter the Field Name and Data Element in the text boxes
    o     Save, continue,
    o     Click on Edit -> Set Release.
    5. Creating the Basic IDOC Object
    o     Go to T. code WE30
    o     Give obj. name as ZBAPI_STUD_IDOC
    o     Click on create
    o     Select create new radio button, give description and continue
    o     Select the IDOC obj name and click on create button
    o     Enter the segment name which is create earlier
    o     Select the check box if you want to make the segment mandatory
    o     Enter 1 in minimum number 99999 in maximum number, continue
    o     Save and back
    o     Click on Edit -> Set Release
    6. Creating Customer Distribution Model
    o     Go to T. Code BD64
    o     Click on change and Create model view button
    o     Enter the short text and Technical name as ZSTUDENT
    o     Select the model and click on Add Message Type Button
    o     Give the Sender as STUD_S,
    o                    Receiver as STUD_R,
    o                    Message Type as ZBAPI_STUD_MAS
    o     Select the model view & click on Environment -> Generate Partner Profiles
    o     Select Transfer IDOC Immediately and Trigger Immediately radio buttons
    o     Click on Execute
    o     You should get a list in green color which means it executed successfully.
    o     Back to main screen, select the model view
    o     Click Edit->Model view->Distribute
    o     Click on continue
    o     You should get a list saying model view is distributed successfully.
    7. Checking the Port
    o     Go to T. Code WE21
    o     Expand Transactional RFC
    o     Find the port from the list which is created using BD64 for STUD_R (Receiving system) RFC Destination.
    8. Checking the Partner Profiles.
    o     Go to T. Code WE20
    o     Expand Partner Type LS
    o     Select the Partner profile STUD_R
    o     Double click on Message Type ZBAPI_STUD_MAS in Outbound parmtrs.
    o     Check Receiver Port is assigned correctly
    o     Check the Basic type as your Basic IDOC object.
    9. Assigning the Message Type to Basic IDOC Object
    o     Go to T. Code WE82
    o     Click on Change & continue, New Entries button
    o     Give the Message type as ZBAPI_STUD_MAS
    o     Give Basic Type as ZBAPI_STUD_IDOC
    o     Release as 46C
    o     Save and back
    10. Creating Inbound Function Module (Posting Program)
    o     Go to T. Code SE37
    o     Create a function Module IDOC_INPUT_ZBAPI_STUD_MAS
    o     Set the Processing type as Remote Enabled Module and mode as start immed, in Attributes Tab.
    o     Import Parameters
    INPUT_METHOD                 LIKE     BDWFAP_PAR-INPUTMETHD
    MASS_PROCESSING     LIKE     BDWFAP_PAR-MASS_PROC
    NO_APPLICATION_LOG     LIKE     SY-DATAR
    MASSSAVEINFOS                 LIKE     MASSSAVINF
    o     Export Parameters
    WORKFLOW_RESULT          LIKE     BDWF_PARAM-RESULT
    APPLICATION_VARIABLE     LIKE     BDWF_PARAM-APPL_VAR
    IN_UPDATE_TASK          LIKE     BDWFAP_PAR-UPDATETASK
    CALL_TRANSACTION_DONE  LIKE     BDWFAP_PAR-CALLTRANS
    o     Tables
    IDOC_CONTRL     LIKE     EDIDC
    IDOC_DATA          LIKE     EDIDD
    IDOC_STATUS     LIKE     BDIDOCSTAT
    RETURN_VARIABLES     LIKE     BDWFRETVAR
    SERIALIZATION_INFO     LIKE     BDI_SER
    o     Exceptions
    WRONG_FUNCTION_CALLED
    o     Source Code
    DATA: FIRST_TRANC LIKE MARA_UEB-TRANC,
          ZBAPI_STUD_SEG like zbapi_stud.
    DATA: ZBAPI_STUD LIKE ZBAPI_STUD.
      DATA: I_ZBAPI_STUD LIKE ZBAPI_STUD.
      DATA: C_TRUE                         VALUE 'X'.
      DATA: C_FALSE                        VALUE ' '.
    DATA: BEGIN OF T_IDOC_ROLLNO OCCURS 0,
            DOCNUM LIKE EDIDC-DOCNUM,
            ROLLNO LIKE ZBAPI_STUD-ROLLNO,
          END   OF T_IDOC_ROLLNO.
      DEFINE APPEND_RESFIELDS.
        PERFORM APPEND_RES_FIELDS TABLES T_MFIELDRES
                                         T_RES_FIELDS
                                  USING  &1
                                         COUNTER-D_IND.
      END-OF-DEFINITION.
      DATA: I_MARA_UEB LIKE MARA_UEB.
      DATA: I_ZSTUD_UEB LIKE ZBAPI_STUD.
      DATA: I_MAKT_UEB LIKE MAKT_UEB.
      DATA: I_MARC_UEB LIKE MARC_UEB.
      DATA: I_MARD_UEB LIKE MARD_UEB.
      DATA: I_MFHM_UEB LIKE MFHM_UEB.
      DATA: I_MARM_UEB LIKE MARM_UEB.
      DATA: I_MEAN_UEB LIKE MEA1_UEB.
      DATA: I_MBEW_UEB LIKE MBEW_UEB.
      DATA: I_STEU_UEB LIKE STEU_UEB.
      DATA: I_STEUMM_UEB LIKE STEUMM_UEB.
      DATA: I_MLGN_UEB LIKE MLGN_UEB.
      DATA: I_MLGT_UEB LIKE MLGT_UEB.      " //br010797 neu zu 4.0
      DATA: I_MPGD_UEB LIKE MPGD_UEB.
      DATA: I_MPOP_UEB LIKE MPOP_UEB.
      DATA: I_MVEG_UEB LIKE MVEG_UEB.
      DATA: I_MVEU_UEB LIKE MVEU_UEB.
      DATA: I_MVKE_UEB LIKE MVKE_UEB.
      DATA: I_MPRW_UEB LIKE MPRW_UEB.
      DATA: I_LTX1_UEB LIKE LTX1_UEB.
      DATA: HELP_MARC_UEB LIKE MARC_UEB.
      DATA: T_MARA_UEB LIKE MARA_UEB OCCURS 0.
      DATA: T_MAKT_UEB LIKE MAKT_UEB OCCURS 0.
      DATA: T_MARC_UEB LIKE MARC_UEB OCCURS 0.
      DATA: T_MARD_UEB LIKE MARD_UEB OCCURS 0.
      DATA: T_MFHM_UEB LIKE MFHM_UEB OCCURS 0.
      DATA: T_MARM_UEB LIKE MARM_UEB OCCURS 0.
      DATA: T_MEAN_UEB LIKE MEA1_UEB OCCURS 0.
      DATA: T_MBEW_UEB LIKE MBEW_UEB OCCURS 0.
      DATA: T_STEU_UEB LIKE STEU_UEB OCCURS 0.
      DATA: T_STEUMM_UEB LIKE STEUMM_UEB OCCURS 0.
      DATA: T_MLGN_UEB LIKE MLGN_UEB OCCURS 0.
      DATA: T_MLGT_UEB LIKE MLGT_UEB OCCURS 0.    " //br010797 neu zu 4.0
      DATA: T_MPGD_UEB LIKE MPGD_UEB OCCURS 0.
      DATA: T_MPOP_UEB LIKE MPOP_UEB OCCURS 0.
      DATA: T_MVEG_UEB LIKE MVEG_UEB OCCURS 0.
      DATA: T_MVEU_UEB LIKE MVEU_UEB OCCURS 0.
      DATA: T_MVKE_UEB LIKE MVKE_UEB OCCURS 0.
      DATA: T_MPRW_UEB LIKE MPRW_UEB OCCURS 0.
      DATA: T_LTX1_UEB LIKE LTX1_UEB OCCURS 0.
    Internal fields/ tables
    DATA: FLAG_ERROR_HAPPENED.
    DATA: flag_material_exists. "//br210397 zu 4.0 keine Verwendung mehr
      DATA: FLAG_EXIT_TO_BE_DONE.
      DATA: HELP_TABIX LIKE SY-TABIX.
      DATA: HELP_TRANC LIKE MARA_UEB-TRANC.
      DATA: HELP_ALAND LIKE STEU_UEB-ALAND.
      DATA: HELP_VKORG LIKE MVKE-VKORG.
      DATA: HELP_WERKS LIKE T001W-WERKS.
      DATA: HELP_LFDNR LIKE STEU_UEB-LFDNR.
      DATA: LAST_MARC_TRANC LIKE MARA_UEB-TRANC.
      DATA: LAST_MLGN_TRANC LIKE MARA_UEB-TRANC.    " //br010797 neu zu 4.0
      DATA: LAST_TEXT_TRANC LIKE MARA_UEB-TRANC.
      DATA: CURRENT_TABIX LIKE SY-TABIX.
      DATA: GENERAL_SUBRC LIKE SY-SUBRC.
      DATA: HELP_FACTOR TYPE P DECIMALS 3.
      DATA: USER_SEGMENTS LIKE EDIDD OCCURS 0 WITH HEADER LINE.  " insert
      DATA: CUST_SEGMENT LIKE EDIDD.
      DATA: I_MFIELDRES LIKE MFIELDRES.
    DATA: I_MERRDAT LIKE MERRDAT.
      DATA: I_EDIDD LIKE EDIDD.
                                           " //br neu zu 3.1g
      DATA: T_RES_FIELDS LIKE DELFIELDS OCCURS 0 WITH HEADER LINE.
      DATA: T_MFIELDRES LIKE MFIELDRES OCCURS 0.
      DATA: T_MERRDAT LIKE MERRDAT OCCURS 0.
      DATA: T_EDIDD LIKE EDIDD OCCURS 0.
    DATA: BEGIN OF t_matnr OCCURS 0, "//br210397 zu 4.0
            matnr LIKE mara-matnr,   " wird nicht mehr verwendet
          END OF t_matnr.            "
      DATA: BEGIN OF COUNTER,
              TRANC LIKE MARA_UEB-TRANC,
              D_IND LIKE MARA_UEB-D_IND,
            END OF COUNTER.
    DATA: BEGIN OF t_idoc_tranc OCCURS 0,                          " 4.0
            docnum LIKE edidc-docnum,                              "
            tranc  LIKE mara_ueb-tranc,                            "
          END OF t_idoc_tranc.                                     "
      DATA T_IDOC_TRANC LIKE MATIDOCTRANC OCCURS 0 WITH HEADER LINE."
      DATA: FLAG_FITS.
      DATA: APPLICATION_SUBRC LIKE SY-SUBRC.
      DATA FLAG_MUSS_PRUEFEN LIKE SY-DATAR.
      DATA MAX_ERRORS LIKE T130S-ANZUM.    " 4.0
    note 419281
      DATA : FLG_MASS.
      CLEAR : FLG_MASS.
      FIELD-SYMBOLS: .            " 4.0
    ALE-distribution unity : IDOC status set by locking      "note0361838
      data:                                                     "note0361838
        it_dsp_idocstat like bdidocstat                         "note0361838
          occurs 0 with header line.                            "note0361838
    Initialize data - general
      REFRESH T_MFIELDRES.
      REFRESH T_IDOC_TRANC.
      REFRESH T_IDOC_TRANC.                "JH/02.02.98/4.0C  KPr100004993
    REFRESH t_idoc_tranc_segment.   " //br 40 : unnötig
    REFRESH matnr_tranc.            "    -"-
    REFRESH t_matnr.
      COUNTER-TRANC = 1.
      COUNTER-D_IND = 1.
      REFRESH T_MARA_UEB.
      REFRESH T_MAKT_UEB.
      REFRESH T_MARC_UEB.
      REFRESH T_MARD_UEB.
      REFRESH T_MFHM_UEB.
      REFRESH T_MARM_UEB.
      REFRESH T_MEAN_UEB.
      REFRESH T_MBEW_UEB.
      REFRESH T_STEU_UEB.
      REFRESH T_STEUMM_UEB.
      REFRESH T_MLGN_UEB.
      REFRESH T_MLGT_UEB.                  " //br010797 neu zu 4.0
      REFRESH T_MPGD_UEB.
      REFRESH T_MPOP_UEB.
      REFRESH T_MVEG_UEB.
      REFRESH T_MVEU_UEB.
      REFRESH T_MVKE_UEB.
      REFRESH T_MPRW_UEB.
    REFRESH VKORG_ALAND.
    REFRESH WERKS_ALAND.
      CLEAR APPLICATION_SUBRC.
      REFRESH T_MERRDAT.
    Check if right function is called
      READ TABLE IDOC_CONTRL INDEX 1.
      IF SY-SUBRC <> 0.
        EXIT.
      ELSE.
        IF  IDOC_CONTRL-IDOCTP <> 'ZBAPI_STUD_IDOC'.
          RAISE WRONG_FUNCTION_CALLED.
        ENDIF.
      ENDIF.
      LOOP AT IDOC_CONTRL.
      Initialize data - per IDOC
      t_idoc_tranc-docnum = counter-tranc.
        T_IDOC_TRANC-DOCNUM = IDOC_CONTRL-DOCNUM.
        T_IDOC_TRANC-FIRST_TRANC_IDOC = COUNTER-TRANC + 2.
        APPEND T_IDOC_TRANC.
      Select segments which belong to IDOC
        REFRESH T_EDIDD.
        LOOP AT IDOC_DATA WHERE DOCNUM = IDOC_CONTRL-DOCNUM.
          APPEND IDOC_DATA TO T_EDIDD.
        ENDLOOP.
       BUSINESS TRANSACTION EVENT (header / data)         "note0388000
         call function 'OPEN_FI_PERFORM_MGV00200_E'         "note0388000
              exporting                                     "note0388000
                  idoc_header       = idoc_contrl           "note0388000
                  FLG_APPEND_STATUS = 'X'                   "note0388000
              tables                                        "note0388000
    (DEL)       idoc_data         = idoc_data "note0388000 note0418561
                  idoc_data         = t_edidd               "note0418561
                  idoc_status       = idoc_status           "note0388000
              exceptions                                    "note0388000
                  others       = 1.                         "note0388000
         if sy-subrc = 1.                                   "note0388000
            continue.                                       "note0388000
         endif.                                             "note0388000
      Within one IDOC: loop through data segments:
      Prepare internal tables for the current material
        LOOP AT T_EDIDD INTO IDOC_DATA.
        Transform from CoreData to Normal Data if necesary
          CASE IDOC_DATA-SEGNAM.
           WHEN 'E1MARAC'.
    *--COMMENTED BY SATISH
             PERFORM MOVE_E1MARAC_TO_E1MARAM USING IDOC_DATA.
           WHEN 'E1MAKTC'.
             PERFORM MOVE_E1MAKTC_TO_E1MAKTM USING IDOC_DATA.
    *--COMMENTES ENDED BY SATISH
             WHEN 'ZBAPI_STUD_SEG'.
              PERFORM MOVE_E1MARAC_TO_E1MARAM USING IDOC_DATA.
                CLEAR I_ZBAPI_STUD.
    Second: Move E1MARAC into E1MARAM
                I_ZBAPI_STUD = IDOC_DATA-SDATA.
    Third: Move E1MARAM back into IDOC-line
                IDOC_DATA-SDATA =  I_ZBAPI_STUD.
                IDOC_DATA-SEGNAM = 'ZBAPI_STUD_SEG'.
          ENDCASE.
          CURRENT_TABIX = SY-TABIX.
          COUNTER-D_IND = COUNTER-D_IND + 1.
          COUNTER-TRANC = COUNTER-TRANC + 2.
          CASE IDOC_DATA-SEGNAM.
             WHEN 'ZBAPI_STUD_SEG'.
            Initialize data - per material
              COUNTER-D_IND = 1.
              FIRST_TRANC = COUNTER-TRANC.
            interpret segment
              ZBAPI_STUD_SEG = IDOC_DATA-SDATA.
              MOVE-CORRESPONDING ZBAPI_STUD TO I_ZSTUD_UEB.
              T_IDOC_ROLLNO-DOCNUM  = IDOC_CONTRL-DOCNUM.
              T_IDOC_ROLLNO-ROLLNO  = I_ZSTUD_UEB-ROLLNO.
              APPEND T_IDOC_ROLLNO.
           ENDCASE.
                if not ZBAPI_STUD_SEG is initial.
                 ZBAPI_STUD-MANDT  = ZBAPI_STUD_SEG-MANDT.
                 ZBAPI_STUD-ROLLNO = ZBAPI_STUD_SEG-ROLLNO.
                 ZBAPI_STUD-FNAME  = ZBAPI_STUD_SEG-FNAME.
                 ZBAPI_STUD-LNAME  = ZBAPI_STUD_SEG-LNAME.
                  INSERT ZBAPI_STUD FROM ZBAPI_STUD_SEG.
                  COMMIT WORK.
                ENDIF.
    *-- ALE ditribution unity : update IDOC status                "note03618
          LOOP AT it_dsp_idocstat.                                  "note036
             LOOP AT IDOC_STATUS WHERE DOCNUM = it_dsp_idocstat.    "note036
                DELETE idoc_status INDEX sy-tabix.                  "note036
             ENDLOOP.                                               "note036
             APPEND it_dsp_idocstat TO idoc_status.                 "note036
          ENDLOOP.                                                  "note036
    *--GENERATING THE IDOC STATUS
      PERFORM HANDLE_ERROR_EXT             " //br40
                  TABLES                                        "
                     IDOC_CONTRL                                "
                     IDOC_STATUS                                "
                     RETURN_VARIABLES                           "
                     T_MERRDAT                                  "
                     T_IDOC_TRANC                               "
                     T_IDOC_ROLLNO          "JH/4.0C/KPr100004993
                  USING                                         "
                     GENERAL_SUBRC                              "
                     NO_APPLICATION_LOG                         "
                     MASSSAVEINFOS         "wk/40c
                  CHANGING                                      "
                     WORKFLOW_RESULT.                           "
                  PERFORM HANDLE_ERROR
                              TABLES
                                 IDOC_CONTRL
                                 IDOC_STATUS
                                 RETURN_VARIABLES
                                 T_MERRDAT
                                 T_IDOC_ROLLNO     "JH/4.0C/KPr100004993
                              USING
                                 APPLICATION_SUBRC
                              CHANGING
                                 WORKFLOW_RESULT.
      SORT T_IDOC_ROLLNO BY ROLLNO. "note 315124
    React on general error
      DATA: I_MERRDAT LIKE MERRDAT.
      IF GENERAL_SUBRC <> 0.
        I_MERRDAT-MSGTY = 'E'.
        I_MERRDAT-MSGID = SY-MSGID.
        I_MERRDAT-MSGNO = SY-MSGNO.
        I_MERRDAT-MSGV1 = SY-MSGV1.
        I_MERRDAT-MSGV2 = SY-MSGV2.
        I_MERRDAT-MSGV3 = SY-MSGV3.
        I_MERRDAT-MSGV4 = SY-MSGV4.
        APPEND I_MERRDAT TO T_MERRDAT.
      ENDIF.
      LOOP AT T_MERRDAT INTO  I_MERRDAT
                        WHERE MSGTY = 'S'  "success
                        OR    MSGTY = 'D'  "dummy
                        OR    MSGTY = 'I'  "Information " //br011097 zu 3.1I
                        OR    MSGTY = 'H'  "dummy       " 4.0
                        OR    MSGTY = 'W'. "warning
        DELETE T_MERRDAT.
      ENDLOOP.
        ENDLOOP.
      ENDLOOP.
    ENDFUNCTION.
    *&      Form  handle_error_ext
    FORM HANDLE_ERROR_EXT
            TABLES
               IDOC_CONTRL                   STRUCTURE EDIDC
               IDOC_STATUS                   STRUCTURE BDIDOCSTAT
               RETURN_VARIABLES              STRUCTURE BDWFRETVAR
               T_MERRDAT                     STRUCTURE MERRDAT
               IDOC_TRANC                    STRUCTURE MATIDOCTRANC
    JH/02.02.98/4.0C  KPr100004993 (Anfang)
               T_IDOC_ROLLNO                 STRUCTURE T_IDOC_ROLLNO
    JH/02.02.98/4.0C  KPr100004993 (Ende)
            USING
               GENERAL_SUBRC                 LIKE SY-SUBRC
               NO_APPLICATION_LOG            LIKE SY-DATAR
               MASSSAVEINFOS                 LIKE MASSSAVINF
            CHANGING
               WORKFLOW_RESULT               LIKE BDWF_PARAM-RESULT.
      DATA FLAG_ERROR_HAPPENED.
      DATA I_MERRDAT LIKE MERRDAT.
      DATA IDOC_INDEX_2_SUBRC LIKE SY-SUBRC.
      DATA AL_HANDLES TYPE BAL_T_LOGH. "//br99
      SORT T_IDOC_ROLLNO BY ROLLNO.                        "note 315124
    React on general error
      IF GENERAL_SUBRC <> 0.
        REFRESH T_MERRDAT.
      i_merrdat-tranc = 0.                              " //br261197
        READ TABLE IDOC_TRANC INDEX 1.     " zu 40b
        I_MERRDAT-TRANC = IDOC_TRANC-FIRST_TRANC_IDOC.          "
        I_MERRDAT-MSGTY = 'E'.
        I_MERRDAT-MSGID = SY-MSGID.
        I_MERRDAT-MSGNO = SY-MSGNO.
        I_MERRDAT-MSGV1 = SY-MSGV1. I_MERRDAT-MSGV2 = SY-MSGV2.
        I_MERRDAT-MSGV3 = SY-MSGV3. I_MERRDAT-MSGV4 = SY-MSGV4.
        APPEND I_MERRDAT TO T_MERRDAT.
      ENDIF.
    DATA: C_TRUE,
          C_FALSE VALUE 'X'.
    If error happened ==> Rollback whole work....
      LOOP AT T_MERRDAT INTO I_MERRDAT WHERE MSGTY NA 'SDHWI'.
        EXIT.
      ENDLOOP.
      IF SY-SUBRC = 0.
        FLAG_ERROR_HAPPENED = C_TRUE.
        ROLLBACK WORK.
      ELSE.
        FLAG_ERROR_HAPPENED = C_FALSE.
      ENDIF.
    Set IDOC status
    two cases:
    single IDOC-processing: ==> error can be written in IDOC status
    package processing ==> anononymous "package error" for all IDOCs
      READ TABLE IDOC_CONTRL INDEX 2.
      IDOC_INDEX_2_SUBRC = SY-SUBRC.
      IF SY-SUBRC = 0.
        IF 1 = 2.                          "//br40
          MESSAGE E051(B1).                                     "
        ENDIF.                                                  "
        CLEAR I_MERRDAT.
        I_MERRDAT-MSGID = 'B1'.
        I_MERRDAT-MSGTY = 'E'.
        I_MERRDAT-MSGNO = '051'.
      ENDIF.
      IF IDOC_INDEX_2_SUBRC NE 0 OR FLAG_ERROR_HAPPENED = C_FALSE.
      Nur in diesen Fällen wird Application Log geschrieben
      Delete all Successes and Dummy records from t_merrdat
      DELETE t_merrdat WHERE msgty = 'S'  "success         " testweise
                       OR    msgty = 'D'. "dummy           "
        LOOP AT T_MERRDAT INTO I_MERRDAT WHERE MSGTY = 'D'.     "
          I_MERRDAT-MSGTY = 'S'.                                "
          MODIFY T_MERRDAT FROM I_MERRDAT.                      "
        ENDLOOP.                                                "
      ENDIF.
      WORKFLOW_RESULT = 0.
      LOOP AT IDOC_CONTRL.
      Set IDOC status
        CLEAR IDOC_STATUS.
        IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
        IF FLAG_ERROR_HAPPENED = C_FALSE.
    Application log
          PERFORM WRITE_APPL_LOG TABLES IDOC_TRANC
                                        T_MERRDAT
                                        IDOC_STATUS
                                 USING  IDOC_CONTRL
                                        FLAG_ERROR_HAPPENED
                                        NO_APPLICATION_LOG
                                        MASSSAVEINFOS
                                        AL_HANDLES.
        idoc_status-status = '53'.       "OK!
        APPEND idoc_status.
    JH/02.02.98/4.0C  KPr100004993 (Anfang)
        Fill Return variables
          CLEAR RETURN_VARIABLES.
          RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
          RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'.
          APPEND RETURN_VARIABLES.
        Verknüpfungseintrag anlegen
          READ TABLE T_IDOC_ROLLNO WITH KEY ROLLNO = IDOC_CONTRL-DOCNUM
                                  BINARY SEARCH.
          IF SY-SUBRC = 0.
            RETURN_VARIABLES-DOC_NUMBER = T_IDOC_ROLLNO-ROLLNO.
            RETURN_VARIABLES-WF_PARAM = 'Appl_Objects'.
            APPEND RETURN_VARIABLES.
          ENDIF.
    JH/02.02.98/4.0C  KPr100004993 (Ende)
        ELSE.
          IF IDOC_INDEX_2_SUBRC NE 0.
    Application Log
            PERFORM WRITE_APPL_LOG TABLES IDOC_TRANC
                                          T_MERRDAT
                                          IDOC_STATUS
                                   USING  IDOC_CONTRL
                                          FLAG_ERROR_HAPPENED
                                          NO_APPLICATION_LOG
                                          MASSSAVEINFOS
                                          AL_HANDLES.
          ELSE.
            IDOC_STATUS-MSGID = I_MERRDAT-MSGID.
            IDOC_STATUS-MSGTY = I_MERRDAT-MSGTY.
            IDOC_STATUS-MSGNO = I_MERRDAT-MSGNO.
            IDOC_STATUS-MSGV1 = I_MERRDAT-MSGV1.
            IDOC_STATUS-MSGV2 = I_MERRDAT-MSGV2.
            IDOC_STATUS-MSGV3 = I_MERRDAT-MSGV3.
            IDOC_STATUS-MSGV4 = I_MERRDAT-MSGV4.
            IDOC_STATUS-STATUS = '51'.     "ERROR!
            APPEND IDOC_STATUS.
          ENDIF.
        Fill Return variables
          CLEAR RETURN_VARIABLES.
          RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
        return_variables-wf_param = c_wf_par_processed_idocs.
          RETURN_VARIABLES-WF_PARAM = 'Error_IDOCs'.
          APPEND RETURN_VARIABLES.
          WORKFLOW_RESULT = 99999.
        ENDIF.
      APPEND idoc_status.
      ENDLOOP.
      IF NO_APPLICATION_LOG IS INITIAL.
        CALL FUNCTION 'BAL_DB_SAVE'                           "//br99
             EXPORTING
                  I_IN_UPDATE_TASK = ' '
                  I_SAVE_ALL       = ' '
                  I_T_LOG_HANDLE   = AL_HANDLES.
           EXCEPTIONS
                LOG_NOT_FOUND    = 1
                SAVE_NOT_ALLOWED = 2
                NUMBERING_ERROR  = 3
                OTHERS           = 4.
        CALL FUNCTION 'BAL_GLB_MEMORY_REFRESH'                "//br99
             EXPORTING
                I_AUTHORIZATION          =
                  I_REFRESH_ALL            = ' '
                  I_T_LOGS_TO_BE_REFRESHED = AL_HANDLES.
           EXCEPTIONS
                NOT_AUTHORIZED           = 1
                OTHERS                   = 2
      ENDIF.
    ENDFORM.                               " handle_error
    Save, check and activate
    11. Assigning the Inbound Function Module to Basic Type & Message Type
    o     Go to T. Code WE57
    o     Click on change, continue, continue and New Entries Button
    o     Enter the Module as IDOC_INPUT_ZBAPI_STUD_MAS
    o     Type as “F”
    o     Basic Type as ZBAPI_STUD_IDOC
    o     Message Type as ZBAPI_STUD_MAS.
    o     Direction as 2
    o     Save and back
    Now Login in 810 client
    12. Assigning the Inbound Function Module in ALE Table
    o     Go to T. Code BD51
    o     Click on continue, New Entries button
    o     Give the Inbound Function Module IDOC_INPUT_ZBAPI_STUD_MAS
    o     Give Input t. as 0 (zero)
    o     Save and back
    13. Creating Process Code
    o     Go to T. Code WE42
    o     Click on Change, New Entries Button
    o     Give Process Code name as ZSTUD, give Description & Save
    o     Select Processing with ALE Services Radio button
    o     Select Processing by Function Module Radio button
    o     Click the ALE Table (arrow Icon) in Identification
    o     Give the Function Module Name ZIDOC_INPUT_ZBAPI_STUD_MAS
    o     Give maximum number of repeats 0
    o     Save and back, back
    o     Select the process code from the list & click on Logical Messages Icon
    o     Give the Message Type as ZBAPI_STUD_MAS
    o     Save & Back, Save & Back, Save & Back
    14. Changing the Customer Distribution model in Receiving system
    o     Go to T. Code BD64
    o     Click on change and Create model view button
    o     Select the model view & click on Environment -> Generate Partner Profiles
    o     Select Transfer IDOC Immediately and Trigger Immediately radio buttons
    o     Click on Execute
    o     You should get a list in green color which means it executed successfully.
    15. Assigning the Process Code to Message Type in Receiving System
    o     Go to T. Code WE20
    o     Expand Partner Type LS
    o     Select the Partner Profile STUD_S
    o     Double click on Message Type ZBAPI_STUD_MAS in Inbound parmtrs.
    o     Give the Process Code as ZSTUD
    o     Click on Trigger Immediately Radio button
    o     Save & Back
    o     Save & Back
    16. Creating the Selection Program (Outbound Program)
    •     Login in client 800.
    •     Go to T. Code SE38
    •     Create a Report Program as   ZSTUD_SEND with the following code
    REPORT ZSTUD_SEND
           NO STANDARD PAGE HEADING.
    TABLES: ZBAPI_STUD.
    DATA: IT_STUD LIKE ZBAPI_STUD OCCURS 0 WITH HEADER LINE.
    SELECTION-SCREEN:BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
    SELECT-OPTIONS: S_ROLLNO FOR ZBAPI_STUD-ROLLNO.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN:BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-H02.
    PARAMETERS:  P_MESTYP LIKE EDIDC-MESTYP,
                 P_RCVPRN LIKE TBDLST-LOGSYS.
    SELECTION-SCREEN:END OF BLOCK B2.
    SELECTION-SCREEN:END OF BLOCK B1.
    START-OF-SELECTION.
      PERFORM CREATE_STUDENT.
      PERFORM CREATE_IDOC.
    *&      Form  CREATE_STUDENT
          sending student
    FORM CREATE_STUDENT.
    SELECT * FROM ZBAPI_STUD
       INTO TABLE IT_STUD
       WHERE ROLLNO IN S_ROLLNO.
    ENDFORM.                    " CREATE_STUDENT
    *&      Form  CREATE_IDOC
          IDOC Creation
    FORM CREATE_IDOC.
    DATA : IMAS_DATA LIKE EDIDD OCCURS 10 WITH HEADER LINE,
           IMAS_CON LIKE EDIDC OCCURS 10 WITH HEADER LINE,
           ICOM_CON LIKE EDIDC OCCURS 10 WITH HEADER LINE.
    IMAS_CON-RCVPRT = 'LS'.
    IMAS_CON-RCVPRN = P_RCVPRN.
    IMAS_CON-IDOCTP = 'ZBAPI_STUD_IDOC'.
    IMAS_CON-MESTYP = P_MESTYP.
    IMAS_CON-DIRECT = 1.
    APPEND IMAS_CON.
    LOOP AT IT_STUD.
      IMAS_DATA-SEGNAM = 'ZBAPI_STUD_SEG'.
      IMAS_DATA-SDATA = IT_STUD.
      APPEND IMAS_DATA.
    ENDLOOP.
    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
         EXPORTING
              MASTER_IDOC_CONTROL            = IMAS_CON
            OBJ_TYPE                       = ''
            CHNUM                          = ''
         TABLES
              COMMUNICATION_IDOC_CONTROL     = ICOM_CON
              MASTER_IDOC_DATA               = IMAS_DATA
       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.
    ENDIF.
    COMMIT WORK.
    LOOP AT  ICOM_CON.
      WRITE :/ 'IDOC: ', ICOM_CON-DOCNUM, 'CREATED SUCCESSFULLY'.
    ENDLOOP.
    ENDFORM.                    " CREATE_IDOC
    17. Transferring the student records from 800 to 810 client
    •     Execute Report Program   ZSTUD_SEND
    •     Give the Range of Roll Nos to Transfer
    •     Give Message Type as    ZBAPI_STUD_MAS
    •     Give Receiver Logical system as   STUD_R
    •     Execute
    •     You should get the IDOC Number
    •     Take the IDOC Number and go to T. Code WE05 & Execute
    •     In Outbox you can see the IDOC Status
    •     Select the status record in left side window
    •     Double click on the Status record in right side window
    •     You can see the Control Record, Data Record and Status Records for that IDOC
    •     If the ICON is green and the status code is 3, it means the IDOC is passed to PORT Successfully.
    Now Login in 810 client
    •     Go to T. Code WE05 & Execute
    •     You can see the status record in left side window
    •     If the status no is 53 and color is green, it means the IDOC is Posted to Application successfully.
    •     You can see the Log Information by double clicking on the status record in right side window.
    •     Now in left side window, you can see the Control Record, Data Record & Status Record of the IDOC
    •     Now go to T. Code SE16
    •     Give the table name ZBAPI_STUD & press F7
    •     See the contents of the table
    •     The table is updated with the students records transferred from 800 client with our selection program.
    Reward if useful
    Regrds
    Jagadeesh.G

  • Distribution model mandatory

    Hi Experts,
    Can anybody please explain when the Distribution model is mandatory for IDoc generation?
    I have done a set up in my sap sytem that as soon as PO is created, IDoc is generated.
    But if I delete the distribution model, IDoc is not generated. But in some other cases, IDocs are generated without having a distribution model. Can someone pls throw some light on this.
    Thanks very much.
    Regards,
    Rudresh

    Hi,
    Distribution Model describes the ALE message flow between logical systems. The relationships between logical systems, message types, BAPIs, and filters are defined in the distribution model. Applications and the ALE layer user the distribution model to determine receivers and to control the data distribution. You can specify the relationships between logical systems, message types, BAPIs and filters in the distribution model. Applications and the ALE layer use the model to determine receivers and to control the data distribution.  In the distribution model you can specify the messages to be sent to a given logical system. You can also define the conditions for the content and dispatch of messages in the filters.  The distribution model consists of one or more views that you can define. With more complex distribution tasks you can assign business sub-areas or groups of logical systems to separate views.
    The relevant views of the distribution model must be available in all the logical systems involved in ALE. You can find the functions for distributing views in Customizing for ALE.
    After creating distribution model we generate partner profiles.In case you have maintained the receiver details in partner profiles in transaction WE20 then you don't have to maintain distribution model.
    KR Jaideep,

  • Material and vendor transfer to GTS sytem

    I am using GTS 8.0. We have a very peculiar issue. Newly cretaed vendor & material doesnot get transferred to GTS. Please provide the step by step configuration settings to transfer material and vendor master to GTS using rbdmidoc.eg. change pointers activation, message type, reduced message type, Distribution model, Idoc partner profile

    In Transaction BD60, make sure that the Function Module /SAPSLL/CREMAS_DISTRIBUTE_R3 is assigned for Message Type /SAPSLL/CREMAS_SLL.  And in Transaction BD52 for that Message Type, make sure that fieldname 'KEY' is assigned for table LFA1, object KRED.
    If those settings are already correct, then try to check whether the Change Pointer record is not being created, or if the CP record is not being sent to GTS.  To do that; for a new Vendor not received in GTS, check for a corresponding entries in tables BDCP / BDCPV.
    And of course, check for log entries in GTS (System Monitoring > Transfer Logs > Business Partners), and also check in SM58 for any RFC failures.
    Hope that helps.
    Regards,
    Dave

Maybe you are looking for