2/9/2016 4:48:24 PM

Outbound IDoc steps in SAP-This blog will discuss step by step in sending an IDoc ( i.e Outbound IDoc) through ALE medium.Outbound processing in SAP involves event handling. An event in SAP is defined as an occurrence of a status change in an object. Events are created when the relevant status change occurs. Implementing outbound IDoc for QA11. The following steps will give complete end to end implementation on SAP Outbound IDoc. From this blog additionally you can configure BizTalk server. Outbound IDoc from SAP to BizTalk server.

Real time scenario on Record usage decision-QA release using the transaction code QA11

Whenever QA release is happening in SAP then outbound IDoc should be triggered to BizTalk server. As I said earlier we need triggering point during Record usage decision(QA11). So we need to implement anyone of the following enhancements.

1) Enhancement Spot

2) Business Add-Ins-(BADIs)

3) Customer exits(Function exit)

As you everyone aware how to find which enhancement will be suitable. Still if you want please read the link http://www.sappractical.com/home/blogd/how-to-find-customer-exits-in-sap-abap/ and http://www.sappractical.com/home/blogd/how-to-find-a-badi-or-kernel-badi-or-user-exit-for-a-particular-transaction-code/

Basically we need to send below the fields to BizTalk server.

a) Warehouse Number / Warehouse Complex(LGNUM)

b) Material Number(MATNR)

c) Batch Number(CHARG_D)

d) Order Number(EBELN)

e) From Status(FROM_STATUS)

f)To Status(TO_STATUS)

First we need to set up the IDoc basics.

Please follow the Step 1 to Step from the link http://www.sappractical.com/Home/blogd/sap-inbound-idoc-step-by-step/ since the IDoc type, segments, message types are common for both inbound and outbound

1. WE31-Create segment type with the name of Segment type         ZQASEG

2. WE30-Create IDoc type with the name of ZQAIT

3. WE81-Create message Type with the name of ZQAMSG

4. WE82-Assign Messages for IDoc Type(Linking message type ZQAMSG with IDoc type ZQAIT)

Now IDoc basic setups are ready and we need to implement the code in enhancements

I have found the enhancement "QEVA0007" and I have created a project which is given below.


Note:Please do not forget to activate the project or else your implementation wont work

Please write below the coding inside the Function Exit "EXIT_SAPMQEVA_007" within the INCLUDE ZXQEVU09. 

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

*&  Include           ZXQEVU09

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


DATA : lwa_qa TYPE zedi_au_qa.


FIELD-SYMBOLS : <fs_mcha> TYPE mcha.

DATA : lv_mcha  TYPE char50 VALUE '(SAPMQEVA)MCHA'.

DATA : lv_cmcha TYPE mcha,

       lv_omcha TYPE mcha.


CONSTANTS : c_segnam TYPE char50 VALUE 'ZQASEG'.

*-IDOC

DATA :   it_edidc   TYPE STANDARD TABLE OF edidc,

         it_edidd   TYPE STANDARD TABLE OF edidd.

DATA :   wa_edidd  TYPE edidd,

         wa_edidc  TYPE edidc.

DATA :   it_model TYPE TABLE OF bdi_mmodel,

         wa_model TYPE bdi_mmodel.


REFRESH : it_edidc,it_edidd,it_model.

CLEAR   : wa_edidd,wa_edidc,wa_model.


ASSIGN (lv_mcha) TO  <fs_mcha>.

IF <fs_mcha> IS ASSIGNED.

  lv_cmcha = <fs_mcha>.

  SELECT SINGLE * FROM mcha

           INTO lv_omcha

           WHERE matnr = lv_cmcha-matnr

           AND   werks = lv_cmcha-werks

           AND   charg = lv_cmcha-charg.


ENDIF.

lwa_qa-lgnum   = i_qals-lgnum.

lwa_qa-matnr   = i_qals-matnr.

lwa_qa-charg   = i_qals-charg.

lwa_qa-ebeln   = i_qals-ebeln.


IF lv_omcha-zustd IS INITIAL.

  lwa_qa-from_status = 'Unrestricted'.

ELSE.

  lwa_qa-from_status = 'Restricted'.

ENDIF.


IF lv_cmcha-zustd IS INITIAL.

  lwa_qa-from_status = 'Unrestricted'.

ELSE.

  lwa_qa-from_status = 'Restricted'.

ENDIF.


PERFORM no_data USING lwa_qa-ebeln       CHANGING lwa_qa-ebeln.

PERFORM no_data USING lwa_qa-from_status CHANGING lwa_qa-from_status.

PERFORM no_data USING lwa_qa-to_status   CHANGING lwa_qa-to_status.


CALL FUNCTION 'MMODEL_INT_VALID_GET'

  EXPORTING

    mestyp = 'ZQAMSG'

  TABLES

    model  = it_model.


wa_edidd-segnam = c_segnam.

wa_edidd-sdata  = lwa_qa.

APPEND wa_edidd TO it_edidd.

CLEAR  wa_edidd.


LOOP AT it_model INTO wa_model.

  REFRESH : it_edidc.

  wa_edidc-idoctp = 'ZQAIT'.

  wa_edidc-mestyp = wa_model-mestyp.

  wa_edidc-rcvprn = wa_model-rcvsystem.

  wa_edidc-rcvprt = 'LS'.

  APPEND wa_edidc TO it_edidc.

*-IDOC Distribute

  CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

    EXPORTING

      master_idoc_control            = wa_edidc

    TABLES

      communication_idoc_control     = it_edidc

      master_idoc_data               = it_edidd

    EXCEPTIONS

      error_in_idoc_control          = 1

      error_writing_idoc_status      = 2

      error_in_idoc_data             = 3

      sending_logical_system_unknown = 4

      OTHERS                         = 5.

ENDLOOP.

Please find below the subroutine no_data

FORM no_data USING p_old CHANGING p_new.
if p_old is INITIAL.
  p_new '/'.
endif.
ENDFORM. 

Step 5) Create distribution model view using the transaction code BD64

Note: before Create distribution model we have to create Program ID using the transaction SM59.


Go to BizTalk server and do the below settings.


Please find below the connection string which is from SAP(SM59) which has ListenerProgramId. 

sap://CLIENT=420;LANG=EN;@a/116.138.76.20/00?ListenerGwServ=sapgw00&ListenerGwHost=116.138.76.20&ListenerProgramId=PI_SAP05&RfcSdkTrace=False&AbapDebug=False


Step 6) Generate partner profile using the transaction BD64

In this method we can avoid some errors so please use the transaction code BD64


Step 7) Configure your message type, receiver port and Basic type using WE20

Actually from WE20 you can have message control or you can write your logic insite the enhancement.


Step 8) Final testing can be done using the transaction code QA11


Press enter


Select inspection lot tab and give the following inputs


Click save

and Check your outbound IDoc using WE02 due to security reason I have not shown the IDoc segment data.

I hope all of you understood the detailed steps for outbound IDoc.

Thanks for using this site and I appreciate your comments in below.

If you like this blog, please share (Facebook/LinkedIn/Google+) to click below links so it will reach to others.


COMMENTS