terça-feira, 23 de outubro de 2018

Outbound Idocs by ALE

Introduction:
 
In this document the steps are mentioned to do the ALE configuration as well as to populate and send the custom IDOC from sending client/system and the processing of IDOC in receiving client/system.

This document does not demonstrate any business scenario. The main purpose of this document is to make you understand the different configuration and technical settings to be done to send the custom IDOC from SAP R/3. It is highly recommended to use the standard IDOC types and message types provided by SAP or extend the standard IDOC types to suite the business requirements.

This document assumes that you have two different clients available on SAP server (You can also follow the steps mentioned in this document to setup the ALE scenario between two different SAP systems) . Also the assumption is that you have all the necessary authorizations to execute the transactions mentioned in this document.

It is recommended for you to get the basic understanding of ALE and its basic configuration steps like setting up the distribution model, setting up partner profiles, maintaining logical ports, message types etc. before going through this document.

Generally the logical systems are available for client of SAP system in which you are working. Please do not create logical systems unnecessarily. Use the existing logical system attached to the client in which you intend to work. You can find the logical system name attached to the client in which you are working by going to the transaction SALE.

1.    Create Custom IDOC Type:
To create the IDoc type, follow these next few steps:
-          Enter transaction WE30 (ALE -> Extensions -> IDoc types -> Maintain IDoc type)
-          Type in 'IDoc Type name' and click on Basic IDoc type, click the Create icon. ('IDoc Type name' is the name of your custom IDoc type)
-          Click on Create new (we are creating an IDoc from scratch but you may want to copy another IDoc if it is similar to your requirements) and enter a description, and press enter
-          Click on 'IDoc Type Name' and then on the Create icon
-          Enter 'Segment Type Name' (name of your custom segment type) as the segment type (must start with Z1), check mandatory if the segment must exist (in this case check it), enter 1 in minimum number and 1 as maximum number. (Make the maximum number 9999999999 if there are going to be many of these segments in each IDoc. IE. When line items are passed via IDocs), click on Segment editor
-          Enter a description for your segment type and create
-          Enter a description for your segment, enter each field required in your IDoc.
-          Save and generate, then press back
-          To release the segment choose Goto --> Release from the menu
-          Check the box on the line of your new segment
-          Save, back and enter
-          Your IDoc type structure should be displayed with your new segment
-          Save and back
-          To release the IDoc type choose Edit->Set Release type from the menu and Yes.

Your IDoc is now ready for use. If you need to add fields or segments to your IDoc type, you will need to cancel the release of the IDoc type as well as the segment release using a similar procedure followed above (except now you uncheck the release box for the segment and you choose cancel release for the IDoc type).
2.    Define Logical system (Transaction SALE):
 To Define Logical system, follow these next few steps:
-          Goto transaction SALE and select Logical Systems-> Define Logical System.
-          You will get the message that 'Caution: The table is cross-client'. Go ahead by clicking on 'Continue'. You will go to the next screen. On next screen define 2 logical systems (K100 as Sender and K200 as Receiver). You can decide your own name while defining the logical system. The next step involved is assigning these logical systems to client. If logical system is already created and assigned to the client then you need not create the new logical system. Use the existing logical systems which are already assigned to clients.


3.    Create RFC Destination for receiving client in sending client (Transaction SM59):(Transaction SM59):
 
-            Goto transaction SM59 and then click on ABAP or R/3 Connection and then create.
-          Enter the Logon Details of the client system in that newly created RFC connection.
-          After saving it Test the connection and also check whether you are able to logon to the Recieving system if not then there is a problem in the RFC connection (You need to report it to the BASIS team)
-          If you can logon remotely then RFC connection has been made.
4.    Define a new message type (Transaction WE81):
  • Goto transaction WE81 and create a message type by giving the description
  • save it.
5.    Assign IDOC type to the message type (Transaction WE82):
o    After creating message type, Goto transaction WE82 and attach your Idoc type with message type which you have created.

6.    Maintain and Distribute the distribution Model (Transaction BD64):
o     In transaction BD64 goto change mode and create a distribution model and add message type to it.
o    while giving the message type you have to enter the Logical system names of the sending and recieving system, after doing it , Save it.
o    Then click on that distribution modal and then goto Environment-> Generate Partner profile->Execute.
o    In this way your partner profile will be generated and you check it by going to the transaction WE20 and your message type will be in the Outbound parameters of the Logical partner of the recieving system.
o    After that goto Edit -> model view -> Distribute, in this way distribute the distibution Modal.

7.    Write a custom code (Executable Report) to populate IDOC:

Here is the code which I have written to populate the IDOC 'Z_CUSTOM_IDOC'. You can refer to this program and write your own code to populate the IDOC created by you. You can write function module, module pool or report program based on the requirement.
 *&---------------------------------------------------------------------*
*& Report Z_CREATE_CUSTOM_IDOC                                       
*&                                                                     *&---------------------------------------------------------------------*
*& This report will create the custom IDOC of type 'Z_CUSTOM_IDOC' with*
*& with message type 'Z_CUSTOM_MESSAGE_TYPE'                         
*&---------------------------------------------------------------------
report  z_create_custom_idoc  .
parameters: p_matnr like mara-matnr obligatory.
data: wa_z1customsegment type z1customsegment.
 data: i_edidc like edidc occurs 0 with header line,      i_edidd like edidd occurs 0 with header line,    
wa_edidd type edidd,    
wa_edidc type edidc. *Segment name
wa_edidd-segnam = 'Z1CUSTOMSEGMENT'.
*This IDOC type contains only one segment.
*This segment contains only 1 field i.e. 'matnr'
wa_z1customsegment-matnr = p_matnr.
wa_edidd-sdata = wa_z1customsegment.
append wa_edidd to i_edidd.
 *Message type
wa_edidc-mestyp = 'Z_CUSTOM_MESSAGE_TYPE'.
*IDOC type
wa_edidc-idoctp = 'Z_CUSTOM_IDOC'.
*Receiver Partner type
wa_edidc-rcvprt = 'LS'.
*Receiving Logical system name
wa_edidc-rcvprn = 'K200'.
*Sender Partner Type
wa_edidc-sndprt = 'LS'.
*Sender Logical System
wa_edidc-sndprn = 'K100'.
 call function 'MASTER_IDOC_DISTRIBUTE'
exporting  
 master_idoc_control                  = wa_edidc
*   OBJ_TYPE                             = ''
*   CHNUM                                =  ''
tables 
  communication_idoc_control           = i_edidc    master_idoc_data                     =  i_edidd exceptions   error_in_idoc_control                = 1   error_writing_idoc_status            = 2   error_in_idoc_data                   = 3   sending_logical_system_unknown       = 4   others                               = 5          .
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
else.
read table i_edidc into wa_edidc with key status = '03'.
 if sy-subrc = 0.  
write: 'IDOC Number: ', wa_edidc-docnum, ' is sent to logical port'.
endif.
endif.
*A COMMIT WORK must be dispatched in the calling program, otherwise the
*IDocs may not be dispatched. 
commit work.
***************************************************************

8.    Get IDOC number.
o    By executing the above program, you get the Idoc Number for the particular material .
o    You can write the above code anywhere based upon your requirements.
o    You can also Goto Transaction WE02 or WE05 to check the Status of the Idoc and the Data which is sent in the segment.
o    Execute the Transaction (WE02 or WE05) and check whether the data is correctly populated in data records. Also make sure that IDOC status icon is Green.
o    You can also know the status of an Idoc from Transaction WE47.
************************************
Important Transaction Codes:
SALE - IMG ALE Configuration root
WE20 - Manually maintain partner profiles
BD64 - Maintain customer distribution model
BD71 - Distribute customer distribution model
SM59 - Create RFC Destinations
BDM5 - Consistency check (Transaction scenarios)
BD82 - Generate Partner Profiles
BD61 - Activate Change Pointers - Globally
BD50 - Activate Change Pointer for Msg Type
BD52 - Activate change pointer per change.doc object
BD59 - Allocation object type -> IDOC type
BD56 - Maintain IDOC Segment Filters
BD53 - Reduction of Message Types
BD21 - Select Change Pointer
BD87 - Status Monitor for ALE Messages
BDM5 - Consistency check (Transaction scenarios)
BD62 - Define rules
BD79 - Maintain rules
BD55 - Defining settings for IDoc conversion
WEDI - ALE IDoc Administration
WE21 - Ports in Idoc processing
WE60 - IDoc documentation
SARA - IDoc archiving (Object type IDOC)
WE47 - IDoc status maintenance
WE07 - IDoc statistics
BALE - ALE Distribution Administration
WE05 - IDoc overview
BD87 - Inbound IDoc reprocessing
BD88 - Outbound IDoc reprocessing
BDM2 - IDoc Trace
BDM7 - IDoc Audit Analysis
BD21 - Create IDocs from change pointers
SM58 - Schedule RFC Failures
Basic config for Distributed data:
BD64: Maintain a Distributed Model
BD82: Generate Partner Profile
BD64: Distribute the distribution Model
Programs
RBDMIDOC - Creating IDoc Type from Change Pointers
RSEOUT00 - Process all selected IDocs (EDI)
RBDAPP01 - Inbound Processing of IDocs Ready for Transfer
RSARFCEX - Execute Calls Not Yet Executed
RBDMOIND - Status Conversion with Successful tRFC Execution
RBDMANIN - Start error handling for non-posted IDocs
RBDSTATE - Send Audit Confirmations
FOr testing you can use WE19.


Fonte: https://wiki.scn.sap.com/wiki/display/ABAP/Outbound+Idocs+by+ALE

Nenhum comentário:

Postar um comentário