Skip to Content

Substitute Account in ME_PROCESS_REQ_CUST (ME51N)

Hello guys,

I want to use BADI ME_PROCESS_REQ_CUST to substitute the account in purchase requisition. Therefor I wanted to use method PROCESS_ACCOUNT but unfortunately it is not getting triggered. I found out that with positiontype 'D' this method does not get triggered. So how else can I substitute the account in position data? I can see that method PROCESS_ITEM is getting triggered, but as far as I can see I canot access accounting data in this method?

Regards

Michael

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Mar 06 at 02:47 PM

    The parameter received in PROCESS_ITEM carries the IF_ACCT_CONTAINER_MM interface, did you check its methods like GET_ITEMS, REMOVE and CREATE_ITEM?

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 06 at 04:53 PM

    Can you give me some help for using them? It is like calling a reference with a reference of a reference. Too much OO for my mind. It looks like that I can use the GET_ITEMS and CREATE_ITEM line but I would be glad to have some help to deal with it.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 06 at 05:08 PM

    Is it correct like this? Do not know if this code looks right, because too much OO for me. At least it does not get a dump ;-)

    But unfortunately nothing gets updated.

       DATA: ls_exkn      TYPE exkn,
             ls_mereqitem TYPE mereq_item,
             lr_acc_list  TYPE mmpur_accounting_list,
             lr_acc_type  TYPE mmpur_accounting_type.
    
    
       ls_mereqitem = im_item->get_data( ).
    
       lr_acc_list = im_item->if_acct_container_mm~get_items( ).
    
       LOOP AT lr_acc_list INTO lr_acc_type.
         ls_exkn = lr_acc_type-model->get_exkn( ).
    
    *    Change SAKTO
         (.....) coding for change
    
    
         lr_acc_type-model->set_exkn( ls_exkn ).
       ENDLOOP.
    Add comment
    10|10000 characters needed characters exceeded

    • Another point of view. Can it depend on the field itself?

      When I want to change SAKTO in foreground I am not able to do this in account assignment tab.

      I have to do this services tab. With F1 Help on the field, it is a structure called ESKN, not EXKN. Maybe updating the wrong field?

  • Mar 07 at 02:32 PM

    I now tried with different itemcategory (blank, 'K'). Everything works fine with it, even PROCESS_ACCOUNT gets triggered then. But as far as I switch it to itemcategory 'D' (service), neither the method gets triggered nor the value changes in method PROCESS_ITEM.

    Any ideas whats so special about this itemcategory?

    unbenannt.png

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 08 at 06:21 PM

    You mean like this?

       CHECK im_count EQ 1.
    
       ls_item = im_item->get_data( ).
    
       TRY.
           lo_services ?= im_item.
         CATCH cx_sy_move_cast_error.
           RETURN.
       ENDTRY.
    
       CALL METHOD lo_services->get_data
         EXPORTING
           im_limit     = lf_limit
         importing
           ex_comsrv    = ls_comsrv
           ex_acc_tab   = lt_acc_tab
         EXCEPTIONS
           failure      = 1
           illegal_data = 2
           OTHERS       = 3.
    
    *  DO Changes In LT_ACC_TAB FIELD SAKTO
       (....)
    
       CALL METHOD lo_services->set_data
         EXPORTING
           im_comsrv  = ls_comsrv
           im_acc_tab = lt_acc_tab.

    It looks good and changes the SAKTO valie. Thanks a lot for that, brilliant! But is it normal that field gets only updated in account assignment tab first, but not in service tab? Only after saving it it gets updated in both.

    Adding the methods lead to an endless loop. I bypassed it with checking the im_count parameter, but why is this method called endless times now? I only got one service position row. So is the coding right like this?

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 14 at 08:16 AM

    Is it possible that this BADI is only triggered in foreground or when using BAPI_PR_CREATE? When creating BANFs with BAPI_REQUISITION_CREATE, it looks like that it not gets triggered. It looks like that I have to use user-exit EXIT_SAPLMEWQ_001 for that?

    Add comment
    10|10000 characters needed characters exceeded