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: 

Purchase requisition, user-exit before save

Former Member
0 Kudos

Hi,

my need is very simple, when i save my purchase requisition i need to access in modification to items (standard fields) of my document.

I'm looking for a few days on SDN or Google but without success, the question has often been discussed but the answers are not accurate or some people say "try this or this" but it doesn't work.

There was an answer to use the Badi ME_PROCESS_REQ_CUST, but all these methods do not suit me. Some people proposes to use the method PROCESS_ITEM or POST. For the first i need to work with global items not line by line and in the method POST i do not have access to lines.

So can you help me ?

Cheers.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

If you are not gettig the required variables in the BADI method, then try to use the field symbol to fetch the required data.

Ex :

 ('('SAPLMEGUI)CALL METHOD im_item->get_data()') 

Thanks & Regards,

Harish

12 REPLIES 12

Former Member
0 Kudos

Hi,

If you are not gettig the required variables in the BADI method, then try to use the field symbol to fetch the required data.

Ex :

 ('('SAPLMEGUI)CALL METHOD im_item->get_data()') 

Thanks & Regards,

Harish

0 Kudos

sorry i don't understand, can you explain to me ?

0 Kudos

Hi,

Say in the case of PROCESS_ITEM method you are not able to get some global values. Through debugging you can find out in which program and variable you will get these values. After that in the BADI, you can create field symbols and point these programs and fields to the field symbol so that you will be able tio capture this golbal values in you BADI method.

Eg

 

FIELD-SYMBOLS : <FS_GOBALVARIABLE1> TYPE ANY 

<FS_GOBALVARIABLE1> = ('(MAIN_PROGRAM_NAME)GLOBAL_FILDNAME') 

by this way you can get the value from a global variable available inside the executing program.

Thanks & Regards,

Harish

0 Kudos

Ok but there is no enhancement spot for my need or BADI ?

0 Kudos

Explore the options available in badi ME_PROCESS_REQ_CUST (check methods CHECK & POST). In both these methods, importing parameter IM_HEADER (type ref to IF_PURCHASE_REQUISITION) can be used to extract all PR related data. See interface method IF_PURCHASE_REQUISITION->GET_ITEMS for item level information.

I would suggest you to search for available Wiki pages/ forum posts to get more information.

0 Kudos

>

> Explore the options available in badi ME_PROCESS_REQ_CUST (check methods CHECK & POST). In both these methods, importing parameter IM_HEADER (type ref to IF_PURCHASE_REQUISITION) can be used to extract all PR related data. See interface method IF_PURCHASE_REQUISITION->GET_ITEMS for item level information.

>

> I would suggest you to search for available Wiki pages/ forum posts to get more information.

Hi Vinod,

thanks for your reply.

I found this wiki http://wiki.sdn.sap.com/wiki/display/ABAP/AccessingtheInacessible-LocalClasseswithinGlobalClasses

I need some help, i would like in method POST change items data (standard), i don't have some success.

My code :

METHOD if_ex_me_process_req_cust~post.

  DATA: l_item_list TYPE mmpur_requisition_items,
      l_item      TYPE mmpur_requisition_item,
      l_item_akt  TYPE mereq_item,
      l_item_ref  TYPE REF TO if_purchase_requisition_item,
      lo_obj      TYPE REF TO object,  " root object
      ld_attr     TYPE string.

  FIELD-SYMBOLS:
    <lo_lcl>        TYPE ANY,
    <ls_item>       TYPE mereq_item,
    <ls_itemx>      TYPE mereq_itemx,
    <item>          TYPE mmpur_requisition_item.

  " Get items of purchase requisition
  l_item_list = im_header->get_items( ).

  LOOP AT l_item_list ASSIGNING <item>.

    l_item_akt = <item>-item->get_data( ).
    l_item_ref = <item>-item.   " TYPE REF TO if_purchase_requisition_item

    l_item_akt-afnam = sy-uname.

    <item>-item->set_data( l_item_akt ).

  ENDLOOP.

  l_item_list = im_header->get_items( ).

ENDMETHOD.

0 Kudos

If you are updating the item level details, why dont you try with PROCESS_ITEM method (even though it works for one line at a time)? I never tried to use POST method for updating the item detaills. The code similar to what you have mentioned works perfectly in PROCESS_ITEM method.

0 Kudos

I can't use PROCESS_ITEM because i need to analyse each lines after the input of user. In fact, if the user enters 3 items lines but he enters only one value for standard field AFNAM (Requisitioner/Requester) my customer want to replicate the AFNAM entered on all empty line for this field. If the user enters differents values and empty line we take the value AFNAM of first line to replicate.

0 Kudos

I try with PROCESS_ITEM and it's work but as i said i need to access to global lines. Is it possible to access to other lines in method PROCESS_ITEM ?

0 Kudos

Sorry stupid question...

0 Kudos

Hi, ToraTora

Did you come right with this one because I have a similar requirement from my client?

I understand your challenge: You need to analyse all the items in the Purchase Requisition before you can update Std. data (e.g. the Processor).

Please let me know.

Regards

Nhlanhla

former_member125661
Contributor
0 Kudos

I am curious to know how you made it work. I also have a similar requirement..Would appreciate if you tells us the solution.