Typically we read the livecache data indirectly using the function modules specific for the diferent objects. To read the planning book you can use BAPI_PBSRVAPS_GETDETAIL2. See below a minimal example of reading some data from a planning book using the BAPI.
ls_selection-characteristic_name = 'SP_MHO_IP'.
ls_selection-char_val_sign = 'I'.
ls_selection-char_val_option = 'EQ'.
ls_selection-char_val_low = 'SP-MHO-MAN-UM'.
append ls_selection to lt_selection.
ls_groupby-characteristic_name = 'SP_MHO_IP'.
append ls_groupby to lt_groupby.
ls_groupby-characteristic_name = 'SP_MHO_IM'.
append ls_groupby to lt_groupby.
ls_keyfigselection-key_figure = 'SP_MHO_CF'.
append ls_keyfigselection to lt_keyfigselection.
call function 'BAPI_PBSRVAPS_GETDETAIL2'
exporting
planningbook = 'SP_MHO_PROGNOSE'
data_view = 'INBOUND MSC'
planning_version = '000'
period_type = 'D'
date_from = '01.06.2004'
date_to = '01.01.2005'
tables
selection = lt_selection
group_by = lt_groupby
key_figure_selection = lt_keyfigselection
key_figure = lt_keyfigure
key_figure_value = lt_keyfigure_value
characteristics_combination = lt_ccomb
return = lt_return.
You can also call directly the LC routines using database calls with native SQL (example below). But for most cases this is not needed.
EXEC "#EC CI_EXECSQL
SQL.
EXECUTE PROCEDURE SAPTS_CHANGE_TG (
IN :LS_GEN_COM_PARAMS,
* Return-Codes der COM-Routine
OUT :LV_RC,
OUT :ET_RC,
* Importdaten (Daten AN die COM-Routine)
IN :IV_TG,
IN :IV_TG_REF,
IN :IV_TYPE,
IN :LT_STAMPS,
IN :IV_CHANGE_MODE
)
ENDEXEC.
Update: Some more information on the parameters of the BAPI_PBSRVAPS_GETDETAIL2
An example probably helps. Consider a PA with characteristics COLOR, SHAPE, TEXTURE and with key figures FORECAST, SALES, OPEN.
These 3 tables are inputs to the function: selection, group_by, key_figure_selection.
selection: is a range table where you specify the characteristic values you want to restrict your data selection.
COLOR I EQ RED <- filter the results to only have CVCs with red color
group_by: lists the characteristics that will be in the output results. So if you have 5 characteristics in the PA but you only put one in this table, then your key figure values will be aggregated for the combinations of this single characteristic.
COLOR, SHAPE <- only show the combinations of color and shape; the key figures are aggregated to this level)
key_figure_selection: only the key figures in this list will be in the output.
FORECAST, SALES <- only show the SALES and FORECAST KF in the results
Output tables:
characteristics_combination - this table lists the output characteristic combinations values (CVCs) and for each CVC there is an ID that links to the other results tables
ID C_NAME C_VALUE
1 COLOR RED
1 SHAPE SQUARE
2 COLOR RED
2 SHAPE CIRCLE
key_figure - this is a table the lists combinations of the selected CVCs and key figures and for each combination there is a unique ID (that will be used in the KF values table)
KF_ID CC_ID KEY_FIGURE
1 1 SALES
2 2 SALES
3 1 FORECAST
4 2 FORECAST
key_figure_value - this table has the key figure values for each period in the selection and for each key figure ID (which is the combination of CVC and key figure).
KF_ID BEGIN END VALUE
1 1.1.2012 31.1.2012 10
2 1.1.2012 31.1.2012 20
3 1.1.2012 31.1.2012 30
4 1.1.2012 31.1.2012 40
1 1.2.2012 29.2.2012 5
2 1.2.2012 29.2.2012 5
3 1.2.2012 29.2.2012 6
4 1.2.2012 29.2.2012 6