Cross Apps
Cross Apps
APPS
NOTES WITH
Programs
RFC
REMOTE FUNCTION CALL
Class 1: 28.07.2011
A Function module is the set of statements which has to be defined once & can be called any number of times. There are two
types of function modules.
Normal Function Module: It is client Dependent object which can be called any number of times and any client in the same server.
Remote Function Module: This function module can be accessed from remote SAP Server.
RFC is the process of executing a function module existing on remote SAP Server.
It is similar to RMI Technology in JAVA.
RMI: Remote Method Invocation.
As the part of RFC process there are two parts involved RFC CLIENT & RFC SERVER.
RFC SERVER: Is the system where the remote function module is stored.
RFC CLIENT: System where the function module is called.
As a part of RFC Client System we need to create an object called RFC DESTINATION.
RFC DESTINATION: Is the object which is always created in RFC Client System, Which stores the physical details of remote system.
This physical detail’s include IP Address (Host Name) of the remote server, system number of remote server and Log On
credentials of remote server (Client, User Name, Password).
1|Pa g e Santosh P
Remote function module can be called in three ways or (three types)
1) Synchronous RFC
2) Asynchronous RFC
3) Transactional RFC
Note: In Case of Synchronous and Asynchronous RFC the remote SAP Server should be available to receive the request.
In case of Transactional RFC the remote server need not to be available at the time of Communication.
In this case the request to the remote function module is executed as background job.
Syntax for Synchronous RFC:
Call function <Remote function> Destination <RFC Destination> Starting New Task <Task Name> Performing<Subroutine>
On End Of Task[Exporting Parameters].
Note: In Case of Asynchronous RFC Results from the remote function module should be received separately in subroutine.
Form <subroutine> Using <Task Name> Receive Results From function <Remote function> [Importing Parameters].
Call function <Remote function> In Background Task Destination <RFC Destination> [Exporting Parameters].
Note:
It is recommended to call only those function module in Transactional RFC mode which doesn’t return any value, Because in
Transactional RFC mode it is executed in background.
In Transactional RFC mode when we sent the request to the remote function module since the remote server is not
available the request will be saved in the following tables of RFC Client System.
1).ARFCSSTATE.
2).ARFCSDATA.
To execute the Transactional RFC request SAP has provided an executable program RSARFCSE.which will be executing
2|Pa g e Santosh P
For every 15minuts, to check whether the remote server is available to process the request by default it executes for
20Attempts.
SE58: T-Code for checking the status of Transactional RFC.
Steps in RFC Server:
Create a remote function module.
Note: The parameters to the remote function module are always passed by value.
STARTING PROGRAM:
IN 6.0:
SM59: Create an FRC Destination.
3|Pa g e Santosh P
In Logon & Security Tab:
Remote Logon: If all the details given are correct it will take you to 4.7 Logon.
IN 4.7:
SE37:
Create a function Module: Z915FM1
4|Pa g e Santosh P
Source Code:
FUNCTION Z915FM1.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(I_X) TYPE I
*" VALUE(I_Y) TYPE I
*" EXPORTING
*" VALUE(E_Z) TYPE I
*"----------------------------------------------------------------------
ENDFUNCTION.
IN 6.0:
SE38:
Create an Executable Program: ZCALL_915FM1
REPORT ZCALL_915FM1.
parameters : p_x type i,
p_y type i.
data lv_z type i.
call function 'Z915FM1'
destination '915DEST'
5|Pa g e Santosh P
exporting
i_x = p_x
i_y = p_y
importing
e_z = lv_z.
write :/ 'sum is ',lv_z.
OUTPUT:
Press Enter
6|Pa g e Santosh P
Class 2: 29.07.2011
Note:
In Synchronous RFC whenever the execution of the RFC Client program starts.SAP creates a Main Thread. This thread is
responsible for calling the remote function module.
When the remote function module is under execution the main thread will be suspended.
During this time the CPU of RFC Client will be idle state.
When the remote function module finishes the execution the control will return back to RFC Client.
Now the main thread resumes the execution & executes the remaining statements of RFC Client Program.
It Means in Synchronous RFC. The idle time of CPU is more, It is not used Efficiently.
Asynchronous RFC:
In asynchronous RFC when we call the remote module. We need to explicitly create the thread (TASK). This thread is
responsible for executing the remote function module.
When the new thread is under execution the main thread will continue the execution i.e. bout the threads will be executing
parallel.
It means main thread doesn’t wait for called thread to finish the execution. This is called as parallel processing.
We go for ARFC mode. When the RFC Client program doesn’t depend up on result of the RFC Service.
Note: In case of Synchronous and Asynchronous if the remote server is not available at the time of communication. It leads to run
time error.
PROGRAM:
IN 6.0:
ZCALL_915FM2:
CASE 1:
REPORT ZCALL_915FM2.
parameters : p_x type i,
p_y type i.
data lv_z type i.
7|Pa g e Santosh P
call function 'Z915FM1'
destination '915DEST'
starting new task 'T1'
performing getdata on end of task
exporting
i_x = p_x
i_y = p_y.
write :/ 'sum is ',lv_z.
write :/ 'End of rfc client program'.
form getdata using T1.
receive results from function 'Z915FM1'
importing
e_z = lv_z.
endform.
OUTPUT:
8|Pa g e Santosh P
CASE 2:
REPORT ZCALL_915FM2.
wait up to 20 seconds.
9|Pa g e Santosh P
10 | P a g e Santosh P
IN 4.7:
SE11:
TABLE: ZDEPT.
SE37:
Z915FM2:
11 | P a g e Santosh P
Source Code:
FUNCTION Z915FM2.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(I_DEPT) TYPE ZDEPT
*"----------------------------------------------------------------------
IN 6.0:
ZCALL_915FM3:
REPORT ZCALL_915FM3.
NOTE:
If the remote server is available the data will be reflected in Database table ZDEPT.
ELSE
12 | P a g e Santosh P
COMMIT WORK: Key work which is used for saving the data permanently in Database Table.
Note:
In Transactional RFC mode when we sent the request to the remote function module since the remote server is not
available the request will be saved in the following tables of RFC Client System.
1).ARFCSSTATE.
2).ARFCSDATA.
To execute the Transactional RFC request SAP has provided an executable program RSARFCSE.which will be executing
For every 15minuts, to check whether the remote server is available to process the request by default it executes for
20Attempts.
SE58: T-Code for checking the status of Transactional RFC.
Class 3: 01.08.2011
13 | P a g e Santosh P
Note:
As part of RFC communication we can refer back to the calling system. By using the keyword ‘BACK’.
PROGRAM:
IN 4.7:
SE37: Z915FM1
14 | P a g e Santosh P
SOURCE CODE:
FUNCTION Z915FM1.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(I_X) TYPE I
*" VALUE(I_Y) TYPE I
*" EXPORTING
*" VALUE(E_Z) TYPE I
*" EXCEPTIONS
*" EXCEPTION1
*"----------------------------------------------------------------------
IN 6.0:
SE37: ZFM50
15 | P a g e Santosh P
SOURCE CODE:
REPORT ZCALLRFCBACK.
data m type i.
IN 6.0:
CALL PROGRAM:
REPORT ZCALLRFCBACK.
data m type i.
16 | P a g e Santosh P
importing
e_z = m.
OUT PUT:
17 | P a g e Santosh P
ALE/IDOCS
ALE: Application Link Enabling.
Distributed Process: It is the process in which a process of a task is performed in multiple systems. By using ALE we can configure
distribute & post the IDOCS to multiple receivers from SAP system. These receivers can be either SAP (OR) NON-SAP systems.
IDOCS: It is a container of data which can carry the data from one system to another. IDOC is SAP’s own format of data which can be
understood only by SAP system.
18 | P a g e Santosh P
XI: Exchange Infrastructure.
1) Logical Systems.
2) RFC Destination.
3) Port Number.
4) Message Type.
5) IDOC Type.
6) Partner Profile.
7) Outbound Parameter.
8) Inbound Parameter.
9) Selection Program.
Logical Systems:
It is the unique name assigned for a sender & receiver system involved ALE communication. It can also be called Alias provided
for IP Address.
RFC Destination:
Port Number:
It is unique number used for identifying a Resource on the system. A resource can be a file , Input (OR) output device.
Message Type:
19 | P a g e Santosh P
T-Code for creating Message type –WE81.
IDOC Type:
IDOC Type doesn’t hold any data it only provides template. The instance of IDOC Type is IDOC.
Partner Profile:
Outbound Parameters:
It is always created in sender system and it is a collection of message type, Receiver Port & IDOC Type.
Inbound Parameters:
It is always created AT THE Receiver side and it is a collection of message type & Process Code.
Selection Program:
20 | P a g e Santosh P
It is also called as outbound program. It is responsible for retrieving the data from sender system database, generating the
IDOCS & Distributing the IDOCS.
Inbound Program:
It is responsible for reading the incoming IDOC Data & Updating the data to the receiver Database.
Process Code:
It is an identifier for inbound program. It is usually the first four characters of Message Type.
T-Code for creating Process Code – WE41 –––––– Outbound Process Code.
Note:
Class 4: 02.08.2011
4) Create Port.
21 | P a g e Santosh P
Steps at sender side (800).
Model view: An object which encapsulates the sender and receiver information along with the message type.
22 | P a g e Santosh P
23 | P a g e Santosh P
SAVE.
24 | P a g e Santosh P
25 | P a g e Santosh P
4) Create Port.
WE21:
26 | P a g e Santosh P
Note: Transactional RFC Port is always create on top of RFC Destination.
27 | P a g e Santosh P
7) Assign Message type to Model view.
28 | P a g e Santosh P
CONTINUE.
SAVE.
WE20:
29 | P a g e Santosh P
9) Assign outbound parameters.
SAVE--------BACK--------SAVE--------BACK
IN Client (811):
30 | P a g e Santosh P
WE20:
IN Client (800):
31 | P a g e Santosh P
Hear we will get Messages.
32 | P a g e Santosh P
15) Process the IDOCS if any errors in Distribution.
Check for the errors. In the current program there are no errors.
33 | P a g e Santosh P
17) Process the IDOCS if any errors in Posting.
Hence there are no errors in the current program no need of this step.
Class 5: 03.08.2011
1) Control Record.
2) Data Record.
3) Status Record.
Control Record:
A control record is like a envelope of a letter which contains Sender and Receiver Information.
34 | P a g e Santosh P
This includes Sender and Receiver Logical System, Port Number, IDOC Type, Message Type and Direction.
Data Record:
It contains the actual data of IDOC. It is associated with two Sections.
1) Administration Section.
2) Data Section.
Administration Section: Administration Section contains segment information like Segment Name and Segment Number.
Data Section: Contains the actual section of the IDOC.
Whenever an IDOC is generated (OR) receive is error status. As a developer we need to analyze the error and identify. Weather
it us functional issue (OR) Technical issue.
If it is a functional issue the functional consultant need to configure functional settings and after this ABAP-consultant is
responsible for processing the error IDOC by using the T-Code BD87 (OR) WE19.
PROGRAM:
IN Client 800:
Create a material in (800) with material type which does not exist in (811).
915MA4
BD10:
35 | P a g e Santosh P
WE02:
36 | P a g e Santosh P
IN Client 811:
37 | P a g e Santosh P
Double Click on Status 51.
38 | P a g e Santosh P
To solve this error go to SPRO
39 | P a g e Santosh P
BD87 (OR) WE19.
BD87:
40 | P a g e Santosh P
The status of the errors will change from 51 to 53.
IDOC Filtering: It is the Process of filtering IDOCS at various levels, IDOC filters are of 3 types.
1) Data Level Filtering.
2) Segment Level Filtering.
3) IDOC Reduction.
Data Level Filtering: This is configured at sender level at Model View Level.
Note:
Whenever a selection Program is executed depending on the range of the objects given. The selection program returns the
corresponding data from sender database and generates the Application Number of Master IDOC.
This Master IDOCS are stored at Operating System Level and they are sent to ALE Layer.
ALE Layer executes the data filter conditions maintained at Model View Level and generates the appropriate number of
Communication IDOC.
These Communication IDOCS stored at database level, which are then distributed to the communication Layer.
This Communication Layer is responsible for distributing the communication IDOCS.
Data Level Filtering:
PROGRAM:
Create Some Materials.
41 | P a g e Santosh P
BD64
Select the Particular Model View, Expand it and Double Click on No Filter Set.
42 | P a g e Santosh P
Click Create filter group.
43 | P a g e Santosh P
Double Click on Material Type
Continue.
Continue.
Save.
BD10:
44 | P a g e Santosh P
Hear we can see only 3 IDOCS are created and 2 IDOCS are communicated.
45 | P a g e Santosh P
IN Client 811:
Check the receiver status.
WE02:
46 | P a g e Santosh P
We can check in it in SE11 in MARA TABLE
47 | P a g e Santosh P
Class 6: 04.08.2011
Segment Level Filtering: It is the Process of filtering a Segment whenever a IDOC is generated between Sender and Receiver. T-code is
BD56:
Pre-requisites:
Sender and Receiver Partner Profile should be available at the sender system.
Mandatory Segments cannot be filtered.
A segment filtering is always configured at Sender side.
PROGRAM:
BD56:
Continue.
New Entries.
48 | P a g e Santosh P
Sender and Receiver Partner Profile should be available at the sender system, so we must create the partner profile.
WE20:
49 | P a g e Santosh P
SAVE.
BD56.
50 | P a g e Santosh P
Now the Segment filter is Created.
BD10.
WE02:
51 | P a g e Santosh P
Double Click on the error and check the status of the error.
52 | P a g e Santosh P
Click on status record 29.
By observing the above Process we came to know that Segment filtering cannot be done on mandatory segments, so we can do the
segment filtering only on Non-Mandatory fields.
53 | P a g e Santosh P
BD10:
54 | P a g e Santosh P
Execute.
WE20.
55 | P a g e Santosh P
Change Pointer: Change Pointers are used for tracking the changes made to master data. To track these changes, change pointer must
be activated at 3 levels.
1) Globally (BD61).
2) Message Type Level (BD50).
3) Field Level (BD52).
Once the change pointers are activated the changes made to master data will be tracked in fallowing tables.
1) CDHDR
2) CDPOS
3) BDCP
4) BDCPS
We can distribute the changes in two ways.
1) Using Program RBDMIDOC.
2) Using T-Code BD21.
PROGRAM:
Globally: BD61
56 | P a g e Santosh P
Message Type Level: BD50
57 | P a g e Santosh P
BD21:
58 | P a g e Santosh P
Now create some materials and make changes in some materials.
BD21:
59 | P a g e Santosh P
Then make changes at the field level in the Material field MAKTX.
BD21:
Class 7: 05.08.2011
CUSTOM IDOCS:
We go for custom IDOCS whenever we want to distribute custom specific data to the receiver, This customer specific
data will be stored in custom tables.
60 | P a g e Santosh P
Sender ------800 Receiver -----------811
61 | P a g e Santosh P
2) Assign Logical System to client.
SCC4 (OR) SALE.
62 | P a g e Santosh P
3) Creating RFC Destination.
SM59 (OR) SALE.
63 | P a g e Santosh P
SAVE.
4) Create TRFC Port.
WE21.
SAVE.
As in the above figure we must create Segment, IDOC Type and Message Type.
64 | P a g e Santosh P
SAVE.
Qualified Segment:
If this checkbox is selected, the segment will prefix with value of the primary key field when the IDOCS are displayed.
65 | P a g e Santosh P
After selecting Set Release.
66 | P a g e Santosh P
Now put the cursor on IDOC Type and Create Segment.
67 | P a g e Santosh P
SAVE.
Back to initial screen.
Yes.
68 | P a g e Santosh P
CONTINUE.
SAVE.
69 | P a g e Santosh P
SAVE.
CONTINUE.
70 | P a g e Santosh P
CONTINUE.
SAVE.
71 | P a g e Santosh P
SAVE.
72 | P a g e Santosh P
Receiver Side Client (811):
SAVE.
Note: To receive a profile we must assign inbound parameters at receiver side, to assign the inbound parameters we need message
type and process code.
Process code is assigned with function module IDOC_INPUT_MATMAS01.this function module is responsible to read the message type.
by reading the message type the receiver it will decrypt the idoc(segments)
In the current we are creating custom idoc so we need custom function module.
a) Creating the custom function module.
SE37.
73 | P a g e Santosh P
Copy.
b) Linking the function module with message type & IDOC Type.
WE57.
74 | P a g e Santosh P
c) Registering Function Module as Inbound Parameter.
Note: If we forget to register the function module with inbound parameter, this function module is not available to link with the
process code.
BD51.
75 | P a g e Santosh P
d) Creating inbound process code and Link with inbound function module.
WE42.
76 | P a g e Santosh P
77 | P a g e Santosh P
Note: Now we are eligible to assign the inbound parameters to receiver system.
Class 8: 06.08.2011
Note: At the Sender side create a database table for storing the customer specific data.
78 | P a g e Santosh P
Sender Objects:
1) Generate the selection screen for accepting the range of business objects, Message and receiver logical system.
2) Prepare the control Record.
3) Prepare the Data Record.
4) Generate and Distribute the IDOC by calling the Function Module MASTER_IDOC_DISTRIBUTE.
ZMATSENDERDEPT :( Program)
REPORT ZMATSENDERDEPT.
DATA : P_DEPTNO TYPE Z915DEPT-DEPTNO. " SELECTION SCREE FOR ACCEPTING THE INPUT
LS_CONT_REC-RCVPRN = P_LOGSYS.
LS_CONT_REC-MESTYP = P_MESTYP.
LS_CONT_REC-IDOCTP = 'ZMETIDOC'.
* END OF CONTROL RECORD
79 | P a g e Santosh P
* PREPARING DATA RECORD
TYPES : BEGIN OF TY_DEPT.
INCLUDE STRUCTURE Z915DEPT.
TYPES END OF TY_DEPT.
EXECUTE.
80 | P a g e Santosh P
MESSAGE.
As Part of the inbound program. We need to use the parameter IDOC_DATA. This parameter carries the actual data of the
IDOC.
We need to use the internal table parameter, Extract the data stored in SDATA field and update the same to corresponding
database table.
Writing the code in Function Module: (ZMET_READ_DEPARTMENT)
Source Code:
FUNCTION ZMET_READ_DEPARTMENT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
*" VALUE(NO_APPLICATION_LOG) LIKE SY-DATAR OPTIONAL
*" VALUE(MASSSAVEINFOS) LIKE MASSSAVINF STRUCTURE MASSSAVINF
*" OPTIONAL
*" 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
81 | P a g e Santosh P
*" WRONG_FUNCTION_CALLED
*"----------------------------------------------------------------------
IF SY-SUBRC EQ 0.
WA_STATUS-DOCNUM = WA_DATA-DOCNUM.
WA_STATUS-STATUS = 53.
WA_STATUS-MSGTY = 'METMSG'.
APPEND WA_STATUS TO IDOC_STATUS.
ELSE.
WA_STATUS-DOCNUM = WA_DATA-DOCNUM.
WA_STATUS-STATUS = 51.
WA_STATUS-MSGTY = 'METMSG'.
APPEND WA_STATUS TO IDOC_STATUS.
ENDIF.
ENDFUNCTION.
WE19:
82 | P a g e Santosh P
BAPI
BUSINESS APPLICATION PROGRAMING INTERFACE
BAPI:
BAPI is a remote function module for an ABAP Consultant and API METHOD for a Legacy programmer.
API: Application Programming Interface.
BAPI’s are used for accessing the SAP business objects from ABAP Application as well as from Legacy Application. All the
business objects are stored in BOR.
BOR: Business objects Repository.
BAPI: Is the T-Code.
Every business object is associated with remote function module and an API Method.
As long as we access business objects from legacy Application we us API Method and if the access in from SAP. We use BAPI
function module.
All the BAPI function modules start with naming convention “BAPI_”.
TOPICS:
Standard BAPI’s.
Enhance Standard BAPI’s.
BAPI Modification.
Custom BAPI Creation and Access from SAP / NONSAP.
LSMW using BAPI.
Transporting LSMW.
83 | P a g e Santosh P
BAPI
84 | P a g e Santosh P
In SAP FI/CO, SD, MM data is stored in the form of header data and item data.
IN SAP HR in the form of Infotypes and they are stored in the table T777D.
Time Constraints:
Xyz-
12th August 2011 to 20th June 2012---------------Project1
29th July 2011 to 30th September 2012---------------Project2
No Overlapping No Gaps.
No Overlapping gaps are allowed
No gaps and Overlapping is allowed
85 | P a g e Santosh P
PA30: T-Code Used for maintaining HR Master Data.
P0006: Table which captures the employee addresses details.
86 | P a g e Santosh P
Requirement:
Uploading Employee Communication details to SAP using BAPI.
BAPI:
Note: Every business object will be associated with different types of operations.
Create Change, Delete and Retrieval.
Method : Create.
Function Module : BAPI_EMPLCOMM_CREATE.
87 | P a g e Santosh P
Note:
If an ALV Message Type is associated with BAPI. Then we can use that BAPI with LSMW integration.
Every BAPI is a Remote Function Module. But every remote function module may not be a BAPI.
Note: Every BAPI function module contains a returning parameter of type BAPIRETURN1 (OR) BAPIRETURN (OR) BAPIRET1 (OR)
BAPIRET2.
88 | P a g e Santosh P
PROGRAM:
REPORT ZCNUBAPI1.
*PROGRAM : ZCNUBAPI1
*AUTHOR : CNU
*START DATA : 12.08.2011
*PURPOSE : Bapi To Upload Employee Communication Details.
*OPERATION : BAPI TO UPLOAD EMPLOYEE COMMUNICATION DETAILS.
*COPIED FROM : NA (or) REF.PROGRAM
********************************************************************************************
DATA : LT_FILETABLE TYPE FILETABLE,
LV_FILETABLE TYPE FILE_TABLE.
DATA : LV_RC TYPE I.
DATA : FNAME TYPE STRING.
89 | P a g e Santosh P
IF LS_RETURN-TYPE NE 'E'.
PERFORM CREATEEMAIL.
WRITE :/'Employee No:',LS_COMM-PERNR,
/ LS_RETURN-TYPE,
/ LS_RETURN-MESSAGE.
SKIP 2.
PERFORM UNLOCKEMPLOYEE.
ENDIF.
ENDLOOP.
ENDIF.
form CREATEEMAIL .
CLEAR LS_RETURN.
CALL FUNCTION 'BAPI_EMPLCOMM_CREATE'
EXPORTING
employeenumber = LS_COMM-PERNR
subtype = '0010'
validitybegin = LS_COMM-BEGDA
validityend = LS_COMM-ENDDA
COMMUNICATIONID = LS_COMM-USRID_LONG
IMPORTING
RETURN = LS_RETURN.
endform. " CREATEEMAIL
form LOCKEMPLOYEE .
CLEAR LS_RETURN.
CALL FUNCTION 'BAPI_EMPLOYEET_ENQUEUE'
EXPORTING
number = LS_COMM-PERNR
validitybegin = '19000101'
IMPORTING
RETURN = LS_RETURN.
endform. " LOCKEMPLOYEE
form UNLOCKEMPLOYEE .
CALL FUNCTION 'BAPI_EMPLOYEET_DEQUEUE'
EXPORTING
number = LS_COMM-PERNR
validitybegin = '19000101'
IMPORTING
RETURN = LS_RETURN.
endform. " UNLOCKEMPLOYEE
90 | P a g e Santosh P
OUTPUT:
PROGRAM:
*PROGRAM : ZCNUBAPI2
*AUTHOR : CNU
*START DATA : 13.08.2011
*PURPOSE : Uploading Bank Details Using BAPI.
*OPERATION : UPLOADING BANK DETAILS USING BAPI.
*COPIED FROM : NA (or) REF.PROGRAM
********************************************************************************************
REPORT ZCNUBAPI2.
CLEAR LS_BADDR.
LS_BADDR-BANK_NAME = 'SBI571 bank'.
91 | P a g e Santosh P
LS_BADDR-REGION = '01'.
LS_BADDR-STREET = 'MALAKPET'.
LS_BADDR-CITY = 'HYDERABAD'.
WRITE:/ LS_RETURN-TYPE,
LS_RETURN-MESSAGE.
Note: Before executing the Program check number of entries in the table.
Execute.
92 | P a g e Santosh P
Note: Check number of entries in the table.
93 | P a g e Santosh P
Changing the Bank Details.
Note:
Some of the Change BAPI’s are associated with the Update flag Parameter.
This parameters ends with X.
As part of these parameters we need to set the flag for the field which needs to be updated.
PROGRAM:
REPORT ZCNUBAPI3.
*PROGRAM : ZCNU_ALV2
*AUTHOR : CNU
*START DATA : 18.07.2011
*PURPOSE : Using BAPI To Update Bank Details.
*OPERATION : USING BAPI TO UPDATE BANK DETAILS.
*COPIED FROM : NA (or) REF.PROGRAM
********************************************************************************************
DATA : LV_BCTRY TYPE BAPI1011_KEY-BANK_CTRY VALUE 'IN',
LV_BKEY TYPE BAPI1011_KEY-BANK_KEY VALUE 'CBB',
LS_BADDR TYPE BAPI1011_ADDRESS,
LS_BADDRX TYPE BAPI1011_ADDRESSX,
LS_RETURN TYPE BAPIRET2.
LS_BADDRX-BANK_NAME = 'X'.
LS_BADDRX-STREET = 'X'.
WRITE : / LS_RETURN-TYPE,
LS_RETURN-MESSAGE.
Execute.
94 | P a g e Santosh P
Check number of entries in the table.
2) Getting the F4 Help Functionality for the field P_FILE in the Program.
95 | P a g e Santosh P
PARAMETERS : P_FILE TYPE IBIPPARMS-PATH.
START-OF-SELECTION.
FNAME = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = FNAME
FILETYPE = 'ASC'
tables
data_tab = LT_LEGACY[].
TOTAL CODE:
REPORT ZCNUBAPI4.
*PROGRAM : ZCNUBAPI4
97 | P a g e Santosh P
*AUTHOR : CNU
*START DATA : 13.08.2011
*PURPOSE : Upload Material Data Using BAPI.
*OPERATION : UPLOAD MATERIAL DATA USING BAPI.
*COPIED FROM : NA (or) REF.PROGRAM
********************************************************************************************
PARAMETERS : P_FILE TYPE IBIPPARMS-PATH.
START-OF-SELECTION.
FNAME = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = FNAME
FILETYPE = 'ASC'
tables
data_tab = LT_LEGACY[].
LS_MATHED-MATERIAL = LS_MATERIAL-MATERIAL.
LS_MATHED-IND_SECTOR = LS_MATERIAL-IND_SECTOR.
LS_MATHED-MATL_TYPE = LS_MATERIAL-MATL_TYPE.
LS_MATHED-BASIC_VIEW = 'X'.
LS_BAPI_MARA-MATL_GROUP = LS_MATERIAL-MATL_GROUP.
LS_BAPI_MARA-BASE_UOM = LS_MATERIAL-BASE_UOM.
LA_BAPI_MARAX-MATL_GROUP = 'X'.
LA_BAPI_MARAX-BASE_UOM = 'X'.
REFRESH LT_MAKT.
LS_MAKT-LANGU = LS_MATERIAL-LANGU.
LS_MAKT-LANGU_ISO = LS_MATERIAL-LANGU_ISO.
LS_MAKT-MATL_DESC = LS_MATERIAL-MATL_DESC.
APPEND LS_MAKT TO LT_MAKT.
WRITE : / LS_MATERIAL-MATERIAL,
/ LS_RETURN-TYPE,
/ LS_RETURN-ID,
/ LS_RETURN-NUMBER,
/ LS_RETURN-MESSAGE.
ENDLOOP.
ENDIF.
CUSTOM BAPI’s:
PROCEDURE:
1) Develop a function module by fallowing BAPI standards.
2) Release the function module.
3) Create the business object referring to BAPI function module.
REQUIRMENT:
100 | P a g e Santosh P
IN 4.7 Server Client (800):
SE11:
PROGRAM:
Attributes Tab:
101 | P a g e Santosh P
Import Tab:
Export Tab:
Source Code:
102 | P a g e Santosh P
Save.
Activate.
103 | P a g e Santosh P
104 | P a g e Santosh P
105 | P a g e Santosh P
Note: The Colure of the method will change.
106 | P a g e Santosh P
Same step for other method also. After redefining all the methods, Choose the method and CLICK on PROGRAM
107 | P a g e Santosh P
[
SAVE.
108 | P a g e Santosh P
Same process for all the methods.
109 | P a g e Santosh P
Same process for all the Methods.
Implement.
110 | P a g e Santosh P
Release.
ZCALLCUSTOMBAPI:
REPORT ZCALLCUSTOMBAPI .
ls_dept-deptno = 1.
ls_dept-dname = 'Sales'.
ls_dept-loc = 'Hyderabad'.
if ls_return-type = 'S'.
message 'Inserted' type 'I'.
111 | P a g e Santosh P
else.
message 'Failed' type 'I'.
endif.
Note:
Once a business object is developed we need to prepare a Technical Spec. Which contains information of the business Objects.
This information includes name of the business Object. APT Methods, Method Parameters List, Name of the function Module.
To invoke the business object from Legacy Application. The Legacy program makes use of technical spec & develop the
Application.
As the part of this Application, the legacy program invokes the API Method which internally calls BAPI Function module.
Class X: 17.08.2011
Requirement: Migrating Bank details from file to SAP using LSMW Tool.
Note: In LSMW Using BAPI we require only one set of object which are specific to receiver.
Steps:
BD54:
112 | P a g e Santosh P
SAVE.
113 | P a g e Santosh P
EDI_PATH_CREATE_MESTYP_DOCNUM: It generates a file which is for SAP purpose we never use this file.
SAVE.
114 | P a g e Santosh P
5) Assigning Inbound Parameters.
SAVE.
Starting LSMW.
115 | P a g e Santosh P
1) Maintain Object Attributes.
SAVE.
116 | P a g e Santosh P
Back.
SAVE.
117 | P a g e Santosh P
SAVE.
118 | P a g e Santosh P
119 | P a g e Santosh P
perform ur_CHECKBANKKEY
using ZBANKSTR-BANKK
changing E1BANK_CREATE-BANK_KEY.
end perform.
SAVE.
SAVE.
BACK.
120 | P a g e Santosh P
SAVE.
BACK.
7) Specify Files.
121 | P a g e Santosh P
SAVE.
8) Assign Files.
122 | P a g e Santosh P
9) Read Data.
123 | P a g e Santosh P
BACK.
ENTER.
124 | P a g e Santosh P
BACK.
125 | P a g e Santosh P
12) Display Converted Data.
126 | P a g e Santosh P
ENTER.
127 | P a g e Santosh P
13) Start IDoc Generation.
128 | P a g e Santosh P
14) Start IDoc Processing.
129 | P a g e Santosh P
Check whether the records are updated (or) not.
WE02:
130 | P a g e Santosh P
Class 1: 18.08.2011
131 | P a g e Santosh P
Integrating BAPI with ALE:
BAPI:
ZDEPTOBJ:
132 | P a g e Santosh P
CONTINUE.
133 | P a g e Santosh P
CONTINUE.
134 | P a g e Santosh P
BAPI MODIFICATION:
It is the process of enhancing the standard BAPI by adding additional functionality. This additional functionality is
achieved by adding additional parameters to the standard BAPI function module (or) API method.
BAPI:
135 | P a g e Santosh P
APT Method : GetList
Procedure:
SE37
IMPORT SECTION.
136 | P a g e Santosh P
We must make some changes in the Source Code, Need to write the new selection statement and create and internal table of
same table type in the TOP INCLUDE Program.
INCLUDE: LZCROSSTOP
TABLES : T001.
END OF MESSAGE.
INCLUDE: LZCROSSTOP
tables: tddat.
138 | P a g e Santosh P
if sy-subrc ne 0 or tddat-cclass eq space.
endif.
clear message.
message-msgty = 'E'.
message-msgid = 'FN'.
message-msgno = 000.
changing return.
message e000(fn).
endif.
endif.
139 | P a g e Santosh P
form set_return_message using value(p_message) like message
exporting
type = p_message-msgty
cl = p_message-msgid
number = p_message-msgno
par1 = p_message-msgv1
par2 = p_message-msgv2
par3 = p_message-msgv3
par4 = p_message-msgv4
* LOG_NO =''
importing
bapireturn = p_return
exceptions
others = 1.
140 | P a g e Santosh P
2) Creating Business Object from the standard business object.
SWO1:
141 | P a g e Santosh P
142 | P a g e Santosh P
143 | P a g e Santosh P
144 | P a g e Santosh P
145 | P a g e Santosh P
Redefine existence check.
146 | P a g e Santosh P
Save Back.
Generate.
147 | P a g e Santosh P
148 | P a g e Santosh P
149 | P a g e Santosh P
150 | P a g e Santosh P
Back to initial Screen.
151 | P a g e Santosh P
BAPI:
152 | P a g e Santosh P
ENHANCEMENTS
Enhancements: It is a process of enhancing the SAP Transaction without disturbing the SAP functionality. There are 4 Types of
Enhancements Techniques.
4) Enhancement Frameworks.
2) Identifying the required components of the Enhancement (CMOD --- Customer-Exit, SE18 --- BADIS).
3) Read the document (If provided) to understand the process of implementing the Enhancement (CMOD --- Customer-Exit, SE18
--- BADIS).
Types of Customer-Exits:
1) Function Exits.
2) Menu Exits.
3) Screen Exits.
Function Exits: They are used for providing customer specific validation in a standard SAP Transaction.
153 | P a g e Santosh P
Menu Exits: Menu Exits are used for adding the additional menu item in the standard SAP menu.
For this additional menu items the function codes are provided by SAP itself. Which start with naming convention ‘+’.
The base for the menu exit is function exit. I.e. the implementation for the additional menu item is done inside a function exit.
Screen Exits: It is used for adding additional customer specific fields in standard SAP Transaction.
These additional fields should be first added in the corresponding base tables of the transaction.
The base for the screen exit if function exit. I.e. the validation specific to the additional fields is implemented in the
corresponding function exit.
PBO Function exit: Is used for transferring the default values from program to screen.
PAI Function exit: Is used for transferring data from screen to program.
Procedure 1:
Procedure 2:
Function Exits:
TASK: While creating the customer in XD01. If the country field is IN the industry field must be MANDATORY.
154 | P a g e Santosh P
Procedure 1:
SE93:
155 | P a g e Santosh P
Program Name: SAPMF02D
Package: VS
156 | P a g e Santosh P
Using SMOD: (Identifying the Customer-Exit)
157 | P a g e Santosh P
158 | P a g e Santosh P
Procedure 2:
SE93:
SE38:
159 | P a g e Santosh P
160 | P a g e Santosh P
161 | P a g e Santosh P
We will write the code in INCLUDE.
Note 1:
Every function exit is associated with a function module which contains a customer specific include.
Note 2:
Customer exits are implemented inside a project as part of a project. We can implement any number of
enhancements related to different transaction.
CMOD:
162 | P a g e Santosh P
163 | P a g e Santosh P
164 | P a g e Santosh P
Activate Enhancement.
After Activation.
XD01:
165 | P a g e Santosh P
So we must give the Industry.
166 | P a g e Santosh P
Class 1: 20.08.2011
167 | P a g e Santosh P
BADI’S
BUSINESS ADDINNS
BADI’S:
Is the enhancement technique used for enhancing the SAP Transactions in object oriented methodology (OR)
approach.
A BADI is associated with Definition & Implementation. Definition of BADI contains fallowing components.
1) BADI Interface:
It starts with naming convention (IF_EX_).It is collection of methods which contains null
implementation as a developer we need to identify the appropriate methods & provide the
implementation.
2) BADI Class:
It starts with naming convention (CL_EX_). This class is initially used by SAP and it contains the list
of active and inactive implementation.
3) It contains the implementation link weather a BADI is single used BADI (OR) multiple used BADI.
A single used BADI can contain any number of implementations but only one active
implementation.
Multiple used BADI can contain any number of active implementations.
4) Filter Types:
A BADI can be filtered dependent (OR) Independent.
BADI Implementation: It starts with naming convention (CL_IM_).It is associated with the implementation class and it is
responsible for implementing the BADI interface method.
Note: Whenever a BADI is triggered SAP executes all BADI’s active implementations one after the other.
168 | P a g e Santosh P
Technique 1:
SE38:
169 | P a g e Santosh P
Double click on 14.
170 | P a g e Santosh P
To check whether CUSTOMER_ADD_DATA is a BADI (OR) NOT go to SE18.
SE18:
171 | P a g e Santosh P
It will take u to BADI INTERFACE.
172 | P a g e Santosh P
SE18:
173 | P a g e Santosh P
Double click on 84.
SE18:
174 | P a g e Santosh P
Double click on IF_EX_CUSTOMER_ADD_DATA.
175 | P a g e Santosh P
Technique 2:
SE38:
176 | P a g e Santosh P
SE84:
177 | P a g e Santosh P
Technique 3:
ST05:
178 | P a g e Santosh P
Open new Session and make changes in the Transactions.
T-Code: XD01
179 | P a g e Santosh P
Enter.
180 | P a g e Santosh P
Back to ST05 Session.
181 | P a g e Santosh P
182 | P a g e Santosh P
Note: Before BADI implementation. We must check for any active implementation.
183 | P a g e Santosh P
SE18:
184 | P a g e Santosh P
BADI Definition : CUSTOMER_ADD_DATA
BADI Interface : IF_EX_CUSTOMER_ADD_DATA
BADI Class : CL_EX_CUSTOMER_ADD_DATA
185 | P a g e Santosh P
186 | P a g e Santosh P
SE19: BADI Implementation.
187 | P a g e Santosh P
In Interface Tab.
BACK.
ACTIVATE.
188 | P a g e Santosh P
XD01:
189 | P a g e Santosh P
Enter.
190 | P a g e Santosh P
Note:
If the T-code has Customer-Exits & BADI, First Customer-Exit will execute.
Whenever a BADI is triggered SAP makes use of BADI Class to identify the list of active and inactive
implementation.
Based on this information SAP execute all the active implementation one after the other.
191 | P a g e Santosh P
192 | P a g e Santosh P