Vous êtes sur la page 1sur 60

ALE(Application Link & Enabling)

ALE is SAP’s Technology to Integrate the Distributed(Physically Separated) Applications Of an Enterprise


If Any.

Note : SAP is Integrated By Default i.e When the Same (Single)SAP System is Used by the entire Enterprise , the
Materials Created by MM Dept Can be Accessed By SD,WM,PP etc as long as they are Authorized and Which
reduces the redundancy of DATA and Avoids un-unnecessary Communication across the Depts.

When it is Not Possible & Profitable to run the Entire Enterprise from the Same SAP System(Place) it is
recommended to go for Distributed Applications, to let the Apps Work Autonomously (Independently) and the
Distributed Systems can be Integrated If Required via SAP’s Technology ALE.

Note : ALE Can be Used to Integrate Both


SAP-CRM
SAP <-> SAP and
SAP <-> Non-SAP

Integrated Applications(SAP-ERP)

SAP-PP SAP-SD

SAP-MM SAP –WM


Distributed Applications

SAP-PP SAP-MM

Can be Integrated Via ALE

SAP-SD
Non -SAP
Note : Using ALE, Integration Can be done at the required Application Data Level But Not at the entire
Application Level.

SD
WM

Material Master
MM
PP

Here Intergration Should be Done to Make Sure that Every Material ie Created, Changed in MM Should be
there in SD,WM,PP Always
Note : The DataTransfer across all the Distributed Applications that are integrated through ALE is Always
Via IDoc (Intermediate Document) and Which Acts as the Container to Carry the data .

Note: IDoc is SAP’s Own Format So that Only SAP – Systems Can understand the Data in IDoc Format
and While Integrating SAP <->Non-SAP, a Mediator(Interface) is required to
Convert IDOC  Any Other Format.

SAP IDO SAP


C

Middle ware
Tool is
OutBound Required
IDO Which Can XM Non-SAP
SAP C Convert L

InBound IDoc <->XML


With No Loss
Of Data

EAI (Enterprise Application Integration) Tools


Ex Tools: TIBCO, WebMethods, …(Non-SAP Tools)
SAP –PI (Process Integrator)/ XI (Xchange Infrastructure)
Note: ALE Can Understand the Syntax & Semantics (Meaning) Of the Data i.e transferred through IDoc i.e

System A Send Customers Company Code Data Conditionally

= 1000 WHEN BUKRS = 3000 This is Known As


= 2000 IDoc Filtering
System B System D
System C

Note : Here Customer’s Company Code Data Only Send Conditionally i.e When the Ccode is 1000 -> Sys B
2000 -> Sys C etc and rest of the Data Can be Sent Un-Conditionally.

IDocType In Detail
IDoc Type: Collection Of Segment types. And Each Segment Type is Collection Related Fields.

Ex : Details Of Std.IDOc type DEBMAS06 For Customer Master

Fields From Segment type Segment Type Name


KUNNR Name1 ORT01 LAND1 Customer General Data(E1KNA1M)
KUNNR BUKRS ZTERM Customer Company Code
Data(E1KNB1)
KUNNR BANKL BANKS BANKN Customer Bank Data(E1KNBK)
Tcodes: WE31 -> Segment Type Editor
WE30 -> IDoc Type Editor
Note : All the Standard Segment Types Begins with ‘E1’ and So it is recommended to begin the Custom
Segment types With ‘Z1’ / ‘Y1’ .
IDoc In Detail
IDOc is the Runtime Component(Instance) Of IDoc type With Unique No(IDoc Number) and
With Three Types of Records

Control record -> Maintains Sendor & Receiver Info.


Can be Only ONE For Each IDoc -> Table EDIDC
Data Records -> Application Data In the Segments -> Can be <N> > 0
Table-> EDIDD(Str)/EDID4(Table)
Status Records -> Status Of IDoc Journey -> Can be <N> > 0
Table EDIDS
Note : WE02/WE05/WE07 is to Display List Of IDOCs.

Steps to Create IDoc Type


1) Create the Required Segment Types –
a. Execute WE31

2) Create the IDOc type i.e Arrange the Segment Types according to the Hierarchy Of Data
And Characterstics of the Data.
Execute - WE30

Note: Std.Segment Names Begin with ‘E1’ so that it is recommended to begin the Custom Segments With
‘Y1’/’Z1’

Note: The Total Length Of all the Fields in a Segment type cannot be more than 1000 Chars(Bytes).
IT_EDIDD

Outbound (IDOc Generation & Dispatching) Procress SegName SDATA(char,1000)


E1KNA1M WA_KNA1
Outbound Program Prepare Master IDoc E1KNB1 WA_KNB1

1 Distribution Model
Select Data For the 2 Tcode – BD64
Segements Of IDocType
List Of Receivers
TType
IDOc type Recvr
ZCUST R1
Database ALE Service Layer
ZCUST R2
3 ZCUST R3
F
M MASTER_IDOC_DISTRIBUTE
IDoc1 IDoc2 IDoc3 Communication IDocs/
Outbound Partner Receiver Specific IDocs
Profile(WE20)

Maintains Mode Of Dispatch ALE Communication Layer


Partnr IDoc Type Dispatches according to Partner Profile
4
Mode
R1 ZCUST Immediate
R2 ZCUST Collect R1 R2 R3
R3 ZCUST Immediate

Note : Master IDoc is an Internal Table to Maintain the Data Records(IT_EDIDD)


For All the Segments types Of the IDoc Type in the Same Physical Sequence
Of the Segment Types in the respective IDoc Type.
Note : Zero Master Idocs Created For No Data in Database.
Zero Communications Idocs Created For No Receivers in Distribution Model.

Example Standard Outbound IDoc Progs(Tcodes)


Tcode – BD10 - Send Materials
BD12 – Send Customers
BD14 – Send Vendors
Inbound (IDoc Posting Process) i.e After Receiving the IDoc
Triggers/Executes
Inbound Program (Process Code
Inserts Data From Segements Into Inbound Partner Profile – WE20
Respective DB Tables
Partner IDoc type Inbound Prog/Process Code
ALE Service Layer S1 DEBMAS DEBM
Database CREMAS CRE1
MATMAS

IDoc1 IDoc2 IDoc3

ALE Communication Layer

Communication IDocs
IDoc1 IDoc IDoc
1 2 3
Message Type Vs IDoc Type
Ex : KUNNR – Customer No (Data Element)

(Data Element)
Vendor No LIFNR
EBELN - Puchase Order No(Data Element)
CHAR,10

DOMAIN ZTEXT10

IDOC TYPE Acts as Domain and Message Type Acts as Data Element i.e IDoc types Can be re-used
For Variaous Application Data So that , Only IDoc type name is not ENOUGH to Identify the Purpose
and the Same Can be done Via Message Type.

IDoc Type Message Type Purpose


DEBMAS06 DEBMAS Send Customer

MATFET Request Material

ALEREQ01 DEBFET Request Customer


(Request)
CREFET Request Vendor

Note : Message Type is to Identify the Application Data in the IDoc type(Purpose)
Mainly When the Same IDoc type Is used for Carrying Various types of Application Data.
List Of Some Standard Message Types
Application IdocType Message Type
Outbound Prog/ Inbound Prog/
Tcode Process Code
Send Mat. MATMAS01,02… MATMAS BD10 MATM

Send Cust. DEBMAS01,02 … DEBMAS BD12 DEBM

Send Vend. CREMAS01,02,… CREMAS BD14 CREM(Old)/CRE1

Send Cost COSMAS01,02… COSMAS BD16 COSM


Center

Note: Table EDIMSG -> For All Message Types & IDoc Types.
Note: Transaction Code is a Link to the Program and Similarly Process Code is a Link to FM.

TSTC -> Table For All the Transaction Codes


TBD05 -> Table For List Of All the Distribution Models & the Entries( Sendor, Receiver, Message Type)
T000 -> Table For List Of Clients & their Logical System Names
ALE Communication Settings
Acts as the Bridge Between the Participated Systems and it is One time Activity and
Not Specific to Any Message Type. It is Generally done by the BASIS Consultants
or ALE Administrators.

Note : Communication From / To an SAP System is Always Via it’s Client So that the Participated
Clients Should be Identified With Unique Names Called Logical Systems(Tcode – SALE)

Note : Make Sure that Both the Logical Systems Can Communicate With Each Other and It Can be
By Maintaining the RFC Destination between the Logical Systems (Tcode – SM59),
Where the Logon details are Actually Provided.

Integration Between 800 and 810 of 7PM


Note : Each Should have one Unique Name known as Logical Systems

Ex : For 800 -> LS_800_7PM


810 -> LS_810_7PM
Client Logical Sys Name
Ex : 800 from 11AM LS_800_11 india123

From 11AM LS_810_11 india786

Identify the Participated Systems(Clients) With Unique Name Names i.e Called Logical
Systems.
Execute – Tcode - SALE
3) Maintain the RFC Destination Between the Participated Clients(Logical Systems)
a. Execute – Tcode - SM59

Mandatory Outbound Configuration For Each Message & Receiver


1) ADD the Receiver LS ,Message type Details in Distribution Model(BD64)
2) Maintain the Outbound Partner Profile For Each Receiver & Message Type(WE20)

Note : Outbound Partner Profile Also Can be Generated From Distribution Model Itself(BD64)

Execute BD64

Testing IDoc Generation & Dispatching Process For DEBMAS


1) Create a New Customer - XD01 -> 56000
2) Send the Customer -> Execute -> BD12
3) Check the IDoc List -> WE05

Note : Make Sure that Outbound Configuration is Maintained for DEBMAS .

Trouble Shoot the ALE Outbound Process


Successful Flow Of Outbound Process

Status 03 -> Sent(Dispatched OK) Doesn’t mean that Received/Delivered OK.


and the Same has to be Confirmed From the Sendor(Current) System It Self.
i.e to Confirm the Same From Sendor Sys
Execute the Std.Program – RBDMOIND (Status Conversion Prog)
For the IDoc with Status – 03

Status After Execution

12 03

Received OK Not Received and Due to Error in RFC


Destination or Rarely Due to the Traffic in the
‘Que’
Note : To re-process the Failed IDocs in RFC -> Execute BD87

Note :
When the IDoc Final Status Is – 30(Yellow Lights)
– Ready to Dispatch
i.e Niether Successful Nor Un-Successful.

Reason: Either Due to the Traffic in the ‘Que’ OR


Due to the Collect Option in the Outbound Parameters.

In Realtime, IDocs are Collected and Dispatched at the


END of the Day Instead of Dispatching Immediately.
Note : In the Outbound Partner Profile , When the Mode of Dispatch
Is Collect, IDoc will be in Ready to Dispatch Status and
In Real time All the IDocs are Collected and Dispatched
Generally at the End of the Day.

Execute Program RSEOUT00 to Dispatch


All the Collected IDOcs at Once and In Realtime
This Prog is Generally Scheduled Daily Once In Background.

Similarly for the Collect Option in the Inbound ,


IDoc Status – 64 – Ready to Process (Yellow Lights)
Execute Program - RBDAPP01, to Post all the Collected IDocs

Note : Frequently Occurred Outbound Error : Status – 26 – IDoc Syntax Error


Possible Errors
Data Record is Not Filled For Mandatory Segment
. Segment Name is Unknown
. Parent, Child Relation Ship is Violated
. Data records are not filled according to the Physical
Sequence Of the Segment Types
. Too Many Repetitions of a Segment
.
Trouble Shoot the Inbound Process
Successful Flow Of Inbound Process

Note :When the IDoc is Stopped with Status – 64(Yellow)


Ready to Transferred to App(Inbound Prog)
Due to the Trigger By Background (Collect)Option
in the Inbound Parameters

Execute Program – RBDAPP01 ->


To Process/Post All the Collected(Ready) IDocs at Once.

Note : Status Codes 0 – 49 (Outbound)


50 – 99 (Inbound)

Filtering: Send the IDoc Conditionally i.e according to the Receivers Requirement.

Either Outbound/Inbound IDocs that are Failed Should be reprocessed from the Point of Failure itself

Tcode – BD87.
Filtering
Purpose: To Generate & Dispatch the IDoc Conditioanlly i.e
according to receiver's requirement
Types Of Filtering
. IDoc Filtering (BD64)
. Segment Filtering(BD56)
. Reduced Message Type(BD53)

Segment Filtering(BD56) In Detail


Maintains the List Of Segments that are not required Always i.e Un-Conditionally
Between the Sendor & Receiver.

System A
Sends Customer
System B System D
System C
Bank Data Company Code Data Sales Data
Not Required Not Required Not Required

Steps to Maintain Segment Filtering


Execute – BD56
IDoc Filtering (BD64) In Detail
Is Conditional i.e By Checking the Values Of the Fields in the Segments.
If the Condition Fails -> Only the respective Segment(s) is Dropped to that
Particular Receiver.

Send Customer Company Code Data(Segment: E1KNB1M) Conditionally


A

= 1000 WHEN BUKRS = 3000


B C

Steps : Execute – BD64


Distribution
Model

Steps : Execute BD64

Note : By Default, For Each IDoc type , Some Std.Filtering Objects(Fields) are
Provided &
If Required , Custom Filtering Objects(Fields) Can be Created for any Message type.

Steps to Create New Filtering Objects For Message Type CREMAS


i.e For Bank Ctry Key
1) Execute –BD95
2) Execute – BD59
To Link the above Filtering Object to the respective Segment’s Field

Steps to Create New Filtering Objects For Message Type DEBMAS


Req : Filtering Object For Terms of payment(ZTERM) from
Segment E1KNB1M(Customer Company Code Data)

Step1: Execute BD95 to Create Filter Object

Step2 : Execute BD59 ->

Note : Make Sure that the New Filtering Object is also now available ,
along with Std.Filtering Objs
and Verify the Same in BD64 By Adding/Creating Filter Group
for the respective Message type.

Reduced Message Type(BD53) ->


Ex :
IDoc type -> Seg1 to Seg50
Receivers 10 receivers

All the 10 Receivers Needs Only S1, S10, S20,S30,S40,S50


So that it is recommended to Create a Message type i.e Reduced MsgType of the Existing
Only With these 6 Segments.

Note : Outbound & Inbound Programs of Std.Message types can be used by the
Respective Reduced Message Types ALso.

Note : BD14 -> Send Vendors Can be used For CREMAS and ZRCREMAS(Reduced Msgtype)
But Make Sure that an Entry is Maintained in Distribution ModeL for the required
Message type I,e CREMAS/ZRCREMAS

Steps to Create Reduced Msg type


Execute BD53.

Note : Distributing the Data through ALE(IDOC) Can be Done Via


. Stand Alone Programs(BD10,BD12,BD14) etc…
. Change Pointers

Change Pointers Technique


Note : The Stand Alone Programs i.e BD10,BD12,BD14 Generates the
Master IDoc Un-Conditionally with Whole Data Even While Sending the
Same Data Repeatedly With No Changes.

Note : Change Pointer Technique Can guarantee that Master IDOC Creation
Can be Done Only For the Newly Created and Changed Data.

Note: Make Sure that Change Pointer Specific Configuration is Maintained


at the Sendor System to Generate the IDoc from the Changes.

1) Execute BD61 –
Note : One time Activitiy and Not Specific to Any Message type

2) Execute BD50
Note : This has to be repeated For Each Message Type

Note : The Same Outbound Program BD21(RBDMIDOC) can Generate the


IDocs from the Changes of Any i.e Customer, Vendor, Material,etc…Because
All the Changes and their Status is Saved Into the Same Set Of Tables
(CDHDR,CDPOS,BDCP,BDCPS)
Testing : Execute Outbound Prog : RBDMIDOC after the Change Pointers Settings and Make
Sure that Master IDocs are Generated Only for the New & Changed Ones.

Note : In Realtime, BD21(RBDMIDOC) Is Executed in Background , Generally at the END Of


Of Every Day for Each required Message Type.

Note : Make Sure that the Input required to Execute the Program in
Background is Saved as Variant , So that Both Program & Variant Can be Provided as
As an Input for Background Job, While Scheduling.

To Create the Variant -> Execute the Tcode/Program and Here it is RBDMIDOC & Fill the Input
i.e

Steps to Schedule a Program(RBDMIDOC – BD21 ) in Background


Execute SM36

The Status of the Job Can be Checked Via SM37.

Change Pointers In Detail - Technically


Every Change in SAP Master Data Is Logged Into
Tables

CDHDR, Change Document Header Is the Standard


CDPOS, Change Document Items Functionality AND Not
Specific to
Message Type AND ALE
Checks For Change Pointers
Specific Configuration
BD61 – Activate Change Pointers Generally
BD50 - Activate Change Pointers For Message Type
IF Maintained
Change Pointers & their Status is Mainained
For the respective Message Into Tables

BDCP : Change BDCPS : Change


Pointers for the above Pointers for Message
Change Docs Type & Their Status

When the Change Pointer Technique Is Not Working i.e Not Generating the
Master IDoc Even for the Changed Data

1) Check For the Change Pointer Specific Settings(BD61,BD50)


2) Check for the Change Document Option in the Further Characterstics Of
The respective Data Element.
Should be Checked

3) Make Sure that an entry Exist in BD52 for the respective Field.
Mandatory INBOUND Configuration For Each Message Type
Maintain the Partner Profile & Inbound Parameters
For the Message type to be Processed/Posted. ( WE20 )

Inbound Parameters : Process Code(Inbound Prog), Message Type


Mode Of Triggering the Inbound Prog
. Immediate
.Collect(By Background)

Note : To Process the Standard Message type – the Mandatory Configuration is


enough.

Execute – WE20
Note : Outbound Programs Can be Implemented in any Form i.e as Program,FM,…
But Inbound Programs Should be Implemented as Function Module Only the FM
Has to be Linked to the Process Code .

Note : The Structure (Interface Parameters) of all the Inbound FMs is SAME, So that
It is recommended to Copy any Std.Inbound FM -> Custom Inbound FM
to Make use of Interface Parameters and Implement the respective Business
Logic.
Ex : FM : ‘IDOC_INPUT_DEBITOR’ -> Process Code -> DEBM
‘IDOC_INPUT_CREDITOR’ -> Process Code -> CRE1

Custom IDocs :
When there is No Standard IDoc type to Carry the required Data.

Outbound IDoc Requirement : To Carry the Customer Legacy Data From Table : KNA1 and
Which is Added as a result of Screen Enhancement(BADI)
IDoc type : ZDEBMAS_01
Segment type : Z1LEGACY_KNA1
KUNNR -> SAP Customer No
LKUNNR -> Legacy Customer No
LEGSYS -> Legacy System Name

Outbound Configuration For Custom IDoc Type


1) Create a New Message Type – Execute WE81

2) Maintain Link between the Message Type & IDoc Type


Execute – WE82
3) Add the Message type to DM and
Generate the Outbound Partner Profiles(BD64)
Outbound Program For Custom IDoc Type

*&---------------------------------------------------------------------*
*& Report ZDEMO_SEND_CUST_LEGACY_DATA *
*& *
*&---------------------------------------------------------------------*
REPORT ZDEMO_SEND_CUST_LEGACY_DATA .

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.


PARAMETER :P_sKUNNR TYPE zsKUNNR OBLIGATORY,
P_MSGTYP TYPE EDI_MESTYP DEFAULT 'ZDEBMAS',
P_LOGSYS TYPE LOGSYS.
SELECTION-SCREEN END OF BLOCK B1.
**************************************************
* WAs & ITABs
**************************************************
DATA : WA_CTRL_REC TYPE EDIDC,
WA_MASTER_IDOC TYPE EDIDD,
IT_MASTER_IDOC TYPE TABLE OF EDIDD,
IT_COMM_IDOCS TYPE TABLE OF EDIDC,
WA_COMM_IDOCS TYPE EDIDC,
v_RECVSYSTEM type RECVSYSTEM,
wa_z1LEGACY_KNA1 TYPE z1LEGACY_KNA1.

SELECT SINGLE * INTO WA_z1LEGACY_KNA1 FROM zLEGACY_KNA1


WHERE SKUNNR = P_SKUNNR.
IF SY-SUBRC = 0.
WA_MASTER_IDOC-SEGNAM = 'Z1LEGACY_KNA1'.
WA_MASTER_IDOC-SDATA = WA_z1LEGACY_KNA1.
APPEND WA_MASTER_IDOC TO IT_MASTER_IDOC.
ENDIF.

IF IT_MASTER_IDOC IS INITIAL.
MESSAGE I000(ZALL). "Zero Master IDocs
EXIT.
ELSE.
MESSAGE I008(ZALL). "One Master IDoc
IF P_LOGSYS IS INITIAL. "No Recivered Enterd
*Check for the receivers in the DM
SELECT SINGLE RCVSYSTEM INTO v_recvsystem FROM TBD05
WHERE SNDSYSTEM = 'LS_800_9AM'
AND MESTYP = P_MSGTYP.
IF SY-SUBRC <> 0. "No Receivers In the DM Also
MESSAGE I001(ZALL). "Zero Comm IDocs
exit.
ENDIF.
ENDIF.

WA_CTRL_rec-MESTYP = P_MSGTYP.
WA_CTRL_rec-IDOCTP = 'ZDEBMAS01'.
IF P_LOGSYS IS NOT INITIAL.
WA_CTRL_REC-RCVPRT = 'LS'.
WA_CTRL_REC-RCVPRN = P_LOGSYS.
ENDIF.

"Triggers ALE Service Layer & Communication Layer


"Only When there is a Master IDOc and Receivers
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
MASTER_IDOC_CONTROL = WA_CTRL_REC "<-
* OBJ_TYPE = ''
* CHNUM = ''
TABLES
COMMUNICATION_IDOC_CONTROL = IT_COMM_IDOCS "->
MASTER_IDOC_DATA = IT_MASTER_IDOC "<-
* 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.
WRITE / 'List Of Communication IDocs'.
LOOP AT IT_COMM_IDOCS INTO WA_COMM_IDOCS.
WRITE / WA_COMM_IDOCS-DOCNUM COLOR 1.
ENDLOOP.
ENDIF.

ENDIF.

IDoc type Details


Segment type – Z1LEGACY_KNA1 (WE31)
SKUNNR
LKUNNR
LEGSYS

IDoc type - ZDEBMAS01(WE30)


*&---------------------------------------------------------------------*
*& Report ZDEMO_SEND_CUST_LEGACY_IDOC *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZDEMO_SEND_CUST_LEGACY_IDOC .
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
PARAMETER :P_sKUNNR TYPE zsKUNNR OBLIGATORY,
P_MSGTYP TYPE EDI_MESTYP DEFAULT 'ZDEBMAS',
P_LEGSYS TYPE LOGSYS.
SELECTION-SCREEN END OF BLOCK B1.

DATA : WA_CTRL_REC TYPE EDIDC,


WA_MASTER_IDOC TYPE EDIDD,
WA_COMM_IDOC TYPE EDIDC,
IT_MASTER_IDOC TYPE TABLE OF EDIDD,
IT_COMM_IDOCS TYPE TABLE OF EDIDC,

WA_LEGaCY_KNA1 TYPE Z1LEGACY_KNA1,


V_RCVSYSTEM TYPE RECVSYSTEM.

SELECT SINGLE SKUNNR LKUNNR LEGSYS INTO WA_LEGACY_KNA1 FROM


ZLEGACY_KNA1 WHERE SKUNNR = P_SKUNNR.
IF SY-SUBRC = 0.
WA_MASTER_IDOC-SEGNAM = 'Z1LEGACY_KNA1'.
WA_MASTER_IDOC-SDATA = WA_LEGACY_KNA1.
APPEND WA_MASTER_IDOC TO IT_MASTER_IDOC.

ENDIF.

IF IT_MASTER_IDOC IS INITIAL.
MESSAGE I007(ZALL).
EXIT.
ELSE.
MESSAGE I008(ZALL).

IF P_LEGSYS IS NOT INITIAL.


WA_CTRL_REC-RCVPRT = 'LS'.
WA_CTRL_REC-RCVPRN = P_LEGSYS.
ENDIF.

WA_CTRL_rec-MESTYP = P_MSGTYP.
WA_CTRL_rec-IDOCTP = 'ZDEBMAS01'.
*Trigger ALE Service Layer & Communication Layer
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
MASTER_IDOC_CONTROL = WA_CTRL_REC
* OBJ_TYPE = ''
* CHNUM = ''
TABLES
COMMUNICATION_IDOC_CONTROL = IT_COMM_IDOCS
MASTER_IDOC_DATA = IT_MASTER_IDOC
* EXCEPTIONS
* ERROR_IN_IDOC_CONTROL = 1
* ERROR_WRITING_IDOC_STATUS = 2
* ERROR_IN_IDOC_DATA = 3
* SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
* OTHERS = 5
.
DATA V_LINES TYPE I.
DESCRIBE TABLE IT_COMM_IDOCS LINES V_LINES.
MESSAGE I010(ZALL) WITH V_LINES.
ENDIF.
*&---------------------------------------------------------------------*
*& Report ZDEMO_SEND_CUST_LEGACY_DATA *
*& *
*&---------------------------------------------------------------------*
REPORT ZDEMO_SEND_CUST_LEGACY_DATA .

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.


PARAMETER :P_sKUNNR TYPE zsKUNNR OBLIGATORY,
P_MSGTYP TYPE EDI_MESTYP DEFAULT 'ZDEBMAS',
P_LOGSYS TYPE LOGSYS.
SELECTION-SCREEN END OF BLOCK B1.

**************************************************
* WAs & ITABs
**************************************************
DATA : WA_CTRL_REC TYPE EDIDC,
WA_MASTER_IDOC TYPE EDIDD,
IT_MASTER_IDOC TYPE TABLE OF EDIDD,
IT_COMM_IDOCS TYPE TABLE OF EDIDC,
WA_COMM_IDOCS TYPE EDIDC,
v_RECVSYSTEM type RECVSYSTEM,
wa_z1LEGACY_KNA1 TYPE z1LEGACY_KNA1.

SELECT SINGLE * INTO WA_z1LEGACY_KNA1 FROM zLEGACY_KNA1


WHERE SKUNNR = P_SKUNNR.
IF SY-SUBRC = 0.
WA_MASTER_IDOC-SEGNAM = 'Z1LEGACY_KNA1'.
WA_MASTER_IDOC-SDATA = WA_z1LEGACY_KNA1.
APPEND WA_MASTER_IDOC TO IT_MASTER_IDOC.
ENDIF.

IF IT_MASTER_IDOC IS INITIAL.
MESSAGE I000(ZALL). "Zero Master IDocs
EXIT.
ELSE.
MESSAGE I008(ZALL). "One Master IDoc
IF P_LOGSYS IS INITIAL. "No Recivered Enterd
*Check for the receivers in the DM
SELECT SINGLE RCVSYSTEM INTO v_recvsystem FROM TBD05
WHERE SNDSYSTEM = 'LS_800_9AM'
AND MESTYP = P_MSGTYP.
IF SY-SUBRC <> 0. "No Receivers In the DM Also
MESSAGE I001(ZALL). "Zero Comm IDocs
exit.
ENDIF.
ENDIF.

WA_CTRL_rec-MESTYP = P_MSGTYP.
WA_CTRL_rec-IDOCTP = 'ZDEBMAS01'.
IF P_LOGSYS IS NOT INITIAL.
WA_CTRL_REC-RCVPRT = 'LS'.
WA_CTRL_REC-RCVPRN = P_LOGSYS.
ENDIF.

"Triggers ALE Service Layer & Communication Layer


"Only When there is a Master IDOc and Receivers
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
MASTER_IDOC_CONTROL = WA_CTRL_REC "<-
* OBJ_TYPE = ''
* CHNUM = ''
TABLES
COMMUNICATION_IDOC_CONTROL = IT_COMM_IDOCS "->
MASTER_IDOC_DATA = IT_MASTER_IDOC "<-
* 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.
WRITE / 'List Of Communication IDocs'.
LOOP AT IT_COMM_IDOCS INTO WA_COMM_IDOCS.
WRITE / WA_COMM_IDOCS-DOCNUM COLOR 1.
ENDLOOP.
ENDIF.
ENDIF.

Outbound Configuration for Customer IDoc


1) Create a New Message Type (WE81)
2) Link the IDoc type & Message Type(WE82)
3) Add the Message type & Receiver Details in Distribution Model(BD64)
4) Maintain the Outbound Partner Profile for the Message type & Receiver(WE20/BD64)

Inbound Process For Custom IDocs


Note : Make Sure that, the Custom IDoc Type(WE30) and the Message Type(WE81) Are Created
& Linked With Each Other(WE82) In the Inbound System Also. It Happens Automatically
When Sr & Rr Clients are from the Same System, When the Same is Already Created in the
Sendor System(Client).

Note : Outbound Programs Can be Implemented in any way(form) i.e As a Program,FM ..


and where as Inbound Program Should be Implemented as Function Module and the Same
has to Linked to Process Code .

Process Code -> Inbound FM.

Note : The Structure(Interface Parameters) Of All the Inbound FMs is Same , So that it is recommend to
Copy any Std.Inbound FM Instead of Creating Newly and After Copying Implement the
Respective Business Logic .
Ex : Std.Inbound FM : IDOC_INPUT_DEBITOR “Post Customer Data
IDOC_INPUT_CREDITOR “Post Vendor Master
Make Sure it is Copied into Custom Function Group

1) Maintain the Other(Each Sendor) as a PARTNER and ADD the Inbound Parameters
For each Message type with Inbound Prog(Process Code) .

Execute WE20 – in the Inbound System

Inbound Configuration For Custom IDoc


1) Create the IDoc type (WE30)
2) Create Message Type(WE81)
3) Link Message type to IDoc Type(WE82) Is Pre-requisite

4) Link Inbound FM, Message type and IDoc type


Execute WE57
5) Define the characteristics Of Inbound FM
Execute BD51

Input type
0 - Call Trasaction
1 - Open SQL Statements Directly
2 - Both 0 + 1

5) Create Process Code & Link to Inbound FM


Execute – WE42

6) Maintain Inbound Partner Profile(WE20) for the Custom Message Type

Note : Inbound FM Can be tested Even Before receiving IDoc From Sendor Sys.
Note : IDoc Can be Generated and Send from Sendor System Even before Completion of
the Outbound Program.
Note : The Tcode : WE19 is for Both the above Cases.

Steps to Test the Inbound FM

Execute – WE19

Mandatory Inbound Configuration For Each Message Type


1) Create the Other LS(Sendor LS)_ as a PARTNER,
2) For Each Message Type to be Processed,
ADD the Inbound Parameters
. Message Type
TCode : WE20
. Process Code(Inbound FM/Prog)
. Mode Of Posting / Processing
. Immediate
. Trigger by Background(Similar to Collect)

Note : The Final Status Of Inbound Process(IDoc) Should be ADDed by Inbound FM


According to the Business Logic Execution i.e

53 -> Application Doc Posted


51 -> Application Doc Not Posted
FUNCTION ZIDOC_INPUT_ZDEBMAS.
DATA : WA_DATA TYPE EDIDD,
WA_Z1LEGACY_KNA1 TYPE Z1LEGACY_KNA1,
WA_IDOC_STATUS TYPE BDIDOCSTAT.
LOOP AT IDOC_DATA INTO WA_DATA.
CASE WA_DATA-SEGNAM.
WHEN 'Z1LEGACY_KNA1'.
WA_Z1LEGACY_KNA1 = wa_data-sdata.
ENDCASE.
ENDLOOP.
MODIFY KNA1 FROM WA_Z1LEGACY_KNA1.
IF SY-SUBRC = 0.
WA_IDOC_STATUS-STATUS = '53'. "Posted
WA_IDOC_STATUS-DOCNUM = WA_DATA-DOCNUM."Curr IDoc No
APPEND WA_IDOC_STATUS TO IDOC_STATUS.
ELSE.
WA_IDOC_STATUS-STATUS = '51'. "Not Posted
WA_IDOC_STATUS-DOCNUM = WA_DATA-DOCNUM.
APPEND WA_IDOC_STATUS TO IDOC_STATUS.
ENDIF.
ENDFUNCTION.

LS_800_5PM -> LS_810_5PM

Extended IDoc Type(IDoc Enhancement)


Extended Idoc = Standard IDoc + Additional Segements

To Carry the Additional Data


Along With Standard IDOc
Requirement:
Create an Extended IDoc type to Carry the Customer Legacy Data if Exists
i.e Along with SAP(Std) Customer Master Data(IDoc)

Std Message Type : DEBMAS - Customer Master


IDoc type : DEBMAS06

Steps to Create Extended IDoc type For DEBMAS


1) Create the required/Additional Segments(WE31)- Z1LEGACY_KNA1
KUNNR
LKUNNR
LEGSYS

2) Execute WE30
IDoc Related BADIs from XD01(Customer Master)

Note : Make Sure that the respective Std.Message type’s Outbound Program is
Also enhanced to fill the Data for the Additional Segments in the Extended IDoc type.

IDoc Specific Enhancement(BADI) Details From Customer Master – XD01

BADI Name : CUSTOMER_ADD_DATA_BI


Outbound Method : FILL_ALE_SEGMENTS_OWN_DATA
Inbound Method : PASS_NON_STANDARD_SEGMENT

Implementation For Outbound to Fill the Data for Additional Segments


method FILL_ALE_SEGMENTS_OWN_DATA ~FILL_ALE_SEGMENTS_OWN_DATA .
DATA : WA_Z1LEGACY_KNA1 TYPE Z1LEGACY_KNA1,
WA_E1KNA1M TYPE E1KNA1M,
wa_idoc_data type edidd.
CASE I_SEGMENT_NAME.
WHEN 'E1KNA1M'.
READ TABLE T_IDOC_DATA INTO WA_IDOC_DATA
with key SEGNAM = 'E1KNA1M' .
WA_E1KNA1M = WA_IDOC_DATA-SDATA.
SELECT SINGLE KUNNR LKUNNR LEGSYS INTO WA_Z1LEGACY_KNA1
FROM KNA1
WHERE KUNNR = WA_E1KNA1M-kunnr. “Crrent KUNNR
"WA_IDOC_DATA-sdata+3(10).
WA_IDOC_DATA-SEGNAM = 'Z1LEGACY_KNA1'.
wa_idoc_data-SDATA = WA_Z1LEGACY_KNA1.
APPEND WA_IDOC_DATA TO T_IDOC_DATA.
ENDCASE.
endmethod.

Note : Make Sure that The Extended IDoc type Name is Known to the respective Std.Message Type
Execute – WE82

Outbound Config For Extended IDoc type


1) Link the Extended IDoc type to the respective Std.Message type, Basic Type
Execute WE82

2) BD64 – Add the Receiver & Respective Std.Message (DEBMAS) to the Distribution Model &
Generate the Outbound Partner Parameters(Profile) Also .

If Already Generated for the Same Message type


i.e before Creating the Ext.IDoc type, then Change the Outbound Parameters
to ADD Extended IDoc type Name also along with the Standard(Basic) IDoc type.
i.e to Change Outbound Parameters -> Execute –> WE20

Note : To Process the Data through the Additional Segments along with Std.Segements,
Make Sure that respective Std.Outbound & Inbound Programs are
Also Extended (Enhanced).

Note : While Creating Outbound Parameters from WE20 Explictly i.e Not From BD64,
The Port has to be Created Explictly which Points the RFC Destination.

Execute WE21

Note : The Port Can be Generated automatically from the DM(BD64) Only When there is
an RFC Destination With the Name Of the Receiver Logical System in DM So that
it is recommended to Maintain the Same Name for both RFC Destination & Reciver
Logical System But they Can be Differed.

Note : Make Sure that the Outboud & Inbound Progs of the respective Std.Msg type
Are Enhanced Since Every Std.IDoc type Can be Enhanced, In Every
Std.IDOc Programs Functional Exit/BADI Should be Provided by SAP to
Process the Additional Segment Types.
IDoc Specific BADI Details From Customer Master (XD01)

Ex For Customer Master - XD01


For Customer Master Creation – Package VS
BADI -> CUSTOMER_ADD_DATA_BI
For Additional Data at Customers (Batch Input and ALE)
Methods : FILL_ALE_SEGMENTS_OWN_DATA(Outbound)
PASS_NON_STANDARD_SEGMENT(Inbound)

Implementing Outbound Method – To Fill Data Records for Additional Segments

Note : The Same Outbound IDOC BADI(Outbound Method) is Called After Filling the
Data For Each Std.Segment and It is to allow the Data Records
for the Additional Segments Also after the respective Std.Segments So that
Master IDoc Can be Prepared according to Extended IDoc type.

BADI Details Specific to IDoc From Vendor Master

CUSTOMER_ADD_DATA_BI
Method: FILL_ALE_SEGMENTS_OWN_DATA (Outbound)

method FILL_ALE_SEGMENTS_OWN_DATA ~FILL_ALE_SEGMENTS_OWN_DATA .


DATA : WA_Z1PRTY_CUST TYPE Z1PRTY_CUST,
WA_E1KNA1M TYPE E1KNA1M,
wa_idoc_data type edidd.

CASE I_SEGMENT_NAME.
WHEN 'E1KNA1M'.
READ TABLE T_IDOC_DATA INTO WA_IDOC_DATA
with key SEGNAM = 'E1KNA1M' .
WA_E1KNA1M = WA_IDOC_DATA-SDATA.
SELECT SINGLE KUNNR prty rank INTO WA_Z1PRTY_CUST
FROM KNA1
WHERE KUNNR = WA_E1KNA1M-kunnr. “Crrent KUNNR
"WA_IDOC_DATA-sdata+3(10).

WA_IDOC_DATA-SEGNAM = 'Z1PRTY_CUST'.
wa_idoc_data-SDATA = WA_Z1PRTY_CUST.
APPEND WA_IDOC_DATA TO T_IDOC_DATA.

ENDCASE.

endmethod.
Note : Make Sure that The Extended IDoc type is Created and Linked to the respective
Std.Message Type.(WE31,WE30,WE82)
Note : Make Sure that Inbound Partner Profile is Mantained for the respective Std.Message type
WE20
Note : The Same Inbound BADI(Method) is
Implementing Inbound IDoc Method(BADI) i.e to Enhance the
Std. Inbound Program to Process the Additional Segments(Tcode – SE19)

Inbound Method- PASS_NON_STANDARD_SEGMENT(Inbound)


DATA WA_Z1LEGACY_KNA1 TYPE Z1LEGACY_KNA1.
CASE I_SEGMENT_NAME.
WHEN 'Z1LEGACY_KNA1'.
WA_Z1LEGACY_KNA1 = I_SEGMENT_DATA.
ENDCASE.
UPDATE KNA1 SET LKUNNR = WA_Z1LEGACY_KNA1-SKUNNR
LEGSYS = WA_Z1LEGACY_KNA1-legsys
WHERE KUNNR = WA_Z1LEGACY_KNA1-KUNNR.
EndMethod.

*Note : Same Inbound Method/Exit is Called Only After Each Additional Segment with both Segment Name &
Segment Data as Input .

*Inbound
method IF_EX_CUSTOMER_ADD_DATA_BI~PASS_NON_STANDARD_SEGMENT .
DATA WA_Z1LEGACY_KNA1 TYPE Z1LEGACY_KNA1.
CASE I_SEGMENT_NAME.
WHEN 'Z1LEGACY_KNA1'.
WA_Z1LEGACY_KNA1 = I_SEGMENT_DATA.
ENDCASE.
UPDATE KNA1 SET SKUNNR = WA_Z1LEGACY_KNA1-SKUNNR
LEGSYS = WA_Z1LEGACY_KNA1-legsys
WHERE KUNNR = WA_Z1LEGACY_KNA1-KUNNR.
endmethod.

Note : The Same Inbound Method Is Called Repeatedly


Only After the Custom/Additional Segments
One By One with the Segment Name & Segment Data.

Implementing the Inbound BADI Method


PASS_NON_STANDARD_SEGMENT (Inbound)

To Process the Data From Additional Segments

method IF_EX_VENDOR_ADD_DATA_BI~PASS_NON_STANDARD_SEGMENT .
DATA WA_Z1LEGACY_LFA1 TYPE Z1LEGACY_LFA1.
CASE I_SEGMENT_NAME.
WHEN 'Z1LEGACY_LFA1'.
WA_Z1LEGACY_LFA1 = I_SEGMENT_DATA.
ENDCASE.
UPDATE LFA1 SET ZLLIFNR = WA_Z1LEGACY_LFA1-llifnr
ZLEGSYS = WA_Z1LEGACY_LFA1-zlegsys
WHERE LIFNR = WA_Z1LEGACY_LFA1-lifnr.
endmethod.

Note : The Same Outbound BADI(Method) is Called Repeatedly After Filling the
Data For Each Std.Segment and It is allow the Data for the Additional
Segments Also After the respective Std.Segments, Where Inbound Method
Is also Called repeatedly but Only after Each Additional Segment.

Exits
. User Exits – Via Subroutine Calls within the Std.Programs with no Functionality
inside FORM – ENDFORM.
Note : Access key is Required to Implement the FORM – ENDFORM in the
Standard Program.

Customer Exits Via Function Module Calls within the Std.Programs with no Functionality
inside FUNCTION – ENDFUNCTION.

Note: No Access key is required as there is a Custom Inlcude i.e begins with ZX Withing
Each Function Module Exit So that Writing the Business Within Custom Include
Requires No Access Key.
Note : The Same Exit Cannot be Implemented more than Once as the Same Include Program
Cannot be accessed by more than one user at a time Where as the same BADI(Interface)
Can have any no of Implementations, Because the Same Interface Can be Implemented
By any No Of Classes an In Each Class with a different Implementation.

Steps to Locate the Exits From the given transaction


Ex : XD01 – Customer Creation
1) Find out the Program Of the Tcode - XD01
2) Find Out the Package Of the above Program - SAPMF02D
3) Open the Package in SMOD - VS

Note : Through Exits, We Can Enhance Only Std.Programs(Via FM Exit),


Std.Menus (Via Menu Exit)
Std.Screen(Via Screen Exit)
But Not Std.FMs,Methods etc and the Same thing With BADIs.

Steps to Menu Exit


Note : Along with Menu Exit, Functional Module Exit Should be available to implement
The Functionality for the Additional Menu Options.
Ex Tcode : MC94(Change Flexible Planning)
Program - SAPMMCP6
Package - MCP2
Enhancement - MCP20003
Menu Options - +CU1,+CU2, … +CU9.
FM Exit - EXIT_SAPMMCP6_003 “ Processing Own Fcodes
To Implement the Exit(Enhancement)
Execute CMOD
Testing
Execute MC94

Populating SDATA
SDATA(1000)

0001 C000000001 Mr ffgfdkfdlfjlfjkhjglkhgkgjgglgflkjg

wa_idoc_data-SDATA = WA_e1KNA1m.

WA_e1KNA1m
MSGFn KUNNR ANRED
3 10 15

001 C1 Mr
WA_e1KNA1m = wa_idoc_data-SDATA.

Note : The Data in SDATA(1000) CHAR has to be Interpreted according to the


Structure of the respective Segment.

Vous aimerez peut-être aussi