Sie sind auf Seite 1von 18

Delegation and Redefining methods of business object BUS1001

view

Delegation:
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:
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.

Entering the required fields as per the conventions

Click on subtype to create its subtype.

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.

After doing that, we can see the entries are transferred at the end of the list and the "tick mark" symbol disappears.

Go, step by step in redefining. Select one entry (method) at a time and click on the redefine button as shown below.

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.

These are the declarations in the "include" for global data in the function group.

Goto --> Main Program


Double-click the include "Global data"

Here is the BDC program. Observe the indications in the below code.

FUNCTION zdave_material_delete.
*"---------------------------------------------------------------------*"*"Local Interface:
*" IMPORTING
*" VALUE(MATERIAL) TYPE BAPIMATALL-MATERIAL
*" VALUE(MATERIAL_EVG) TYPE BAPIMGVMATNR OPTIONAL
*" VALUE(SALESORGANIZATION) TYPE VBAK-VKORG
*" VALUE(DISTRIBUTIONCHANNEL) TYPE VBAK-VTWEG
*" VALUE(FLAG) TYPE BAPIMATALL-DEL_FLAG
*" EXPORTING
*" VALUE(DELETION_FLAG) TYPE BAPIMATALL-DEL_FLAG
*" TABLES
*" RETURN STRUCTURE BAPIRET2
*"----------------------------------------------------------------------

CALL FUNCTION 'MATNR_BAPI_CONV_FROM_EXTERNAL'


EXPORTING
matnr_ext = material_evg-material_ext
matnr_vers = material_evg-material_vers
matnr_guid = material_evg-material_guid
CHANGING
matnr_int = material.
IF flag NE 'X'.

PERFORM bdc_dynpro USING 'SAPMM03G'

'0100'.

PERFORM bdc_field

USING 'BDC_CURSOR'

'RM03G-VTWEG'.

PERFORM bdc_field

USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field

USING 'RM03G-MATNR'

material.

PERFORM bdc_field

USING 'RM03G-VKORG'

salesorganization.

PERFORM bdc_field

USING 'RM03G-VTWEG'

distributionchannel.

PERFORM bdc_dynpro USING 'SAPMM03G'

'0111'.

PERFORM bdc_field

USING 'BDC_CURSOR'

'RM03G-LVOMA'.

PERFORM bdc_field

USING 'BDC_OKCODE'

'=BU'.

PERFORM bdc_field

USING 'RM03G-LVOMA' 'X'.

CALL TRANSACTION 'MM06' USING bdcdata


MODE 'N'
UPDATE 'L'
MESSAGES INTO it_messtab.
IF NOT it_messtab IS INITIAL.
LOOP AT it_messtab.
* WRITE: it_messtab-msgtyp.
ENDLOOP.
ELSE.
MESSAGE 'Material MARKED for Deletion' TYPE 'S'.
ENDIF.
ELSE.
PERFORM bdc_dynpro USING 'SAPMM03G'

'0100'.

PERFORM bdc_field

USING 'BDC_CURSOR'

'RM03G-VTWEG'.

PERFORM bdc_field

USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field

USING 'RM03G-MATNR'

material.

PERFORM bdc_field

USING 'RM03G-VKORG'

salesorganization.

PERFORM bdc_field

USING 'RM03G-VTWEG'

distributionchannel.

PERFORM bdc_dynpro

USING 'SAPMM03G'

'0111'.

PERFORM bdc_field

USING 'BDC_CURSOR'

'RM03G-LVOMA'.

PERFORM bdc_field

USING 'BDC_OKCODE'

'=BU'.

PERFORM bdc_field

USING 'RM03G-LVOMA' ' '.

CALL TRANSACTION 'MM06' USING bdcdata


MODE 'N'
UPDATE 'L'
MESSAGES INTO it_messtab.
IF NOT it_messtab IS INITIAL.
LOOP AT it_messtab.
* WRITE: it_messtab-msgtyp.
ENDLOOP.
ELSE.
MESSAGE 'Material UNMARKED for Deletion' TYPE 'S'.
ENDIF.
ENDIF.
ENDFUNCTION.

Again, Goto --> Main Program

Here, we call the sub-routines (performs) for the BDC in the function module. The above sub-programs located in

Double-click the include "Sub-programs"

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.


Follow path:

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.


Follow path:

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.

.....

Das könnte Ihnen auch gefallen