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

BADI ME_PROCESS_REQ_CUST SET_DATA issue in POST

Former Member
0 Likes
3,138

Hello All,

I'm trying to change the value of a custom field in ME53N using BADI ME_PROCESS_REQ_CUST during POST. But at 'CALL METHOD im_item->set_data', it throws a runtime error 'Access via 'NULL' object reference not possible.'. Am I missing something in the below code ?

Regards.

Code:

DATA:  lt_items      TYPE mmpur_requisition_items,

     ls_item       TYPE mmpur_requisition_item,

     ls_header     TYPE mereq_header,

*    im_item TYPE REF TO if_purchase_requisition_item,

     lv_count type i value 1,

     lv_item type i value 0.

   data:     ls_mereq_item type mereq_item,

         lv_zzarno type eban-zzarno.

   if lv_count = 1.

   import lv_zzarno to lv_zzarno from MEMORY id 'ZZARNO'.

   lt_items = im_header->get_items( ).

   loop at lt_items into ls_item.

   ls_mereq_item = ls_item-item->get_data( ).

   if ls_mereq_item-zzarno NE lv_zzarno.

   ls_mereq_item-zzarno = lv_zzarno.

  CALL METHOD im_item->set_data

       EXPORTING

         im_data = ls_mereq_item.

endif.

endloop.

endif.


3 REPLIES 3
Read only

gouravkumar64
Active Contributor
0 Likes
1,227

Hi,

This error due to ,access the object without actually creating it.

Try to create the object and then use this object or U have not object reference for process.

For one example look at this one,

http://scn.sap.com/thread/416848

Change as per ur logic.

Hope it helps.

Thnaks

Gourav.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,227

Well, read again what you have written

ls_mereq_item = ls_item-item->get_data( ).

if ls_mereq_item-zzarno NE lv_zzarno.

    ls_mereq_item-zzarno = lv_zzarno.

   CALL METHOD im_item->set_data " replace im_item with ls_item-item

       EXPORTING

         im_data = ls_mereq_item.

You read data for object ls_item-item and try to update in another unknown object, source copied from another method ?

But POST method seems late in the process, couldn't you perform this in PROCESS_ITEM or CHECK methods ?

Regards,

Raymond


Read only

0 Likes
1,227

yes..silly mistake...got it..thanks !