实现TCODE:CJ40/CJ30 功能,其实多个TCODE都可以使用该FM来实现,该函数使用存在很多问题,必须要注意参数。

为该函数在网上找了不少资料,将觉得有用的部分分级部分收藏。

第一篇文章网址为:http://www.sap4.com/index.php?title=KBPP_EXTERN_UPDATE_CO

KBPP EXTERN UPDATE CO

Note 625613 - Interface for overall planning and budgeting`

Symptom You want to create overall planning values (value type 01 or 10) or budget values (value type 41 or 45) from an external system for orders or projects in R/3. There is no suitable BAPI.

Other terms KO12, CJ40, CJ42, structure planning CJ30, CJ32, CJ37, CJ38, KO22, KO24, KO26

Reason and Prerequisites This problem is caused by a missing function.

Solution Release 4.6C: As of Support Package SAPKH46C46, you can use the new function module KBPP_EXTERN_UPDATE_CO to create overall planning values and budget values for internal orders or projects in R/3. An advance delivery for earlier releases or Support Packages is not possible. Release 470: The module is contained in Release 4.70. The function has been extended slightly compared to Version 4.6C. Refer to the function module documentation there.

The function of the function module is explained below. (This description applies to all releases. See the function module documentation for possible enhancements in Release 4.70.)


Functionality The function module is used for transferring the budgeting and the cost-element-independent total costs planning to orders and projects as well as transferring the cost-element-independent total revenue planning to projects. Only the following objects are supported: WBS elements Orders from order category 01 and 02 for plan values Orders from order category 01, 02 and 30 for plan values

Only one object type and one business transaction can be processed for each call. For example, transferring original budget values for WBS elements and overall plan values for orders must be carried out with two separate calls.

Processing data: If not otherwise specified (see parameters I_DELTA_AMOUNTS, I_ROLLUP_DATA), the transferred values are added to existing values. In addition, in the case of WBS elements, they are rolled up within the project hierarchy. The update must be triggered explicitly by the I_COMMIT_DATA parameter.

Line items: For budgeting, budget line items are always updated. For overall planning, plan line items are only written if a relevant user status is set that permits the business transaction (KSTP or KSTR). For new budget records and new planned records, a line item is written in the same amount of the value; for already existing records, a corresponding difference line item is written. After a successful update, the document number of the line item is returned for the relevant data record in the IT_BPAK-BELNR field.

Check and error output: When you transfer budget values, the system ALWAYS performs a consistency check of the new budget of the project or of the order. In the same way, the system performs an active availability control according to the relevant Customizing settings. Error messages displayed due to these checks are displayed in the table IT_RETURN (structure BAPIRT2). Warning messages are not issued. For overall planning, the consistency check is performed only if the parameter I_CHECK_PLAN_DATA is set to 'X'. After the validation, a transfer is performed for valid data records only. For a correct data record, the value 00 is returned in the STATUS field of the table IT_BPAK after a successful check or update. For incorrect data records, the table IT_RETURN contains a relevant error message. If an error occurred, the STATUS field of the table IT_BPAK contains a value between 1 and 99 for the incorrect data record.

Table with data records: The individual data records must be transferred to the table IT_BPAK (with the structure BPAK). The import parameters of the module apply equally to all data records in the table and are automatically copied to the table entries by the function module. Since the structure BPAK is also used for other business transactions or for different objects, only the relevant fields must be supplied in each case. The following fields of the table IT_BPAK must or can be filled:

IT_BPAK-E_OBJNR: The object number of the WBS element or order.

          This field must be filled.

IT_BPAK-WERT: The plan value or budget value.

          This field must be filled.

IT_BPAK-TWAER: The transaction currency for the value. (Keep in mind the permitted transaction currencies according to the budget profile or planning profile.)

          This field must be filled.

IT_BPAK-E_GJAHR: The fiscal year for year-dependent budget values or plan values.

          In addition, if the field IT_BPAK-E_GES is filled, the affected data record is updated both as a year-dependent value and a year-independent value. At least one of the two fields IT_BPAK-E_GJAHR or IT_BPAK-E_GES must be filled.

IT_BPAK-E_GES: Indicator whether the value is to be updated as year-independent budget value or plan value.

          In addition, if the field IT_BPAK-E_GJAHR is filled, the data record in question is updated as a year-independent value as well as a year-dependent value. At least one of the two fields IT_BPAK-E_GJAHR or IT_BPAK-E_GES must be filled.

IT_BPAK-E_VERSN: The plan version.

          The field must be filled for plan values. For budget values, the field must remain blank since the plan version is not explicitly used in the budgeting.

IT_BPAK-BLDAT: The document date for the line item.

          This field can be filled.

IT_BPAK-SGTEXT: The text of the document item of the line item.

          This field can be filled.


All other fields of the table IT_BPAK should not be filled, since this may result in problems with the update.

Import/export parameter: I_COMMIT_DATA:

          Indicator of whether the module performs the update. Note: The ABAP command COMMIT WORK is executed with I_COMMIT_DATA = 'X' within the module.

I_DELTA_AMOUNTS:

          Indicator of whether the values are to be added to existing values (X) or whether data records, which already exist in the database, are to be overwritten ( ). Note that for budget supplement and budget return only I_DELTA_AMOUNTS = 'X' is permitted (see below "Special logic for budget supplement and budget return").

I_ROLLUP_DATA:

          This parameter is relevant exclusively for projects.
          Indicator of whether the values are to be rolled up within the project hierarchy (X) or not ( ).

In this case, the changes are not implemented for the WBS element entered in IT_BPAK. Instead they are implemented for the hierarchically superior WSB element (the "path" above the WSB element). Note 1: Setting the parameter I_ROLLUP_DATA does not have the same effect as the function "Total Up" within transaction CJ40. Note 2: If the 'Bottom-up planning' indicator is set in the relevant planning profile, the system automatically performs a total up in the same way as when saving or checking within transaction CJ40. You do not need to set the parameter I_ROLLUP_DATA in this case.

I_BUDGET_ACTIVITY:

          Business transaction
          The following business transactions are supported:
          Budget:

Original budget
- KBUD Budget supplement(TCODE:CJ30/CJ32)
- KBN0 Budget return(TCODE:CJ37)
- KBR0 Budget release(TCODE:CJ38)
- KBFR (only projects)

          Overall plan:

Overall planning
- KSTP Total revenues(TCODE:CJ40)
- KSTR (only projects TCODE:CJ42)

I_CHECK_PLAN_DATA:

          This parameter is relevant for the overall planning only.
          Indicator of whether the overall plan values are to be checked regarding consistency (X) or not ( ). The availability control is performed.

I_APPLICATION:

          This parameter describes object type: 'P' for projects, 'O' for orders. If there is a large dataset, the initiator should set this parameter to improve the runtime. However, it is not absolutely necessary to set this parameter.

E_ERRORS_FOUND:

          This export parameter returns the value 'X' as soon as at least one data record of the table IT_BPAK is incorrect and if the error table IT_RETURN contains at least one entry.


All import/export parameters are optional.

Special logic for budget supplement and budget return: With budget supplement and budget return the budget values can only be added to already existing budget data. Therefore, you cannot overwrite budget supplements or budget returns which already exist in the database. That is, it is not possible to set the parameter I_DELTA_AMOUNTS = ' ' for budget supplement and budget return. Therefore, this logic is valid if I_BUDGET_ACTIVITY = KBN0 or KBR0.

Recommendation for processing WBS elements: If you want to update data for several WBS elements of a project, sort the data records according to descending project hierarchy. That is, the data for WBS elements with the smallest level should be at the first position in the table IT_BPAK. The other data records should be entered with increasing hierarchy level in the table IT_BPAK. Reason: The consistency check is carried out for each individual data record of the table IT_BPAK. In this case, the IT_BPAK entries that were already checked are also taken into account in the subsequent checks of the next entries. Example: The table IT_BPAK contains six data records. For example, when you check the fourth entry, the system checks the values of data records 1 to 4 as well as the already existing data records of the database. The values 5 and 6 are not taken into account.

Revenue planning: When processing total revenues, enter negative values in the table IT_BPAK so that the revenue values are updated as positive revenues in the database.

posted on 2011-02-18 17:35  zhumk  阅读(15382)  评论(0编辑  收藏  举报