Application Development and Automation 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: 
Read only

How to get field data from a TYPE REF TO Method import parameter?

Former Member
0 Likes
3,945

Hi Good People

I’m trying to add an additional check to a purchase order item through a Badi implementation by using a ME_PROCESS_PO_CUST definition with method IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM

I’m debugging the Purchase Order program but I don’t have any clue on how to deal with the IM_ITEM importing parameter which this method uses..

This parameter is of type TYPE REF TO and it contains a reference value on debugging mode. How can I get normal item data (material number, material group, plant, etc) from this parameter, so I can perform my checks later on?

Many Thanks

Nuno Natividade

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,405

Hello Nuno

Have a look at my posting in thread:

It may help to address your problem.

Regards

Uwe

11 REPLIES 11
Read only

Former Member
0 Likes
2,405

Hiou

U need to do a double click on the interfaced used to build the BADI, you'll to SE24 where you can see all components, in particular the methods and their parameters.

Max

Read only

0 Likes
2,405

Hi Max

Yes, that's what I have done before. I can see that for interface IF_EX_ME_PROCESS_PO_CUST and method PROCESS_ITEM there is a parameter IM_ITEM. But this parameter is of type TYPE REF TO. When I'm working on debug mode this parameter is filled with , instead of the traditional field / values...

Read only

0 Likes
2,405

Right, it is looking for an instance of the class CL_PO_ITEM_HANDLE_MM, is there an object(instance) which you can pass to this parameter?

Regards,

Rich Heilman

Read only

0 Likes
2,405

Hi Rich

Sorry, i'm not sure i follow you. Why should it require an instance from another class interface (in this case CL_PO_ITEM_HANDLE_MM). why and how should I pass an object to this IM_ITEM parameter which belongs to another interface (IF_EX_ME_PROCESS_PO_CUST) . Sorry , but as i said i'm still too fresh about these object language business...

thanks for your help.

Read only

Former Member
0 Likes
2,405

status was erroneously put

Read only

uwe_schieferstein
Active Contributor
0 Likes
2,406

Hello Nuno

Have a look at my posting in thread:

It may help to address your problem.

Regards

Uwe

Read only

0 Likes
2,405

Hi Uwe

You really hit the spot with that one. Thank you very much. I'm starting with the object-oriented programming and i really don't know how to start. Do you think you can send me any valuable literature or references about the subject to [email protected].

Once again many thanks

Nuno

Read only

Former Member
0 Likes
2,405

In transaction SE19, if you display the BADI then select menu option goto>sample code>display, you will be able to drill down on the PROCESS_ITEM method to some SAP supplied sample code.

This includes the definitions and method calls to get the item data:

DATA: ls_mepoitem TYPE mepoitem.

ls_mepoitem = im_item->get_data( ).

You then just change relevant fields in structure ls_mepoitem and call the set_data method to pass the data back

call method im_item->set_data exporting im_data = ls_mepoitem.

Take care with what you change - SAP does not validate that you have passed back correct / consistant data.

Andrew

Read only

0 Likes
2,405

Hi Andrew

I got the answer from Uwe's post just before. But you're answer is helpuful just the same. Do you think you can send me any valuable literature or references about object-oriented programming to [email protected].

many thanks

Nuno

Read only

Former Member
0 Likes
2,405

Further to my previous reply, I suggest you look at using the CHECK method for PO checking as well, depending on how you want the error showing.

If you use the MACRO's as in in the sample SAP code, you will get the messages integrating into the ME21N error list that shows when you try to save or check. To do this you need to also call the INVALIDATE() method of the Header and Line items - this is also in the SAP example.

Andrew

Read only

Pawan_Kesari
Active Contributor
0 Likes
2,405

Hi ..

Can you please write this code in the method PROCESS_ITEM of your BADI implementation.


DATA : item_data TYPE MEPOITEM .

CALL METHOD im_item->get_data
  receiving
    re_data = item_data .

You will have the item data in variable item_data.

Hope I understood you requirement correctly...

Message was edited by:

Pawan Kesari