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: 

BAPI_PR_CHANGE

Former Member
0 Kudos

I'm having some trouble using this BAPI, even at the most basic operation. I am trying to update a current requisition (in this case the Short Text and QTY) using the code below. Inexplicably, even after a commit (bapi or just 'commit work') the requisition is not getting updated even though the BAPI it_return table states otherwise. Any thoughts?

DATA it_PRITEM TYPE TABLE OF BAPIMEREQITEMIMP.

DATA wa_PRITEM TYPE BAPIMEREQITEMIMP.

DATA it_PRITEMX TYPE TABLE OF BAPIMEREQITEMX.

DATA wa_PRITEMX TYPE BAPIMEREQITEMX.

wa_PRITEM-PREQ_ITEM = '00020'.

wa_PRITEM-QUANTITY = '111'.

wa_PRITEM-SHORT_TEXT = 'asdfadsfasdfasdf'.

APPEND wa_PRITEM TO it_PRITEM.

wa_PRITEMX-PREQ_ITEM = '00020'.

wa_PRITEMX-QUANTITY = 'X'.

wa_PRITEMX-SHORT_TEXT = 'X'.

APPEND wa_PRITEMX TO it_PRITEMX.

CALL FUNCTION 'BAPI_PR_CHANGE'

EXPORTING

number = '0010001348'

  • PRHEADER =

  • PRHEADERX =

  • VERSIONS =

  • TESTRUN =

  • IMPORTING

  • PRHEADEREXP =

TABLES

RETURN = it_return

PRITEM = it_PRITEM

PRITEMX = it_PRITEMX

  • PRITEMEXP = it_reqlineitems

  • PRITEMSOURCE =

  • PRACCOUNT = it_reqlineaccass

  • PRACCOUNTPROITSEGMENT =

  • PRACCOUNTX =

  • PRADDRDELIVERY =

  • PRITEMTEXT =

  • PRHEADERTEXT =

  • EXTENSIONIN =

  • EXTENSIONOUT =

  • PRVERSION =

  • PRVERSIONX =

  • ALLVERSIONS =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Why don't you uncomment the exporting parameter RETURN in the commit and see if there's anything there after it executes?

Rob

12 REPLIES 12

Former Member
0 Kudos

Why don't you uncomment the exporting parameter RETURN in the commit and see if there's anything there after it executes?

Rob

0 Kudos

Rob,

Thanks for the quick reply. I tried that but the structure in the COMMIT BAPI is empty.

BTW, here is the return from the PR_CHANGE BAPI:

S |06 |403 |Purchase requisition 10001348 changed <

0 Kudos

You should probably look at OSS note 565099.

Rob

0 Kudos

Hey Rob,

I had seen this note, but am unsure if this is applicable? We are running on mySAP 5.0 and these are for 4.7?

0 Kudos

Hi,

Why don't you use BAPI BAPI_REQUISITION_CHANGE for changing purchase requisition.

Is it also used for purchase req. change.

Thanks,

Ramakrishna

0 Kudos

Hello Ramakrishna,

Thanks for the reply. Unfortunately this BAPI has numerous limitations:

- Can not add a line to a REQ once its created.

- Can not mark req lines as deleted (via the indicator)

- Can not maintain the Ship to Address

Surely, there are bound to be more. We are running on ERP 2004 ECC 5.0, and the BAPI's are in there and seem to be functional. I've run into this issues using the CHANGE BAPI. While I assume its the BAPI's fault, it could be I'm doing something wrong.

Really hoping someone could shed some light on this. Been stuck for 2 days.

Thanks,

EnriqueL

0 Kudos

Have you looked for other notes?

Rob

0 Kudos

Hi Enrique,

You must inculde BASPI FM BAPI_TRANSACTION_COMMIT after calling BAPI BAPI_PR_CHANGE.

I tried in a simple program to change the PR. I could able to change PR qty.

The below is the code I used...

&----


*& Report ZBAPI_PR_CHANGE *

*& *

&----


*& *

*& *

&----


REPORT ZBAPI_PR_CHANGE .

DATA:

RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,

PRITEM LIKE BAPIMEREQITEMIMP OCCURS 0 WITH HEADER LINE,

PRITEMX LIKE BAPIMEREQITEMX OCCURS 0 WITH HEADER LINE.

PARAMETERS: P_REQUI LIKE BAPIMEREQHEADER-PREQ_NO,

P_ITEM LIKE BAPIMEREQITEMIMP-PREQ_ITEM,

P_QTY LIKE BAPIMEREQITEMIMP-QUANTITY,

P_PLANT LIKE BAPIMEREQITEMIMP-PLANT,

P_TEXT LIKE BAPIMEREQITEMIMP-SHORT_TEXT.

START-OF-SELECTION.

PRITEM-PREQ_ITEM = P_ITEM.

PRITEM-QUANTITY = P_QTY.

PRITEM-SHORT_TEXT = P_TEXT.

PRITEM-PLANT = P_PLANT.

APPEND PRITEM .

PRITEMX-PREQ_ITEM = P_ITEM.

IF NOT P_QTY IS INITIAL.

PRITEMX-QUANTITY = 'X'.

ENDIF.

IF NOT P_TEXT IS INITIAL.

PRITEMX-SHORT_TEXT = 'X'.

ENDIF.

IF NOT P_PLANT IS INITIAL.

PRITEM-PLANT = 'X'.

ENDIF.

APPEND PRITEMX .

CALL FUNCTION 'BAPI_PR_CHANGE'

EXPORTING

PRNUMBER = P_REQUI

  • VERSIONS =

  • SKIP_ITEMS_WITH_ERROR =

  • TESTRUN =

TABLES

RETURN = RETURN

PRITEM = PRITEM

PRITEMX = PRITEMX

  • PRITEMEXP =

  • PRITEMSOURCE =

  • PRACCOUNT =

  • PRACCOUNTPROITSEGMENT =

  • PRACCOUNTX =

  • PRADDRDELIVERY =

  • PRITEMTEXT =

  • PRHEADERTEXT =

  • PRLIMITS =

  • PRCONTRACTLIMITS =

  • PRSERVICES =

  • PRSRVACCESSVALUES =

  • PRSERVICESTEXT =

  • EXTENSIONIN =

  • EXTENSIONOUT =

  • ALLVERSIONS =

  • CHANGING

  • PRHEADER =

  • PRHEADERX =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

  • IMPORTING

  • RETURN =

.

END-OF-SELECTION.

LOOP AT RETURN.

WRITE:/ RETURN-MESSAGE.

ENDLOOP.

Thanks,

Ramakrishna

0 Kudos

Rob:

Yes, I did search through SAP Notes when I first encountered the issue but did not see anything that might help other than the note you pointed out yesterday. I spoke to the the BASIS guys here and that support pack has already been installed. The only problem I can think of is that since we are on ERP 2004, this is being caused by old code in the BAPI (although the SP should have fixed that?)

Ramakrishna:

Thanks for the great reply! I tried your code but unfortunately I can not replicate your results in our systems (ERP 2004 ECC 5.0). Would you by any chance be running ERP 2005? Thanks again!!

Best,

Enrique Leon

0 Kudos

Hi Enrique,

I am using SAP R/3 Enterprise(4.7D).

1. Try to change the same PR from ME52, If you can able to change, then there is no problem with the data.

2. Are you able to change the PR manually. I mean did you try from SE37. If not, do the follow steps...

You have to run both BAPIs BAPI_PR_CHANGE & BAPI_TRANSACTION_COMMIT IN test sequence.( SE37 + (Shift+F8)).

If it is working fine here means,it should work in the program also.

Thanks,

ramakrishna

0 Kudos

Ramakrishna,

Thanks for the assist, I have rewarded points. I changed the Req order I was working on and am now able to change the QTY. The short text, however, stays the same. At least I know I'm using the BAPI in the correct way. I can move forward now!

THANKS!

Former Member
0 Kudos

You have to use BAPI_REQUISITION_DELETE to delete PR Document or lineitems in PR