cancel
Showing results for 
Search instead for 
Did you mean: 

Hi How do we create Methods inside the Business objects of Z

Former Member
0 Kudos

Hi Abapers,

How do we create Methods inside the Business objects (z objects) and how cum an import parameter or export parameter to be defined for the new Methods.

Regards

Bhaskar Rao.M

Accepted Solutions (0)

Answers (2)

Answers (2)

KKilhavn
Active Contributor
0 Kudos

It shouldn't come as a surprise to you that you simply <u>Create New</u> methods in <u>Edit Mode</u> - but if it does you probably haven't read the standard help yet.

Please have a look at <a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/c5/e4ac12453d11d189430000e829fbbd/frameset.htm">Definition of Methods for an Object Type</a> and other documentation in the same section.

Former Member
0 Kudos

Kjetil Kilhavn,

Thnks .

Regards

Bhaskar Rao.M

Former Member
0 Kudos

Hi Bhaskar,

that ´s not difficult.

Open your Bus.Obj. in SWO1 with CHANGE/EDIT

Click on the "Methods" header line and then use the button for "Create".

If you want to add the method on basis of a function module, choose next in the next pop up. Then the system will offer you the ex/import parameter from the function module. So this is a really simple way.

If you don´t have a FM, it is a little bit more difficult.

Choose No on the quetion about a FM, fill in the next pop up methode name (no blanks allowed).

Dialogue is for user related method (call screen...) synchronous for methods which have to give back a result directly in to the workflow.

After completing the screen the method will be displayed as new method at the end of method list. Now add parameters (first click on the method name, then choose parameter button, same functionality to add program to the method).

Programm:

Code snip:

BEGIN_METHOD ZWFCHECKMIRO CHANGING CONTAINER.

DATA:

ZBELNR TYPE RBKP-BELNR,

ZGJAHR TYPE RBKP-GJAHR,

RESULT TYPE HRP1001-ISTAT,

BELNR TYPE BKPF-BELNR,

GJAHR TYPE BKPF-GJAHR,

BUKRS TYPE BKPF-BUKRS.

  • to import parameter

SWC_GET_ELEMENT CONTAINER 'Zbelnr' ZBELNR.

SWC_GET_ELEMENT CONTAINER 'Zgjahr' ZGJAHR.

*(or SWC_GET_TABLE)

      • here add the functionality of your method!

  • to export parameter

SWC_SET_ELEMENT CONTAINER 'Result' RESULT.

SWC_SET_ELEMENT CONTAINER 'Belnr' BELNR.

*(or SWC_SET_TABLE)

!!! Important: naming convention!!! Use same writing of parameter names in

PARAM area (button PARAMETER) and here in code.

To use your method, change it to implemented after adding your code.

-> Edit -> Change release status -> object type component -> into implemented

(Sorry , have a german screen here, possibly terms are a little bit different.

Hope this helps a little bit.!

regards

Dirk