How to create solved fact table and corresponding cube
Hello,
I want to create cube with solved fact table. It means, i need to feed data for higher levels of dimension also from fact table instead of aggreting from base level.
I am using star schema and AWM 10g R2 for creating cube.
If anyone knows how to do this, i would be very benificial.
Thanks
Subash
I have generated parent child script using cwm2_olap_pc_transform.create_script. After running this generated script, it has created 3 table/view.
My Base Parent Child table is like this:-
drop table PARENT_CHILD;
create table PARENT_CHILD (PARENT varchar2(30), CHILD varchar2(30));
insert into PARENT_CHILD values ('Eligible', 'Compliant');
insert into PARENT_CHILD values ('Eligible', 'Non-Compliant');
insert into PARENT_CHILD values ('All', 'Eligible');
insert into PARENT_CHILD values ('All', 'Ineligible');
insert into PARENT_CHILD values (null, 'All');
After running generated script thru cwm2_olap_pc_transform.create_script, it has created :-
Table - PARENT_CHILD_SOLVED
View - PARENT_CHILD_SOLVED_view , PARENT_CHILD_view
This script also inserted data in above table/view. (5 rec in each). Table/View structure is like this:-
SQL> desc PARENT_CHILD_view
Name Null? Type
GID NUMBER
CHILD1 VARCHAR2(30)
CHILD2 VARCHAR2(30)
CHILD3 VARCHAR2(30)
Data:-
0 All Eligible Compliant
0 All Eligible Non-Compliant
1 All Eligible
1 All Ineligible
3 All
SQL> desc PARENT_CHILD_SOLVED
Name Null? Type
GID NUMBER
CHILD1 VARCHAR2(30)
CHILD2 VARCHAR2(30)
CHILD3 VARCHAR2(30)
Data:-
0 All Eligible Compliant
0 All Eligible Non-Compliant
1 All Eligible
1 All Ineligible
3 All
SQL> desc PARENT_CHILD_SOLVED_view
Name Null? Type
GID NUMBER
SHORT_DESCRIPTION VARCHAR2(30)
LONG_DESCRIPTION VARCHAR2(30)
CHILD1 VARCHAR2(30)
CHILD2 VARCHAR2(30)
CHILD3 VARCHAR2(30)
Data:-
0 Compliant Compliant All Eligible Compliant
0 Non-Compliant Non-Compliant All Eligible Non-Compliant
1 Eligible Eligible All Eligible
1 Ineligible Ineligible All Ineligible
3 All All All
I tried to create dim and cube based on this. I am not sure whether its correct or not! Though validate_dimension API call shows that it is valid.
Script for Dim:-
DECLARE
-- variable to hold error message
errtxt varchar(60);
BEGIN
-- To be on safer side just drop dimension before creating new one and catch exceptions
BEGIN
cwm2_olap_dimension.drop_dimension('APPS', 'HCP_DIM_PC');
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Dimension HCP_DIM_PC not dropped');
END;
cwm2_olap_dimension.create_dimension(
'APPS',
'HCP_DIM_PC',
'Parent Child',
NULL,
'Parent Child',
'Parent Child',
NULL);
cwm2_olap_dimension_attribute.create_dimension_attribute(
'APPS',
'HCP_DIM_PC',
'Short Description',
'Short Description',
'Short Description',
'Short Description',
TRUE);
cwm2_olap_dimension_attribute.create_dimension_attribute(
'APPS',
'HCP_DIM_PC',
'Long Description',
'Long Description',
'Long Description',
'Long Description',
TRUE);
cwm2_olap_dimension_attribute.create_dimension_attribute(
'APPS',
'HCP_DIM_PC',
'Grouping ID',
'Grouping ID',
'Grouping ID',
'Grouping ID',
TRUE);
cwm2_olap_hierarchy.create_hierarchy(
'APPS',
'HCP_DIM_PC',
'HCP_DIM_PC_HIER',
'Standard',
'Standard',
'Standard Parent Child Hierarchy',
'SOLVED LEVEL-BASED');
cwm2_olap_dimension.SET_DEFAULT_DISPLAY_HIERARCHY ('APPS', 'HCP_DIM_PC', 'HCP_DIM_PC_HIER');
cwm2_olap_level.create_level(
'APPS',
'HCP_DIM_PC',
'ALL_PARENT_LVL',
'All Parent Child',
'All Parent Child',
'All Parent Child',
'All Parent Child Level');
cwm2_olap_level_attribute.create_level_attribute(
'APPS',
'HCP_DIM_PC',
'Short Description',
'ALL_PARENT_LVL',
'Short Description',
'Short Description',
'Short Description',
'Short Description',
TRUE);
cwm2_olap_level_attribute.create_level_attribute(
'APPS',
'HCP_DIM_PC',
'Long Description',
'ALL_PARENT_LVL',
'Long Description',
'Long Description',
'Long Description',
'Long Description',
TRUE);
cwm2_olap_level_attribute.create_level_attribute(
'APPS',
'HCP_DIM_PC',
'Grouping ID',
'ALL_PARENT_LVL',
'Grouping ID',
'Grouping ID',
'Grouping ID',
'HTB Grouping ID',
TRUE);
-- Add all levels one by one to dimension hierarchy. For top most level last parameter is null.
cwm2_olap_level.add_level_to_hierarchy(
'APPS',
'HCP_DIM_PC',
'HCP_DIM_PC_HIER',
'ALL_PARENT_LVL',
NULL);
BEGIN
cwm2_olap_table_map.removemap_dimtbl_hierlevel(
'APPS',
'HCP_DIM_PC',
'HCP_DIM_PC_HIER',
'ALL_PARENT_LVL');
cwm2_olap_table_map.removemap_DimTbl_HierLevelAttr(
'APPS', 'HCP_DIM_PC', 'Short Description', 'HCP_DIM_PC_HIER', 'ALL_PARENT_LVL', 'Short Description');
cwm2_olap_table_map.removemap_DimTbl_HierLevelAttr(
'APPS', 'HCP_DIM_PC', 'Long Description', 'HCP_DIM_PC_HIER', 'ALL_PARENT_LVL', 'Long Description');
cwm2_olap_table_map.removemap_DimTbl_HierLevelAttr(
'APPS', 'HCP_DIM_PC', 'Grouping ID', 'HCP_DIM_PC_HIER', 'ALL_PARENT_LVL', 'Grouping ID');
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Level map for ALL_PARENT_LVL not removed');
END;
-- Map ALL_PARENT_LVL level to dimension table. Last parameter is null since it is top most level
cwm2_olap_table_map.map_dimtbl_hierlevel(
'APPS',
'HCP_DIM_PC',
'HCP_DIM_PC_HIER',
'ALL_PARENT_LVL',
'APPS',
'PARENT_CHILD_SOLVED_VIEW',
'GID',
NULL);
-- one by one map all the level attributes to respective columns in the dimension table.
cwm2_olap_table_map.Map_DimTbl_HierLevelAttr(
'APPS',
'HCP_DIM_PC',
'Short Description',
'HCP_DIM_PC_HIER',
'ALL_PARENT_LVL',
'Short Description',
'APPS',
'PARENT_CHILD_SOLVED_VIEW',
'SHORT_DESCRIPTION');
cwm2_olap_table_map.Map_DimTbl_HierLevelAttr(
'APPS',
'HCP_DIM_PC',
'Long Description',
'HCP_DIM_PC_HIER',
'ALL_PARENT_LVL',
'Long Description',
'APPS',
'PARENT_CHILD_SOLVED_VIEW',
'LONG_DESCRIPTION');
cwm2_olap_table_map.Map_DimTbl_HierLevelAttr(
'APPS',
'HCP_DIM_PC',
'Grouping ID',
'HCP_DIM_PC_HIER',
'ALL_PARENT_LVL',
'Grouping ID',
'APPS',
'PARENT_CHILD_SOLVED_VIEW',
'GID');
-- Use cwm2_olap_validate.validate_dimension to validate the dimension
cwm2_olap_validate.validate_dimension('APPS', 'HCP_DIM_PC');
cwm2_olap_metadata_refresh.mr_refresh;
-- Rollback if any exception occurs during processing this script
EXCEPTION
WHEN OTHERS THEN
cwm_utility.dump_error;
errtxt := cwm_utility.get_last_error_description;
dbms_output.put_line('ERROR: ' || errtxt);
ROLLBACK;
RAISE;
END;
Script for Cube:-
declare
HCP_time_dim number;
errtxt varchar(60);
begin
cwm_utility.collect_garbage;
begin
cwm2_olap_cube.drop_cube('APPS', 'HCP_PC_CUBE');
exception
when others then
dbms_output.put_line('No HCP_PC_CUBE to drop');
end;
begin
cwm2_olap_catalog.drop_catalog('HCP_PC_CAT');
exception
when others then
dbms_output.put_line('No HCP_PC_CAT to drop');
end;
CWM2_OLAP_CUBE.Create_Cube('APPS', 'HCP_PC_CUBE', 'Parent Child Cube', 'Parent Child Cube','Parent Child Cube');
cwm2_olap_cube.add_dimension_to_cube('APPS', 'HCP_PC_CUBE','APPS', 'HCP_DIM_PC');
cwm2_olap_measure.create_measure('APPS', 'HCP_PC_CUBE', 'HCP_PC_MEASURE', 'PC Measure','PC Measure', 'PC Measure Fact');
cwm2_olap_table_map.map_facttbl_levelkey('APPS','HCP_PC_CUBE','APPS','HCP_PC_FACT','ET', 'DIM:APPS.HCP_DIM_PC/HIER:HCP_DIM_PC_HIER/GID:GID/LVL:ALL_PARENT_LVL/COL:CHILD3;');
cwm2_olap_table_map.Map_FactTbl_Measure('APPS', 'HCP_PC_CUBE','HCP_PC_MEASURE', 'APPS', 'HCP_PC_FACT', 'MEASURE_COL', 'DIM:APPS.HCP_DIM_PC/HIER:HCP_DIM_PC_HIER/GID:GID/LVL:CHILD3/COL:SHORT_DESCRIPTION;');
cwm2_olap_catalog.create_catalog('HCP_PC_CAT', 'Parent Child Catalog');
cwm2_olap_catalog.add_catalog_entity('HCP_PC_CAT', 'APPS', 'HCP_PC_CUBE', 'HCP_PC_MEASURE');
cwm2_olap_validate.validate_cube('APPS', 'HCP_PC_CUBE','DEFAULT','YES');
cwm2_olap_metadata_refresh.mr_refresh;
exception
when others then
cwm_utility.dump_error;
errtxt := cwm_utility.get_last_error_description;
dbms_output.put_line('ERROR: ' || errtxt);
rollback;
raise;
END;
My Fact Table is :-
DROP TABLE HCP_PC_FACT CASCADE CONSTRAINT;
CREATE TABLE HCP_PC_FACT (
SHORT_DESCRIPTION VARCHAR2(30) NOT NULL,
GID NUMBER NOT NULL,
CHILD1 VARCHAR2(30) NOT NULL,
CHILD2 VARCHAR2(30) ,
CHILD3 VARCHAR2(30) ,
MEASURE_COL NUMBER NOT NULL);
Data in Fact Table:-
insert into HCP_PC_FACT values('Compliant',0,'All','Eligible','Compliant', 100);
insert into HCP_PC_FACT values('Non-Compliant',0,'All','Eligible','Non-Compliant', 200);
insert into HCP_PC_FACT values('Eligible',1,'All','Eligible',null, 300);
insert into HCP_PC_FACT values('Ineligible',1,'All','Ineligible',null, 400);
insert into HCP_PC_FACT values('All',3,'All',null,null, 500);
I am not sure how to create level, level attr, dim attr for such dim.
All CWM2 validation API shows that my all dims, cubes are valid but when I try to create presentation thru JDev it hangs after selecting Parent-Child Measure.
Any complete working exapmle will be helpful.
P.S. One more query I have can we have one solved and one un-solved dim in the same cube/measure?
regds
Prakash
Similar Messages
-
How to combine multiple fact tables and dimensions in one worksheet?
Hello Forum,
I am encountering a reporting problem when trying to create a worksheet that uses more than one cube/fact table and common dimensions. I have used Oracle Warehouse Builder 10Gr2 to design and deploy a pretty simple ROLAP data mart. We are using Discoverer Plus for OLAP as our reporting tool. We have 5 dimension tables using a star schema and 3 fact tables, when I create the worksheet I bring in our sales measure from our sales item table and then Store_Name from my Stores Dimension and then day from my time dimension, everything looks good at the stage, we're just trying to get a sum of all sales for that store on that day. Then I bring in a measure from our advertising cost table and a join window pops up asking which join to use, if I choose either the Store or the Time dimension I get correct data for the first fact table (sales) and grossly incorrect data for the ad cost measure from the second fact table (advertsing costs)...... any help would be appreciatedYou have encountered one of the key limitations of Discoverer... which I complained about to the Discoverer product manager at OpenWorld in 2001....
Anyhow, to get around this, you are going to have to deal with it either in the database, (views, materialized views, tables), or within the admin tool by creating a custom folder.
Discoverer also calls this the "fan trap", but never really had a solution to the problem. [The solution only worked is you joined to one and only one dimension!]
What you want (using Sales_Fact and Inventory_Fact as an example) is to join Sales to Time, Store, and Product, and save that result. Then join Inventory to Time, Store, and Product, save that result, then do a double outer join between the two intermediate temporary tables in order to calculate something useful like inventory turns by store and product line.
This is also known a "multipass SQL", and is supported by some (but not many) other tools.
So, to accomplish this with Discoverer, you'll either need to create a view, or table, or materialized view that has already put Sales and Inventory into a single (virtual?) fact table. Alternatively you can write the SQL for how to do this linkage (don't forget to handle missing data), and use the Discoverer admin tool to create a custom folder that uses your SQL.
Hope this helps! -
How to create logical fact table in BMM layer ?
Hello,
I have 3 Dimension table - 2 are in one schema and last is another schema. Using this 3 dimension tables, I need to create a logical fact table.
So, my question is whether we can create this fact table by joining these 3 dimension table which are in 2 different schema s ?
ThanksFiaz,
you are correct. We can use tables from different subject area to create a report. However, my question was related to rpd design. Sorry, I was not very clear about the queries earlier.
Here is the whole scenario in the physical layer of the rpd
Table name Databse name Connection pool name Schema name
AV AV_PXRPAM AVAILABILITY CRMODDEV
OUTAGE AV_PXRPAM AVAILABILITY CRMODDEV
COMPANY PXRPAM PXRPAM_POOL CRMODDEV
AV and OUTAGE have the joins already. I want to make a join between COMPANY with OUTAGE. And then I want to include a column from each of above tables to the logical fact table in the BMM layer. then I want to do a star schema with the logical fact table to the above 3 tables in the BMM layer.
Thanks -
pleae let me know how to create the fatc table by using pl/sql packages
Edited by: 792988 on Sep 6, 2010 3:34 AMPlease let us know something about your fact table.
There's no create_fact_table() procedure that could satisfy everybody. -
How 2 create dynamic internal table and can we pass it to gui_download FM
HI all,
How can we create a dynamic internal table?
I have a requirement where i have to create an internal table with the no. of fields depending on the selection screen values, i think tat can be possible though dynamic creation only.
How to solve this issue..?Pointers will be very much useful..
Thanks
Sunny.hi
Follow the code it will help you out....
REPORT YUSMM_TEXT2 .
*TABLES
TABLES: MARA, " General Material Data
MAKT, " Material Descriptions
T002. " Language Keys
* GLOBAL TYPE-POOL
TYPE-POOLS : SLIS.
* GLOBAL TYPES
TYPES: BEGIN OF TP_LANG ,
SPRAS LIKE T002-SPRAS,
LAISO LIKE T002-LAISO,
SRNO(3) TYPE N,
END OF TP_LANG.
TYPES: BEGIN OF TP_MATNR,
MATNR LIKE MARA-MATNR,
BEGRU LIKE MARA-BEGRU,
END OF TP_MATNR.
* DECLARATION FOR GLOBAL INTERNAL TABLES (WITH INCLUDE STRUCTURE)
DATA:GT_MAKT TYPE STANDARD TABLE OF MAKT, "Materialkurztexte,
GT_THEAD TYPE STANDARD TABLE OF THEAD, "SAPscript: Text-Header,
GT_LINETAB TYPE STANDARD TABLE OF TLINE, "SAPscript: Text-Zeilen,
GT_T002 TYPE STANDARD TABLE OF T002. "Language key
DATA: BEGIN OF GV_TEXT_OUTPUT_LINE,
MATNR LIKE MARA-MATNR,
BEGRU LIKE MARA-BEGRU,
MAKTX LIKE MAKT-MAKTX,
LTXT40(1250) TYPE C,
SRNO(3) TYPE N,
SPRAS LIKE T002-SPRAS,
END OF GV_TEXT_OUTPUT_LINE.
DATA: GT_MATNR TYPE STANDARD TABLE OF TP_MATNR,
WA_GT_MATNR TYPE TP_MATNR.
DATA: GT_LANG TYPE STANDARD TABLE OF TP_LANG,
WA_GT_LANG TYPE TP_LANG.
DATA: GT_TEXT_OUTPUT_LINE LIKE STANDARD TABLE OF GV_TEXT_OUTPUT_LINE,
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GV_FIELDCAT LIKE LINE OF GT_FIELDCAT,
CT_GT_FIELDCAT_IN LIKE GV_FIELDCAT,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
GV_REPID TYPE SY-REPID.
DATA: BEGIN OF GV,
FORMER_ERROR LIKE SY-MARKY, " Fehlermeldung bereits
FILE_OPEN(1), " Flag open file
REC_LENGTH TYPE I, " record length
MATNR TYPE MARA-MATNR, " material
REPID TYPE SYST-REPID,
RETCO TYPE SY-SUBRC,
END OF GV.
DATA: GV_MAKT TYPE MAKT,
GV_T002 TYPE T002,
GV_LANGU TYPE THEAD-TDSPRAS.
* DECLARATION FOR FIELD-SYMBOLS
FIELD-SYMBOLS: <FS_DATA> TYPE REF TO DATA,
<FS_DATA1> TYPE REF TO DATA,
<FS_2> TYPE STANDARD TABLE,
<FS_22> TYPE STANDARD TABLE,
<FS_1>,
<FS_11>,
<F>,
<FA>,
<LWA_LINE_WA>,
<LWA_LINE_WA1>.
DATA: IT_FLDCAT TYPE LVC_T_FCAT.
DATA: T_FLDCAT1 TYPE SLIS_T_FIELDCAT_ALV.
DATA: L_LT TYPE SLIS_LAYOUT_ALV.
DATA: WA_IT_FLDCAT TYPE LVC_S_FCAT.
DATA: WA_IT_FLDCAT1 TYPE SLIS_FIELDCAT_ALV.
DATA: GP_TABLE TYPE REF TO DATA.
DATA: WA_NEWLINE TYPE REF TO DATA.
*DECLARATION FOR CONSTANTS
CONSTANTS:
BEGIN OF GC,
TDID_GRUN TYPE THEAD-TDID VALUE 'GRUN',
TDOBJECT_MAT TYPE THEAD-TDOBJECT VALUE 'MATERIAL',
ON(01) TYPE C VALUE 'X',
YES(01) TYPE C VALUE 'X',
TXT(25) TYPE C VALUE 'MATERIAL DETAILS',
MAT(25) TYPE C VALUE 'MATERIAL NUMBER',
AUT(25) TYPE C VALUE 'AUTHORIZATION GROUP',
FOUND TYPE SY-SUBRC VALUE '00', " Return-Code
RC_OK TYPE SY-SUBRC VALUE '00', " Return-Code
OFF TYPE SY-SUBRC VALUE '00', " return code
FALSE TYPE SY-SUBRC VALUE '00', " boolean
TRUE TYPE SY-SUBRC VALUE '01', " boolean
END OF GC.
* DECLARATION FOR VARIABLES
DATA: V(3) TYPE N,
STR TYPE STRING,
STR1 TYPE STRING,
V_VAR(3) TYPE N,
V_VAR1(3) TYPE N,
V_FIELDNAME(15) TYPE C,
V_CHAR(15) TYPE C,
V_LINES(3) TYPE N,
MAKTEXT LIKE MAKT-MAKTX,
LT_DATA TYPE REF TO DATA,
LT_DATA1 TYPE REF TO DATA,
LWA_LINE TYPE REF TO DATA,
LWA_LINE1 TYPE REF TO DATA.
*SELECTION-SCREEN AND PARAMETERS
SELECTION-SCREEN: BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS:
S_MATNR FOR MARA-MATNR, "MATERIAL NUMBER
S_MTART FOR MARA-MTART, "MATERIAL TEXT
S_LANG FOR MAKT-SPRAS. "LANGUAGE
PARAMETER: GP_SIZE TYPE I DEFAULT 200. "DATA LENGTH
SELECTION-SCREEN: END OF BLOCK A1.
* AT SELECTION SCREEN
AT SELECTION-SCREEN.
IF GP_SIZE < 0.
MESSAGE E002(00).
ENDIF.
IF GP_SIZE > 50000.
MESSAGE W130(26) WITH TEXT-004.
SET CURSOR FIELD 'gp_size'.
ENDIF.
* INITIALIZATION
INITIALIZATION.
GV-REPID = SY-REPID.
*START-OF-SELECTION
START-OF-SELECTION.
PERFORM GET_MARA_DATA
TABLES
GT_TEXT_OUTPUT_LINE
USING
S_MATNR[]
S_MTART[]
GP_SIZE
CHANGING
GV-RETCO
PERFORM GET_MAT_TEXT
TABLES
GT_MAKT
GT_TEXT_OUTPUT_LINE
GT_THEAD
GT_LINETAB
USING
GC
GV-RETCO
CHANGING
GV_TEXT_OUTPUT_LINE
GV_MAKT
PERFORM GET_LANG.
PERFORM DYNAMIC_TABLES.
PERFORM POPULATE_FINAL_TABLE.
PERFORM POPULATE_DYNAMIC_TABLE.
* END-OF-SELECTION
END-OF-SELECTION.
PERFORM DATA_OUTPUT.
*& Form get_mara_data
* Materialdaten lesen
* <->ct_gt_text_output_line Ausgabetabelle
* -->it_s_matnr Parameter Materialnummer
* -->it_s_mtart Parameter Materialart
* -->if_gp_size Parameter Anzahl Materialnummern
FORM GET_MARA_DATA TABLES CT_GT_TEXT_OUTPUT_LINE STRUCTURE
GV_TEXT_OUTPUT_LINE
USING IT_S_MATNR LIKE S_MATNR[]
IT_S_MTART LIKE S_MTART[]
IF_GP_SIZE
CHANGING IF_GV-RETCO. "#EC *
* MARA in die Übergabestruktur einlesen
SELECT MATNR BEGRU
FROM MARA UP TO IF_GP_SIZE ROWS
APPENDING CORRESPONDING FIELDS OF TABLE GT_MATNR
WHERE MATNR IN IT_S_MATNR
AND MTART IN IT_S_MTART.
IF_GV-RETCO = SY-SUBRC.
ENDFORM. " get_mara_data
*& Form get_mat_text
* Kurz- und Langtexte zum Material lesen
* <->ct_gt_makt Materialkurztexte
* <->ct_gt_text_output_line Ausgabetabelle
* <->ct_gt_thead Kopftabelle für ALV
* <->ct_gt_linetab Zeilentabelle für ALV
* -->if_gc Globale Konstanten
* <--cf_gv_text_output_line Struktur Ausgabetabelle
* <--cf_gv_makt Struktru Materialkurztexte
FORM GET_MAT_TEXT TABLES CT_GT_MAKT STRUCTURE MAKT
CT_GT_TEXT_OUTPUT_LINE STRUCTURE
GV_TEXT_OUTPUT_LINE
CT_GT_THEAD STRUCTURE THEAD
CT_GT_LINETAB STRUCTURE TLINE
USING
IF_GC LIKE GC
IF_GV-RETCO
CHANGING CF_GV_TEXT_OUTPUT_LINE LIKE
GV_TEXT_OUTPUT_LINE
CF_GV_MAKT LIKE GV_MAKT
DATA: STRG TYPE STRING,
STRG1(1255) TYPE C.
IF IF_GV-RETCO = IF_GC-FOUND.
* Materialkurztexte in alles Sprachen einlesen
SELECT * FROM MAKT APPENDING TABLE CT_GT_MAKT
FOR ALL ENTRIES IN GT_MATNR "ct_gt_text_output_line
WHERE MATNR = GT_MATNR-MATNR " ct_gt_text_output_line-matnr
* Kurztexte in die sprachabhängigen Felder bringen
LOOP AT GT_MATNR INTO WA_GT_MATNR.
LOOP AT CT_GT_MAKT INTO CF_GV_MAKT
WHERE MATNR = WA_GT_MATNR-MATNR.
CF_GV_TEXT_OUTPUT_LINE-MATNR = WA_GT_MATNR-MATNR.
CF_GV_TEXT_OUTPUT_LINE-BEGRU = WA_GT_MATNR-BEGRU.
CF_GV_TEXT_OUTPUT_LINE-MAKTX = CF_GV_MAKT-MAKTX.
CF_GV_TEXT_OUTPUT_LINE-SPRAS = CF_GV_MAKT-SPRAS.
* LANGTEXT
CLEAR CT_GT_THEAD[].
CT_GT_THEAD-TDOBJECT = IF_GC-TDOBJECT_MAT.
CT_GT_THEAD-TDNAME = WA_GT_MATNR-MATNR.
CT_GT_THEAD-TDID = IF_GC-TDID_GRUN.
CT_GT_THEAD-TDSPRAS = CF_GV_MAKT-SPRAS.
CALL FUNCTION 'TEXT_READ'
EXPORTING
I_HEADER = CT_GT_THEAD
I_READONLY = IF_GC-ON
IMPORTING
E_HEADER = CT_GT_THEAD
TABLES
T_LINES = CT_GT_LINETAB[]
EXCEPTIONS
NOTFOUND = 1.
IF SY-SUBRC = IF_GC-FOUND.
LOOP AT CT_GT_LINETAB.
STRG = CT_GT_LINETAB-TDLINE.
IF STRG1 <> ' '.
CONCATENATE STRG1 ';' STRG INTO STRG1.
ELSE.
STRG1 = STRG.
ENDIF.
ENDLOOP.
CF_GV_TEXT_OUTPUT_LINE-LTXT40 = STRG1.
APPEND CF_GV_TEXT_OUTPUT_LINE TO CT_GT_TEXT_OUTPUT_LINE.
CLEAR CF_GV_TEXT_OUTPUT_LINE.
STRG1 = ' '.
ELSE.
APPEND CF_GV_TEXT_OUTPUT_LINE TO CT_GT_TEXT_OUTPUT_LINE.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDIF.
ENDFORM. " get_mat_text
*& Form data_output
* Daten mit ALV ausgeben
* <->ct_GT_FIELDCAT Feldkatalog für ALV
* <->ct_gt_text_output_line Ausgabetabelle
* -->P_GS_LAYOUT Layout für ALV
* -->if_gc Globale Konstanten
* <--cf_GV_REPID Zur Zeit aufgerufener Reportname
* <--cf_gv_fieldcat Struktur Feldkatalog
* <--cf_gv Globale Variablen
FORM DATA_OUTPUT.
PERFORM FIELDCATBUILD.
PERFORM LAYOUT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = GV-REPID
I_CALLBACK_PF_STATUS_SET = 'EVENT_SET_STATUS_01'
I_CALLBACK_USER_COMMAND = 'EVENT_USER_COMMAND'
IS_LAYOUT = L_LT
IT_FIELDCAT = T_FLDCAT1[]
TABLES
T_OUTTAB = <FS_2>
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> GC-FOUND.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " data_output
*& Form fieldcatbuild
* text
* --> p1 text
* <-- p2 text
FORM FIELDCATBUILD. " TABLES ct_gt_fieldcat_in STRUCTURE gv_fieldcat.
LOOP AT IT_FLDCAT INTO WA_IT_FLDCAT.
WA_IT_FLDCAT1-FIELDNAME = WA_IT_FLDCAT-FIELDNAME.
WA_IT_FLDCAT1-TABNAME = WA_IT_FLDCAT-TABNAME.
WA_IT_FLDCAT1-SELTEXT_L = WA_IT_FLDCAT-FIELDNAME.
APPEND WA_IT_FLDCAT1 TO T_FLDCAT1.
CLEAR : WA_IT_FLDCAT,WA_IT_FLDCAT1.
ENDLOOP.
ENDFORM. " fieldcatbuild
* Form event_set_status_01*
FORM EVENT_SET_STATUS_01 USING LT_EXCL TYPE SLIS_T_EXTAB.
SET PF-STATUS 'ABCD' .
ENDFORM. "EVENT_SET_STATUS_01
*& Form Name: event_user_command *
*& Form Desc: For Handling USER_COMMAND *
FORM EVENT_USER_COMMAND USING
IF_UCOMM TYPE SY-UCOMM
IS_SELFIELD TYPE SLIS_SELFIELD.
CASE IF_UCOMM.
WHEN 'DOWNLOAD'.
PERFORM POPULATE_DOWNLOAD_TABLE.
DATA: L_LENGHT TYPE I.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:data.xls'
FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = 'X'
TRUNC_TRAILING_BLANKS = 'X'
DAT_MODE = 'X'
IMPORTING
FILELENGTH = L_LENGHT
TABLES
DATA_TAB = <FS_22>.
IF SY-SUBRC <> GC-FOUND.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF L_LENGHT NE GC-FOUND.
MESSAGE S398(00) WITH 'DATA downloaded to c:data.xls'.
ENDIF.
ENDCASE.
ENDFORM. "event_user_command
*& Form get_lang
* text
* --> p1 text
* <-- p2 text
FORM GET_LANG.
SELECT SPRAS
LAISO FROM T002 INTO CORRESPONDING FIELDS OF TABLE GT_LANG
WHERE SPRAS IN S_LANG.
DESCRIBE TABLE GT_LANG LINES V_LINES.
LOOP AT GT_LANG INTO WA_GT_LANG.
V = V + 1.
WA_GT_LANG-SRNO = V.
MODIFY GT_LANG FROM WA_GT_LANG TRANSPORTING SRNO.
ENDLOOP.
LOOP AT GT_LANG INTO WA_GT_LANG.
CONCATENATE 'MATEDESC-' WA_GT_LANG-LAISO INTO V_FIELDNAME.
CLEAR WA_IT_FLDCAT.
WA_IT_FLDCAT-FIELDNAME = V_FIELDNAME.
WA_IT_FLDCAT-SELTEXT = V_FIELDNAME.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-INTLEN = 40.
WA_IT_FLDCAT-TABNAME = '<FS_2>'.
APPEND WA_IT_FLDCAT TO IT_FLDCAT .
CLEAR WA_GT_LANG.
ENDLOOP.
LOOP AT GT_LANG INTO WA_GT_LANG.
CONCATENATE 'BASDAT-' WA_GT_LANG-LAISO INTO V_FIELDNAME.
CLEAR WA_IT_FLDCAT.
WA_IT_FLDCAT-FIELDNAME = V_FIELDNAME.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-INTLEN = 255.
WA_IT_FLDCAT-SELTEXT = V_FIELDNAME.
WA_IT_FLDCAT-TABNAME = '<FS_2>'.
APPEND WA_IT_FLDCAT TO IT_FLDCAT .
CLEAR WA_GT_LANG.
ENDLOOP.
V_FIELDNAME = 'MATNR'.
CLEAR WA_IT_FLDCAT.
WA_IT_FLDCAT-FIELDNAME = V_FIELDNAME.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-SELTEXT = 'Matnr'.
WA_IT_FLDCAT-INTLEN = 18.
WA_IT_FLDCAT-TABNAME = '<FS_2>'.
INSERT WA_IT_FLDCAT INTO IT_FLDCAT INDEX 1.
V_FIELDNAME = 'BEGRU'.
CLEAR WA_IT_FLDCAT.
WA_IT_FLDCAT-FIELDNAME = V_FIELDNAME.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-SELTEXT = 'BEGRU'.
WA_IT_FLDCAT-INTLEN = 4.
WA_IT_FLDCAT-TABNAME = '<FS_2>'.
INSERT WA_IT_FLDCAT INTO IT_FLDCAT INDEX 2.
ENDFORM. " get_lang
*& Form dynamic_tables
* text
* --> p1 text
* <-- p2 text
FORM DYNAMIC_TABLES.
ASSIGN LT_DATA TO <FS_DATA>.
* Creating the Dynamic Internal Table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FLDCAT " Fieldcatalogue
IMPORTING
EP_TABLE = <FS_DATA> " Dynamic Internal Table
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
OTHERS = 2.
* Assign Dyn Table To Field Sumbol
ASSIGN <FS_DATA>->* TO <FS_1>.
* Assigning the Internal Table TYPE ANY to Standard internal Table
ASSIGN <FS_1> TO <FS_2>.
* Creating a Workarea
CREATE DATA LWA_LINE LIKE LINE OF <FS_2> .
* Assigning the Content to the workares as a Pointer
ASSIGN LWA_LINE->* TO <LWA_LINE_WA>.
ENDFORM. " dynamic_tables
*& Form populate_final_table
* text
* --> p1 text
* <-- p2 text
FORM POPULATE_FINAL_TABLE.
LOOP AT GT_TEXT_OUTPUT_LINE INTO GV_TEXT_OUTPUT_LINE.
READ TABLE GT_LANG INTO WA_GT_LANG
WITH KEY SPRAS = GV_TEXT_OUTPUT_LINE-SPRAS.
IF SY-SUBRC EQ GC-FOUND.
GV_TEXT_OUTPUT_LINE-SRNO = WA_GT_LANG-SRNO.
ENDIF.
MODIFY GT_TEXT_OUTPUT_LINE FROM GV_TEXT_OUTPUT_LINE.
ENDLOOP.
ENDFORM. " populate_final_table
*& Form populate_dynamic_table
* text
* --> p1 text
* <-- p2 text
FORM POPULATE_DYNAMIC_TABLE.
DATA: INDX TYPE SY-TABIX.
LOOP AT GT_TEXT_OUTPUT_LINE INTO GV_TEXT_OUTPUT_LINE.
AT NEW MATNR.
INDX = SY-TABIX.
ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA> TO <F>.
<F> = GV_TEXT_OUTPUT_LINE-MATNR.
ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA> TO <F>.
<F> = GV_TEXT_OUTPUT_LINE-BEGRU.
ENDAT.
LOOP AT GT_LANG INTO WA_GT_LANG.
IF GV_TEXT_OUTPUT_LINE-SRNO = WA_GT_LANG-SRNO.
V_VAR = GV_TEXT_OUTPUT_LINE-SRNO + 2.
ASSIGN COMPONENT V_VAR OF STRUCTURE <LWA_LINE_WA> TO <F>.
<F> = GV_TEXT_OUTPUT_LINE-MAKTX.
V_VAR = GV_TEXT_OUTPUT_LINE-SRNO + V_LINES + 2.
ASSIGN COMPONENT V_VAR OF STRUCTURE <LWA_LINE_WA> TO <F>.
<F> = GV_TEXT_OUTPUT_LINE-LTXT40.
ENDIF.
ENDLOOP.
AT END OF MATNR.
APPEND <LWA_LINE_WA> TO <FS_2>.
CLEAR <LWA_LINE_WA>.
ENDAT.
ENDLOOP.
ENDFORM. " populate_dynamic_table
*& Form LAYOUT
* text
* --> p1 text
* <-- p2 text
FORM LAYOUT.
CLEAR L_LT.
L_LT-ZEBRA = GC-YES.
L_LT-COLWIDTH_OPTIMIZE = 'X'.
L_LT-WINDOW_TITLEBAR = GC-TXT.
ENDFORM. " LAYOUT
*& Form populate_download_table
* text
* --> p1 text
* <-- p2 text
FORM POPULATE_DOWNLOAD_TABLE.
ASSIGN LT_DATA1 TO <FS_DATA1>.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FLDCAT " Fieldcatalogue
IMPORTING
EP_TABLE = <FS_DATA1> " Dynamic Internal table
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
OTHERS = 2.
* Assign Dyn Table To Field Sumbol
ASSIGN <FS_DATA1>->* TO <FS_11>.
* Assigning the Internal Table TYPE ANY to Standard internal Table
ASSIGN <FS_11> TO <FS_22>.
* Creating a Workarea
CREATE DATA LWA_LINE1 LIKE LINE OF <FS_22> .
* Assigning the Content to the workares as a Pointer
ASSIGN LWA_LINE1->* TO <LWA_LINE_WA1>.
DATA: STRN1 TYPE STRING,
STRN2 TYPE STRING,
INDX TYPE SY-TABIX.
ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = GC-MAT.
ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = GC-AUT.
LOOP AT GT_LANG INTO WA_GT_LANG.
V_VAR1 = WA_GT_LANG-SRNO + 2.
CONCATENATE 'MATERIALDESCRIPTION-' WA_GT_LANG-LAISO INTO STRN1.
ASSIGN COMPONENT V_VAR1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = STRN1.
V_VAR1 = WA_GT_LANG-SRNO + V_LINES + 2.
CONCATENATE 'BASICDATA-' WA_GT_LANG-LAISO INTO STRN2.
ASSIGN COMPONENT V_VAR1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = STRN2.
ENDLOOP.
APPEND <LWA_LINE_WA1> TO <FS_22>.
CLEAR <LWA_LINE_WA1>.
APPEND <LWA_LINE_WA1> TO <FS_22>.
V_VAR1 = 0.
LOOP AT GT_TEXT_OUTPUT_LINE INTO GV_TEXT_OUTPUT_LINE.
AT NEW MATNR.
INDX = SY-TABIX.
ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = GV_TEXT_OUTPUT_LINE-MATNR.
ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = GV_TEXT_OUTPUT_LINE-BEGRU.
ENDAT.
LOOP AT GT_LANG INTO WA_GT_LANG.
IF GV_TEXT_OUTPUT_LINE-SRNO EQ WA_GT_LANG-SRNO.
V_VAR1 = GV_TEXT_OUTPUT_LINE-SRNO + 2.
ASSIGN COMPONENT V_VAR1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = GV_TEXT_OUTPUT_LINE-MAKTX.
V_VAR1 = GV_TEXT_OUTPUT_LINE-SRNO + V_LINES + 2.
ASSIGN COMPONENT V_VAR1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
* STR = GV_TEXT_OUTPUT_LINE-LTXT40.
* SEARCH STR FOR ';'.
* DO.
* IF SY-SUBRC = 0.
* SPLIT STR AT ';' INTO STR1 STR.
* <FA> = STR1.
* APPEND <LWA_LINE_WA1> TO <FS_22>.
* SEARCH STR FOR ';'.
* CLEAR <LWA_LINE_WA1>.
* ELSE.
* EXIT.
* ENDIF.
* ENDDO.
* <FA> = STR.
* APPEND <LWA_LINE_WA1> TO <FS_22>.
<FA> = GV_TEXT_OUTPUT_LINE-LTXT40.
ENDIF.
ENDLOOP.
AT END OF MATNR.
APPEND <LWA_LINE_WA1> TO <FS_22>.
CLEAR <LWA_LINE_WA1>.
ENDAT.
ENDLOOP.
ENDFORM. " populate_download_table
thanks
Nitya -
How to resolve many fact tables and Dimensions tables
Hi,
The scenario is we have many facts and dimension tables. Based on some conditions one measure from one fact will be divided by another fact measure. I have encoutered with many errors like " Unable to navigate .... " ? How to resolve these errors and reduce many to few ? ( I assume creating logical tables, but is there any other alternatives ? )
thanks
SureshSuresh,
I assume that you know how to create a single logical fact from n-physical facts, ie only if the fact tables are related. Then join all the conformed dimensions to this single Logical table using a join in the Business Model layer. Remember to set the mappings in the LTS. All if you have any hierarchies please set the aggregation level for those.
- Red -
How to create one master table and two detail for it
I have one table , imagine it like mastertable( empid,deptid );
and two different tables like employeetable(empid ) , departmenttable ( deptid )....
I dont have any relation on database side. I need to create view link and ı need to use only one master table for two detail tables.
How can ı manage this scenerio ?
thanks...yes Shay ı really want to use two detail table in one UI as you suggest in your blog. But in that scenerio probably tables have link in database side with foreign key. My detail tables dont have any connection in database side with my master table. How can ı link them under one mastertableVO ?
I am really sorry about my bad explanation. I am a newbie and probably ı dont know the correct words to tell my problem.
Thanks for your time... -
How to create a cluster table and cluster view?
Hi,
Can anyone guide me in creation of cluster table in general and also creation of cluster view?Hi,
check this links.
http://help.sap.com/saphelp_nw04/helpdata/en/cf/21f0b7446011d189700000e8322d00/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/d0/999246b2aa11d1a5700000e82deaaa/content.htm
Regard's
SHAIK. -
Reg: Fact table and Dimension table in Data Warehousing -
Hi Experts,
I'm not exactly getting the difference between the criteria which decide how to create a Fact table and Dimension table.
This link http://stackoverflow.com/questions/9362854/database-fact-table-and-dimension-table states :
Fact table contains data that can be aggregate.
Measures are aggregated data expressions (e. Sum of costs, Count of calls, ...)
Dimension contains data that is use to generate groups and filters.
This's fine but how does one decide which columns to consider for Fact table and which columns for Dimension table?
Any help is much appreciated.
Pardon me if this's not the correct place for this question. My first question in the new forum.
Thanks and Regards,
Ranit BiswasranitB wrote:
But my main doubt was - what is the criteria to differentiate between columns for Fact tables and Dimension tables? How can one decide upon the design?
Columns of a fact table will often be 'scalar' attributes of the 'fact' data item. A dimension table will often be 'compound' attributes of a 'fact'.
Consider employee information. The EMPLOYEE table can be a fact table. It might have scalar attribute columns such as: DATE_HIRED, STATUS, EMPLOYEE_ID, and so on.
Other related information that can't be specified as a single attribute value would often be stored in a 'dimension' table: ADDRESS, PHONE_NUMBER.
Each address requires several columns to define it: ADDRESS1, ADDRESS2, CITY, STATE, ZIP, COUNTRY. And an employee might have several addresses: WORK_ADDRESS, HOME_ADDRESS. That address info would be stored in a 'dimension' table and only the primary key value of the address record would be stored in the EMPLOYEE 'fact' table.
Same with PHONE_NUMBER. Several columns are required to define a phone number and each employee might have several of them. The dimension tables are used to help 'normalize' the data in the employee 'fact' table.
And that EMPLOYEE table might also be a DIMENSION table for other FACT tables. A DEVELOPER table might have an EMPLOYEE_ID column with a value that points to a 'dimension' row in the EMPLOYEE dimension table. -
How to create the custom table?
Hi, how to create the custom table and how to integrate the table with defferent R/3?
my requiremnt is i have to create the two tables and those i have to integrate with the existed R/3 and using those R/3 i have to update my custom tables .....can give me some idea?
Tks
DPkhow to create the custom table
There are two approach in creating a table.
1. Bottom-up approach
2. Top-down approach.
Both are valid and you can choose which approach is suitable for you. I always use the bottom-up approach. Here are the steps to create the tables with this approach.
1. SE11 will take you to the DDIC and enter the name of the new table to be created. Let us say Zname. Click create.
2. Enter the short discription of the table and enter the field of the table. If it is primary key and you have to check the box.
3. Enter the data element and double click it, you will be asked to save and will take you to data element discription page. Enter the short discription of the data element and enter the information of domain like the length of field and type of field.
4. If you wanted to use the existing domain then its fine, or else, you have to create one. Enter the domain name in the data element page and double click it. Page will ask to save and jump to domain creation page.
5. In the domain page, you have to save the information which you have already given in the data elements page and check it. Before going to data element page, you have to activate the domain.
6. Go to data element page and save, check and activate.
7. Go to main table page and save, check, and activate.
8. Also, you have to save the technical settings of the table.
The table is now ready for operation. You can use it in your program or you can use it to enter information.
Check table: It is the table which will have all the information about the Foreign keys which are the primary keys in the check table.
It can be created by creating the foreign key from the main table. Click foreign key in the main table and it will take you to a page which will ask for table name and field to which foreign key relation has to be associated. Enter the information and you can create the check table automatically.
SM30 is used for maintenance of the table, that is to realease the errors occured during the creation of the table.
how to integrate the table with defferent R/3
Transport the Table to the another server/client/qas/prd
Kanagaraja L -
How and when to create a fact table
hi every1,
I am new to oracle and specially to Data Warehousing. I am using OWB 11g on windows XP.
I have created the dimensional for a database, now i am in the implementation phase.
i have the following questions.
1. I don't know how and when to create a fact table. I have already created the dimensions (ROLAP).
2. Do i need to create a mapping for a Cube. if yes, then how to load them from 4 different dimensions. how will be the join condition, they don't match?
3. I will also try for aggregation, do i need to use MOLAP for the dimensions or ROLAP works?
Please, give a quick reply.
regards
RFYou should ask your question here:
Warehouse Builder
where it is on topic. -
How to create Implicit Fact column ?and how to use it ?
Hi all,
How to create Implicit Fact column ?
and how to use it ?
Thanks in advanceWhen you create a request with only dimension columns, the Oracle BI engine has to choose a fact table to join the dimensions to each other. If you have multiple fact tables in your BMM layer, the Oracle BI engine will use the most economical fact table, depending on the number of dimensions of the fact table.
In some cases you do not want to use this fact table, but you want to force the Oracle BI engine to use the fact table you want.
In that case you should create a fact (or select an existing fact) of the fact table you want to use for the dimension only query. In the presentation catalog of the subject area you should select this fact as the implicit fact. This fact will always be used in the query, but it won't be visible in your report. An example of an implicit fact is the count of the primary key (id) of the fact table. -
Merging Multiple fact tables and creating a BIA target
Hi Folks
We are using Dataservices with BIA.
We want to merge mutliple fact table and create a sinvglc cube on BIA.
when we tried to do that we get a error message that we cannot merge multiple fact tables.
any pointers ?
PoonamYou could have the cubes individually on the BIA and then have a multiprovider which you can use..?
or create separate universes on the cubes and then merge the universes in BO and then you could hit the BIA for the same..? -
Multiple fact tables and dimensions
I have two fact tables actual sales and planned sales and 8 dimension tables, using a star schema. I want to query on the two fact tables with two dimensions, product and time. When I create the report in discoverer i bring in the sales from actuals and then the product_desc and month_desc. Then I bring in the measure from the second fact table and a join window pops up asking which join to use. If I choose the join to the time dimension then I get no data for the second fact table and correct data for the first fact table. If I choose the product dimension then I get correct data for the first fact table and grossly incorrect data for the second fact table.
How can I stop this from happening?
NickNick,
I hope you solved your reporting issue and can share the solution with me. I am encountering the same problem. I have used Oracle Warehouse Builder 10Gr2 to design and deploy a pretty simple ROLAP data mart. We are using Discoverer Plus for OLAP as our reporting tool. We have 5 dimension tables using a star schema and have 3 fact tables, when I create the worksheet I bring in our sales measure from our sales item table and then Store_Name from my Stores Dimension and then week-ending from my time dimension, everything looks good at the stage. Then I bring in a measure from our advertising cost table and a join window pops up asking which join to use, if I choose either the Store or the Time dimension I get correct data for the first fact table (sales) and grossly incorrect data for the ad cost from the second fact table (advertsing costs)...... any help would be appreciated
monalisa -
How to design a fact table to keep track of active dimensions?
I would like to design a classic OLAP facts table using a star scheme. The SQL model of the facts table should be independent of any concrete RDBMS technology and portable between different systems.
The problem is this: users should be able to select subsets of the facts based on conjunctive queries on the dimension values defined for the facts. However, the program that provides the interface for doing this to the user should only present those dimensions where anything is still selectable at all. For example, if a user selected year 2001 and for dimension contract code there is only a single value for all records in the fact table for that year, this dimension should not be shown to the user any more. This should be solved in a generic way. So for n dimensions in total, if the current set of facts is based on constraints from j dimensions, I want to know for which of the remaining n-j dimensions there is still something to select from and only show those.
The obvious way is to make a count(*) query on the distinct foreign keys of each of the dimensions on the fact table, using the same where clause. That means that one would need (n-j) such queries on the whole facts table and that sounds like an awful waste of resources given that the original query for selecting the facts could have done it internally "on the fly".
How can this be achieved in the most performant way? Is there a "classical" way of how to approach this problem? Is there tool support for doing this efficiently?
Any help or pointers to where one could find out more about this would be greatly apreciated - thank you!>
Did you get the counts for each value of each dimension by doing a separate query with the current "WHERE" clause on each dimension?
>
My method doesn't apply to your use case. I wrote a Java class to create my own bit-mapped indexes on CSV files. So each attribute value was a one million bit binary raw.
I don't know, and don't want to know, what your particular requirements are. But I can show you a basic process that will work for large numbers of rows. Get a simple process working and then explore to see if it will meet your particular needs. Not going to answer questions here about anything but about my example code
1. Assume a single fact table with one primary key column and multiple single-value attribute columns.
2. The table is not subject to DML operations AT ALL - truncate and load if you want apply changes. Meaning it will be useful for research purposes on archived data.
3. The purpose of the table is to select the fact table ROWIDs for records of interest. So the only value selected is a result set of ROWIDs that can then be used to get any of the normal FACt table data and other linked data as needed.
Create the table - insert some records, create a bitmap index on each dimension column and collect the statistics
ALTER TABLE SCOTT.STAR_FACT
DROP PRIMARY KEY CASCADE;
DROP TABLE SCOTT.STAR_FACT CASCADE CONSTRAINTS;
create table star_fact (
fact_key varchar2(30) DEFAULT 'N/A' not null,
age varchar2(30) DEFAULT 'N/A' not null,
beer varchar2(30) DEFAULT 'N/A' not null,
marital_status varchar2(30) DEFAULT 'N/A' not null,
softdrink varchar2(30) DEFAULT 'N/A' not null,
state varchar2(30) DEFAULT 'N/A' not null,
summer_sport varchar2(30) DEFAULT 'N/A' not null,
constraint star_fact_pk PRIMARY KEY (fact_key)
INSERT INTO STAR_FACT (FACT_KEY) SELECT ROWNUM FROM ALL_OBJECTS;
create bitmap index age_bitmap on star_fact (age);
create bitmap index beer_bitmap on star_fact (beer);
create bitmap index marital_status_bitmap on star_fact (marital_status);
create bitmap index softdrink_bitmap on star_fact (softdrink);
create bitmap index state_bitmap on star_fact (state);
create bitmap index summer_sport_bitmap on star_fact (summer_sport);
exec DBMS_STATS.GATHER_TABLE_STATS('SCOTT', 'STAR_FACT', NULL, CASCADE => TRUE);Now if you run the 'complex' query for the example from my first reply you will get
SQL> set serveroutput on
SQL> set autotrace on explain
SQL> select rowid from star_fact where
2 (state = 'CA') or (state = 'CO')
3 and (age = 'young') and (marital_status = 'divorced')
4 and (((summer_sport = 'baseball') and (softdrink = 'pepsi'))
5 or ((summer_sport = 'golf') and (beer = 'coors')));
no rows selected
Execution Plan
Plan hash value: 1934160231
| Id | Operation | Name | Rows | Bytes |
| 0 | SELECT STATEMENT | | 1 | 30 |
| 1 | BITMAP CONVERSION TO ROWIDS | | 1 | 30 |
| 2 | BITMAP OR | | | |
|* 3 | BITMAP INDEX SINGLE VALUE | STATE_BITMAP | | |
| 4 | BITMAP AND | | | |
|* 5 | BITMAP INDEX SINGLE VALUE | AGE_BITMAP | | |
|* 6 | BITMAP INDEX SINGLE VALUE | MARITAL_STATUS_BITMAP | | |
|* 7 | BITMAP INDEX SINGLE VALUE | STATE_BITMAP | | |
| 8 | BITMAP OR | | | |
| 9 | BITMAP AND | | | |
|* 10 | BITMAP INDEX SINGLE VALUE| SOFTDRINK_BITMAP | | |
|* 11 | BITMAP INDEX SINGLE VALUE| SUMMER_SPORT_BITMAP | | |
| 12 | BITMAP AND | | | |
|* 13 | BITMAP INDEX SINGLE VALUE| BEER_BITMAP | | |
|* 14 | BITMAP INDEX SINGLE VALUE| SUMMER_SPORT_BITMAP | | |
Predicate Information (identified by operation id):
3 - access("STATE"='CA')
5 - access("AGE"='young')
6 - access("MARITAL_STATUS"='divorced')
7 - access("STATE"='CO')
10 - access("SOFTDRINK"='pepsi')
11 - access("SUMMER_SPORT"='baseball')
13 - access("BEER"='coors')
14 - access("SUMMER_SPORT"='golf')
SQL>As you can see Oracle is combining bitmap indexes on columns in a single table to implement the same AND/OR complex conditions I showed earlier. It doesn't need any other table to do this.
In 11g you can create virtual columns and then index them.
so if you find that the condition 'young' and 'divorced' is used frequently you could create a VIRTUAL 'young_divorced' column and create an index.
alter table star_fact add (young_divorced AS (case
when (age = 'young' and marital_status = 'divorced') then 'TRUE' else 'N/A' end) VIRTUAL);
create bitmap index young_divorced_ndx on star_fact (young_divorced);
exec DBMS_STATS.GATHER_TABLE_STATS('SCOTT', 'STAR_FACT', NULL, CASCADE => TRUE);Now you can query using the name of the virtual column
SQL> select rowid from star_fact where young_divorced = 'TRUE'
2 and (state = 'CA') or (state = 'CO')
3 /
no rows selected
Execution Plan
Plan hash value: 2656088680
| Id | Operation | Name | Rows | Bytes | Cost
| 0 | SELECT STATEMENT | | 1 | 28 |
| 1 | BITMAP CONVERSION TO ROWIDS | | | |
| 2 | BITMAP OR | | | |
|* 3 | BITMAP INDEX SINGLE VALUE | STATE_BITMAP | | |
| 4 | BITMAP AND | | | |
|* 5 | BITMAP INDEX SINGLE VALUE| STATE_BITMAP | | |
|* 6 | BITMAP INDEX SINGLE VALUE| YOUNG_DIVORCED_NDX | | |
Predicate Information (identified by operation id):
3 - access("STATE"='CO')
5 - access("STATE"='CA')
6 - access("YOUNG_DIVORCED"='TRUE')
SQL>
----------------------------------------------------------------Notice that at line #6 the new index was used. The VIRTUAL column itselfl doesn't create data for the fact table; the definition only exists in the data dictionary.
The YOUNG_DIVORCE_NDX is real and does consume space. The tradeoff is additional space for the index but you make the query easier because you don't have to recreate the complex condition every time.
Oracle can work with the complex condition and combine the indexes so this really only helps the query writer. Your UI should be able to hide the query construction from the user so I would avoid the use of VIRTUAL columns and an additional index until you demonstrate you really need it.
If you provide users with their own RESULT table to store custom query results you could just store the query name and the set of primary keys from the result set. I used ROWIDs in the example but don't use rowid for a real application - use a primary key value that won't change.
So your UI would let users construct complext dimension queries for 'young_sportsters' and get a result set of primary keys for that. They could save the label 'young_sportsters' and the primary keys in their own work table. Then you can let them run queries that use the primary keys to query data from your active data warehouse to get any other data it contains.
>
Did you get the counts for each value of each dimension by doing a separate query with the current "WHERE" clause on each dimension?
>
For an Oracle implementation you need to do a count select for each dimension. I haven't tried it but you might be able to do multiple dimensions in a singe query. One query would look like this>
-- get the dimension counts
SQL> select beer, count(*) from star_fact group by beer;
BEER COUNT(*)
N/A 56977
Execution Plan
Plan hash value: 1692670403
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Ti
| 0 | SELECT STATEMENT | | 1 | 12 | 3 (0)| 00
| 1 | SORT GROUP BY NOSORT | | 1 | 12 | 3 (0)| 00
| 2 | BITMAP CONVERSION COUNT| | 56977 | 667K| 3 (0)| 00
| 3 | BITMAP INDEX FULL SCAN| BEER_BITMAP | | | |
SQL>Notice that Oracle uses only the index to gather the data.
Maybe you are looking for
-
Sleep/Wake button stuck but they wont replace for free?!
So my sleep/wake button is stuck and I went to the apple store, but they are making me pay $199 to replace it when I still have warranty! I don't understand they say I have a speck of pink of the LCI but no corrosion which means they should still be
-
[JAI IMAGEIO] TIFF to JPEG Loss DPI, HOW TO?
Hi! I tried to convert a tiff image to jpeg with the same dpi resolution but i don't know how to make it or if i'm on the right way. Here is my code. Thanks for your help! public static void convertFromTifToJpgPrim(String sSourceFileName, String sTar
-
How to delete and avoid notes in mail application
CAN ANYBODY HELP ME ON THIS SUBJECT PLEASE
-
New SCSI drive does not appear in disk manager - what can I do?
I am working on an older HP ML350G4 It has server 2003 installed. It has run out of memory, so I added another drive. I rebooted, and went to format it but !! not in disc manager. I cannot find it anywhere. There's no unrecognised devices in devmgr,
-
Do not know how to call Servlet from a JSP???
How do I call a Servlet from a JSP page? I have an JSP page that does a few things but when there is an error I need the JSP page to call a Servlet but do not know how to do it. I want to call a ServletFaillogin from a JSP page how can I do it? <html