‎2008 Mar 25 6:33 AM
dear sir
i want to ask that how data send through ale for select particuler table-field..plz say in detailes and with t code.
thanks
‎2008 Mar 25 9:07 AM
Hi Mukesh,
Go through this to know about the ALE
http://abapprogramming.blogspot.com/2007/05/ale-abap-cross-applications.html
And download this Application-Link-Enabling.Pdf from this URL.
http://www.esnips.com/doc/065ab6a5-e42d-4aa1-a11e-308c04f7c43f/Application-Link-Enabling
I hope this is helpful to you,if so please reward me.
Thanks,
Thishya
‎2008 Mar 25 10:16 AM
Hi
You need to take the date in an internal table
and pass that internal tabel to function module
'MASTER_IDOC_DISTRIBUTE'
see the code
and ask if doubt
and also plzz reward points
ALE: CREATING AND USING NEW IDOC TYPES
SAP supplies maximal IDoc types for master data. We can create our own reduced IDoc types, by selecting only those segments and fields which are relevant to a specific project. We can also create extended IDoc types, by appending one or more segments to an existing IDoc type. In both cases, we use a standard SAP IDoc type as a template for the reduction or extension. As an alternative, R/3 allows the customers to create their own IDoc types, from scratch. This alternative method is the topic of this article.
In our simplified scenario, an ABAP program on the sending system reads a message and a one-character key entered by the user. The program adds the user name, the current date and time, and sends the information to the receiving system. The receiving system processes the data and posts it to the database. It also sets the appropriate status of the IDoc, which then can be checked in the IDoc List (WE05).
In order to achieve our task, the following steps are necessary:
1. Create data container (Idoc)
2. Create database table
3. Create outbound program
4. Create inbound function
5. Set up ALE customizing
6. Send data
Step 1: Creating a new IDoc
Create new segments
Segments are field strings that contain grouped data of the message. The name of the segment type must start with Z1. For each field in the segment, define a field name, a data element for the segment structure, and a data element for the segment documentation. The system will create three structures:
Z1xxxxx - field names
Z2xxxxx - data elements for structure definitions
Z3xxxxx - data elements for documentation
To create a new segment: in the ALE IMG, select Extensions->Idoc types->Maintain IDoc type (transaction WE31); Goto->Maintain segment. Enter the segment name and description, and click on Create. After entering the segment fields, save and activate your segment. This should be done for each new segment in your IDoc (in our case we have one segment).
Create new IDoc type
The IDoc type describes the technical structure of a message. It defines which segments will be used, and what is the hierarchical structure of the segments. For each segment, it also specifies whether it's mandatory or optional, and how many times the segment may appear in the IDoc.
To create a new IDoc type: WE30, select "Basic IDoc type", enter the name, and click on Create. Add segments to the new IDoc type (menu Segment->Create).
Create new message type
The message type describes the contents of the message. It helps the system to decide how to process the message. To create a new message type: WE30, Environment->Message types; Display->Change; New entries. Enter the message type name and description.
Link message type with IDoc type
ALE IMG->Extensions->IDoc types->Maintain message type for intermed. structure; choose "EDI: Message types and assignment to IDoc types"; Display->Change; New entries. Enter the Message type, the BasIDoc type, and the release. Your link will not be valid for prior releases.
Step 2: Create a new database table
Go to the ABAP/4 Dictionary Initial screen (SE11), and create a new table. The table should mirror the structure of the segment created above.
Step 3: Create a program for outbound processing
Fill data into Idoc and pass IDoc to ALE layer. Close LUW (commit work). The IDoc consists of a control record and one or more data records (segments). The data segments contain the data of the message. They are passed to ALE as an internal table (structure EDIDD). The control record contains general information about the IDoc (structure EDIDC). Function MASTER_IDOC_DISTRIBUTE is called to pass the IDoc to ALE. For further details, see the code in Appendix A.
Step 4: Inbound processing
Create a function module for the inbound processing. Check that the IDoc contains the correct message type. Convert the character data to internal format, if necessary. If the data is OK, post it to the database table. Otherwise, return an error message to ALE. For further details, see the code in Appendix B.
a) Allocate API to Message Type
ALE IMG->Extensions->Inbound->Allocate function module to logical message; New entries
Module name of your function
Type 'F' (function module)
BasicIDoc type you created in step 1
Message type you created in step 1
Direction '2' (inbound)
b) Declare API Attributes
ALE IMG->Extensions->Inbound->Define settings for input modules; New entries
Function module name of your function
Input t. '1' (individual input)
Dialog alllowed ' '
c) Maintain Inbound Process Code
ALE Extensions->Inbound->Maintaining process codes (inbound); select "Inbound with ALE service" ->"Processing by function module"; Create;
New entries
Identification name of your function
Step 5: Set up ALE customizing
In the distribution model, you have to define which messages are distributed from one system to another. The model directly controls the distribution. ALE IMG->Distribution customer model->Maintain customer distribution model directly; Maintain message flow. We assume that the communication parameters, like partner profiles, ports, RFC destinations, have been set up by this time. You can run a consistency check for your set up.
Step : Send data
On the sending system, run the program created in Step 3. The data will be put into an IDoc and sent to the receiving system. On the receiving system, use the IDoc overview (WE05) to check that your IDoc has arrived. If it has been processed successfully, the database table created in Step 2 must contain the new record.
Appendix A
REPORT ZALE2LK.
TABLES: Z1MESLK. "IDoc segment
PARAMETERS: MESSAGE LIKE Z1MESLK-MESSAGE OBLIGATORY,
MESKEY LIKE Z1MESLK-MESKEY OBLIGATORY.
DATA: BEGIN OF F_IDOC_HEADER.
INCLUDE STRUCTURE EDIDC.
DATA: END OF F_IDOC_HEADER.
DATA: BEGIN OF T_IDOC_DATA OCCURS 0.
INCLUDE STRUCTURE EDIDD.
DATA: END OF T_IDOC_DATA.
DATA: BEGIN OF T_COMM_IDOC_CONTROL OCCURS 0.
INCLUDE STRUCTURE EDIDC.
DATA: END OF T_COMM_IDOC_CONTROL.
CLEAR T_IDOC_DATA.
REFRESH T_IDOC_DATA.
CLEAR F_IDOC_HEADER.
move parameters into field string
Z1MESLK-MESKEY = MESKEY.
Z1MESLK-MESSAGE = MESSAGE.
add data to field string
Z1MESLK-SENDER = SY-UNAME.
Z1MESLK-MDATE = SY-DATUM.
Z1MESLK-MTIME = SY-UZEIT.
field string to IDoc-data
T_IDOC_DATA-SDATA = Z1MESLK.
segment name
T_IDOC_DATA-SEGNAM = 'Z1MESLK'.
append data
APPEND T_IDOC_DATA.
fill IDoc header
F_IDOC_HEADER-MESTYP = 'ZMESLK'.
F_IDOC_HEADER-IDOCTP = 'ZALE2LK'.
send IDoc
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
MASTER_IDOC_CONTROL = F_IDOC_HEADER
TABLES
COMMUNICATION_IDOC_CONTROL = T_COMM_IDOC_CONTROL
MASTER_IDOC_DATA = T_IDOC_DATA
EXCEPTIONS
ERROR_IN_IDOC_CONTROL = 1
ERROR_WRITING_IDOC_STATUS = 2
ERROR_IN_IDOC_DATA = 3
SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
OTHERS = 5.
check results
IF SY-SUBRC = 0.
WRITE:/ 'IDoc created.'.
ELSE.
WRITE:/ 'Error',SY-SUBRC,'in MASTER_IDOC_DISTRIBUTE'.
ENDIF.
close LUW
COMMIT WORK.
Appendix B
FUNCTION Z_IDOC_INPUT_ZMESLK.
*"----
""Local interface:
*" IMPORTING
*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
*" EXPORTING
*" VALUE(WORKFLOW_RESULT) LIKE BDWF_PARAM-RESULT
*" VALUE(APPLICATION_VARIABLE) LIKE BDWF_PARAM-APPL_VAR
*" VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK
*" VALUE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS
*" TABLES
*" IDOC_CONTRL STRUCTURE EDIDC
*" IDOC_DATA STRUCTURE EDIDD
*" IDOC_STATUS STRUCTURE BDIDOCSTAT
*" RETURN_VARIABLES STRUCTURE BDWFRETVAR
*" SERIALIZATION_INFO STRUCTURE BDI_SER
*" EXCEPTIONS
*" WRONG_FUNCTION_CALLED
*"----
IDoc inbound processing for ALE2
database tables
TABLES: ZALE2.
field string for segment data
DATA: F_Z1MESLK LIKE Z1MESLK.
read IDoc control record
LOOP AT IDOC_CONTRL.
check correct IDoc type
IF IDOC_CONTRL-IDOCTP <> 'ZALE2LK'.
RAISE WRONG_FUNCTION_CALLED.
ENDIF.
clear segment field string
CLEAR F_Z1MESLK.
read segments of the IDoc
LOOP AT IDOC_DATA WHERE DOCNUM = IDOC_CONTRL-DOCNUM.
move segment data into field string
F_Z1MESLK = IDOC_DATA-SDATA.
common 3 statements for error or success
CLEAR IDOC_STATUS.
IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
check error
IF F_Z1MESLK-MESKEY IS INITIAL. "error
IDOC_STATUS-STATUS = '51'.
IDOC_STATUS-MSGTY = 'E'.
IDOC_STATUS-MSGID = 'ZA'.
IDOC_STATUS-MSGNO = '001'.
IDOC_STATUS-UNAME = SY-UNAME.
IDOC_STATUS-REPID = SY-REPID.
WORKFLOW_RESULT = 99999.
RETURN_VARIABLES-WF_PARAM = 'Error_IDOCs'.
ELSE. "no error
post data
MOVE-CORRESPONDING F_Z1MESLK TO ZALE2.
MODIFY ZALE2.
write IDoc status OK
IDOC_STATUS-STATUS = '53'.
RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'.
WORKFLOW_RESULT = 0.
ENDIF.
common 2 statements for error or success
APPEND IDOC_STATUS.
APPEND RETURN_VARIABLES.
ENDLOOP. "loop at idoc_data
ENDLOOP. "loop at idoc_contrl.
ENDFUNCTION.