Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Programming with Object->method(s)

Former Member
0 Kudos

Guys,

Can someone help me, I have the Purchase Requisition number and I want to create an object for the requisition. I need to use the methods IS_ACTIVE, GET_DATA, GET_ITEMS, GET_ACTIVITY in the program rather than using SELECT from EBAN. Please help.

Thank you,

Sard.

4 REPLIES 4

Former Member
0 Kudos

Hi,

The idea is pretty good.

1. Create a class in SE24 (ZPURCHASE_REQ), the parameter for the constructor of the class, could be your Purchase Req, you can also store this in the class attribute. This will be instantiated class.

2. Now define methods as you want - IS_ACTIVE, GET_DATA, GET_ITEMS, GET_ACTIVITY and define them with appropriate import and export parameters. The export parameters will give you the values for you. You will have to define the table types for the parameters where you are expecting tables back.

Also, define exceptions and raise them appropriately.

Were you looking for more details.

Regards,

Ravi

NOte :Please mark the helpful answers

0 Kudos

Ravi,

Thank you very much. I was wondering if any of the SAP provided classes couldn't be used for this than having to create a z_class.

The purchase requisition transactions have used many classes and I don't know which of these classes would be the best.

You may have guessed, I am newbie in OO programming, and any help, suggestion is most welcome.

Thanks again,

Sard.

0 Kudos

Sard,

There are some standard classes that SAP uses, but I am not sure which one of them we can use, as there is no official documentation for the same. I have seen some classes, but have not played around with the same.

Officially its still BAPI, which is the safer route. You can look into the BAPI transaction for the Purchase Req. object and call that inside your method.

Mean while, if I find any classes that can be used, I will let you know.

Regards,

Ravi

Note :Please mark all the helpful answers

Former Member
0 Kudos

Hi,

Follow the follwing step.

1) declare object

DATA : o_object TYPE REF TO class_name.

2) Create object for ur class with the key

  • Creating object Instance

CREATE OBJECT o_object

EXPORTING

Key = value_of_key "... It can be any vale

EXCEPTIONS

OTHERS = 5.

Use pattern button to do the same like when u call function module

3) Call the method which u want like this.

CALL METHOD o_object->method_name

EXPORTING

CHANGING

EXCEPTIONS

OTHERS .

Pass values for the corresponding exporting, changing parameter etc.

Use pattern button

4) Call the save method of the object to save the value.

Mark Helpfull answers & close the thread

Regards

Message was edited by: Manoj Gupta