2014 Dec 11 12:24 PM
Hi,
Can anybody help me in regard to using the function module BAPI_PR_CHANGE function module to modify service line item in PR?
My problem is as follows -
I have the following PR with a service line item.
The gross-value of the service line Content Writing/Development is INR 5000. I need to change the gross-value so that whole PR value gets changed automatically.
I am trying to use the function module BAPI_PR_CHANGE in the following way -
I have updated the PR number and the tables SERVICELINES and SERVICELINESX (only the following fields) as per the following entries -
SERVICELINES table
DOC_ITEM = '00010'
OUTLINE='2'
SRV_LINE='00010'
GROSS_PRICE= '4000.00'
SERVICELINESX table
DOC_ITEM = '00010'
OUTLINE='2'
SRV_LINE='00010'
GROSS_PRICE= 'X'
After executing the function module with the above data, I am not finding any change in the service line item or the whole PR.
Can you please tell me the exact process to change the service line using the above function module?
Regards,
Subhabaha Pal
2014 Dec 11 12:37 PM
When you tested this BAPI did you test it in a test sequence and called BAPI_TRANSACTION_COMMIT in the same test sequence ?
Or did you use the BAPI in a report (same question did you also call BAPI_TRANSACTION_COMMIT )?
2014 Dec 11 12:42 PM
Hi Peter,
Thanks for your query.
I directly executed the function module - not in any test run sequence. Can you please give me some example code for changing service line item using the function module BAPI_PR_CHANGE?
That will be of great help to me.
Regards,
Subhabaha Pal
2014 Dec 11 12:49 PM
You either need to test the BAPI with a test sequence (SE37 FunctionModule/Test/testSequence and fill in both bapi names)
or
in this case you can also set a breakpoint at line 224 statement:
IF lf_cr EQ cl_mmpur_constants=>yes. COMMIT WORK. ENDIF.
Change the value of lf_cr to cl_mmpur_constants=>yes ( = 'X') and then continue.
In this specific case the developer has put this statement for testpurposes to be able to commit the changes. Normally you would have to use a test sequence like I decsribed before.
I recommend you try the test sequence so yo are prepared whenever you need to test a BAPI where a commit needs to be done to finalzie the changes in the database.
Also did you check the RETURN table for messages ?
2014 Dec 12 4:42 AM
Hi Peter,
Thanks for your reply.
Yes I checked the return text message. It does not show any error. It gives following message.
S 06 403 Purchase requisition 10004915 changed
S BAPI 002 Instance 10004915 of object type PurchaseRequisition has been changed.
It will be of great help if you can tell me the format of changing service line item of a PR using the function module BAPI_PR_CHANGE through a report or through any other means.
Regards,
Subhabaha Pal
2014 Dec 12 9:18 AM
Hi Subhabaha Pal,
You had filled the service line items correct when you tested the function module (BAPI), just the commit was missing.
Without commit the changes are not finalized in the database. You need to call a commit (BAPI_TRANSACTION_COMMIT) in the same LUW (Logical Unit Of Work).
For testing you can do this as I described in my previous message. You are almost there 😉
The message says the update was succesfull, therefore the way you had filled the service line items seems to be correct.
In a report you have to call this BAPI with the servic lines filled as you have done in your test, check the return table if it was succesfull and if yes call BAPI_TRANSACTION_COMMIT.
After the last BAPI (BAPI_TRANSACTION_COMMIT) has been called the changes will be visible in the PR.
Peter
2014 Dec 12 10:32 AM
Hi Peter,
Thanks a lot for your reply. I am trying to put that in a FM or Report program with BAPI_TRANSACTION_COMMIT at the end.
I have a small doubt. I was going through SAP Note 499627 released on 22.11.2013.
As per the note, there was query as follows -
8. Question:
Can service items be created using BAPI_REQUISITION_CREATE or changed using BAPI_REQUISITION_CHANGE?
Answer:
No, this is only possible with the new API functions for the object BUS2105. See the following point.
---------------------------
9. Question:
Can service items be created using BAPI_PR_CREATE or changed using BAPI_PR_CHANGE?
Answer:
Yes. Release 6.04 (Enhancement Package 4) provides new API functions for the object BUS2105 that include this function. In addition the
business function LOG_MM_CI_2 or the switch MM_SFWS_SC2 must be active.
See Note 1312947 for further information.
Now we are using SAP EHP 6 with ECC 6.0 component. When we tried to implement the node 1312947 it did not work as it was for lower version. It was further telling "
the
business function LOG_MM_CI_2 or the switch MM_SFWS_SC2 must be active" in order to BAPI_PR_CHANGE or BAPI_PR_CREATE to work for service line-items.
One thing I found out that BAPI_PR_GETDETAIL is not providing the service line items though it should provide the table whereas BAPI_REQUISITION_GETDETAIL is providing the same. BAPI_REQUISITION_CHANGE does not have the option of entering changed service line items and so could not use the same.
Please tell me whether in our SAP version it is needed to activate business function LOG_MM_CI_2 or the switch MM_SFWS_SC2 to modify service lines using BAPI_PR_CHANGE or I can try without that also.
Without activation of business function LOG_MM_CI_2, is it possible to work in MM purchase requistion?
Awaiting....
Regards,
Subhabaha Pal
2014 Dec 12 10:38 AM
Hi Subhababa Pal,
I am not able to answer that question, I am sorry. That goes beyond my knowledge.
But I would say try it out since you already tested the BAPI and it gave you a succes message I think it will work.
If you need to activate a business function to have it work first I do not think the BAPI would have given back a succes message in your previous test.
Just try it out with a small test report where you call the BAPI with the values you used in yout test followed by the Commit Bapi and if it fails contact your basis administrator and ask him/her to activate that specific business function and then try again.
However my gut feeling says it is not necessary and it will work already as is now.
Peter
2014 Dec 12 10:41 AM
Hi Peter,
Thanks for your reply.
I am trying to do the same and will let you know the result.
Regards,
Subhabaha Pal
2014 Dec 12 11:33 AM
Hi Peter,
I used the following code in a FM and executed the function module -
DATA it_return TYPE TABLE OF bapiret2.
DATA it_return1 TYPE TABLE OF bapiret2.
DATA lt_servicelines TYPE TABLE OF bapi_srv_service_line.
DATA ls_servicelines TYPE bapi_srv_service_line.
DATA lt_servicelinesx TYPE TABLE OF bapi_srv_service_linex.
DATA ls_servicelinesx TYPE bapi_srv_service_linex.
ls_servicelines-doc_item = is_lineitem-bnfpo.
ls_servicelines-srv_line = is_lineitem-introw .
ls_servicelines-gross_price = is_lineitem-preis1.
append ls_servicelines to lt_servicelines.
ls_servicelinesx-doc_item = is_lineitem-bnfpo.
ls_servicelinesx-srv_line = is_lineitem-introw .
ls_servicelinesx-gross_price = 'X'.
append ls_servicelinesx to lt_servicelinesx.
CALL FUNCTION 'BAPI_PR_CHANGE'
EXPORTING
number = is_lineitem-banfn
* PRHEADER =
* PRHEADERX =
* TESTRUN =
* IMPORTING
* PRHEADEREXP =
TABLES
return = it_return
* PRITEM =
* PRITEMX =
* PRITEMEXP =
* PRITEMSOURCE =
* PRACCOUNT =
* PRACCOUNTPROITSEGMENT =
* PRACCOUNTX =
* PRADDRDELIVERY =
* PRITEMTEXT =
* PRHEADERTEXT =
* EXTENSIONIN =
* EXTENSIONOUT =
* PRVERSION =
* PRVERSIONX =
* ALLVERSIONS =
* PRCOMPONENTS =
* PRCOMPONENTSX =
* SERVICEOUTLINE =
* SERVICEOUTLINEX =
SERVICELINES = lt_servicelines
SERVICELINESX = lt_servicelinesx
* SERVICELIMIT =
* SERVICELIMITX =
* SERVICECONTRACTLIMITS =
* SERVICECONTRACTLIMITSX =
* SERVICEACCOUNT =
* SERVICEACCOUNTX =
* SERVICELONGTEXTS =
* SERIALNUMBER =
* SERIALNUMBERX =
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
* IMPORTING
* RETURN =
.
ls_servicelinesx-doc_item has been taken as the main PR line item - value '00010'.
ls_servicelinesx-srv_line has been taken as the service line item - here taken '10' as I want to change the 1st line.
I ran the code. But it is not giving any result, i.e., not changing the value of the PR. I think using the code in FM or report is same and I need to run the code in a RFC only which will be used by an UI5 application for changing the service line items.
Awaiting your guidance,
Regards,
Subhabaha Pal
2014 Dec 12 12:03 PM
Comparing your code with the previous code of your test I see you didn't fille the OUTLINE in the service line. Is that correct ?
If there is an outline, you need to fill it. The BAPI documentation states that (transaction BAPI tab Documentation). Copied at the end of this post.
Could that be the issue ? Also did you check the return tabel after the call of BAPI_PR_CHANGE ?
You should put some logic to check this table for errors or success, but this depends on what is returned. Some BAPI's return nothing which means succes, others sopecifically return a succesmessage. Since this BAPI returns a succes message I would put a check if this message is there.
Something like a check for succesfull
read table it_return into wa_return with key type = 'S'
number = '403'
if sy-subrc = 0.
call BAPI_TRANSACTION_COMMIT.
else.
loop at it_return into wa_return.
write: / wa_return.
endloop.
endif.
or the opposite check for errors (which I most times do)
read table it_return into wa_return with key type = 'E'
if sy-subrc <> 0.
read table it_return into wa_return with key type = 'A'.
if sy-subrc <> 0.
call BAPI_TRANSACTION_COMMIT.
else.
write values of return table
endif.
else.
write values of return table
endif.
BAPI DOCUMENTATION:
ServiceLines
Transfer Structure Enjoy Purchase Requisition
- Service Lines
Description
This parameter contains information on the individual service lines of the service package. Reference the service lines with the purchase requisition item via the DOC_ITEM field and with the outline level under which the service is to appear via the OUTLINE field.
If no outline has been created for the service package, the OUTLINE field need not be passed on. The SRV_LINE field is the number of the service line. It is unique within a service level.
Please ajust the program accordingly and see if the change get posted. If not tell us what the error message is.
Peter
2014 Dec 15 5:36 AM
Hi Peter,
Thanks for your detailed reply.
It is helpful and I am trying what you have mentioned.
Actually, I am not aware of the format to pass for service line item change in BAPI_PR_CHANGE and nowhere got an example and hence I am facing some problem.
BAPI_PR_GETDETAIL is not providing the service level value though options are there and hence I am facing this problem. BAPI_REQUISITION_GETDETAIL provides the format in order to pass in BAPI_REQUISITION_CHANGE and hence it is possible for enter data in the BAPI_REQUISITION_CHANGE in correct format. However, since BAPI_PR_GETDETAIL does not provide the service level value for a PR hence I am facing this problem.
I am trying your solution and will get back on it soon.
Thanks once again.....
Regards,
Subhabaha Pal
2014 Dec 12 11:54 AM
Hi Subhabaha,
I think you can use the FM bapi_alm_notif_data_modify ...
Regards,
Mahesh somanath.
2015 Sep 15 7:53 AM
hi Mahesh,
Can you please explain how to use this BAPI_ALM_NOTIF_DATA_MODIFY to change PR service data.?
Thanks and regards,
Hrishikesh Vaishampayan
2015 Sep 15 7:50 AM
hi subhabaha,
I am also trying to change service PR using BAPI_PR_CHANGE.
I want to change quantity of each service line item of each package of PR . But facing the same issue as you faced.
I am getting success message in return table but changes are not reflecting in PR.
Even I am getting one more information message on PRITEM table. Its as below
type : I
ID : ME
Number : 664
Text : Change MENGE couldn't be effected.
I am don't know about format to pass data for service line item change and didn't got any example to refer.
Can please tell me how did you solved your issue ? It will be great help for me.
I am waiting for your response.
Thanks and regards.
Hrishikesh Vaishampayan
2015 Sep 15 8:03 AM
Hi Hrisikesh,
Through any standard BAPI I could not change the service line-items. I did direct table-level changes through code.
Regards,
Dr. Subhabaha Pal
2016 Jan 20 11:41 PM
For Service Items to be processed by BAPI BAPI_PR_CHANGE the switch framework MM_SFWS_SC2 (under LOG_MM_CI_2) needs to be turned on.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |