Skip to Content

BAPI_PO_CHANGE. Dump FAILURE

Hi all.

I need modifying delivery date in a purchase order when I release the PO. I have created a implementation ZME_PROCESS_PO_CUST from ME_PROCESS_PO_CUST, and I have called 'BAPI_PO_CHANGE' from method POST. In BAPI I have filled structures POSCHEDULE and POSCHEDULEX:

METHOD if_ex_me_process_po_cust~post.
TYPES: BEGIN OF ty_eket,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
eindt TYPE eindt,
END OF ty_eket.
DATA: lt_eket TYPE STANDARD TABLE OF ty_eket,
wa_eket TYPE ty_eket.
DATA: t_schedule TYPE STANDARD TABLE OF bapimeposchedule,
wa_schedule type bapimeposchedule.
DATA: t_schedulex TYPE STANDARD TABLE OF bapimeposchedulx,
wa_schedulex type bapimeposchedulx.
BREAK-POINT.
if sy-ucomm = 'MESAVE' and sy-tcode = 'ME29N'.
SELECT ebeln ebelp eindt FROM eket
INTO TABLE lt_eket
WHERE ebeln = im_ebeln.

LOOP AT lt_eket INTO wa_eket.
wa_schedule-po_item = wa_eket-ebelp.
wa_schedule-delivery_date = wa_eket-eindt.
APPEND wa_schedule TO t_schedule.
wa_schedulex-po_item = wa_eket-ebelp.
wa_schedulex-po_itemx = 'X'.
wa_schedulex-delivery_date = 'X'.
APPEND wa_schedulex TO t_schedulex.
ENDLOOP.

CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = im_ebeln
TABLES
poschedule = t_schedule
poschedulex = t_schedulex
.
IF sy-subrc = 0.
WRITE: 'Pedido correctamente modificado'.
ENDIF.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.

ENDMETHOD.

When I realese the PO in ME29N and save, I get a dump:

"Exception condition "FAILURE" raised."

A RAISE statement in the program 'CL_HANDLE_MANAGER_MM==========CP" raised the exception condition "FAILURE""

I have looked for some note in OSS but it isn't work in my problem. My SAP_APPL release is 600 and path level 27.

Somebody could help me?

Thanks a lot.

Marta.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

8 Answers

  • avatar image
    Former Member
    Nov 02, 2016 at 04:22 PM

    Hi

    You are already in PO, so you shouldn't use the BAPI, but the methods of the BADI, in order to change the data of PO

    And never to call a COMMIT inside a BADI, in generally in a user-exit.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 10, 2016 at 03:06 PM

    I suppose the methods PROCESS_ITEM and PROCESS__SCHEDULE are called if an item and/or schedule is proccesed, and it's not your situation

    Probably method CHECK doesn't allow the modifications, so in method CHECK, you can try to change the data by field-symbols, it's not real good job, but it's usually works.

    You need to define the strutucture to change the data and to manage the changes documents:

      FIELD-SYMBOLS: <FS_ETT> TYPE STANDARD TABLE,
                     <FS_EKET> TYPE BEKET.
    
      FIELD-SYMBOLS: <FS_POT> TYPE STANDARD TABLE,
                     <FS_EKPO> TYPE BEKPO.
    
      FIELD-SYMBOLS: <FS_YEKPO> TYPE STANDARD TABLE,   "Structure for changes document
                     <WA_YEKPO> TYPE UEKPO.
    
      FIELD-SYMBOLS: <FS_YEKET> TYPE STANDARD TABLE,
                     <WA_YEKET> TYPE UEKET.
    
      DATA: WA_YEKPO TYPE UEKPO.
      DATA: WA_YEKET TYPE UEKET.
    
      DATA: OLD_RECORD TYPE FLAG.

    Get data from program SAPLMEPO

      ASSIGN ('(SAPLMEPO)POT[]') TO <FS_POT>.
      CHECK SY-SUBRC = 0.
    
      ASSIGN ('(SAPLMEPO)YEKPO[]') TO <FS_YEKPO>.
      CHECK SY-SUBRC = 0.
    
      ASSIGN ('(SAPLMEPO)YEKET[]') TO <FS_YEKET>.
      CHECK SY-SUBRC = 0.
    
      ASSIGN ('(SAPLMEPO)ETT[]') TO <FS_ETT>.
      CHECK SY-SUBRC = 0.

    Change the data

      LOOP AT <FS_POT> ASSIGNING  <FS_EKPO>.
    
        <FS_EKPO>-EINDT = '20161203'.
        <FS_EKPO>-UPDKZ = 'U'.
    
        CLEAR OLD_RECORD.
    
        LOOP AT <FS_YEKPO> ASSIGNING <WA_YEKPO>.
    
          CHECK <WA_YEKPO>-EBELP = <FS_EKPO>-EBELP.
          OLD_RECORD = 'X'.
    
        ENDLOOP.
    
        CHECK OLD_RECORD IS INITIAL.
    
        SELECT SINGLE * INTO WA_YEKPO
          FROM EKPO
            WHERE EBELN = <FS_EKPO>-EBELN
              AND EBELP = <FS_EKPO>-EBELP.
    
        CHECK SY-SUBRC = 0.
        APPEND WA_YEKPO TO <FS_YEKPO>.
    
      ENDLOOP.
    
    
      LOOP AT <FS_ETT> ASSIGNING  <FS_EKET>.
    
        <FS_EKET>-EINDT = '20161128'.
        <FS_EKET>-UPDKZ = 'U'.
    
        CLEAR OLD_RECORD.
    
        LOOP AT <FS_YEKET> ASSIGNING <WA_YEKET>.
    
          CHECK <WA_YEKET>-EBELP = <FS_EKET>-EBELP
            AND <WA_YEKET>-ETENR = <FS_EKET>-ETENR.
          OLD_RECORD = 'X'.
    
        ENDLOOP.
    
        CHECK OLD_RECORD IS INITIAL.
    
        SELECT SINGLE * INTO WA_YEKET
          FROM EKET
            WHERE EBELN = <FS_EKET>-EBELN
              AND EBELP = <FS_EKET>-EBELP
              AND ETENR = <FS_EKET>-ETENR.
    
        CHECK SY-SUBRC = 0.
        APPEND WA_YEKET TO <FS_YEKET>.
    
      ENDLOOP.
    Add comment
    10|10000 characters needed characters exceeded

  • Nov 03, 2016 at 09:47 AM

    As Max already wrote, don't call a BAPI in the same transaction, and don't interrupt the commit. Also the BAPI may share some objects in memory with the current transaction, so the dump preserved data integrity...

    You are already in the BAdI so you should change the data in the current session before the SAVE, so first switch to a suitable method like CHECK (a method that allows change of data) or one of the PROCESS methods, it's depend of the data required, from header use PROCESS_HEADER, etc.

    For example in CHECK method you receive IM_HEADER, with method GET_ITEMS you get the list of item and from every item you get the schedule data with GET_SCHEDULES method, there use method GET_DATA and SET_DATA to change required values.(You could also add schedules lines with CREATE_SCHEDULE from item)

    Theorically you could wrap the BAPI_PO_CHANGE and its commit in a RFC FM and schedule it IN BACKGROUND TASK, but actually there is no interest here to do that...

    Regards,
    Raymond

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 04, 2016 at 12:31 PM

    Hi both.

    I'm afraid I don't know how apply your answers.

    I'm trying in CHECK method from ZME_PROCESS_PO_CUST.

    First I get items from header:

    CALL METHOD im_header->get_items
    RECEIVING
    re_items = lt_items.

    Then I try getting shedule from items but I get an error:

    CALL METHOD lt_items->get_schedules
    RECEIVING
    re_schedules = ls_scheditems.

    I have defined lt item as: lt_items TYPE PURCHASE_ORDER_ITEMS.

    Could you say to me the code? Sorry, I haven't done this before.

    Thanks a lot.

    Marta.

    ,

    Hi both.

    I'm afraid I don't know how apply your answers.

    I'm applied this in CHECK method from ZME_PROCESS_PO_CUST.

    First I have got the items:

    CALL METHOD im_header->get_items
    RECEIVING
    re_items = lt_items.

    Then I try getting the schecule but I get an error:

    CALL METHOD lt_items->get_schedules
    RECEIVING
    re_schedules = ls_scheditems.

    where lt_items TYPE PURCHASE_ORDER_ITEMS.

    Could you say to me how is the code? Sorry, I never have developed this.

    Thanks a lot.

    Marta.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 10, 2016 at 11:09 AM

    Hello again.

    I have got to create the code but I haven't got modify 'Delivery date' field (EINDT). I have tried in methods: CHECK, POST,

    PROCESS_ITEM, PROCESS_SCHEDULE and FIELDSELECTION_ITEM but field isn't modified. Any other idea?

    Thanks a lot.

    Marta.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 10, 2016 at 11:47 AM

    Hi

    Can you post your code?

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 10, 2016 at 12:07 PM

    Hi Max.

    I have done many tests:

    - Method PROCESS_ITEM

    DATA: et_item TYPE mepoitem.
    if sy-ucomm = 'MESAVE' and sy-tcode = 'ME29N'.
    BREAK-POINT.
    et_item = im_item->get_data( ).
    et_item-EINDT = '20161212'.
    et_item-eeind = '12.12.2016'.
    CALL METHOD im_item->set_data( et_item ).
    ENDIF.

    - Method CHECK:

    DATA:

    l_item TYPE REF TO if_purchase_order_item_mm,

    l_schedule TYPE REF TO if_purchase_order_schedule_mm,
    ls_mepoitem TYPE mepoitem,
    ls_scheditems TYPE purchase_order_schedules,
    wa_scheditems TYPE purchase_order_schedule,
    ls_meposchedule TYPE meposchedule,
    lt_items TYPE purchase_order_items,
    ls_item TYPE purchase_order_item,
    wa_items LIKE LINE OF lt_items.

    FIELD-SYMBOLS: <meposchedule> TYPE meposchedule.
    IF sy-ucomm = 'MESAVE' AND sy-tcode = 'ME29N'.
    *get reference to schedule line object
    BREAK-POINT.
    lt_items = im_header->get_items( ).
    LOOP AT lt_items INTO wa_items.
    ls_scheditems = wa_items-item->get_schedules( ).

    LOOP AT ls_scheditems INTO wa_scheditems.
    l_schedule ?= wa_scheditems-schedule.
    l_item = l_schedule->get_item( ).
    * Get actual schedule line data
    ls_meposchedule = l_schedule->get_data( ).

    ASSIGN ls_meposchedule TO <meposchedule>.
    <meposchedule>-eindt = '20161203'.

    ** Update changes to schedule line data
    l_schedule->set_data( ls_meposchedule ).

    ENDLOOP.
    ENDLOOP.

    ENDIF.

    Thanks a lot.

    Marta.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 22, 2016 at 02:35 PM

    Hello Max.

    Your solution works fine!!! Thanks a lot!!!

    Marta.

    Add comment
    10|10000 characters needed characters exceeded