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: 

Error changing WBS in Purchase Req. by BAPI_PR_CHANGE while not in ME52N

e_maino
Explorer
0 Kudos
1,201

Hello guys,

I am trying to change WBS Element

on Account Assignment of Purchase Requisition

by BAPI_PR_CHANGE and i am facing some errors,

while by transaction ME52N I have no problem changing this data.

These are the errors faced by the bapi..

EMEPO82
EBAPI3
EME83
E670
EMEPO80

and this is the code I wrote..

LOOP AT t_poitem INTO ls_poitem.
     CLEAR: lv_number, ls_out, lt_account[], lt_accountx[].
     READ TABLE t_out INTO ls_out
       WITH KEY ebelp = ls_poitem-po_item.
     lv_number = ls_poitem-preq_no. "Purchase Request Number
     CALL FUNCTION 'BAPI_PR_GETDETAIL'
       EXPORTING
         number                      = lv_number
         account_assignment          = 'X'
*       ITEM_TEXT                   = ' '
*       HEADER_TEXT                 = ' '
*       DELIVERY_ADDRESS            = ' '
*       VERSION                     = ' '
*       SC_COMPONENTS               = ' '
*       SERIAL_NUMBERS              = ' '
*       SERVICES                    = ' '
*     IMPORTING
*       PRHEADER                    =
      TABLES
*       RETURN                      =
*       PRITEM                      =
        praccount                   = lt_praccount
*       PRADDRDELIVERY              =
*       PRITEMTEXT                  =
*       PRHEADERTEXT                =
*       EXTENSIONOUT                =
*       ALLVERSIONS                 =
*       PRCOMPONENTS                =
*       SERIALNUMBERS               =
*       SERVICEOUTLINE              =
*       SERVICELINES                =
*       SERVICELIMIT                =
*       SERVICECONTRACTLIMITS       =
*       SERVICEACCOUNT              =
*       SERVICELONGTEXTS            =
               .

     LOOP AT lt_praccount INTO ls_praccount.
        CLEAR: ls_accountx, ls_account.
        ls_account-preq_item = ls_praccount-preq_item.
        ls_account-serial_no = ls_praccount-serial_no.
        PERFORM get_wbs_posid USING ls_out-zcommessam
                          CHANGING ls_account-wbs_element.
        APPEND ls_account TO lt_account.

        ls_accountx-preq_item = ls_praccount-preq_item.
        ls_accountx-serial_no = ls_praccount-serial_no.
        ls_accountx-preq_itemx = 'X'.
        ls_accountx-wbs_element = 'X'.
        APPEND ls_accountx TO lt_accountx.
     ENDLOOP.

     CALL FUNCTION 'BAPI_PR_CHANGE'
       EXPORTING
         number                       = lv_number
*       PRHEADER                     =
*       PRHEADERX                    =
         testrun                      = lv_test
*     IMPORTING
*       PRHEADEREXP                  =
      TABLES
        return                       = lt_return
*       PRITEM                       =
*       PRITEMX                      =
*       PRITEMEXP                    =
*       PRITEMSOURCE                 =
        praccount                    = lt_account
*       PRACCOUNTPROITSEGMENT        =
        praccountx                   = lt_accountx
*       PRADDRDELIVERY               =
*       PRITEMTEXT                   =
*       PRHEADERTEXT                 =
*       EXTENSIONIN                  =
*       EXTENSIONOUT                 =
*       PRVERSION                    =
*       PRVERSIONX                   =
*       ALLVERSIONS                  =
*       PRCOMPONENTS                 =
*       PRCOMPONENTSX                =
*       SERVICEOUTLINE               =
*       SERVICEOUTLINEX              =
*       SERVICELINES                 =
*       SERVICELINESX                =
*       SERVICELIMIT                 =
*       SERVICELIMITX                =
*       SERVICECONTRACTLIMITS        =
*       SERVICECONTRACTLIMITSX       =
*       SERVICEACCOUNT               =
*       SERVICEACCOUNTX              =
*       SERVICELONGTEXTS             =
*       SERIALNUMBER                 =
*       SERIALNUMBERX                =
               .
     READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
     IF sy-subrc NE 0.
       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait          = 'X'.

     ELSE.
       e = 'X'.
       EXIT.
     ENDIF.


   ENDLOOP.




1 ACCEPTED SOLUTION

e_maino
Explorer
0 Kudos
572

Hi guys,

in the end we changed the flow of the report, setting status Cancelled on the Purchase Request using BAPI_REQUISITION_DELETE...in this way we were able after to modify Purchase Order via BAPI_PO_CHANGE.


Thanks anyway to everybody who answered..

6 REPLIES 6

jyotheswar_p2
Active Participant
0 Kudos
572

Hi

Your error message is not clear.

But however just a remainder - make sure you use conversion exits for sending the WBS in that appropriate field and try.

CONVERSION_EXIT_ABPSP_INPUT    Conversion External > Internal WBS Element Number

CONVERSION_EXIT_ABPSP_OUTPUT   Conversion Internal > External WBS Element Number

Thanks & Regards

Eswar

raymond_giuseppi
Active Contributor
0 Kudos
572

Can you give more information on those received errors or analyze those yourself : e.g. for E083(ME) give the two first variables (missing data ?) and E080(MEPO) give a wrong status code.

Also if this form/method is called multiple times, don't forget to use BAPI_TRANSACTION_ROLLBACK to refresh buffers before trying next call of the BAPI.

Regards,

Raymond

0 Kudos
572

But however just a remainder - make sure you use conversion exits for sending the WBS in that appropriate field and try.


I'll check this as soon as possible..



Can you give more information on those received errors or analyze those yourself : e.g. for E083(ME) give the two first variables (missing data ?) and E080(MEPO) give a wrong status code.

E ME 083:         Insert Plant

E 06  070:          Insert quantity

E MEPO 080:     Elaboration status not valid

The strange thing for me is that I'm passing just the WBS, not any other data requested by return table..

Also if this form/method is called multiple times, don't forget to use BAPI_TRANSACTION_ROLLBACK to refresh buffers before trying next call of the BAPI.


Yes, by now i was debugging and trying to understand these errors...next step I'll put bapi_rollback after bapi if it faces some errors..





By now, thanks everyone for your suggestions..I'll let you know..

0 Kudos
572

Did you look for OSS notes for your version, e.g. 1490525 - BAPI Err ME083 etc; MEREQX not clearing when held PReq saved and correction 1542925 for held PR ?

Regards,

Raymond

e_maino
Explorer
0 Kudos
573

Hi guys,

in the end we changed the flow of the report, setting status Cancelled on the Purchase Request using BAPI_REQUISITION_DELETE...in this way we were able after to modify Purchase Order via BAPI_PO_CHANGE.


Thanks anyway to everybody who answered..

former_member185932
Participant
0 Kudos
572

I recently encountered similar errors returned from BAPI_PR_CHANGE (i.e. errors MEPO 080 Processing status invalid and MEPO 082 Purchase requisition still contains items with errors). To fix the issue I applied OSS notes 1705810 and 1748182.


Regards,

JB