Application Development and Automation 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: 
Read only

Ambiguity in BAPI_PR_CHANGE

Arun_Prabhu_K
Active Contributor
0 Likes
2,657

Hi guys.

I am using SAP R/3 4.7.

I tried to use BAPI_PR_CHANGE to change PR quantity and text.

For this,I populated the structure BAPIMEREQITEMIMP with PREQ_ITEM,QUANTITY and SHORT_TEXT individually (since BAPI_PR_GETDETAIL is not available in R/3 4.7).Correspondingly I filled the structure BAPIMEREQITEMX correspondingly with PR no and 'X'.

First I got the error : Enter Plant.

Then I gave plant details to the structure.

Now I didn't get the error but got the message Purchase Requisition xxxxxxxx changed.

Actually the PR didn't change.

Hi guys.

I am using SAP R/3 4.7.

I tried to use BAPI_PR_CHANGE to change PR quantity and text.

For this,I populated the structure BAPIMEREQITEMIMP with PREQ_ITEM,QUANTITY and SHORT_TEXT individually (since BAPI_PR_GETDETAIL is not available in R/3 4.7).Correspondingly I filled the structure BAPIMEREQITEMX correspondingly with PR no and 'X'.

First I got the error : Enter Plant.

Then I gave plant details to the structure.

Now I didn't get the error but got the message Purchase Requisition xxxxxxxx changed.

Actually the PR didn't change.

15 REPLIES 15
Read only

Former Member
0 Likes
2,345

Hi,

Did you called "BAPI_TRANSACTION_COMMIT" after calling your BAPI.

Regards,

Harish

Read only

Former Member
0 Likes
2,345

Hi,

Did you use 'BAPI_TRANSACTION_COMMIT' after the BAPI success.

Regards,

Dhina..

Read only

Former Member
0 Likes
2,345

Hi,

You need to call, Bapi Transaction Commit after you bapi, to complete databse commit.

Read only

Arun_Prabhu_K
Active Contributor
0 Likes
2,345

Yes I did use 'BAPI_TRANSACTION_COMMIT'.

Read only

0 Likes
2,345

Hi,

Please ref the link.

hopes it help full.

Regards,

Dhina..

Read only

former_member213275
Contributor
0 Likes
2,345

HI,

Did you pass ' ' ( space ) to tetrun parameter in FM : BAPI_PR_CHANGE and then BAPI_TRANSACTION_COMMIT.

If you pass Testrun = X then the The values will not be changed.

Srikanth

Read only

madhu_vadlamani
Active Contributor
0 Likes
2,345

Hi Kap,

If all parameters you passed aand there is no change in Pr. Please paster your code here.

Regards,

Madhu.

Read only

Arun_Prabhu_K
Active Contributor
0 Likes
2,345

iBAPIMEREQITEMIMP-PREQ_ITEM = itab-bnfpo.

iBAPIMEREQITEMIMP-PLANT = itab-werks.

iBAPIMEREQITEMIMP-QUANTITY = itab-clqty.

iBAPIMEREQITEMIMP-short_text = itab-txz01.

append iBAPIMEREQITEMIMP.

iBAPIMEREQITEMX-preq_item = itab-bnfpo.

iBAPIMEREQITEMX-plant = 'X'.

iBAPIMEREQITEMX-QUANTITY = 'X'.

iBAPIMEREQITEMX-short_text = 'X'.

append iBAPIMEREQITEMX.

CALL FUNCTION 'BAPI_PR_CHANGE'

EXPORTING

PRNUMBER = prno

TABLES

RETURN = ibapireturn

PRITEM = iBAPIMEREQITEMIMP

PRITEMX = iBAPIMEREQITEMX.

LOOP AT ibapireturn.

error-type = ibapireturn-type.

error-banfn = prno.

error-bnfpo = itab-bnfpo.

error-message = ibapireturn-message.

APPEND error.

CLEAR error.

ENDLOOP.

READ TABLE ibapireturn WITH KEY type = 'E'.

CASE sy-subrc.

WHEN 0.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

WHEN OTHERS.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

WAIT UP TO 1 SECONDS.

ENDCASE.

The Message I am getting is "S : Purchase Requisition xxxxxxxx changed".

But it is not getting changed.

Read only

0 Likes
2,345

HI ,

EPORT 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.

Check with this and change your fields what you need.

Regards,

Madhu.

Read only

Arun_Prabhu_K
Active Contributor
0 Likes
2,345

The code is similar to mine.Still not able to find out why the BAPI is not working.

Read only

0 Likes
2,345

HI,

Are you giving the leading zeros in item no.Post all the return messages from return table.

Regards,

Madhu.

Read only

Arun_Prabhu_K
Active Contributor
0 Likes
2,345

Yes,Leading zeroes are added to the item number.

The return messages are:

S:Purchase requisition 0016676771 changed

W:Delivery date is in the past

W:Requisition date is in the past

Read only

0 Likes
2,345

Hi,

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)).

give the input what your passing in your program.

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

Regards,

Dhina..

Read only

Arun_Prabhu_K
Active Contributor
0 Likes
2,345

I even tried out using SE37 + Shift-F8. Same info I am getting "Purchase Requisition xxxx changed".But no use.

And I found out one thing,

I tried BAPI_REQUISITION_CHANGE for a PR,it works and the return type is 'I' with message "Purchase Requisiton xxxx successfully changed'.

But in this case, the return type is 'S' and the message is only 'Purchase Requisition xxxx changed'.

Why such misleading output occurs with return type as 'S-SUCCESS'????

Read only

0 Likes
2,345

Hi,

Instead of this field check with any other field to change.Did you tried like that.

Regards,

Madhu.