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

ABAP objects, drilling down into methods/parameter/method/parameter...

Former Member
0 Likes
583

Hello all,

When creating or changing purchase orders using the enjoy transactions ME21N and ME22N, I want to force the users to have the same delivery address on every line item. I have found and activated the BADI ME_PROCESS_PO_CUST. I have added some code in method CHECK and put a breakpoint on that code. The transaction is stopping on my breakpoint. So far so good.

Parameter IM_HEADER is of type IF_PURCHASE_ORDER_MM,

that has method GET_ITEMS,

that has parameter RE_ITEMS that is a table of of type PURCHASE_ORDER_ITEMS,

...

method GET_DATA

with parameter RE_DATA

with fields ADRNR & ADRN2

From inside of the method CHECK of BADI, what syntax do I need to create an internal table of the line item fields that are in parameter RE_DATA of method GET_DATA? I am just starting to work with ABAP objects. Any help would be greatly appreciated.

Thanks

Bruce

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
554

Hello Bruce

A possible implementation of the method could look like this:

METHOD if_ex_me_process_po_cust~check.
* define local data
  DATA:
    lt_items      TYPE purchase_order_items,
    ls_item       TYPE purchase_order_item,
*    ls_item       LIKE LINE OF lt_items,  " alternatively
*
    ls_header     TYPE mepoheader.


* (1) Get the order items
*  CALL METHOD im_header->get_items
*    receiving
*      re_items = lt_items.
* Short version:
  lt_items = im_header->get_items( ).

  LOOP AT lt_items INTO ls_item.
*   do something
  ENDLOOP.


* (2) Get header data
*  CALL METHOD im_header->get_data
*    receiving
*      re_data = ls_header.
* Short version:
  ls_header = im_header->get_data( ).

  IF ( ls_header-adrnr = '<some value>' ).
*  do something
  ELSE.
*  do something else
  ENDIF.

ENDMETHOD.

Regards

Uwe

4 REPLIES 4
Read only

uwe_schieferstein
Active Contributor
0 Likes
555

Hello Bruce

A possible implementation of the method could look like this:

METHOD if_ex_me_process_po_cust~check.
* define local data
  DATA:
    lt_items      TYPE purchase_order_items,
    ls_item       TYPE purchase_order_item,
*    ls_item       LIKE LINE OF lt_items,  " alternatively
*
    ls_header     TYPE mepoheader.


* (1) Get the order items
*  CALL METHOD im_header->get_items
*    receiving
*      re_items = lt_items.
* Short version:
  lt_items = im_header->get_items( ).

  LOOP AT lt_items INTO ls_item.
*   do something
  ENDLOOP.


* (2) Get header data
*  CALL METHOD im_header->get_data
*    receiving
*      re_data = ls_header.
* Short version:
  ls_header = im_header->get_data( ).

  IF ( ls_header-adrnr = '<some value>' ).
*  do something
  ELSE.
*  do something else
  ENDIF.

ENDMETHOD.

Regards

Uwe

Read only

0 Likes
554

Uwe, thanks for the quick response.

Your solution,

DATA: lt_items TYPE purchase_order_items,

ls_item TYPE purchase_order_item.

  • CALL METHOD im_header->get_items

  • receiving

  • re_items = lt_items.

  • Short version:

lt_items = im_header->get_items( ).

LOOP AT lt_items INTO ls_item.

  • do something

ENDLOOP.

got me very close to the solution. The table lt_items contain the number of entries corresponding to the actual line items. But the data element ls_item does not contain the fields I'm expecting from:

method GET_DATA ,

parameter RE_DATA,

type MEPOITEM.

How do I populate ls_item with the 197 fields from structure MEPOITEM?

If I knew more about ABAP objects, I'm sure I could easily change the code myself. But today, I need the generosity of others to help me solve this.

Thanks

Bruce

Read only

0 Likes
554

Hello Bruce

Sorry that I did not exactly match your question. Here is the missing part:

METHOD if_ex_me_process_po_cust~check.
* define local data
  DATA:
    lt_items      TYPE purchase_order_items,
*    ls_item       LIKE LINE OF lt_items,  " alternatively
    ls_item       TYPE purchase_order_item,
*
    ls_header     TYPE mepoheader,    " header
    ls_detail     type MEPOITEM.        " item details
...
  LOOP AT lt_items INTO ls_item.
    ls_detail = ls_item-item->get_data( ).
*   do something ...
  ENDLOOP.
...

endmethod.

Regards

Uwe

Read only

0 Likes
554

Uwe,

That change you recommended did in fact solve my problem and give me the data that I needed.

Thank you very much.

Bruce