on 02-04-2015 10:22 AM
Hello experts,
I'm trying to update data in the planning book using BAPI, but it's not working.
I'm getting data using BAPI_PBSRVAPS_GETDETAIL2, then making changes in lt_keyfig_val anf finally I'm running BAPI_PBSRVAPS_CHANGEKEYFIGVAL2. There is no errors, but planning book does not contain any changes.
Maybe I should change something in save option or commit control?
CALL FUNCTION 'BAPI_PBSRVAPS_GETDETAIL2'
EXPORTING
planningbook = 'XXXX'
data_view = 'XXX'
planning_version = '000'
* SELECTION_ID =
* READ_OPTIONS =
* period_type = 'F'
date_from = lv_from
date_to = lv_to
TABLES
selection = lt_selection
group_by = lt_group
key_figure_selection = lt_keyfig_sel
key_figure = lt_keyfig
key_figure_value = lt_keyfig_val
characteristics_combination = lt_char_comb
return = lt_return.
IF sy-subrc EQ 0.
LOOP AT it_week_quan ASSIGNING <ls_week_quan>.
CONVERT DATE <ls_week_quan>-pdatu INTO TIME STAMP lv_timestamp TIME ZONE sy-zonlo.
LOOP AT lt_keyfig_val ASSIGNING <ls_keyfig_val> WHERE period_begin LE lv_timestamp AND period_end GE lv_timestamp.
MOVE <ls_week_quan>-plnmg TO <ls_keyfig_val>-value.
ENDLOOP.
ENDLOOP.
LOOP AT lt_keyfig ASSIGNING <ls_keyfig>.
APPEND INITIAL LINE TO lt_keyfig_change ASSIGNING <ls_keyfig_change>.
MOVE-CORRESPONDING <ls_keyfig> TO <ls_keyfig_change>.
ENDLOOP.
LOOP AT lt_keyfig_val ASSIGNING <ls_keyfig_val>.
APPEND INITIAL LINE TO lt_keyfig_val_change ASSIGNING <ls_keyfig_val_change>.
MOVE-CORRESPONDING <ls_keyfig_val> TO <ls_keyfig_val_change>.
ENDLOOP.
LOOP AT lt_char_comb ASSIGNING <ls_char_comb>.
APPEND INITIAL LINE TO lt_char_comb_change ASSIGNING <ls_char_comb_change>.
MOVE-CORRESPONDING <ls_char_comb> TO <ls_char_comb_change>.
ENDLOOP.
CALL FUNCTION 'BAPI_PBSRVAPS_CHANGEKEYFIGVAL2'
EXPORTING
planningbook = 'XXXX'
data_view = 'XXX'
planning_version = '000'
* SAVE_OPTIONS =
* COMMIT_CONTROL =
TABLES
key_figure = lt_keyfig_change
key_figure_value = lt_keyfig_val_change
characteristics_combination = lt_char_comb_change
return = lt_return
* EXTENSION_IN =
Hi,
You may need to call BAPI_TRANSACTION_COMMIT after BAPI_PBSRVAPS_CHANGEKEYFIGVAL2.
BR, Ada
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Wojciech,
To get sample code, you can go to SE37, enter the BAPI and press where is used.
Here you have a couple of samples codes:
The BAPI is used in Include: /SAPAPO/APO_SNC_EXTRACTION_F01
CALL FUNCTION 'BAPI_PBSRVAPS_CHANGEKEYFIGVAL2'
EXPORTING
planningbook = '9ASNP_SNC'
data_view = 'SNC_INT'
planning_version = '000'
* SAVE_OPTIONS =
TABLES
key_figure = lt_key_figure
key_figure_value = lt_key_figure_value
characteristics_combination = it_charcomb
return = lt_return
* EXTENSION_IN =
.
COMMIT WORK.
As you can see in that code, a commit work is called, even when in the documentation of the BAPI said that it is automatilly executed:
Notes
The data for the individual characteristic combinations is processed and
saved in sequence. This means that this method always attempts to process as
much data as possible. If an error occurs for the data for a characteristics
combination, processing continues with the data for the following
characteristics combination. If a characteristics combination could not be
locked, the settings in the "SaveOptions"
parameter ("RetryNumber", "RetryWaitingTime") determine when the system will
attempt to lock the characteristics combination again in the future ( Note About Lock
Logic).
If the data for a characteristics combination could not be processed when an
error occurs, the BAdI "APO_BAPI_BUS10030-CHANGE_CHANGEKEYFIGUREVALUE2"
is called with the data of the faulty characteristics combination. This enables
extended error handling.
Only characteristics combinations on the same aggregation level can be
processed in one call. If data on various aggregation levels is transferred,
processing is terminated.
The error messages are always returned with reference to a characteristics
combination.
For SNP planning books, you should note that only the key figures "9APPROD",
"9APSHIP", and "9ADFCST" can be changed from the SNP standard planning area.
As standard, no macros are executed for DP planning books. If you want to
execute the macros for the planning book or data view, you have to set the
"MacroExecutionFlag" in the "SaveOptions"
parameter. In contrast, macros are always executed for SNP planning books.
Note that a commit work or rollback work is automatically executed when this
method is executed.
Kind Regards,
Mariano
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Wojciech
You need to pass either 'E' or 'A' in the commit control, then only the system will perform commit and the changes will be reflected. In case you don't want to pass the commit control, then you have to explicitly commit after the BAPI call.
I would prefer the use of commit control parameter.
Thanks and regards
Swati
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.