Question:
Hi fans!
Could somebdy please provide me with some information on how to create and use a return table?
We need to return four lines from one line read from the info source.
Best regards
Pål
Answer:
dear Pal,
I have created a return table for one of our key figures in one of our cubes.
To do this you need to perform the following :
- in the update rules, tab page key figure calculation, choose 'routine' as the update method and check the 'return table' checkbox
- push the create button to create the routine which will fill up your return table
That's it
Below you will find the code from our routine as an example. In this example, we had records coming in with a from and end date and needed to return a record in the cube for every year it was covering (e.g. record from 02/05/1999-06/03/2000 needed to return 2 lines, one for 1999 and one for 2000)
Principle :
* the structure "COMM_STRUCTURE" holds the data from the record of the communication structure you are dealing with
* the structure "ICUBE_VALUES" holds the data which will be uploaded in the cube for this record - characteristics are already filled
* the table "RESULT_TABLE" is the table you need to fill with your code
Good luck
FORM compute_key_figure
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
RESULT_TABLE STRUCTURE /BIC/VHRTMPT
USING COMM_STRUCTURE LIKE /BIC/CSHRPERIODS
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
ICUBE_VALUES LIKE /BIC/VHRTMPT
CHANGING RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
*
*$*$ begin of routine - insert your code only below this line *-*
* fill the internal table "MONITOR", to make monitor entries
data: year(4) type n.
clear year.
* add first record to result table with period = 1
* year = year of start day absence
move-corresponding ICUBE_VALUES to RESULT_TABLE.
move RESULT_TABLE-/BIC/CABPS(4) to RESULT_TABLE-calyear.
move '1' to RESULT_TABLE-/BIC/CABNP.
append RESULT_TABLE.
move RESULT_TABLE-/BIC/CABPS(4) to year.
* as long as the calendar year of the added record does not equal the
* year of the last day of the absence => keep adding 1 to year and add
* a record to the result table.
while year ne RESULT_TABLE-/BIC/CABPE(4).
year = year + 1.
move year to RESULT_TABLE-calyear.
move '0' to RESULT_TABLE-/BIC/CABNP.
append RESULT_TABLE.
endwhile.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.
*$*$ end of routine - insert your code only before this line *-*
*
ENDFORM.