Bapi: kbpp_extern_update_co, tcode: cj30/CJ40 Part 2

Source: Internet
Author: User
Example, reproduced to the following address: http://blog.csdn.net/yf_sap/archive/2009/07/29/4390435.aspx

To implement the cj30 update or add Project (WBS) budget, you can use the following functions:Kbpp_extern_update_co

What I want to achieve now is to modify the annual budget and increase the overall budget. The following steps can achieve the required functions:

1,Data: Lt_bpakType Standard Table OfBpakWith Header Line.

Data: Lt_bpak_nType Standard Table OfBpakWith Header Line.
Data: Lt_retturnType Standard Table OfBapiret2With Header Line.

2, Loop At Gt_itab.
Clear Rochelle wtjhr.
Data : L_pspnr Like PRPs-pspnr.
Call Function 'Conversion _ exit_abpsp_input'
Exporting
Input = Gt_itab-posid
Importing
Output = L_pspnr
Exceptions
Not_found = 1
Others = 2 .
If Sy-subrc <> 0 .
Message ID Sy-msgid Type Sy-msgty Number Sy-msgno
With Sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Endif .

Select Single Objnr Into Lt_bpak-e_objnr From PRPs Where Pspnr = l_pspnr.
If Sy-subrc EQ 0 .
Lt_bpak-e_vorga = 'Kbud' .
Lt_bpak-twaer = 'Cny' .
Lt_bpak-wert = gt_itab-wtjhr.
Lt_bpak-e_vorga = 'Kbud' .
Select Wtjhr Into Rochelle wtjhr From Bpja
Where Objnr = lt_bpak- E_objnr
And Wrttp = '41'
And Vorga = 'Kbud'
And Twaer = 'Cny'
And GjahrNe P_gjahr.

Lt_bpak-wert = lt_bpak-wert + l_wtjhr.
ClearRochelle wtjhr.
Endselect.
AppendLt_bpak.

Move-correspondingLt_bpakToLt_bpak_n.
Lt_bpak_n-e_gjahr = p_gjahr.
Lt_bpak_n-wert = gt_itab-wtjhr.

AppendLt_bpak_n.
Endif.
Clear: Lt_bpak, lt_bpak_n.
Endloop.

** Modify the overall budget (you must modify the overall budget first. Otherwise, when you increase the annual budget, the system will check that the overall budget is insufficient and report an error.

Call Function 'Kbpp _ extern_update_co'
Exporting
I _budget_activity = 'Kbud'
* I _budget_activ_sup_ret = 'X'
* I _commit_data = 'X'
I _delta_amounts = ''
I _rollup_data = ''
* I _check_plan_data = 'X'
* I _application = 'P'
I _commit_all = 'X'
* Importing
* E_errors_found =
Tables
It_bpak = lt_bpak []
It_return = lt_retturn []
Exceptions
No_update = 1
Others = 2
.

IfSy-subrc <>0.
Message IDSy-msgidTypeSy-msgtyNumberSy-msgno
WithSy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Endif.

** Modify the annual budget

Refresh Lt_retturn.
Call Function 'Kbpp _ extern_update_co'
Exporting
I _budget_activity = 'Kbud'
* I _budget_activ_sup_ret = 'X'
* I _commit_data = 'X'
I _delta_amounts = ''
I _rollup_data = ''
* I _check_plan_data = 'X'
I _application = 'P'
I _commit_all = 'X'
* Importing
* E_errors_found =
Tables
It_bpak = lt_bpak_n []
It_return = lt_retturn []
Exceptions
No_update =1
Others = 2
.

IfSy-subrc <>0.
Message IDSy-msgidTypeSy-msgtyNumberSy-msgno
WithSy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Endif.

Note:

1. You must first modify the top-layer WBS and then modify the WBS layer. Otherwise, check that the upper-layer budget is insufficient and an error will be reported.

2. If the parameter I _delta_amounts is equal to 'x', it means appending, equals to '', or modifying

3. If the I _rollup_data parameter is set to 'x', The WBS on the upper layer will automatically increase the budget.

4. I personally think there is a problem with writing this function.SortIt_bpakByE_gesDescending.

However, when we modify the overall budget, all e_ges are 'x', so the sorting will be out of order and the underlying WBS may be put on top, put the upper-layer WBS below, and then modify the budget, especially when a new WBS, will report an error saying that the lower-layer WBS budget is larger than the upper-layer WBS budget. I have been searching for parameters for a long time, this problem was not implemented, so I set the standardsProgramChangedSortIt_bpakByE_gesDescendingE_objnrAscending.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.