Delegation allows a subtype to use its own defined methods as well as the original inherited methods from the standard business object.
This is very important in terms of business aspect as it allows us to customize our standard business applications effectively and improves the performance by means of re-usability.
In large business applications this concept of delegation plays a vital role considering its high level of re-usability brings reduction in coding procedures as well as in testing or maintenance and in turn increases savings.
Redefinition deals with customization of the standard business object methods by modifying / extending the subtype methods.
Delegation is a pre-requisite for redefinition.
- Scenario: Redefining method Delete
I had a requirement in Materials Management (MM), where I was supposed to Mark material for deletion (MM06) as well as Uncheck the material if it was already marked for deletion using Business Objects through SAP Business Workflow.
Before this requirement I was not that clear with the concept of business objects. But, continuous practice and revision benefited me to complete my scenario.
1. Creating a subtype of the standard business object "BUS1001"
- Enter the name of standard business object.
- Click on subtype to create its subtype.
- Entering the required fields as per the conventions
- After creating the subtype "ZDAVE_OBJT", and Save.
- Go back to initial screen and delegate the business object.
2. Delegating the business object
- At the initial screen, go to "Settings" --> "Delegate"
- It is necessary to save in a package.
- After entering into the delegation table menu "TOJTD", click on Edit and then on "New entries" push button.
- This is the screen where the delegation has to be made. Note that the required business objects to be delegated must be filled in the below manner.
- If you want to delegate as "system-wide" enable the check box "GUI-specific"
- To check the delegated entry, go back and it can be seen as below.
- Now, go back to the business object "ZDAVE_OBJT". Travel down the method node and check the two methods we are concerned about.
3. Redefining the methods of business object
- It is essential to redefine our methods to achieve the necessary customization.
- Go, step by step in redefining. Select one entry (method) at a time and click on the redefine button as shown below.
- After doing that, we can see the entries are transferred at the end of the list and the "tick mark" symbol disappears. Check below.
- Now, double-click the method (say) "delete" and travel to the "ABAP" window, where we get to know the function module called by this method.
- It's a standard one which we do not want to change. Hence, we use our custom BAPI ,
4. Creating a function module "ZDAVE_MATERIAL_DELETE"
- Create a function group first "ZDAVE_MATERIAL_DELETE_FGP".
- We create our custom BAPI as follows. Check the Attributes of the function module as well as make sure you have the option "Remote-enabled" checked (RFC).
- Before quitting the function group, properly activate it by making sure it is error free.
- Here are the required Import parameters.
- Check the export parameter.
- The parameter for returning messages (Return table)
- Confirm with the declarations that are generated automatically in the source code window of the function module.
- Goto --> Main Program
- Double-click the include "Global data"
- These are the declarations in the "include" for global data in the function group.
- Here is the BDC program. Observe the indications in the below code.
- Again, Goto --> Main Program
- Double-click the include "Sub-programs"
- Here, we call the sub-routines (performs) for the BDC in the function module. The above sub-programs located in function group are contained in the include "highlighted" below
- Save, perform syntax check and activate the function module
5. Releasing the function module ,
- To release the function module enter the RFC function module name in SE37.
- Click on Function module > Release --> Release
6. Creating parameters for methods
- Go back to our custom business object and create the parameters for the method.
- It can be observed that it contains the parameters of the standard business object. But, to access the functionality provided in the function module created, we need to add those parameters here. Follow the steps below.
- As prompted, create with the option of ABAP dictionary fields.
- Enter the table name and select the two entries (Sales Organization and Distribution Channel) which are mentioned in the list and "OK".
- Then we are prompted to enter the creation details, where it is needed to enable "Import" attribute and click "OK".
- Similarly it is necessary for Distribution channel. Follow same step.
- Check for the entries that have been created. These entries are just created but not linked with the parameters in the function module. Follow the below step by entering the name of the parameter in the function module we have used. We need to double-click the entry.
- Perform similar steps for the parameter "DEL_FLAG" (Deletion Indicator).
- But, here we want the value to be exported, so check the export option.
- Save and return back to main screen .
7. Generating program for "Method"
- Click on the "Program" to generate a program for our method.
- Generate automatically the method "EXISTENCECHECK".
- Here, there is no need to modify any code, but check for errors, in case if any. Don't forget to save
- Go back and Implement the method "Delete" as prompted by dialog click on "Yes" for generating automatic template ,
- Confirm with the declarations mentioned below as well as the parameters in the calling of the function module. If any missing ones, please include them manually. Check for errors (Syntax check) and finally save
8. Implementation Convention (Implementing object type and Methods)
- Now, we need to "implement" the methods which we have "Redefined" as well as the key field. In general, it is recommended to follow a particular convention while implementing the components of a business object.
- Now, to implement a business object type completely we need to "Implement" in the below way.
- Here, we "implement" the method (component) in this way.
- Edit > Change Release Status > Object Component > To Implemented
9. Release Convention (Releasing object type and Methods)
- Similarly, for "releasing" the components it is necessary to follow the convention below.
- Same way we "release" the object type as shown below
- Also, we "release" the method (component) in the way mentioned below.
- Edit > Change Release Status > Object Component > To Released
- After "releasing" the object type as well as the object component, make sure that released "symbol" is there.
10. Generating business object "ZDAVE_OBJT"
- At the end after the object is ensured "error free", don't forget to "Generate" the object.
- Confirm the message. , .....
Any Suggestions or Comments in order to improve this content are Welcome....