on 04-07-2006 2:23 AM
Hi geniuses,
Please help:)
Is it possible to populate fields in infocube in the start routine?
I am trying to load data from ODS to Infocube. They are 1:1 mapping, but there a few fields are not populated in ODS like occupy_percentage_low. Now I am asked to calculate those values in start routine and send the values to coresponding fields in the infocube.
I tried to use the following code, but there is no values in the cube after I load data to cube.
loop at data_package assigning <fs>.I
IF <fs>-/BIC/occupy / <fs>-/BIC/Totalavailable < '0.10'.
DATA_PACKAGE-/BIC/OCCU_LOW = 'Y'.
CONTINUE.
ENDIF.
ENDLOOP.
I also tried to use <fs>-/BIC/OCCU_LOW = 'Y'. In debugging mode, there is no value for <fs>-/BIC/OCCU_LOW either. Really lost!
Thanks!
Lin
Message was edited by: Lin Cong
hi Lin,
if the infoobject name is 0occupy and 0totalavailable then it should be like
<fs>-occupy / <fs>-Totalavailable
(without /bic/; /bic/ is for customized infoobject, e.g you have infoobject zoccupy then it will be like <fs>-/bic/zoccupy.
if the calculation didn't involved any data from other table, only from ods (occupy and Totalavailable are exist in ods) then you have no need to populate with start routine, you can simply populate e.g infoobject occupy_percentage_low using method 'routine', create routine and put code like
result = 'N'.
IF comm_structure-occupy / comm_structure-Totalavailable < '0.10'.
result = 'Y'.
ENDIF.
or ..
IF comm_structure-/BIC/zoccupy / comm_structure-/BIC/z... < '0.10'.
(zTotalavailable is too long for customized infoobject name, so the name should be not like that).
hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you AHP.
totalavailable is the name I made up in order to make its meaning clearly.
The value of totalavailable is not in the ODS but a master data table. I think I need to retrieve the values from master data table into an internal table. Then read the internal table, do calculation and populate fields in the infocube. Is it right?
Lin
hi Lin,
yes, you are right, read from master data into internal table and read from internal table, you can calculate in start routine or individual routine for infoobject
check sample code with start routine
PROGRAM UPDATE_ROUTINE.
$$ begin of global - insert your declaration only below this line -
TABLES: /bic/p[masterdata].
DATA: l_tabix like sy-tabix,
it_masterdata like /bic/p[masterdata] occurs 0 with header line.
$$ begin of routine - insert your code only below this line -
fill the internal tables "MONITOR" and/or "MONITOR_RECNO",
to make monitor entries
data : it_data_package like DATA_PACKAGE occurs 0 with header line.
select * from /bic/p[masterdata]
into table it_masterdata.
loop at data_package.
l_tabix = sy-tabix.
move-corresponding DATA_PACKAGE to it_data_package.
read it_masterdata with key [field name] = it_data_package-[fieldname]
if more key add it_data_package-[fieldname] - without AND
if sy-subrc = 0.
*.... calculation
modify data_package from it_data_package index l_tabix.
endif.
endloop.
hope this helps.
hi Lin,
yes, you are right
it_data_package-/bic/occupy_percentage_low = 'Y'
if you have multiple calculation,
you can modify data_package later,
put 'modify data_package from it_data_package index l_tabix.' after all calculation, like
read table ...
if sy-subrc = 0.
...
it_data_package-/bic/occupy_percentage_low = 'Y'
it_data_package-other infoobject = ' .... '
..
modify data_package from it_data_package index l_tabix.
endif.
or if read from other table or other calculation
if ...
endif.
if ...
endif.
modify data_package from it_data_package index l_tabix.
don't worry, if we modify data_package, and no value change, it will have just the same previous value as we have move data_package to it_data_package and we modifty from it.
hope this clears your doubt.
Hi AHP,
I am coming back.
I wrote the code as you gave me. I still cannot send values to the target cube. I test it with a very simple logic.
The code is like:
LOOP AT DATA_PACKAGE.
l_tabix = sy-tabix.
MOVE-CORRESPONDING DATA_PACKAGE TO IT_DATA_PACKAGE.
IF it_data_package-/BIC/*** < 0.
it_data_package-/BIC/***_LOW = 'Y'.
LOWLINE-CARRID = it_data_package-/BIC/CARRID.
LOWLINE-FLIGHTID = it_data_package-/BIC/FLIGHTID.
APPEND LOWLINE TO LOWTABLE.
CONTINUE.
ENDIF.
modify DATA_PACKAGE from it_data_package index l_tabix.
ENDLOOP.
......
I delete the all the records that are not in the lowtable from datapackage.
In the target cube, I only see the records in the lowtable (I want), but not the 'low' column. Any clue?
Thanks!
Lin
The answer to your question is absolutly possible to add a field to your cube. Make sure you have that field to your comm. structure as well; and follow AHP's code.
Regards:
BK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.