In this lecture, we
will create the final two objects before we dive into BPC itself. We will
create a real-time InfoCube and a MultiProvider.
InfoProviders
InfoCube ZPRC01
Custom InfoObjects
The Custom InfoObjects’ settings are as
follows:
Characteristic ZKRECH
Characteristic CRECTYPE
Text:
A Detail
Price Planning
B Aggregated
Prices - Product Hierarchy
C Aggregated
Prices - Material Group
Key Figure ZPRINC2
Transformation ODSO ZBPC_DS4 -> CUBE CPRC01
Start Routine
*$*$ begin of routine - insert your code only below this line *-*
... "insert your code here*-- fill table "MONITOR" with values of structure "MONITOR_REC"*- to make monitor entries
... "to cancel the update process* raise exception type CX_RSROUT_ABORT.data: lo_dataref type ref to data, ls_source_package like line of SOURCE_PACKAGE, lv_curr_calmonth type /bi0/oicalmonth, lt_calmonth type standard table of /bi0/oicalmonth, lv_calmonthfrom type /bi0/oicalmonth, lv_calmonthto type /bi0/oicalmonth, n type i, lv_tabix type sy-tabix.
field-symbols: <lv_new_data> type any, <lt_new_data> type any table, <ls_new_data> type any, <ls_data> type any, <lv_dateto> type any, <lv_datefrom> type any.
data: lc_calmonth type string value 'TABLE_LINE'.
"how many years are we planning/loading data from? select calmonth from /bi0/scalmonth into table lt_calmonth where calmonth ge '201501' and calmonth le '201712'. "SET YOUR OWN DATES OR SELECT FROM /BI0/MCALMONTH ETC.
sort lt_calmonth ascending. delete adjacent duplicates from lt_calmonth.
describe table lt_calmonth lines n.
create data lo_dataref like SOURCE_PACKAGE. assign lo_dataref->* to <lt_new_data>.
create data lo_dataref like line of SOURCE_PACKAGE. assign lo_dataref->* to <ls_data>.
create data lo_dataref like line of <lt_new_data>. assign lo_dataref->* to <ls_new_data>.
break-point.
loop at SOURCE_PACKAGE assigning <ls_data>. move-corresponding <ls_data> to <ls_new_data>. assign component 'DATEFROM' of structure <ls_new_data> to <lv_datefrom>. assign component 'DATETO' of structure <ls_new_data> to <lv_dateto>. lv_calmonthfrom = <lv_datefrom>+0(6). lv_calmonthto = <lv_dateto>+0(6).
read table lt_calmonth into lv_curr_calmonth with key (lc_calmonth) = lv_calmonthfrom. if sy-subrc = 0. lv_tabix = sy-tabix. else. read table lt_calmonth into lv_curr_calmonth index 1. if lv_calmonthfrom lt lv_curr_calmonth. lv_tabix = 1. else. lv_tabix = n + 1. "out of range". endif. endif.
while ( lv_tabix le n ) and ( lv_curr_calmonth le lv_calmonthto
).
read table lt_calmonth into lv_curr_calmonth index lv_tabix.
concatenate lv_curr_calmonth '01' into <lv_datefrom>.
call function 'SN_LAST_DAY_OF_MONTH' exporting day_in = <lv_datefrom>
importing end_of_month = <lv_dateto>.
collect <ls_new_data> into <lt_new_data>.
lv_tabix = lv_tabix + 1.
endwhile.
endloop.
clear: SOURCE_PACKAGE.
SOURCE_PACKAGE = <lt_new_data>.
0AMOUNT
data: ls_salesorg type /bi0/psalesorg.
select single * from /bi0/psalesorg into ls_salesorg where salesorg = SOURCE_FIELDS-salesorg and objvers = 'A'.
RESULT = SOURCE_FIELDS-amount. if SOURCE_FIELDS-/bic/zkrech = 'A'. CURRENCY = ls_salesorg-currency. else. CURRENCY = SOURCE_FIELDS-currency. endif.
data: lv_calmonth type /bi0/oicalmonth.
lv_calmonth = SOURCE_FIELDS-DATEFROM+0(6).
call function 'FISCPER_FROM_CALMONTH_CALC' exporting iv_calmonth = lv_calmonth
iv_periv iv_periv = 'K4' importing* EV_FISCPER3 =* EV_FISCYEAR = ev_fiscper = RESULT.
data: lv_calmonth type /bi0/oicalmonth.
lv_calmonth = SOURCE_FIELDS-DATEFROM+0(6).
call function 'FISCPER_FROM_CALMONTH_CALC' exporting iv_calmonth = lv_calmonth
iv_periv iv_periv = 'K4' importing* EV_FISCPER3 = ev_fiscyear = RESULT.
data: lv_calmonth type /bi0/oicalmonth.
lv_calmonth = SOURCE_FIELDS-DATEFROM+0(6).
call function 'FISCPER_FROM_CALMONTH_CALC' exporting iv_calmonth = lv_calmonth
iv_periv iv_periv = 'K4' importing ev_fiscper3 = RESULT.
data: mat_division type /bi0/oidivision,
t_sales_off type /bi0/oisales_off.
if SOURCE_FIELDS-customer <> ''.
select divisioninto mat_division
from /bi0/mmaterial
where material = SOURCE_FIELDS-material
and objvers = 'A'. "into @data(_division). endselect.
if sy-subrc = 0. . else. mat_division = '10'.
endif.
select sales_off
into t_sales_off
from /bi0/mcust_sales
where cust_sales = SOURCE_FIELDS-customer
and salesorg = SOURCE_FIELDS-salesorg
and distr_chan = SOURCE_FIELDS-distr_chan
and division = mat_division
and objvers = 'A'. endselect.
if sy-subrc = 0. RESULT = t_sales_off. else. RESULT = '100'. "DEFAULT TO 100 endif.
else. RESULT = ''. "DEFAULT TO # endif.
data: mat_division type /bi0/oidivision,
if SOURCE_FIELDS-customer <> ''.
select division
into mat_division
from /bi0/mmaterial
where material = SOURCE_FIELDS-material
and objvers = 'A'.
"into @data(_division).
endselect.
if sy-subrc = 0.
.
else.
mat_division = '10'.
endif.
select cust_group
into t_cust_group
from /bi0/mcust_sales
where cust_sales = SOURCE_FIELDS-customer
and salesorg = SOURCE_FIELDS-salesorg
and distr_chan = SOURCE_FIELDS-distr_chan
and division = mat_division
and objvers = 'A'.
endselect.
if sy-subrc = 0.
RESULT = t_cust_group.
else.
RESULT = '100'. "DEFAULT TO 100
endif.
else.
RESULT = ''. "DEFAULT TO 100
endif.
if SOURCE_FIELDS-customer <> ''.
select division
into mat_division
from /bi0/mmaterial
where material = SOURCE_FIELDS-material
and objvers = 'A'.
"into @data(_division).
endselect.
if sy-subrc = 0.
.
else.
mat_division = '10'.
endif.
select cust_group
into t_cust_group
from /bi0/mcust_sales
where cust_sales = SOURCE_FIELDS-customer
and salesorg = SOURCE_FIELDS-salesorg
and distr_chan = SOURCE_FIELDS-distr_chan
and division = mat_division
and objvers = 'A'.
endselect.
if sy-subrc = 0.
RESULT = t_cust_group.
else.
RESULT = '100'. "DEFAULT TO 100
endif.
else.
RESULT = ''. "DEFAULT TO 100
endif.
t_cust_group type /bi0/oicust_group.
No comments:
Post a Comment