Dws Data Export Filter Body

download Dws Data Export Filter Body

of 146

Transcript of Dws Data Export Filter Body

  • 8/18/2019 Dws Data Export Filter Body

    1/146

    CREATE OR REPLACE package body DWSADM.dws_data_export_filteris procedure log_time_info(  p_from_time varchar2

    , p_to_time varchar2  , p_date_format varchar2)isbegin  dws_logging.logevent(p_event_code => 2022, p_add_txt => 'Local Time: '

    || to_char(to_date(p_from_time, p_date_format),'yyyy-mm-dd hh24:mi') || ' - '

    || to_char(to_date(p_to_time, p_date_format),'yyyy-mm-dd hh24:mi'));

    dws_logging.logevent(p_event_code => 2022, p_add_txt => 'UTC Time: '|| to_char(dws_time.get_utc_from_financia

    ltime(to_date(p_from_time, p_date_format)), 'yyyy-mm-dd hh24:mi') ||  ' - ' || to_char(dws_time.get_utc_from_financialtime(to_date(p_to_time, p_date_format)), 'yyyy-mm-dd hh24:mi'));end;

    ----------------------------------------------------------------  -- procedure: export_stat_static

      -- purpose: wrapper function for export_stat_static_for_thid to handle conversions of dates to thids (time_hour_id:s)  -----------------------------------------------------------------  procedure export_stat_static(p_from_time varchar2,  p_to_time varchar2,  p_date_format varchar2,

    type varchar2) is  begin 

    log_time_info(p_from_time, p_to_time, p_date_format); 

    export_stat_static_for_utc(dws_time.get_utc_from_financialtime(to_date(p_from_time,

      p_date_format)),  dws_time.get_utc_from_financialtime(to_date(p_to_time,  p_date_format)),

    type); end export_stat_static;

      -----------------------------------------------------------------  -- procedure: export_stat_static_for_utc  -- purpose: export Subscriber Status data (CS40) for given time interval (In

    UTC) to staging table-----------------------------------------------------------------

      procedure export_stat_static_for_utc(p_from_utc date, p_to_utc date,type varchar2) is 

    P_FROM_TIME_HOUR_ID number := dws_time.date2thid(p_from_utc);  P_TO_TIME_HOUR_ID number := dws_time.date2thid(p_to_utc);  fin_date_key number(11) := dws_time.getfinancialsdatekey(trunc(dws_time.get_financialtime_from_utc(p_from_utc)));  to_fin_date date := dws_time.Get_Financialtime_From_UTC(p_to_utc);

  • 8/18/2019 Dws Data Export Filter Body

    2/146

     

    begin 

    dbms_application_info.set_module(module_name => 'dws_data_export',  action_name => 'export_subsriber_status (CS40)'); IF TYPE='S' THEN

     execute immediate 'truncate table wrk_de_stat_static_stg';

     begin

      execute immediate 'drop table SLCE_STAT_STATIC';  execute immediate 'drop table SCL_STAT_STATIC';  execute immediate 'drop table ALCE_STAT_STATIC';  execute immediate 'drop table ITL_STAT_STATIC';  execute immediate 'drop table ACTI_STAT_STATIC';

      exception  when others then  null;  end;

      execute immediate 'alter session set nls_date_format=''dd-mon-yyyy hh24:mi:ss'''; 

    dws_logging.logevent(p_event_code => 2022,  p_add_txt => 'export subscriber status (CS40) to stage for period: ' ||  p_from_time_hour_id || ' - ' ||  p_to_time_hour_id); 

    EXECUTE IMMEDIATE 'CREATE TABLE SLCE_STAT_STATICTABLESPACE STAGINGAS

    SELECT SUBSCRIBER_ID, MAX(CASE  WHEN LC_EVENT_TYPE_ID = 3 THEN  EVENT_VALUE_AFTER  END) SUBS_LANGUAGE,  MAX(CASE  WHEN LC_EVENT_TYPE_ID = 14 THEN  EVENT_VALUE_AFTER  END) COMMUNITY_ID1,  MAX(CASE  WHEN LC_EVENT_TYPE_ID = 15 THEN  EVENT_VALUE_AFTER  END) COMMUNITY_ID2,

      MAX(CASE  WHEN LC_EVENT_TYPE_ID = 16 THEN  EVENT_VALUE_AFTER  END) COMMUNITY_ID3  FROM (SELECT ROW_NUMBER() OVER(PARTITION BY SUBSCRIBER_ID, LC_EVENT_TYPE_ID ORDER BY UTC_TIMESTAMP DESC) RNO,  EVENT_VALUE_AFTER,  SUBSCRIBER_ID,  LC_EVENT_TYPE_ID  FROM (SELECT /*+ parallel (slce,4) parallel (MS,4)*/

  • 8/18/2019 Dws Data Export Filter Body

    3/146

      EVENT_VALUE_AFTER,  SLCE.SUBSCRIBER_ID,  LC_EVENT_TYPE_ID,  UTC_TIMESTAMP  FROM SUBSCRIBER_LIFE_CYCLE_EVENTS SLCE,  (select ma.msisdn,  ma.account_id,  ma.allocation_start_time_utc,  ma.allocation_end_time_utc,  ma.subscriber_id,  row_number() over (partition by ma.subscriber_id order by ma.allocation_ start_time_utc desc) rno  from msisdn_allocations ma) MS  WHERE MS.ALLOCATION_START_TIME_UTC   to_date(''' || p_to_utc ||  ''',''dd-mon-yyyy hh24:mi:ss'')-' ||  dws_config.get_integer_value(dws_constants.disconnection_history) || '  AND MS.SUBSCRIBER_ID = SLCE.SUBSCRIBER_ID

     AND MS.RNO=1  AND LC_EVENT_TYPE_ID IN (3, 14, 15, 16)

      AND UTC_TIMESTAMP = to_date('''||p_to_utc ||''',''dd-mon-yyyy hh24:mi:ss'')) MS,  SUBSCRIBERS_CHANGE_LOG SCL WHERE MS.SUBSCRIBER_ID = SCL.SUBSCRIBER_ID

  • 8/18/2019 Dws Data Export Filter Body

    4/146

      AND MS.RNO=1  AND ALLOCATION_START_TIME_UTC   to_date(''' || p_to_utc ||  ''',''dd-mon-yyyy hh24:mi:ss'')-' ||  dws_config.get_integer_value(dws_constants.disconnection_history) || '  AND VALID_FROM_UTC to_date(''' || p_to_utc ||  ''',''dd-mon-yyyy hh24:mi:ss'')'; 

    dws_logging.logevent(p_event_code => 2022,  p_add_txt => 'export subscriber status (CS40) - SCL_ STAT_STATIC for period: ' ||  p_from_time_hour_id || ' - ' ||  p_to_time_hour_id); 

    EXECUTE IMMEDIATE 'create table alce_stat_static tablespace stagingasSELECT ACCOUNT_ID,  MAX(CASE  WHEN LC_EVENT_TYPE_ID = 1 THEN

      EVENT_VALUE_AFTER  END) ACC_STATUS,  MAX(CASE  WHEN LC_EVENT_TYPE_ID = 7 THEN  EVENT_VALUE_AFTER  END) SERVICE_CLASS_ID,  MAX(CASE  WHEN LC_EVENT_TYPE_ID = 8 THEN  TO_DATE(EVENT_VALUE_AFTER, ''YYYYMMDDHH24MISS'')  END) SERVICE_EXPIRY_DATE,  MAX(CASE  WHEN LC_EVENT_TYPE_ID = 10 THEN  TO_DATE(EVENT_VALUE_AFTER, ''YYYYMMDDHH24MISS'')

      END) AIRTIME_EXPIRY_DATE,  MAX(CASE  WHEN LC_EVENT_TYPE_ID = 26 THEN  EVENT_VALUE_AFTER  END) CREDIT_CLEARANCE_PERIOD,  MAX(CASE  WHEN LC_EVENT_TYPE_ID = 25 THEN  EVENT_VALUE_AFTER  END) SERVICE_REMOVAL_PERIOD  FROM (SELECT ROW_NUMBER() OVER(PARTITION BY ACCOUNT_ID, LC_EVENT_TYPE_ID ORDER BY UTC_TIMESTAMP DESC) RNO,  EVENT_VALUE_AFTER,  ACCOUNT_ID,

      LC_EVENT_TYPE_ID  FROM (SELECT /*+ parallel (alce,4) parallel (MS,4)*/  alce.EVENT_VALUE_AFTER,  alce.ACCOUNT_ID,  alce.LC_EVENT_TYPE_ID,  alce.UTC_TIMESTAMP  FROM ACCOUNT_LIFE_CYCLE_EVENTS ALCE,  (select ma.msisdn,

      ma.account_id,  ma.allocation_start_time_utc,

  • 8/18/2019 Dws Data Export Filter Body

    5/146

      ma.allocation_end_time_utc,  ma.subscriber_id,  row_number() over (partition by ma.subscriber_id order by ma.allocation_start_time_utc desc) rno  from msisdn_allocations ma) MS  WHERE alce.ACCOUNT_ID > 0

      AND MS.RNO=1  AND MS.ALLOCATION_START_TIME_UTC   to_date(''' || p_to_utc ||  ''',''dd-mon-yyyy hh24:mi:ss'')-' ||  dws_config.get_integer_value(dws_constants.disconnection_history) || '  AND MS.ACCOUNT_ID = ALCE.ACCOUNT_ID  AND alce.LC_EVENT_TYPE_ID IN (1, 7, 8, 10, 25, 26)  AND alce.UTC_TIMESTAMP

  • 8/18/2019 Dws Data Export Filter Body

    6/146

      p_add_txt => 'export subscriber status (CS40) - ITL_ STAT_STATIC for period: ' ||  p_from_time_hour_id || ' - ' ||  p_to_time_hour_id); 

    EXECUTE IMMEDIATE 'CREATE TABLE ACTI_STAT_STATICTABLESPACE STAGINGASSELECT /*+ PARALLEL (ALCE,4) */  ALCE.ACCOUNT_ID,  DWS_TIME.GET_FINANCIALTIME_FROM_UTC(ALCE.UTC_TIMESTAMP) ACTIVATION_DATEFROM  ACCOUNT_LIFE_CYCLE_EVENTS ALCE WHERE ALCE.ACCOUNT_ID > 0  AND ALCE.LC_EVENT_TYPE_ID = 1  AND ALCE.UTC_TIMESTAMP

  • 8/18/2019 Dws Data Export Filter Body

    7/146

      ''',''dd-mon-yyyy hh24:mi:ss'') 0 then ''W''  WHEN CREDIT_CLEARANCE_DATE

  • 8/18/2019 Dws Data Export Filter Body

    8/146

      execute immediate 'alter session set nls_date_format=''dd-mon-yyyy hh24:mi:ss'''; 

    dws_logging.logevent(p_event_code => 2022,  p_add_txt => 'export subscriber DA status (CS40) tostage for period: ' ||  p_from_time_hour_id || ' - ' ||  p_to_time_hour_id); 

    EXECUTE IMMEDIATE 'CREATE TABLE ITL_DA_STAT_STATICTABLESPACE STAGINGASselect  t.SUBSCRIBER_ID,  DA_ID,  DA_BALANCE,  CURRENCY_TYPE  from(SELECT /*+ parallel(csa,4) parallel(itl,4) parallel(ms,4) */MS.SUBSCRIBER_ID,

      CASH_ACCOUNT_ID DA_ID,  POSITIVE_BALANCE_AMOUNT - NEGATIVE_BALANCE_AMOUNT DA_BALANCE,

      CURRENCY_TYPEFROM MSISDN_ALLOCATIONS MS,

      ITL_LIAB_EXTRACT_STG ITL  where MS.ALLOCATION_START_TIME_UTC   to_date(''' || p_to_utc ||  ''',''dd-mon-yyyy hh24:mi:ss'')-' ||  dws_config.get_integer_value(dws_constants.disconnection_history) || '  AND MS.ACCOUNT_ID = ITL.ACCOUNT_ID  AND ITL.FINANCIAL_DATE_KEY = ' || FIN_DATE_KEY || '  AND ITL.CASH_ACCOUNT_ID>0) t  ,CRS_SUBSCRIBER_ALLOCATIONS csa

      where t.subscriber_id = csa.subscriber_id  and csa.start_time_utc < to_date('''||p_to_utc ||''',''dd-mon-yyyy hh24:mi:ss'')  and csa.end_time_utc >= to_date('''||p_to_utc ||''',''dd-mon-yyyy hh24:mi:ss'')'; 

    dws_logging.logevent(p_event_code => 2022,  p_add_txt => 'export subscriber status (CS40) - ITL_ DA_STAT_STATIC for period: ' ||  p_from_time_hour_id || ' - ' ||  p_to_time_hour_id);

     

    EXECUTE IMMEDIATE 'create table scl_da_stat_static tablespace stagingasSELECT /*+ parallel (ms,4) parallel (scl,4)*/ms.msisdn,MS.SUBSCRIBER_ID,ms.account_id,SCL.MARKET_ID MARKET_ID  FROM MSISDN_ALLOCATIONS MS,

  • 8/18/2019 Dws Data Export Filter Body

    9/146

      SUBSCRIBERS_CHANGE_LOG SCL WHERE MS.SUBSCRIBER_ID = SCL.SUBSCRIBER_ID  AND ALLOCATION_START_TIME_UTC   to_date(''' || p_to_utc ||  ''',''dd-mon-yyyy hh24:mi:ss'')-' ||  dws_config.get_integer_value(dws_constants.disconnection_history) || '  AND VALID_FROM_UTC to_date(''' || p_to_utc ||  ''',''dd-mon-yyyy hh24:mi:ss'')'; 

    dws_logging.logevent(p_event_code => 2022,  p_add_txt => 'export subscriber status (CS40) - SCL_ DA_STAT_STATIC for period: ' ||  p_from_time_hour_id || ' - ' ||  p_to_time_hour_id);

     

    EXECUTE IMMEDIATE 'INSERT /*+ APPEND*/ INTO WRK_DE_STAT_DA_STG

    ( SUBSCRIBER_ID,  DA_ID,  DA_BALANCE,  MARKET_ID)SELECT /*+ PARALLEL(A,4),PARALLEL(B,4)*/A.SUBSCRIBER_ID,A.DA_ID,A.DA_BALANCE,B.MARKET_IDFROMITL_DA_STAT_STATIC A,SCL_DA_STAT_STATIC B

    WHEREA.SUBSCRIBER_ID=B.SUBSCRIBER_ID';

     

    ELSIF TYPE='A' THEN

    execute immediate 'truncate table wrk_de_stat_ua_stg'; 

    begin  execute immediate 'drop table SCL_UA_STAT_STATIC';

    execute immediate 'drop table ACC_UA_STAT_STATIC';

      exception  when others then  null;  end; 

    execute immediate 'alter session set nls_date_format=''dd-mon-yyyy hh24:mi:s

  • 8/18/2019 Dws Data Export Filter Body

    10/146

    s'''; 

    dws_logging.logevent(p_event_code => 2022,  p_add_txt => 'export subscriber UA status (CS40) tostage for period: ' ||  p_from_time_hour_id || ' - ' ||  p_to_time_hour_id);

    EXECUTE IMMEDIATE 'CREATE TABLE ACC_UA_STAT_STATICTABLESPACE STAGINGASSELECTMS.SUBSCRIBER_ID,BASE_DATA.UA_ID,BASE_DATA.UA_BALANCEFROM(SELECT /*+ PARALLEL (ACC,6) parallel(csa,4)*/DISTINCTACCOUNT_ID,ACCUMULATOR_ID UA_ID,first_value(ACCUMULATOR_AFTER_EVENT) OVER (PARTITION BY account_id,ACCUMULATOR_ID ORDER BY utc_timestamp DESC) UA_BALANCEFROM

    ACC_ACCUMULATOR_BALANCES ACCWHERE ACC.UTC_TIMESTAMP 0) BASE_DATA,MSISDN_ALLOCATIONS MS,  CRS_SUBSCRIBER_ALLOCATIONS csa  where ms.subscriber_id = csa.subscriber_id  and csa.start_time_utc < to_date('''||p_to_utc ||''',''dd-mon-yyyy hh24:mi:ss'')  and csa.end_time_utc >= to_date('''||p_to_utc ||''',''dd-mon-yyyy hh24:mi:ss'')  AND MS.ALLOCATION_START_TIME_UTC   to_date(''' || p_to_utc ||  ''',''dd-mon-yyyy hh24:mi:ss'')-' ||  dws_config.get_integer_value(dws_constants.disconnection_history) || '  AND MS.ACCOUNT_ID = BASE_DATA.ACCOUNT_ID';

     

    dws_logging.logevent(p_event_code => 2022,  p_add_txt => 'export subscriber status (CS40) - ACC_ UA_STAT_STATIC for period: ' ||

      p_from_time_hour_id || ' - ' ||  p_to_time_hour_id);

     

    EXECUTE IMMEDIATE 'create table scl_ua_stat_static tablespace stagingasSELECT /*+ parallel (ms,4) parallel (scl,4)*/ms.msisdn,

  • 8/18/2019 Dws Data Export Filter Body

    11/146

    MS.SUBSCRIBER_ID,ms.account_id,SCL.MARKET_ID MARKET_ID  FROM MSISDN_ALLOCATIONS MS,  SUBSCRIBERS_CHANGE_LOG SCL WHERE MS.SUBSCRIBER_ID = SCL.SUBSCRIBER_ID  AND ALLOCATION_START_TIME_UTC   to_date(''' || p_to_utc ||  ''',''dd-mon-yyyy hh24:mi:ss'')-' ||  dws_config.get_integer_value(dws_constants.disconnection_history) || '  AND VALID_FROM_UTC to_date(''' || p_to_utc ||  ''',''dd-mon-yyyy hh24:mi:ss'')'; 

    dws_logging.logevent(p_event_code => 2022,  p_add_txt => 'export subscriber status (CS40) - SCL_ STAT_STATIC for period: ' ||  p_from_time_hour_id || ' - ' ||  p_to_time_hour_id);

     

    EXECUTE IMMEDIATE 'INSERT /*+APPEND*/ INTO WRK_DE_STAT_UA_STG( SUBSCRIBER_ID,  UA_ID,  UA_BALANCE,  MARKET_ID)SELECT /*+ PARALLEL(A,4),PARALLEL(B,4)*/B.SUBSCRIBER_ID,A.UA_ID,A.UA_BALANCE,B.MARKET_IDFROMACC_UA_STAT_STATIC A,

    SCL_UA_STAT_STATIC BWHEREA.SUBSCRIBER_ID=B.SUBSCRIBER_ID';

     

    END IF; 

    EXCEPTION  WHEN OTHERS THEN  dws_logging.logevent(p_event_code => 2014,  p_add_txt => 'export subscriber status (CS40) Data Extraction ERROR for period: '||

      p_from_time_hour_id || ' - ' ||  p_to_time_hour_id||' : '||SQLERRM); 

    commit; 

    dws_logging.logevent(p_event_code => 2022,  p_add_txt => 'export subscriber status (CS40) to stage finished'); 

  • 8/18/2019 Dws Data Export Filter Body

    12/146

      dbms_application_info.set_module(module_name => null,  action_name => null); end export_stat_static_for_utc;

      ----------------------------------------------------------------  -- procedure: export_acts  -- purpose: wrapper function for export_acts_for_thid to handle conversions of dates to thids (time_hour_id:s)  -----------------------------------------------------------------  procedure export_acts(p_from_time varchar2,  p_to_time varchar2,  p_date_format varchar2) is  begin 

    log_time_info(p_from_time, p_to_time, p_date_format); 

    export_acts_for_thid(dws_time.date2thid(dws_time.get_utc_from_financialtime(to_date(p_from_time, 

    p_date_format))),  dws_time.date2thid(dws_time.get_utc_from_financialtime(to_date(p_to_time, 

    p_date_format)))); end;

      -----------------------------------------------------------------  -- procedure: export_acts_for_thid-- purpose: export acts data for given time interval (in time_hour_id) to sta

    ging table wrk_de_acts_stg  -----------------------------------------------------------------  procedure export_acts_for_thid(p_from_time_hour_id varchar2,  p_to_time_hour_id varchar2) is 

    from_thid_to_date date;

      to_thid_to_date date;  OBJ_FLG NUMBER;  SPLIT_FLAG NUMBER; begin

     dbms_application_info.set_module(module_name => 'dws_data_export',

      action_name => 'export_acts'); 

    begin  select 1  INTO OBJ_FLG  from dual

      where exists (select *  from user_objects  where object_name = 'WRK_DE_ACTS_STG'  AND OBJECT_TYPE = 'TABLE');  exception  when others then  null; 

    end; 

  • 8/18/2019 Dws Data Export Filter Body

    13/146

      IF OBJ_FLG = 1 THEN  EXECUTE IMMEDIATE 'DROP TABLE WRK_DE_ACTS_STG';  END IF; 

    dws_logging.logevent(p_event_code => 2022,  p_add_txt => 'export acts to stage for period: ' ||  p_from_time_hour_id || ' - ' ||  p_to_time_hour_id); 

    from_thid_to_date := dws_time.thid2date(p_from_time_hour_id);  to_thid_to_date := dws_time.thid2date(p_to_time_hour_id); 

    EXECUTE IMMEDIATE 'TRUNCATE TABLE WRK_DE_acts_STGW REUSE STORAGE'; 

    insert /*+ append */  into wrk_de_acts_stgw  SELECT nvl(scl.MARKET_ID, -1),  nvl(acl.SERVICE_CLASS_ID, -1),  nvl(acc.SDP_NODE_ID, -1),  nvl(dws_cc_report.gethubid(scl.market_id), -1) hub_id,  count(1) number_of_subscribers  from (Select /*+ PARALLEL_INDEX(acc_lcy, alce_idx3,6) PARALLEL(MA,6) parallel(csa,4)*/ ma.SUBSCRIBER_ID,  ma.ACCOUNT_ID,

      acc_lcy.ACCOUNT_EVENT_ID,  ma.ALLOCATION_START_TIME_UTC,  ma.ALLOCATION_END_TIME_UTC  FROM (select ma.msisdn,  ma.ACCOUNT_ID,  ma.ALLOCATION_END_TIME_UTC,  ma.ALLOCATION_START_TIME_UTC,  ma.SUBSCRIBER_ID,  row_number() over (partition by ma.SUBSCRIBER_ID order by ma.ALLOCATION_START_TIME_UTC desc) rno  from

    msisdn_allocations ma) MA,  ACCOUNT_LIFE_CYCLE_EVENTS acc_lcy,

      CRS_SUBSCRIBER_ALLOCATIONS csa  where acc_lcy.subscriber_id = csa.subscriber_id  and csa.start_time_utc < acc_lcy.UTC_TIMESTAMP  and csa.end_time_utc >= acc_lcy.UTC_TIMESTAMP  AND ma.ACCOUNT_ID = acc_lcy.ACCOUNT_ID  AND acc_lcy.ACCOUNT_ID > 0  AND acc_lcy.LC_EVENT_TYPE_ID = 1  AND acc_lcy.EVENT_VALUE_BEFORE = 'INSTALLED'  AND acc_lcy.EVENT_VALUE_AFTER = 'ACTIVATED'  AND MA.RNO=1  AND ma.ALLOCATION_START_TIME_UTC = acc_lcy.UTC_TIMESTAMP  AND acc_lcy.UTC_TIMESTAMP >= from_thid_to_date

      AND acc_lcy.UTC_TIMESTAMP

  • 8/18/2019 Dws Data Export Filter Body

    14/146

      from accounts acc  where SDP_CREATION_TIME_UTC = to_thid_to_date) acc  where base_data.SUBSCRIBER_ID = scl.SUBSCRIBER_ID(+)  and base_data.ACCOUNT_ID = acl.ACCOUNT_Id(+)  and base_data.ACCOUNT_ID = acc.ACCOUNT_ID(+)  group by nvl(scl.MARKET_ID, -1),  nvl(acl.SERVICE_CLASS_ID, -1),  nvl(acc.SDP_NODE_ID, -1),  nvl(dws_cc_report.gethubid(scl.market_id), -1); 

    commit; 

    select decode(cn.VALUE, 'TRUE', 1, 0)  INTO split_flag  from oam.dws_configuration cn  where cn.CONFIGURATION_ID = 12023; 

    IF SPLIT_FLAG = 1 THEN 

    EXECUTE IMMEDIATE 'CREATE TABLE dwsadm.WRK_DE_acts_STG (  ROW_id NUMBER,  ID VARCHAR2(200),  HUB_ID VARCHAR2(10),

      CNT NUMBER)LOGGINGNOCACHENOPARALLELMONITORING TABLESPACE STAGING'; 

    execute immediate 'grant select on dwsadm.WRK_DE_acts_STG to repadm'; 

    execute immediate 'insert /*+ append */ into wrk_de_acts_stgselect''1'',market_id,

    hub_id,sum(nvl(number_of_subscribers,0))fromwrk_de_acts_stgwgroup by ''1'',market_id,hub_id'; 

    commit; 

    execute immediate 'insert /*+ append */ into wrk_de_acts_stgselect''2'',sdp_id,hub_id,

    sum(nvl(number_of_subscribers,0))fromwrk_de_acts_stgwgroup by ''2'',sdp_id,hub_id'; 

    commit; 

    execute immediate 'insert /*+ append */ into wrk_de_acts_stgselect''3'',

  • 8/18/2019 Dws Data Export Filter Body

    15/146

    service_class_id,hub_id,sum(nvl(number_of_subscribers,0))fromwrk_de_acts_stgwgroup by ''3'',service_class_id,hub_id'; 

    commit; 

    ELSE 

    EXECUTE IMMEDIATE 'CREATE TABLE dwsadm.WRK_DE_acts_STG TABLESPACE STAGINGas select ' || dws_cc_report.getDeFields('ACTS') ||  ',sum(number_of_subscribers) number_of_subscribersfrom wrk_de_acts_stgw group by ' ||  dws_cc_report.getDeFields('ACTS'); 

    execute immediate 'grant select on dwsadm.WRK_DE_acts_STG to repadm'; 

    END IF; 

    dws_logging.logevent(p_event_code => 2022,  p_add_txt => 'export acts to stage finished'); 

    dbms_application_info.set_module(module_name => null,  action_name => null); end export_acts_for_thid;

    ------------------------------------------------------------------- procedure: export_usage_static-- purpose: wrapper function for export_usage_static_for_thid to handle conversions of dates to thids (time_hour_id:s)-----------------------------------------------------------------PROCEDURE export_usage_static(  p_from_time VARCHAR2

    , p_to_time VARCHAR2

      , p_date_format VARCHAR2 , type VARCHAR2)ISBEGIN

      log_time_info(p_from_time, p_to_time, p_date_format); 

    export_usage_static_for_thid(  Dws_Time.date2thid(Dws_Time.get_utc_from_financialtime(TO_DATE(p_from_time, p_date_format)))  , Dws_Time.date2thid(Dws_Time.get_utc_from_financialtime(TO_DATE(p_to_time, p_date_format)))

      ,type);

    END; ------------------------------------------------------------------- procedure: export_usage_static_for_thid-- purpose: export usage data for given time interval (in time_hour_id) to staging table wrk_de_usage_stg-----------------------------------------------------------------PROCEDURE export_usage_static_for_thid(

  • 8/18/2019 Dws Data Export Filter Body

    16/146

      p_from_time_hour_id USAGE_EVENTS.time_hour_id%TYPE,p_to_time_hour_id USAGE_EVENTS.time_hour_id%TYPE,

      type VARCHAR2)IS

    m_extra_from_thid USAGE_EVENTS.time_hour_id%TYPE;  m_extra_to_thid USAGE_EVENTS.time_hour_id%TYPE;  v_crs_id varchar2(10);BEGIN

    /*  increase the timespan for usage events by 1 day in the beginning at and the end.  sometimes usage and msc events for the same call can differ some seconds in time.  by adding an extra day we can take care of this but still use partition pruning.

    */  m_extra_from_thid := Dws_Time.move_thid_days(p_from_time_hour_id,-1);  m_extra_to_thid := Dws_Time.move_thid_days(p_to_time_hour_id,1); 

    v_crs_id := dws_config.get_varchar_value(p_configuration_id => dws_constants.conf_comp_crs_id); 

    dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export usage det

    ails (CS40) to stage for period: ' || p_from_time_hour_id || ' - ' || p_to_time_ hour_id);

    dbms_application_info.set_module(module_name => 'dws_data_export',  action_name => 'export_usage_static start'); 

    execute immediate 'TRUNCATE TABLE NUMBER_RANGE_CRS_MAP_TEMP';

    insert into NUMBER_RANGE_CRS_MAP_TEMP (

      CONFIGURATION_ID, 

    MSISDN_RANGE_START,  MSISDN_RANGE_END,

     FROM_DATE_UTC,

     TO_DATE_UTC)

    selectCONFIGURATION_ID,MSISDN_RANGE_START,MSISDN_RANGE_END,dws_time.Get_UTC_From_Financialtime(FROM_DATE),dws_time.Get_UTC_From_Financialtime(TO_DATE)

    from NUMBER_RANGE_CRS_MAPwhere UPPER(crs_id) = UPPER(v_crs_id);

    DBMS_STATS.GATHER_TABLE_STATS(OWNNAME => 'DWSADM', TABNAME => UPPER('NUMBER_RANGE_CRS_MAP_TEMP'), ESTIMATE_PERCENT => 1);

    --EXECUTE IMMEDIATE 'alter session enable parallel dml';

  • 8/18/2019 Dws Data Export Filter Body

    17/146

      IF TYPE='S' THEN 

    EXECUTE IMMEDIATE 'truncate table wrk_de_usage_static_stg'; 

    dws_logging.logevent(p_event_code => 2022, p_add_txt => 'Truncate table for usage stat (CS40) export finished');

    INSERT /*+append*/ INTO WRK_DE_USAGE_STATIC_STG(EVENT_ID, TELE_SERVICE_CODE, TELE_SERVICE_NAME, TRAFFIC_DIRECTION,TRAFFIC_CASE_NAME, SERVICE_CLASS, ORIGINAL_TIMESTAMP, UTC_TIMESTAMP,DWS_CREATION_DATE, TIME_HOUR_ID, CALLED_NUMBER, DURATION,VOLUME, NUMBER_OF_EVENTS, MAIN_ACC_BEF_CALL, MAIN_ACC_AFT_CALL,COST, CURRENCY_CODE, SERVED_MSISDN, MASTER_MSISDN,HOME_CITY, ACCOUNT_STATUS, IMSI, IMEI,ORIGINATING_CELL_ID, TERMINATING_CELL_ID, FAF_INDICATOR, LOCATION_CITY,LOCATION_COUNTRY, LOCATION_REGION, LOCATION_REGION_CODE, LOCATION_TIME_ZONE_REGION,CH_CATEGORY_NAME, CREDIT_DURATION, DEBIT_DURATION, FREE_DURATION,TARIFF_NAME, NON_CHARGED_SUBSCRIBER_NUMBER, ROAMING_CAT_NAME)SELECT /*+ parallel(ue,4),parallel(msc,4),parallel(acl,4),parallel(ma,4),parallel(mm,4),parallel(uab,4)*/ue.USAGE_EVENT_ID,tt.tele_service_code,tt.tele_service_name,tt.traffic_direction

    ,tt.traffic_case_name,nvl(sc.SERVICE_CLASS_NAME,sc.SDP_SC_NAME) service_class,ue.original_timestamp,ue.UTC_TIMESTAMP,ue.DWS_CREATION_DATE,ue.TIME_HOUR_ID,ue.called_number,ue.duration,ue.volume,ue.number_of_events,uab.BALANCE_BEFORE_EVENT ma_balalce_before,uab.BALANCE_after_event ma_balalce_after,ue.total_cost cost,ct.CURRENCY_CODE, ue.served_msisdn,mm.msisdn master_msisdn,  DECODE(h.home_level_1,  NULL, 'Unknown',  'Undefined', 'Unknown',  DECODE(h.home_level_2,  NULL, h.home_level_1,  DECODE(h.home_level_3,

      NULL, h.home_level_1 || ' ,' ||h.home_level_2 ,  h.home_level_1 || ' ,' ||h.home_level_2 || ' ,' ||h.home_level_3 ))) home_city ,acl.account_status,msc.served_imsi,msc.served_imei,msc.first_cell_identity,msc.last_cell_identity,ue.faf_indicator,uns.city,uns.country,uns.region,uns.REGION_CODE,uns.time_zone_region,cc.ch_category_name,ue.credit_duration,ue.debit_duration,ue.free_duration,tc.tariff_cat_name,ue.non_charged_subscriber_number,rc.roaming_cat_namefromusage_events ue,traffic_types tt,usage_number_series uns,roaming_categories rc,

    currency_types ct,service_classes sc,tariff_categories tc,charging_categories cc,msc_events msc,(select ma.msisdn,  ma.account_id,  ma.allocation_start_time_utc,  ma.allocation_end_time_utc,  ma.subscriber_id,

  • 8/18/2019 Dws Data Export Filter Body

    18/146

      row_number() over (partition by ma.subscriber_id order by ma.allocation_ start_time_utc desc) rno  from msisdn_allocations ma) ma,accounts_change_log acl,subscribers_change_log scl,homes h,(select ma.msisdn,  ma.account_id,  ma.allocation_start_time_utc,  ma.allocation_end_time_utc,  ma.subscriber_id,  row_number() over (partition by ma.subscriber_id order by ma.allocation_ start_time_utc desc) rno  from msisdn_allocations ma) mm,usg_account_balances uab,NUMBER_RANGE_CRS_MAP_TEMP nrmwhere  ue.time_hour_id >= p_from_time_hour_idand ue.time_hour_id < p_to_time_hour_id

    and ue.served_msisdn >= nrm.MSISDN_RANGE_STARTand ue.served_msisdn < nrm.MSISDN_RANGE_ENDand nrm.FROM_DATE_UTC < UE.UTC_TIMESTAMPand nrm.TO_DATE_UTC >= UE.UTC_TIMESTAMP

    --and ue.subscriber_id >0

    and ma.rno=1and mm.rno=1and ue.traffic_type_id=tt.traffic_type_id(+)and ue.location_number_ns_id = uns.usa_ns_id (+)and ue.original_timestamp between uns.valid_from(+) and uns.valid_to(+) /*checkthis condition*/and ue.roaming_cat_id=rc.roaming_cat_id(+)and ue.currency_type = ct.currency_type (+)and ue.service_class_id=sc.service_class_id(+)and ue.tariff_cat_id=tc.tariff_cat_id(+)and ue.ch_category_id=cc.ch_category_id(+)and msc.time_hour_id(+) >= m_extra_from_thidand msc.time_hour_id(+) < m_extra_to_thid

    and ue.gsm_call_reference_number = msc.gsm_call_reference_number(+)and ue.served_msisdn = msc.served_msisdn(+)AND msc.gsm_call_reference_number(+) > 0 AND msc.gsm_call_reference_number(+) IS NOT NULLAND nvl(abs(ue.original_timestamp - msc.answer_time(+)), 0 ) = ue.utc_timestampand ue.served_msisdn=ma.msisdnand ma.account_id=acl.account_idand acl.valid_from_utc ue.utc_timestampAND scl.subscriber_id = ma.subscriber_idAND scl.valid_from_utc ue.utc_timestampand scl.home_id = h.home_id(+)and mm.allocation_start_time_utc < ue.utc_timestampand mm.allocation_end_time_utc >= ue.utc_timestampand ma.ACCOUNT_ID=mm.SUBSCRIBER_ID--AND uab.account_id(+) > 0and uab.CASH_ACCOUNT_ID(+)=0AND uab.time_hour_id(+) >= p_from_time_hour_idAND uab.time_hour_id(+) < p_to_time_hour_idand ue.USAGE_EVENT_ID=uab.USAGE_EVENT_ID(+);

  • 8/18/2019 Dws Data Export Filter Body

    19/146

     dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export usage (CS40

    ) details finished. '|| 'Extracted ' || SQL%rowcount);

    COMMIT; 

    ELSIF TYPE='D' THEN

    EXECUTE IMMEDIATE 'truncate table wrk_de_usage_da_stg'; 

    dws_logging.logevent(p_event_code => 2022, p_add_txt => 'Truncate table for usage da (CS40) export finished');

    INSERT /*+APPEND*/ INTO WRK_DE_USAGE_DA_STG(EVENT_ID, DA_ACCOUNT_ID, DA_VALUE_BEFORE,

    DA_VALUE_AFTER, DA_CAMPAIGN_ID, TIME_HOUR_ID)SELECT /*+ PARALLEL(UJE,4),PARALLEL(UAB,4) PARALLEL(ue,4)*/UJE.USAGE_EVENT_ID, UJE.CASH_ACCOUNT_ID DA_ACCOUNT_ID,UAB.BALANCE_BEFORE_EVENTDA_VALUE_BEFORE,UAB.BALANCE_AFTER_EVENT DA_VALUE_AFTER, UJE.CAMPAIGN_ID DA_CAMPAIGN_ID,UJE.TIME_ HOUR_IDFROMusage_events ue,

    USAGE_JOURNAL_ENTRIES UJE,USG_ACCOUNT_BALANCES UAB,NUMBER_RANGE_CRS_MAP_TEMP nrmwhere

    ue.usage_event_id = uje.usage_event_idand ue.time_hour_id >= p_from_time_hour_idand ue.time_hour_id < p_to_time_hour_idand ue.served_msisdn >= nrm.MSISDN_RANGE_STARTand ue.served_msisdn < nrm.MSISDN_RANGE_ENDand nrm.FROM_DATE_UTC < UE.UTC_TIMESTAMPand nrm.TO_DATE_UTC >= UE.UTC_TIMESTAMPand UJE.USAGE_EVENT_ID=UAB.USAGE_EVENT_ID(+)

    AND UJE.CASH_ACCOUNT_ID=UAB.CASH_ACCOUNT_ID(+)

    AND UJE.CASH_ACCOUNT_ID>0AND UAB.TIME_HOUR_ID>=p_from_time_hour_idAND UAB.TIME_HOUR_ID=p_from_time_hour_idAND UJE.TIME_HOUR_ID 2022, p_add_txt => 'export usage DA (CS40) details finished. '|| 'Extracted ' || SQL%rowcount);

    COMMIT; 

    ELSIF TYPE='A' THEN

     EXECUTE IMMEDIATE 'truncate table wrk_de_usage_ua_stg';

     dws_logging.logevent(p_event_code => 2022, p_add_txt => 'Truncate table fo

    r usage UA (CS40) export finished');

    INSERT INTO /*+APPEND*/ WRK_DE_USAGE_UA_STG(EVENT_ID, UA_ID, UA_VALUE, TIME_HOUR_ID)SELECT /*+ PARALLEL(AAH,4)*/

  • 8/18/2019 Dws Data Export Filter Body

    20/146

    AAH.USAGE_EVENT_ID,AAH.ACCUMULATOR_ID,AAH.ACCUMULATOR_VALUE,AAH.TIME_HOUR_IDFROMusage_events ue,ACCOUNT_ACCUMULATORS_HISTORY AAH,NUMBER_RANGE_CRS_MAP_TEMP nrmwhere

    ue.usage_event_id = AAH.usage_event_idand ue.time_hour_id >= p_from_time_hour_idand ue.time_hour_id < p_to_time_hour_idand ue.served_msisdn >= nrm.MSISDN_RANGE_STARTand ue.served_msisdn < nrm.MSISDN_RANGE_ENDand nrm.FROM_DATE_UTC < UE.UTC_TIMESTAMPand nrm.TO_DATE_UTC >= UE.UTC_TIMESTAMPand AAH.TIME_HOUR_ID>=p_from_time_hour_id

      AND AAH.TIME_HOUR_ID 2022, p_add_txt => 'export usage UA (CS40) details finished. '|| 'Extracted ' || SQL%rowcount);

    COMMIT;

      dbms_application_info.set_module(module_name => NULL,  action_name => NULL); 

    dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export usage (CS40) to stage finished.');

     

    END IF;

    END export_usage_static_for_thid;-- added by ealphan

    ------------------------------------------------------------------- procedure: export_usage_for_thid-- purpose: export usage data for given time interval (in time_hour_id) to staging table wrk_de_usage_stg-----------------------------------------------------------------procedure export_usage_for_thid(  p_from_time_hour_id usage_events.time_hour_id%type,

    p_to_time_hour_id usage_events.time_hour_id%type)is

    m_extra_from_thid usage_events.time_hour_id%type;  m_extra_to_thid usage_events.time_hour_id%type;  v_crs_id varchar2(10);begin

    /*  increase the timespan for usage events by 1 day in the beginning at and the end.  sometimes usage and msc events for the same call can differ some seconds in time.  by adding an extra day we can take care of this but still use partition pruning.

    */  m_extra_from_thid := dws_time.move_thid_days(p_from_time_hour_id,-1);

  • 8/18/2019 Dws Data Export Filter Body

    21/146

      m_extra_to_thid := dws_time.move_thid_days(p_to_time_hour_id,1); 

    dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export usage tostage for period: ' || p_from_time_hour_id || ' - ' || p_to_time_hour_id);

    dbms_application_info.set_module(module_name => 'dws_data_export',  action_name => 'export_usage start'); 

    --execute immediate 'alter session enable parallel dml';

    execute immediate 'truncate table wrk_de_usage_stg'; 

    v_crs_id := dws_config.get_varchar_value(p_configuration_id => dws_constants.conf_comp_crs_id); 

    execute immediate 'TRUNCATE TABLE NUMBER_RANGE_CRS_MAP_TEMP';

      insert into NUMBER_RANGE_CRS_MAP_TEMP (

      CONFIGURATION_ID, 

    MSISDN_RANGE_START, 

    MSISDN_RANGE_END,

     FROM_DATE_UTC, 

    TO_DATE_UTC)select

    CONFIGURATION_ID,MSISDN_RANGE_START,MSISDN_RANGE_END,dws_time.Get_UTC_From_Financialtime(FROM_DATE),dws_time.Get_UTC_From_Financialtime(TO_DATE)

    from NUMBER_RANGE_CRS_MAPwhere UPPER(crs_id) = UPPER(v_crs_id);

    DBMS_STATS.GATHER_TABLE_STATS(OWNNAME => 'DWSADM', TABNAME => UPPER('NUMBER_RANGE_CRS_MAP_TEMP'), ESTIMATE_PERCENT => 1); 

    dws_logging.logevent(p_event_code => 2022, p_add_txt => 'truncated table wrk_de_usage_stg');

    /**step 1

    **/ 

    insert /*+ append */ into wrk_de_usage_stgselect /*+ parallel(master_s,6) parallel(s,6) parallel(scl,6) parallel(acl

    ,6) parallel(ma,6) */

      mod(s.subscriber_id,5)  ,main_query.tele_service_code  ,main_query.tele_service_name  ,main_query.traffic_direction  ,main_query.traffic_case_name  ,decode(main_query.service_class_id,-1,nvl(s_c.service_class_name,s_c.sdp

     _sc_name),main_query.service_class) /* HH70012*/  ,main_query.original_timestamp  ,main_query.utc_timestamp  ,main_query.dws_creation_date

  • 8/18/2019 Dws Data Export Filter Body

    22/146

      ,main_query.time_hour_id  ,main_query.called_number  ,main_query.duration  ,main_query.volume  ,main_query.number_of_events  ,main_query.main_acc_bef_call  ,main_query.ded_acc_bef_call  ,main_query.main_acc_aft_call  ,main_query.ded_acc_aft_call  ,main_query.cost  ,main_query.currency_code  ,main_query.da_account_id  ,main_query.served_msisdn  ,master_ma.msisdn

    ,decode(h.home_level_1,

      null, 'Unknown',  'Undefined', 'Unknown',  decode(h.home_level_2,  null, h.home_level_1,  decode(h.home_level_3,  null, h.home_level_1 || ' ,' ||h.home_level_2 ,  h.home_level_1 || ' ,' ||h.home_level_2 || ' ,' ||h.home_level_3 ))) home_city

      ,acl.account_status  ,main_query.imsi  ,main_query.imei  ,main_query.originating_cell_id  ,main_query.terminating_cell_id  ,main_query.faf_indicator  ,main_query.location_city  ,main_query.location_country  ,main_query.location_region  ,main_query.location_region_code  ,main_query.location_time_zone_region  ,main_query.accumulator_1  ,main_query.accumulator_2

      ,main_query.accumulator_3  ,main_query.accumulator_4  ,main_query.accumulator_5  ,main_query.ch_category_name  ,main_query.credit_duration  ,main_query.debit_duration  ,main_query.free_duration  ,main_query.tariff_name  ,main_query.additional_fee

    ,uda.da_first_id /* CP3 changes, evicvit START */  ,uda.da_first_value_before  ,uda.da_first_value_after  ,uda.da_first_campaign_id

      ,uda.da_second_id  ,uda.da_second_value_before  ,uda.da_second_value_after  ,uda.da_second_campaign_id  ,uda.da_third_id  ,uda.da_third_value_before  ,uda.da_third_value_after  ,uda.da_third_campaign_id  ,uda.da_fourth_id  ,uda.da_fourth_value_before

  • 8/18/2019 Dws Data Export Filter Body

    23/146

      ,uda.da_fourth_value_after  ,uda.da_fourth_campaign_id  ,uda.da_fifth_id  ,uda.da_fifth_value_before  ,uda.da_fifth_value_after  ,uda.da_fifth_campaign_id /* CP3 changes, evicvit END */  ,main_query.non_charged_subscriber_number --JPN107(etkzoci)  ,main_query.roaming_cat_name --TRHH90946  from  (  select /*+ parallel(ue,6) parallel(msc,6) parallel(master_ab,4) parallel(non_master_ab,4) parallel(uje,6) */

    tt.tele_service_code tele_service_code -- search  , tt.tele_service_name tele_service_name  , tt.traffic_direction traffic_direction -- search  , tt.traffic_case_name traffic_case_name  , nvl(sc.service_class_name,sc.sdp_sc_name) service_class  , ue.original_timestamp original_timestamp  , ue.utc_timestamp utc_timestamp -- search  , ue.dws_creation_date dws_creation_date  , ue.time_hour_id time_hour_id

    , ue.service_class_id service_class_id /* HH70012*/  , ue.called_number called_number  , ue.duration duration

      , ue.volume volume  , ue.number_of_events number_of_events  , ue.subscriber_id served_subscriber_id  , master_ab.balance_before_event main_acc_bef_call  , non_master_ab.balance_before_event ded_acc_bef_call  , master_ab.balance_after_event main_acc_aft_call  , non_master_ab.balance_after_event ded_acc_aft_call  , ue.total_cost cost  , ct.currency_code currency_code  , ue.ded_account_id da_account_id

    , ue.served_msisdn served_msisdn  , msc.served_imsi imsi  , msc.served_imei imei

      , msc.first_cell_identity originating_cell_id  , msc.last_cell_identity terminating_cell_id  , ue.faf_indicator faf_indicator  , location_uns.city location_city  , location_uns.country location_country  , location_uns.region location_region  , location_uns.region_code location_region_code  , location_uns.time_zone_region location_time_zone_region

    , aah_1.accumulator_value accumulator_1  , aah_2.accumulator_value accumulator_2  , aah_3.accumulator_value accumulator_3  , aah_4.accumulator_value accumulator_4  , aah_5.accumulator_value accumulator_5

      , cc.ch_category_name ch_category_name -- service_type  , ue.credit_duration credit_duration  , ue.debit_duration debit_duration  , ue.free_duration free_duration  , tc.tariff_cat_name tariff_name  , uje.amount additional_fee  , ue.usage_event_id usage_event_id /* CP3 changed, evicvit */  , ue.non_charged_subscriber_number non_charged_subscriber_number --JPN107(etkzoci)

  • 8/18/2019 Dws Data Export Filter Body

    24/146

      , rc.roaming_cat_name roaming_cat_name --TR HH90946  from  usage_events ue  ,traffic_types tt  ,currency_types ct

    ,msc_events msc  ,usg_account_balances non_master_ab  ,usg_account_balances master_ab  ,tariff_categories tc  ,service_classes sc  ,charging_categories cc  ,usage_journal_entries uje -- this is used for getting additional_fee. should be removed if its not a common field  ,usage_number_series location_uns

    ,account_accumulators_history aah_1  ,account_accumulators_history aah_2  ,account_accumulators_history aah_3  ,account_accumulators_history aah_4  ,account_accumulators_history aah_5  ,roaming_categories rc

    ,NUMBER_RANGE_CRS_MAP_TEMP nrmwhere  ue.time_hour_id >= p_from_time_hour_id and

    ue.time_hour_id < p_to_time_hour_id

    and ue.served_msisdn >= nrm.MSISDN_RANGE_STARTand ue.served_msisdn < nrm.MSISDN_RANGE_ENDand nrm.FROM_DATE_UTC < UE.UTC_TIMESTAMPand nrm.TO_DATE_UTC >= UE.UTC_TIMESTAMP /* TR HH90946 */

      and ue.usage_event_id = non_master_ab.usage_event_id (+) and  ue.time_hour_id = non_master_ab.time_hour_id (+)

    --ue.subscriber_id > 0 andand non_master_ab.cash_account_id (+) = ue.ded_account_id and /* CP3 cha

    nged, evicvit */  --non_master_ab.cash_account_id (+) != 0 and --dedicated account /* CP3 changed, evicvit */  ue.usage_event_id = master_ab.usage_event_id (+) and  ue.time_hour_id = master_ab.time_hour_id (+) and

      ue.currency_type = ct.currency_type (+) and -- to get currency code  master_ab.cash_account_id (+) = 0 and --main account  ue.traffic_type_id = tt.traffic_type_id (+) and  ue.ch_category_id = cc.ch_category_id (+) and

    ue.roaming_cat_id = rc.roaming_cat_id (+) and /* TR HH90946 */  ue.tariff_cat_id = tc.tariff_cat_id (+) and  ue.service_class_id = sc.service_class_id (+) and  -- the join between msc and usage  ue.gsm_call_reference_number = msc.gsm_call_reference_number(+) and  ue.served_msisdn = msc.served_msisdn(+) AND

    msc.gsm_call_reference_number(+) IS NOT NULL AND msc.gsm_call_reference_ number (+) > 0 AND  nvl(abs(ue.original_timestamp - msc.answer_time(+)), 0 )

  • 8/18/2019 Dws Data Export Filter Body

    25/146

      aah_1.accumulator_id (+) =1 and  aah_1.time_hour_id(+) >= ue.time_hour_id and  ue.usage_event_id = aah_2.usage_event_id (+) and  aah_2.accumulator_id (+) =2 and  aah_2.time_hour_id(+) >= ue.time_hour_id and  ue.usage_event_id = aah_3.usage_event_id (+) and  aah_3.accumulator_id (+) =3 and  aah_3.time_hour_id(+) >= ue.time_hour_id and  ue.usage_event_id = aah_4.usage_event_id (+) and  aah_4.accumulator_id (+) =4 and  aah_4.time_hour_id(+) >= ue.time_hour_id and  ue.usage_event_id = aah_5.usage_event_id (+) and  aah_5.accumulator_id (+) =5 and  aah_5.time_hour_id(+) >= ue.time_hour_id and  msc.time_hour_id(+) >= m_extra_from_thid and msc.time_hour_id(+) < m_extra_to_thid and  ue.original_timestamp between location_uns.valid_from(+) and location_uns.valid_to(+)  )

    main_query  , (SELECT usage_event_id /* CP3 changes, evicvit START */  , nvl(max(id_1),-1) da_first_id  , nvl(max(id_2),-1) da_second_id  , nvl(max(id_3),-1) da_third_id

      , nvl(max(id_4),-1) da_fourth_id  , nvl(max(id_5),-1) da_fifth_id  , nvl(max(bbe_1),0) da_first_value_before  , nvl(max(bbe_2),0) da_second_value_before  , nvl(max(bbe_3),0) da_third_value_before  , nvl(max(bbe_4),0) da_fourth_value_before  , nvl(max(bbe_5),0) da_fifth_value_before  , nvl(max(bae_1),0) da_first_value_after  , nvl(max(bae_2),0) da_second_value_after  , nvl(max(bae_3),0) da_third_value_after  , nvl(max(bae_4),0) da_fourth_value_after  , nvl(max(bae_5),0) da_fifth_value_after  , nvl(max(campaign_id_1),-1) da_first_campaign_id

      , nvl(max(campaign_id_2),-1) da_second_campaign_id  , nvl(max(campaign_id_3),-1) da_third_campaign_id  , nvl(max(campaign_id_4),-1) da_fourth_campaign_id  , nvl(max(campaign_id_5),-1) da_fifth_campaign_idFROM (SELECT uje.usage_event_id  , case when uje.position = uje_1.position then  uje.cash_account_id  end id_1

    , case when uje.position = uje_1.position + 1 then  uje.cash_account_id  end id_2

    , case when uje.position = uje_1.position + 2 then

      uje.cash_account_id  end id_3

    , case when uje.position = uje_1.position + 3 then  uje.cash_account_id  end id_4

    , case when uje.position = uje_1.position + 4 then  uje.cash_account_id  end id_5  , case when uje.position = uje_1.position then  uab.balance_before_event

  • 8/18/2019 Dws Data Export Filter Body

    26/146

      end bbe_1  , case when uje.position = uje_1.position + 1 then  uab.balance_before_event  end bbe_2  , case when uje.position = uje_1.position + 2 then  uab.balance_before_event  end bbe_3  , case when uje.position = uje_1.position + 3 then  uab.balance_before_event  end bbe_4  , case when uje.position = uje_1.position + 4 then  uab.balance_before_event  end bbe_5  , case when uje.position = uje_1.position then  uab.balance_after_event  end bae_1  , case when uje.position = uje_1.position + 1 then  uab.balance_after_event  end bae_2  , case when uje.position = uje_1.position + 2 then  uab.balance_after_event  end bae_3  , case when uje.position = uje_1.position + 3 then  uab.balance_after_event

      end bae_4  , case when uje.position = uje_1.position + 4 then  uab.balance_after_event  end bae_5  , case when uje.position = uje_1.position then  uje.campaign_id  end campaign_id_1  , case when uje.position = uje_1.position + 1 then  uje.campaign_id  end campaign_id_2  , case when uje.position = uje_1.position + 2 then  uje.campaign_id  end campaign_id_3

      , case when uje.position = uje_1.position + 3 then  uje.campaign_id  end campaign_id_4  , case when uje.position = uje_1.position + 4 then  uje.campaign_id  end campaign_id_5FROM

    (  SELECT rownum position, usage_event_id, cash_account_id, campaign_id FROM(  SELECT /*+ parallel(uje,5) */usage_event_id, cash_account_id, amount, campaign_id  FROM usage_journal_entries uje

      WHERE account_id > 0 AND (cash_account_id > 0) AND time_hour_id >= p _from_time_hour_id and time_hour_id < p_to_time_hour_id  ORDER BY usage_event_id)  ) uje,

    (  SELECT min(rn) position, usage_event_id FROM (  SELECT rownum rn, usage_event_id FROM(  SELECT /*+ parallel(uje,5) */usage_event_id  FROM usage_journal_entries uje  WHERE account_id > 0 AND (cash_account_id > 0) AND time_ 

  • 8/18/2019 Dws Data Export Filter Body

    27/146

    hour_id >= p_from_time_hour_id and time_hour_id < p_to_time_hour_id  ORDER BY usage_event_id)  )  GROUP BY usage_event_id  ) uje_1,  usg_account_balances uab  WHERE uje.usage_event_id = uje_1.usage_event_id  AND uab.usage_event_id = uje.usage_event_id  AND uab.time_hour_id >= p_from_time_hour_id and uab.time_hour_id < p_to

     _time_hour_id  AND uab.account_id > 0

    AND uab.cash_account_id = uje.cash_account_id)GROUP BY usage_event_id) uda /* CP3 changes, evicvit END */  ,subscribers s  ,subscribers master_s  ,( select /*+ parallel(master_ma,6) */ subscriber_id, msisdn, allocation_end

     _time_utc,  row_number() over (partition by subscriber_id order by allocation_end_time_utc desc) row_num  from msisdn_allocations) master_ma  ,subscribers_change_log scl  ,accounts_change_log acl  ,homes h

      ,msisdn_allocations ma  ,service_classes s_c /* HH70012*/  where  uda.usage_event_id (+) = main_query.usage_event_id /* CP3 changed, evicvit*/  and scl.home_id = h.home_id /* CP3 changed, evicvit*/  and scl.subscriber_id = ma.subscriber_id  and scl.valid_from_utc utc_timestamp  and acl.valid_from_utc utc_timestamp  and acl.account_id = ma.account_id  and acl.service_class_id = s_c.service_class_id (+) /* HH70012*/  and served_msisdn = ma.msisdn

      and served_subscriber_id = ma.subscriber_id  and ma.allocation_start_time_utc < utc_timestamp  and (ma.allocation_end_time_utc >= utc_timestamp or ma.allocation_end_time_ utc is null)

    and s.account_id=master_s.account_id  and master_s.subscriber_type='M'  and master_s.subscriber_id=master_ma.subscriber_id

    and s.subscriber_id=ma.subscriber_id  and master_ma.row_num=1;

      dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export usage step1 finished. Extracted ' || sql%rowcount);

    commit;

     

    /**step 2

    **/ 

    insert /*+ append */ into wrk_de_usage_stgselect /*+ parallel(master_s,6) parallel(s,6) parallel(scl,6) parallel(acl

    ,6) parallel(ma,6) */  mod(s.subscriber_id,5)

  • 8/18/2019 Dws Data Export Filter Body

    28/146

      ,main_query.tele_service_code  ,main_query.tele_service_name  ,main_query.traffic_direction  ,main_query.traffic_case_name  ,main_query.service_class  ,main_query.original_timestamp  ,main_query.utc_timestamp  ,main_query.dws_creation_date  ,main_query.time_hour_id  ,main_query.called_number  ,main_query.duration  ,main_query.volume  ,main_query.number_of_events  ,main_query.main_acc_bef_call  ,main_query.ded_acc_bef_call  ,main_query.main_acc_aft_call  ,main_query.ded_acc_aft_call  ,main_query.cost  ,main_query.currency_code  ,main_query.da_account_id  ,main_query.served_msisdn  ,master_ma.msisdn  ,

    decode(h.home_level_1,

      null, 'Unknown',  'Undefined', 'Unknown',  decode(h.home_level_2,  null, h.home_level_1,  decode(h.home_level_3,  null, h.home_level_1 || ' ,' ||h.home_level_2 ,  h.home_level_1 || ' ,' ||h.home_level_2 || ' ,' ||h.home_level_3 ))) home_city  ,acl.account_status  ,main_query.imsi  ,main_query.imei  ,main_query.originating_cell_id  ,main_query.terminating_cell_id

      ,main_query.faf_indicator  ,main_query.location_city  ,main_query.location_country  ,main_query.location_region  ,main_query.location_region_code  ,main_query.location_time_zone_region  ,main_query.accumulator_1  ,main_query.accumulator_2  ,main_query.accumulator_3  ,main_query.accumulator_4  ,main_query.accumulator_5  ,main_query.ch_category_name  ,main_query.credit_duration

      ,main_query.debit_duration  ,main_query.free_duration  ,main_query.tariff_name  ,main_query.additional_fee  ,main_query.da_first_id /* CP3 changes, evicvit START */  ,main_query.da_first_value_before  ,main_query.da_first_value_after  ,main_query.da_first_campaign_id  ,main_query.da_second_id  ,main_query.da_second_value_before

  • 8/18/2019 Dws Data Export Filter Body

    29/146

      ,main_query.da_second_value_after  ,main_query.da_second_campaign_id  ,main_query.da_third_id  ,main_query.da_third_value_before  ,main_query.da_third_value_after  ,main_query.da_third_campaign_id  ,main_query.da_fourth_id  ,main_query.da_fourth_value_before  ,main_query.da_fourth_value_after  ,main_query.da_fourth_campaign_id  ,main_query.da_fifth_id  ,main_query.da_fifth_value_before  ,main_query.da_fifth_value_after  ,main_query.da_fifth_campaign_id /* CP3 changes, evicvit END */  ,main_query.non_charged_subscriber_number --JPN107(etkzoci)  ,main_query.roaming_cat_name --TRHH90946  from  (  select  tt.tele_service_code tele_service_code  , tt.tele_service_name tele_service_name  , tt.traffic_direction traffic_direction  , tt.traffic_case_name traffic_case_name  , null service_class

      , answer_time original_timestamp  , utc_answer_time utc_timestamp  , dws_creation_date dws_creation_date  , time_hour_id time_hour_id  , called_number called_number  , call_duration duration  , 0 volume  , e_number_of_sms number_of_events  , 0 main_acc_bef_call  , 0 ded_acc_bef_call  , 0 main_acc_aft_call  , 0 ded_acc_aft_call  , 0 cost

      , '' currency_code, -1 da_account_id, served_msisdn served_msisdn

      , served_imsi imsi  , served_imei imei  , first_cell_identity originating_cell_id  , last_cell_identity terminating_cell_id  , -1 faf_indicator  , location_uns.city location_city  , location_uns.country location_country  , location_uns.region location_region  , location_uns.region_code location_region_code  , location_uns.time_zone_region location_time_zone_region

    , 0 accumulator_1  , 0 accumulator_2  , 0 accumulator_3  , 0 accumulator_4  , 0 accumulator_5  , cc.ch_category_name ch_category_name -- service_type  , 0 credit_duration  , 0 debit_duration  , 0 free_duration  , tc.tariff_cat_name tariff_name

  • 8/18/2019 Dws Data Export Filter Body

    30/146

      , 0 additional_fee  ,-1 da_first_id /* CP3 changes, evicvit START */  ,0 da_first_value_before  ,0 da_first_value_after  ,-1 da_first_campaign_id  ,-1 da_second_id  ,0 da_second_value_before  ,0 da_second_value_after  ,-1 da_second_campaign_id  ,-1 da_third_id  ,0 da_third_value_before  ,0 da_third_value_after  ,-1 da_third_campaign_id  ,-1 da_fourth_id  ,0 da_fourth_value_before  ,0 da_fourth_value_after  ,-1 da_fourth_campaign_id  ,-1 da_fifth_id  ,0 da_fifth_value_before  ,0 da_fifth_value_after  ,-1 da_fifth_campaign_id /* CP3 changes,evicvit END */  ,msc_without_usage.non_charged_subscriber_number non_charged_subscrib

    er_number --JPN107(etkzoci)  ,rc.roaming_cat_name roaming_cat_name ----TRHH90946  from  (  select * from  (  select /*+ parallel(ue,6) parallel(me,6) */  me.answer_time,

    me.utc_answer_time,  me.dws_creation_date,  me.time_hour_id,  me.called_number,  me.call_duration,

      me.e_number_of_sms,  me.served_msisdn,  me.called_number_ns_id,

    me.ch_category_id,me.tariff_cat_id,

      me.traffic_type_id,  me.last_cell_identity,  me.first_cell_identity,  me.served_imei,  me.served_imsi,  nvl(ue.usage_event_id, -1) usage_event_id,  me.non_charged_subscriber_number, --JPN107(etkzoci)  me.roaming_cat_id, /* TR HH90946 */

      me.LOCATION_NUMBER_NS_IDfromusage_events ue,

      msc_events me ,NUMBER_RANGE_CRS_MAP_TEMP nrm

    where  me.time_hour_id >= p_from_time_hour_id

    and me.time_hour_id < p_to_time_hour_id  and me.served_msisdn >= nrm.MSISDN_RANGE_START

    and me.served_msisdn < nrm.MSISDN_RANGE_END

  • 8/18/2019 Dws Data Export Filter Body

    31/146

    and nrm.FROM_DATE_UTC < me.UTC_ANSWER_TIMEand nrm.TO_DATE_UTC >= me.UTC_ANSWER_TIME

      and me.served_msisdn = ue.served_msisdn(+)  and me.gsm_call_reference_number = ue.gsm_call_reference_number(+)  -- greater timespan because of late arrivals  and ue.time_hour_id(+) >= m_extra_from_thid and ue.time_hour_id(+) < m_extra_to_thid

    and ue.gsm_call_reference_number(+) > 0  )

    all_msc  where usage_event_id = -1 -- only keep msc events that has no usage event  ) msc_without_usage

    ,traffic_types tt  ,tariff_categories tc  ,charging_categories cc

    ,roaming_categories rc /* TR HH90946 */,usage_number_series location_uns

      wheremsc_without_usage.traffic_type_id = tt.traffic_type_id (+)

      and msc_without_usage.tariff_cat_id = tc.tariff_cat_id (+)and msc_without_usage.ch_category_id = cc.ch_category_id (+)

    and msc_without_usage.roaming_cat_id = rc.roaming_cat_id (+) /* TR HH90946 */

      and location_uns.usa_ns_id (+) = msc_without_usage.location_number_ns_id and utc_answer_time between location_uns.valid_from(+) and location_uns.

    valid_to(+)  )

    main_query  ,subscribers s  ,subscribers master_s  ,( select /*+ parallel(master_ma,6) */ subscriber_id, msisdn, allocation_end

     _time_utc,  row_number() over (partition by subscriber_id order by allocation_end_time_utc desc) row_num  from msisdn_allocations) master_ma

    ,subscribers_change_log scl  ,accounts_change_log acl  ,homes h  ,msisdn_allocations ma  where  scl.home_id = h.home_id  and scl.subscriber_id = ma.subscriber_id  and scl.valid_from_utc utc_timestamp  and acl.valid_from_utc utc_timestamp  and acl.account_id = ma.account_id  and served_msisdn = ma.msisdn

      and ma.allocation_start_time_utc < utc_timestamp  and (ma.allocation_end_time_utc >= utc_timestamp or ma.allocation_end_time_ utc is null)

    and s.account_id=master_s.account_id  and master_s.subscriber_type='M'  and master_s.subscriber_id=master_ma.subscriber_id

    and s.subscriber_id=ma.subscriber_id  and master_ma.row_num=1; 

    dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export usage step

  • 8/18/2019 Dws Data Export Filter Body

    32/146

    2 finished. '|| 'Extracted ' || sql%rowcount);

    commit; 

    dbms_application_info.set_module(module_name => null,  action_name => null); 

    dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export usage to stage finished.');

    end export_usage_for_thid;

    ------------------------------------------------------------------- procedure: export_adjm_static-- purpose: wrapper function for export_adjm_static_for_thid to handle conversions of dates to thids (time_hour_id:s)-----------------------------------------------------------------PROCEDURE export_adjm_static(  p_from_time VARCHAR2

    , p_to_time VARCHAR2  , p_date_format VARCHAR2

     , type VARCHAR2)ISBEGIN

      log_time_info(p_from_time, p_to_time, p_date_format); 

    export_adjm_static_for_thid(  Dws_Time.date2thid(Dws_Time.get_utc_from_financialtime(TO_DATE(p_from_time, p_date_format)))  , Dws_Time.date2thid(Dws_Time.get_utc_from_financialtime(TO_DATE(p_to_time, p_date_format)))

      ,type);

    END; ------------------------------------------------------------------- procedure: export_adjm_static_for_thid-- purpose: export adjm data for given time interval (in time_hour_id) to staging table-----------------------------------------------------------------PROCEDURE export_adjm_static_for_thid(  p_from_time_hour_id USAGE_EVENTS.time_hour_id%TYPE,

    p_to_time_hour_id USAGE_EVENTS.time_hour_id%TYPE,  type VARCHAR2)

    IS

    m_extra_from_thid USAGE_EVENTS.time_hour_id%TYPE;  m_extra_to_thid USAGE_EVENTS.time_hour_id%TYPE;

      ic_inclusion_flag_boolean BOOLEAN;  ic_inclusion_flag NUMBER(1);

      sfd_inclusion_flag_boolean BOOLEAN;  sfd_inclusion_flag NUMBER(1);

     BEGIN

    /*

  • 8/18/2019 Dws Data Export Filter Body

    33/146

      increase the timespan for usage events by 1 day in the beginning at and the end.  sometimes usage and msc events for the same call can differ some seconds in time.  by adding an extra day we can take care of this but still use partition pruning.

    */  m_extra_from_thid := Dws_Time.move_thid_days(p_from_time_hour_id,-1);  m_extra_to_thid := Dws_Time.move_thid_days(p_to_time_hour_id,1);

     /*Initial Credit DE inclusion flag*/  ic_inclusion_flag_boolean := dws_config.get_boolean_value(dws_constan

    ts.adjm_ic_inclusion);  IF ic_inclusion_flag_boolean = TRUE

      THEN ic_inclusion_flag := 1;  ELSE ic_inclusion_flag := 0;

      END IF;

    /*SFD inclusion flag*/sfd_inclusion_flag_boolean := dws_config.get_boolean_value(dws_constants

    .adj_sfd_inclusion);  IF sfd_inclusion_flag_boolean = TRUE  THEN sfd_inclusion_flag := 1;  ELSE sfd_inclusion_flag := 0;

      END IF;

     dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export adjm (CS4

    0) details to stage for period: ' || p_from_time_hour_id || ' - ' || p_to_time_hour_id);

    dbms_application_info.set_module(module_name => 'dws_data_export',  action_name => 'export_adjm_static start'); 

    --EXECUTE IMMEDIATE 'alter session enable parallel dml';

    IF TYPE='S' THEN 

    EXECUTE IMMEDIATE 'truncate table wrk_de_adjm_static_stg'; 

    dws_logging.logevent(p_event_code => 2022, p_add_txt => 'Truncate table for adjm stat static export finished');

    INSERT /*+APPEND*/ INTO WRK_DE_ADJM_STATIC_STG(EVENT_ID, MASTER_SUBSCRIBER_ID, MASTER_MSISDN, SUBSCRIBER_ID,MSISDN, SERVICE_CLASS_ID, TRANSACTION_CODE, ORIGINAL_TIMESTAMP,CURRENCY_CODE, MA_AMOUNT, MA_ACTION, OPERATOR_ID,

    JOURNAL_TYPE, TIME_HOUR_ID, UTC_TIMESTAMP, DWS_CREATION_DATE,ORIGIN_NODE_ORIGINAL_TIMESTAMP, LOCAL_TIMESTAMP, ORIGINAL_TRANSACTION_ID, TOTA

    L_AMOUNT,ORIGINAL_NODE_ID, MARKET_ID)

     SELECTSTAT.ACCOUNT_EVENT_ID,MM.SUBSCRIBER_ID MASTER_SUBSCRIBER_ID,MM.MSISDN MASTER_MSISDN,BASE_DATA.SUBSCRIBER_ID SUBSCRIBER_ID,BASE_DATA.MSISDN,STAT.SERVICE_CLASS_ID,STAT.TRANSACTION_CODE ADJUSTMENT_CODE,STAT.ORIGINAL_TIMESTAMP,BASE_DATA.CURRENCY_CODE,BASE_DATA.MA_AMOUNT,BASE_DATA.MA_ACTION,STAT.CSO_USERNAM

  • 8/18/2019 Dws Data Export Filter Body

    34/146

    E,BASE_DATA.JOURNAL_TYPE_ID,STAT.TIME_HOUR_ID,STAT.UTC_TIMESTAMP,STAT.DWS_CREATION

     _DATE,STAT.ORGIN_NODE_ORIGINAL_TIMESTAMP,STAT.local_TIMESTAMP AS ADJUSTMENT_DATE,STAT.ORIGINAL_TRANSACTION_ID,BASE_DATA.TOTAL_AMOUNT,STAT.ORIGINAL_NODE_ID,STAT.MARKET_ID FROM(SELECT /*+ PARALLEL (SDP_JRN,4) PARALLEL (AIR_JRN,4),PARALLEL (MA,4) parallel(csa,4)*/  MA.MSISDN,  MA.SUBSCRIBER_ID,SDP_JRN.ACCOUNT_EVENT_ID,

      NVL(AIR_JRN.AIR_JOURNAL_TYPE_ID,SDP_JRN.JOURNAL_TYPE_ID) JOURNAL_TYPE_ID,  CT.CURRENCY_CODE,  SUM(CASE WHEN SDP_JRN.CASH_ACCOUNT_ID=0 THEN SDP_JRN.AMOUNT ELSE 0 END) MA_AMOUNT,  MAX(CASE WHEN SDP_JRN.CASH_ACCOUNT_ID=0 THEN DECODE(ADJUSTMENT_ACTION,0,'Set',1,'Add',2,'Sub','Add') END) MA_ACTION,  SUM(SDP_JRN.AMOUNT) TOTAL_AMOUNTFROMSDP_JOURNAL_ENTRIES SDP_JRN,

      AIR_JOURNAL_ENTRIES AIR_JRN,  (select ma.msisdn,

      ma.account_id,  ma.allocation_start_time_utc,  ma.allocation_end_time_utc,  ma.subscriber_id,  row_number() over (partition by ma.subscriber_id order by ma.allocation_ start_time_utc desc) rno  from msisdn_allocations ma) MA,  CURRENCY_TYPES CT,  CRS_SUBSCRIBER_ALLOCATIONS csa where

    csa.subscriber_id = SDP_JRN.account_idand csa.START_TIME_UTC < SDP_JRN.UTC_TIMESTAMPand csa.END_TIME_UTC >= SDP_JRN.UTC_TIMESTAMP

      AND SDP_JRN.ACCOUNT_ID=MA.ACCOUNT_ID  AND SDP_JRN.ACCOUNT_EVENT_ID=AIR_JRN.ACCOUNT_EVENT_ID(+)  AND sdp_jrn.time_hour_id = air_jrn.time_hour_id(+)  AND SDP_JRN.CASH_ACCOUNT_ID = AIR_JRN.CASH_ACCOUNT_ID(+)  AND MA.RNO=1  AND ma.ALLOCATION_START_TIME_UTC sdp_jrn.UTC_TIMESTAMP  AND (NVL(AIR_JRN.AIR_JOURNAL_TYPE_ID,SDP_JRN.JOURNAL_TYPE_ID)=7

    OR sdp_jrn.JOURNAL_TYPE_ID=DECODE(ic_inclusion_flag,1,1,0) -- Initial Credit Inclusion

      OR sdp_jrn.JOURNAL_TYPE_ID=DECODE(sfd_inclusion_flag,1,4,0)) -- SFD Inclusion  AND SDP_JRN.TIME_HOUR_ID >= p_from_time_hour_id

      AND SDP_JRN.TIME_HOUR_ID < p_to_time_hour_id  AND AIR_JRN.TIME_HOUR_ID (+) >= p_from_time_hour_id  AND AIR_JRN.TIME_HOUR_ID (+) < p_to_time_hour_id  AND SDP_JRN.CURRENCY_TYPE=CT.CURRENCY_TYPE(+)  GROUP BY

    SDP_JRN.ACCOUNT_EVENT_ID,  NVL(AIR_JRN.AIR_JOURNAL_TYPE_ID,SDP_JRN.JOURNAL_TYPE_ID),  MA.MSISDN,  MA.SUBSCRIBER_ID,  CT.CURRENCY_CODE ) BASE_DATA,

  • 8/18/2019 Dws Data Export Filter Body

    35/146

    ( SELECT /*+ PARALLEL (SDP_ACC,4) PARALLEL (SCL,4)*/  SDP_ACC.ACCOUNT_EVENT_ID,  SDP_ACC.UTC_TIMESTAMP,  SDP_ACC.SERVICE_CLASS_ID,  TT.TRANSACTION_CODE,  CSO.CSO_USERNAME,  SDP_ACC.TIME_HOUR_ID,  SDP_ACC.DWS_CREATION_DATE,  SDP_ACC.ORGIN_NODE_ORIGINAL_TIMESTAMP,  SDP_ACC.ORIGINAL_TIMESTAMP,  SDP_ACC.ORIGINAL_TRANSACTION_ID,  SDP_ACC.ORIGINAL_NODE_ID,  sdp_acc.local_timestamp,  SCL.MARKET_ID  FROMSDP_ACCOUNT_EVENTS SDP_ACC,

      SUBSCRIBERS_CHANGE_LOG SCL,  TRANSACTION_TYPES TT,  CUSTOMER_SERVICE_OPERATORS CSO  WHERESDP_ACC.TIME_HOUR_ID >= p_from_time_hour_id

      AND SDP_ACC.TIME_HOUR_ID 2022, p_add_txt => 'export adjm stat (CS40) details finished. '|| 'Extracted ' || SQL%rowcount);

    COMMIT; 

    ELSIF TYPE='D' THEN

    EXECUTE IMMEDIATE 'truncate table wrk_de_adjm_da_stg'; 

    dws_logging.logevent(p_event_code => 2022, p_add_txt => 'Truncate table for adjm da (CS40) export finished');

    INSERT /*+APPEND*/ INTO WRK_DE_ADJM_DA_STG(EVENT_ID, DA_ID, CAMPAIGN_ID, DA_AMOUNT,DA_ACTION, JOURNAL_TYPE, MARKET_ID, TIME_HOUR_ID)SELECT /*+ PARALLEL (SDP_JRN,4) PARALLEL (AIR_JRN,4), PARALLEL (MA,4),PARALLEL (

  • 8/18/2019 Dws Data Export Filter Body

    36/146

    SCL,4) parallel(csa,4)*/  SDP_JRN.ACCOUNT_EVENT_ID,  SDP_JRN.CASH_ACCOUNT_ID,  SDP_JRN.CAMPAIGN_ID,  SDP_JRN.AMOUNT,  DECODE(ADJUSTMENT_ACTION,0,'Set',1,'Add',2,'Sub','Add') DA_ACTION,NVL(AIR_JRN.AIR_JOURNAL_TYPE_ID,SDP_JRN.JOURNAL_TYPE_ID) JOURNAL_TYPE_ID, SCL.MARKET_ID , SDP_JRN.TIME_HOUR_ID  FROMSDP_JOURNAL_ENTRIES SDP_JRN,

      AIR_JOURNAL_ENTRIES AIR_JRN,  MSISDN_ALLOCATIONS MA,  SUBSCRIBERS_CHANGE_LOG SCL,  CRS_SUBSCRIBER_ALLOCATIONS csa where

    csa.subscriber_id = SDP_JRN.account_idand csa.START_TIME_UTC < SDP_JRN.UTC_TIMESTAMPand csa.END_TIME_UTC >= SDP_JRN.UTC_TIMESTAMP

      and SDP_JRN.ACCOUNT_ID=ma.ACCOUNT_ID  AND MA.SUBSCRIBER_ID=SCL.SUBSCRIBER_IDAND SDP_JRN.ACCOUNT_EVENT_ID=AIR_JRN.ACCOUNT_EVENT_ID(+)

      AND SDP_JRN.CASH_ACCOUNT_ID = AIR_JRN.CASH_ACCOUNT_ID(+)  AND sdp_jrn.time_hour_id = air_jrn.time_hour_id(+)

      AND SDP_JRN.CASH_ACCOUNT_ID>0  AND (NVL(AIR_JRN.AIR_JOURNAL_TYPE_ID,SDP_JRN.JOURNAL_TYPE_ID)=7OR sdp_jrn.JOURNAL_TYPE_ID=DECODE(ic_inclusion_flag,1,1,0) -- Initial

    Credit Inclusion  OR sdp_jrn.JOURNAL_TYPE_ID=DECODE(sfd_inclusion_flag,1,4,0)) -- SFD In

    clusion  AND ma.ALLOCATION_START_TIME_UTC sdp_jrn.UTC_TIMESTAMP  AND VALID_FROM_UTC=sdp_jrn.UTC_TIMESTAMP  AND SDP_JRN.TIME_HOUR_ID >= p_from_time_hour_id  AND SDP_JRN.TIME_HOUR_ID < p_to_time_hour_id  AND AIR_JRN.TIME_HOUR_ID (+) >= p_from_time_hour_id

      AND AIR_JRN.TIME_HOUR_ID (+) < p_to_time_hour_id;

      dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export ADJM DA (CS40) details finished. '|| 'Extracted ' || SQL%rowcount);

    COMMIT; 

    dbms_application_info.set_module(module_name => NULL,  action_name => NULL); 

    dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export adjm (CS40) to stage finished.');

     

    END IF;

    END export_adjm_static_for_thid;

    -- Added by ealphan for CRS 4.1 Backward Compatibility------------------------------------------------------------------- procedure: export_adjm

  • 8/18/2019 Dws Data Export Filter Body

    37/146

    -- purpose: wrapper function for export_adjm_for_thid to handle conversions ofdates to thids (time_hour_id:s)-----------------------------------------------------------------procedure export_adjm(  p_from_time varchar2  , p_to_time varchar2  , p_date_format varchar2)isbegin

      log_time_info(p_from_time, p_to_time, p_date_format);

      export_adjm_for_thid(  dws_time.date2thid(dws_time.get_utc_from_financialtime(to_date(p_from_time, p_date_format)))  , dws_time.date2thid(dws_time.get_utc_from_financialtime(to_date(p_to_time, p_date_format))));

    end;

    ------------------------------------------------------------------- procedure: export_adjm_for_thid-- purpose: export adjm data for given time interval (in time_hour_id) to stagi

    ng table wrk_de_adjm_stg-----------------------------------------------------------------procedure export_adjm_for_thid(  p_from_time_hour_id varchar2,  p_to_time_hour_id varchar2)is  ic_inclusion_flag_boolean boolean;  ic_inclusion_flag number(1);  m_air_from_thid air_account_events.time_hour_id%type;  m_air_to_thid air_account_events.time_hour_id%type;  from_thid_to_date date;  to_thid_to_date date; 

    begin

      dbms_application_info.set_module(module_name => 'dws_data_export',  action_name => 'export_adjm');

      execute immediate 'truncate table wrk_de_adjm_stg';

      dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export adjm to stage for period: ' || p_from_time_hour_id || ' - ' || p_to_time_hour_id);

     /*Initial Credit DE inclusion flag*/

      ic_inclusion_flag_boolean := dws_config.get_boolean_value(dws_constants.adjm_ic_inclusion);

      if ic_inclusion_flag_boolean = TRUE  then ic_inclusion_flag := 1;  else ic_inclusion_flag := 0;  end if;

      m_air_from_thid := dws_time.move_thid_days(p_from_time_hour_id,-1);  m_air_to_thid := dws_time.move_thid_days(p_to_time_hour_id,1);

     from_thid_to_date :=dws_time.thid2date(p_from_time_hour_id); to_thid_to_date :=dws_time.thid2date(p_to_time_hour_id);

  • 8/18/2019 Dws Data Export Filter Body

    38/146

      insert /*+ append */  into wrk_de_adjm_stg  SELECT base_data.msisdn,  BASE_DATA.SERVICE_CLASS_ID,  BASE_DATA.TOTAL_AMOUNT,  MA_AMOUNT,  DA1_AMOUNT,  DA2_AMOUNT,  DA3_AMOUNT,  DA4_AMOUNT,  DA5_AMOUNT,  DA6_AMOUNT,  DA7_AMOUNT,  DA8_AMOUNT,  DA9_AMOUNT,  DA10_AMOUNT,  DA1_ACTION,  DA2_ACTION,  DA3_ACTION,  DA4_ACTION,  DA5_ACTION,  DA6_ACTION,  DA7_ACTION,  DA8_ACTION,

      DA9_ACTION,  DA10_ACTION,  CURRENCY_TYPE,  scl.market_id,  base_data.subscriber_id,  cso.CSO_USERNAME,-- dws_time.Get_Financialtime_From_UTC(sdp_acc.UTC_TIMESTAMP) adjustment_date,  sdp_acc.local_timestamp adjustment_date,

    sdp_acc.ORIGINAL_TRANSACTION_ID,  sdp_acc.ORIGINAL_NODE_ID  FROM (SELECT /*+ PARALLEL (SDP_JRN,6) PARALLEL (AIR_JRN,6) parallel(csa,4)*/

      ma.MSISDN,  SDP_JRN.ACCOUNT_EVENT_ID,  SDP_JRN.ACCOUNT_ID,  SDP_JRN.SERVICE_CLASS_ID,  SUM(NVL(SDP_JRN.AMOUNT, 0)) TOTAL_AMOUNT,  SUM(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 0 THEN  NVL(SDP_JRN.AMOUNT, 0)  ELSE  0  END) MA_AMOUNT,  SUM(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 1 THEN

      NVL(SDP_JRN.AMOUNT, 0)  ELSE  0  END) DA1_AMOUNT,  SUM(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 2 THEN  NVL(SDP_JRN.AMOUNT, 0)  ELSE  0  END) DA2_AMOUNT,

  • 8/18/2019 Dws Data Export Filter Body

    39/146

      SUM(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 3 THEN  NVL(SDP_JRN.AMOUNT, 0)  ELSE  0  END) DA3_AMOUNT,  SUM(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 4 THEN  NVL(SDP_JRN.AMOUNT, 0)  ELSE  0  END) DA4_AMOUNT,  SUM(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 5 THEN  NVL(SDP_JRN.AMOUNT, 0)  ELSE  0  END) DA5_AMOUNT,  SUM(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 6 THEN  NVL(SDP_JRN.AMOUNT, 0)  ELSE  0  END) DA6_AMOUNT,

      SUM(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 7 THEN  NVL(SDP_JRN.AMOUNT, 0)  ELSE  0  END) DA7_AMOUNT,  SUM(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 8 THEN  NVL(SDP_JRN.AMOUNT, 0)  ELSE  0  END) DA8_AMOUNT,  SUM(CASE

      WHEN SDP_JRN.CASH_ACCOUNT_ID = 9 THEN  NVL(SDP_JRN.AMOUNT, 0)  ELSE  0  END) DA9_AMOUNT,  SUM(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 10 THEN  NVL(SDP_JRN.AMOUNT, 0)  ELSE  0  END) DA10_AMOUNT,  MAX(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 1 THEN

      DECODE(ADJUSTMENT_ACTION,  0,  'Set',  1,  'Add',  2,  'Sub',  'Add')  END) DA1_ACTION,  MAX(CASE

  • 8/18/2019 Dws Data Export Filter Body

    40/146

      WHEN SDP_JRN.CASH_ACCOUNT_ID = 2 THEN  DECODE(ADJUSTMENT_ACTION,  0,  'Set',  1,  'Add',  2,  'Sub',  'Add')  END) DA2_ACTION,  MAX(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 3 THEN  DECODE(ADJUSTMENT_ACTION,  0,  'Set',  1,  'Add',  2,  'Sub',  'Add')  END) DA3_ACTION,  MAX(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 4 THEN  DECODE(ADJUSTMENT_ACTION,

      0,  'Set',  1,  'Add',  2,  'Sub',  'Add')  END) DA4_ACTION,  MAX(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 5 THEN  DECODE(ADJUSTMENT_ACTION,  0,  'Set',

      1,  'Add',  2,  'Sub',  'Add')  END) DA5_ACTION,  MAX(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 6 THEN  DECODE(ADJUSTMENT_ACTION,  0,  'Set',  1,  'Add',

      2,  'Sub',  'Add')  END) DA6_ACTION,  MAX(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 7 THEN  DECODE(ADJUSTMENT_ACTION,  0,  'Set',  1,

  • 8/18/2019 Dws Data Export Filter Body

    41/146

      'Add',  2,  'Sub',  'Add')  END) DA7_ACTION,  MAX(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 8 THEN  DECODE(ADJUSTMENT_ACTION,  0,  'Set',  1,  'Add',  2,  'Sub',  'Add')  END) DA8_ACTION,  MAX(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 9 THEN  DECODE(ADJUSTMENT_ACTION,  0,  'Set',  1,  'Add',  2,

      'Sub',  'Add')  END) DA9_ACTION,  MAX(CASE  WHEN SDP_JRN.CASH_ACCOUNT_ID = 10 THEN  DECODE(ADJUSTMENT_ACTION,  0,  'Set',  1,  'Add',  2,  'Sub',  'Add')

      END) DA10_ACTION,  CURRENCY_TYPE,  ma.SUBSCRIBER_ID  FROM SDP_JOURNAL_ENTRIES SDP_JRN,  AIR_JOURNAL_ENTRIES AIR_JRN,  (select ma.msisdn,  ma.account_id,  ma.allocation_start_time_utc,

      ma.allocation_end_time_utc,  ma.subscriber_id,  row_number() over (partition by ma.subscriber_id order by

    ma.allocation_start_time_utc desc) rno  from msisdn_allocations ma) MA,

      CRS_SUBSCRIBER_ALLOCATIONS csa  where

    csa.subscriber_id = SDP_JRN.account_idand csa.START_TIME_UTC < SDP_JRN.UTC_TIMESTAMPand csa.END_TIME_UTC >= SDP_JRN.UTC_TIMESTAMPand SDP_JRN.ACCOUNT_ID = ma.ACCOUNT_ID

      and SDP_JRN.ACCOUNT_EVENT_ID = AIR_JRN.ACCOUNT_EVENT_ID(+)  and SDP_JRN.CASH_ACCOUNT_ID = AIR_JRN.CASH_ACCOUNT_ID(+)

      AND sdp_jrn.time_hour_id = air_jrn.time_hour_id(+)  AND (NVL(AIR_JRN.AIR_JOURNAL_TYPE_ID,

  • 8/18/2019 Dws Data Export Filter Body

    42/146

      SDP_JRN.JOURNAL_TYPE_ID) = 7 or  sdp_jrn.JOURNAL_TYPE_ID =  decode(ic_inclusion_flag, 1, 1, 0)) -- Initial CreditInclusion  AND ma.ALLOCATION_START_TIME_UTC = sdp_jrn.UTC_TIMESTAMP

      AND ma.rno=1  AND SDP_JRN.TIME_HOUR_ID >= p_from_time_hour_id  AND SDP_JRN.TIME_HOUR_ID < p_to_time_hour_id  AND AIR_JRN.TIME_HOUR_ID(+) >= p_from_time_hour_id  AND AIR_JRN.TIME_HOUR_ID(+) = p_from_time_hour_id  AND sdp_acc.TIME_HOUR_ID < p_to_time_hour_id) sdp_acc,

      (SELECTCSO_ID,CSO_USERNAME

    FROM CUSTOMER_SERVICE_OPERATORS) cso  WHERE BASE_DATA.SUBSCRIBER_ID = SCL.SUBSCRIBER_ID  and base_data.account_event_id = sdp_acc.ACCOUNT_EVENT_ID  and sdp_acc.CSO_ID=cso.CSO_ID(+);

     commit;

      dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export adjm to stagefinished');

      dbms_application_info.set_module(module_name => null,  action_name => null);

    end export_adjm_for_thid;

    ----------------------------------------------------------------

    -- procedure: export_pre-- purpose: wrapper function for export_pre_for_thid to handle conversions of dates to thids (time_hour_id:s)-----------------------------------------------------------------procedure export_pre(  p_from_time varchar2  , p_to_time varchar2  , p_date_format varchar2)isbegin

  • 8/18/2019 Dws Data Export Filter Body

    43/146

      log_time_info(p_from_time, p_to_time, p_date_format);

      export_pre_for_thid(  dws_time.date2thid(dws_time.get_utc_from_financialtime(to_date(p_from_time, p_date_format)))  , dws_time.date2thid(dws_time.get_utc_from_financialtime(to_date(p_to_time, p_date_format))));

    end;

    ------------------------------------------------------------------- procedure: export_pre_for_thid-- purpose: export prepaid recharge data for given time interval (in time_hour_ id) to staging table wrk_de_pre_stg-----------------------------------------------------------------procedure export_pre_for_thid(  p_from_time_hour_id varchar2,  p_to_time_hour_id varchar2)is

    --m_air_from_thid air_account_events.time_hour_id%type;--m_air_to_thid air_account_events.time_hour_id%type;

    from_thid_to_date date;to_thid_to_date date;

    begin

      dbms_application_info.set_module(module_name => 'dws_data_export',  action_name => 'export_pre');

      execute immediate 'truncate table wrk_de_pre_stg';

      dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export pre to stage for period: ' || p_from_time_hour_id || ' - ' || p_to_time_hour_id);

    /*  increase the timespan for sdp events by 1 day in the beginning at and the end.  sometimes sdp and air events for the same refill etc. can differ some seconds in time.  by adding an extra day we can take care of this but still use partition pruning.

    */  -- HJ66902 - this difference in time span is not required since the comparison is not based on Origin node timestamp.  -- AIR_ACCOUNT_EVENTS.TIME_HOUR_ID is populated based on SDP_ACCOUNT_EVENTS.TIME_HOUR_ID in SDP AIR Event Matching activity.

      -- m_air_from_thid := dws_time.move_thid_days(p_from_time_hour_id,-1);  -- m_air_to_thid := dws_time.move_thid_days(p_to_time_hour_id,1);

     from_thid_to_date :=dws_time.thid2date(p_from_time_hour_id); to_thid_to_date :=dws_time.thid2date(p_to_time_hour_id);

      INSERT /*+ append */ INTO wrk_de_pre_stgSELECT base_data.msisdn,

    base_data.voucher_serial_number,base_data.activation_date,base_data.refill_date,

  • 8/18/2019 Dws Data Export Filter Body

    44/146

    base_data.voucher_group_id,cso.cso_username,base_data.subscriber_id,base_data.nominal_transaction_amount,alce.supervision_extension,alce.service_extension,acl.service_class_id,acc_bal.balance_after_refill,acc_bal.actual_talk_value,scl.market_id

    FROM(SELECT /*+ parallel(sdp_acc,5) parallel(air_acc,5) parallel(csa

    ,4)*/ma.msisdn,air_acc.voucher_serial_number,dws_time.get_financialtime_from_utc(dws_cc_report.getAcc

    ActivationDate(ma.account_id)) activation_date,-- dws_time.Get_Financialtime_From_UTC(dws_time.thid2date(air_acc.TIME_HOUR_ID)) refill_date,-- HJ66902 - local timestamp is available in sdp_account_events table from CP6 onwards. no need for a function call.

    sdp_acc.local_timestamp refill_date,air_acc.voucher_group_id,air_acc.nominal_transaction_amount,

    sdp_acc.cso_id,ma.subscriber_id,air_acc.account_event_id,ma.account_id

    FROM (select ma.msisdn,  ma.account_id,  ma.allocation_start_time_utc,  ma.allocation_end_time_utc,  ma.subscriber_id,  row_number() over (partition by ma.subscriber_id order by ma.allocation_ start_time_utc desc) rno  from msisdn_allocations ma) ma,

    sdp_account_events sdp_acc,

    air_account_events air_acc,  CRS_SUBSCRIBER_ALLOCATIONS csa  where

    csa.subscriber_id = sdp_acc.subscriber_idand csa.START_TIME_UTC < sdp_acc.UTC_TIMESTAMPand csa.END_TIME_UTC >= sdp_acc.UTC_TIMESTAMP

      AND air_acc.account_event_id = sdp_acc.account_event_idAND air_acc.time_hour_id = sdp_acc.time_hour_idAND sdp_acc.subscriber_id > 0AND ma.subscriber_id = sdp_acc.subscriber_idAND ma.rno=1AND air_acc.cdr_type_id IN (2002, 2006) -- 2006

    for super value voucher

    AND air_acc.voucher_serial_number IS NOT NULL-- AND dws_time.date2thid(ma.ALLOCATION_START_TIME_UTC)

    =

     air_acc.TIME_HOUR_IDAND sdp_acc.time_hour_id >= p_from_time_hour_idAND sdp_acc.time_hour_id < p_to_time_hour_idAND air_acc.time_hour_id >= p_from_time_hour_idAND air_acc.time_hour_id < p_to_time_hour_id

    ) base_data,

  • 8/18/2019 Dws Data Export Filter Body

    45/146

    (SELECT /*+ parallel(alc,5)*/account_event_id,MAX(CASE WHEN lc_event_type_id = 8 THEN

    FLOOR(TO_DATE(event_value_after,'yyyymmddhh24miss') - TO_DATE(event_value_before,'yyyymmddhh24miss'))

    END) service_extension,MAX(CASE WHEN lc_event_type_id = 10 THEN

    FLOOR(TO_DATE(event_value_after,'yyyymmddhh24miss') - TO_DATE(event_value_before,'yyyymmddhh24miss'))

    END) supervision_extensionFROM account_life_cycle_events alcWHERE account_id > 0

    AND lc_event_type_id IN (8, 10)AND utc_timestamp >= from_thid_to_dateAND utc_timestamp = from_thid_to_date

    AND utc_timestamp = p_from_time_hour_idAND time_hour_id < p_to_time_hour_idAND account_id > 0

    GROUP BY account_event_id) acc_bal,

    (SELECT market_id,subscriber_id

    FROM subscribers_change_logWHERE valid_from_utc to_thid_to_date) scl,customer_service_operators cso

    WHERE base_data.account_event_id = alce.account_event_id(+)AND base_data.account_id = acl.account_idAND base_data.account_event_id = acc_bal.account_event_id(+)AND base_data.subscriber_id = scl.subscriber_idAND base_data.cso_id=cso.cso_id(+);

     commit;

      dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export pre to stage finished');

      dbms_application_info.set_module(module_name => null,  action_name => null);

  • 8/18/2019 Dws Data Export Filter Body

    46/146

    end export_pre_for_thid;

    ------------------------------------------------------------------ procedure: export_pay_static-- purpose: wrapper function for export_pay_static_for_thid to handle conversions of dates to thids (time_hour_id:s)-----------------------------------------------------------------PROCEDURE export_pay_static(  p_from_time VARCHAR2  , p_to_time VARCHAR2  , p_date_format VARCHAR2

     ,type VARCHAR2)ISBEGIN

      log_time_info(p_from_time, p_to_time, p_date_format);

      export_pay_static_for_thid(  Dws_Time.date2thid(Dws_Time.get_utc_from_financialtime(TO_DATE(p_from_time, p_date_format)))  , Dws_Time.date2thid(Dws_Time.get_utc_from_financialtime(TO_DATE(p_to_time, p_date_format)))

      ,TYPE);

    END;

    ------------------------------------------------------------------- procedure: export_pay_static_for_thid-- purpose: export payment data for given time interval (in time_hour_id) to staging table wrk_de_pay_static_stg-----------------------------------------------------------------PROCEDURE export_pay_static_for_thid(  p_from_time_hour_id VARCHAR2,  p_to_time_hour_id VARCHAR2,

      type VARCHAR2)IS

    m_air_from_thid AIR_ACCOUNT_EVENTS.time_hour_id%TYPE;m_air_to_thid AIR_ACCOUNT_EVENTS.time_hour_id%TYPE;from_thid_to_date DATE;to_thid_to_date DATE;

    BEGIN

      dbms_application_info.set_module(module_name => 'dws_data_export',  action_name => 'export_pay_static');

     /*

      increase the timespan for sdp events by 1 day in the beginning at and the end.

      sometimes sdp and air events for the same refill etc. can differ some seconds in time.  by adding an extra day we can take care of this but still use partition pruning.

    */  m_air_from_thid := Dws_Time.move_thid_days(p_from_time_hour_id,-1);  m_air_to_thid := Dws_Time.move_thid_days(p_to_time_hour_id,1);  from_thid_to_date :=Dws_Time.thid2date(p_from_time_hour_id);  to_thid_to_date :=Dws_Time.thid2date(p_to_time_hour_id); 

  • 8/18/2019 Dws Data Export Filter Body

    47/146

      IF TYPE='S' THEN 

    EXECUTE IMMEDIATE 'truncate table wrk_de_pay_static_stg';

      dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export pay STAT (CS40) to stage for period: ' || p_from_time_hour_id || ' - ' || p_to_time_hour_id); 

    INSERT /*+ append */ INTO WRK_DE_PAY_STATIC_STG (EVENT_ID, MSISDN, SUBSCRIBER_ID, SERVICE_CLASS_ID,VOUCHER_GROUP_ID, REFILL_DATE, NOMINAL_TRANSACTION_AMOUNT, CSO_USERNAM

    E,ORIGINAL_NODE_ID, CURRENCY_TYPE, EXTERNAL_DATA_1, EXTERNAL_DATA_2,ORIGINAL_TRANSACTION_ID, MA_BEFORE_EVENT, MA_AFTER_EVENT, ORIGINAL_TIM

    ESTAMP,TIME_HOUR_ID, UTC_TIMESTAMP, DWS_CREATION_DATE, ORIGIN_NODE_ORIGINAL_T

    IMESTAMP,MARKET_ID, MARKET_LEVEL_3, MASTER_MSISDN, MASTER_SUBSCRIBER_ID,

      REFILL_TYPE_ID)  SELECT

    BASE_DATA.ACCOUNT_EVENT_ID,BASE_DATA.MSISDN,BASE_DATA.SUBSCRIBER_ID,

    BASE_DATA.SERVICE_CLASS_ID,BASE_DATA.VOUCHER_GROUP_ID,BASE_DATA.REFILL_DATE,BASE_DATA.NOMINAL_TRANSACTION_AMOUNT,BASE_DATA.CSO_USERNAME,BASE_DATA.ORIGINAL_NODE_ID,ACC_BAL.CURRENCY_TYPE,BASE_DATA.EXTERNAL_DATA_1,BASE_DATA.EXTERNAL_DATA_2,BASE_DATA.ORIGINAL_TRANSACTION_ID,ACC_BAL.MA_BEFORE_EVENT,ACC_BAL.MA_AFTER_EVENT,BASE_DATA.ORIGINAL_TIMESTAMP,

    BASE_DATA.TIME_HOUR_ID,BASE_DATA.UTC_TIMESTAMP,BASE_DATA.DWS_CREATION_DATE,BASE_DATA.ORGIN_NODE_ORIGINAL_TIMESTAMP,BASE_DATA.MARKET_ID,BASE_DATA.MARKET_LEVEL_3 ,BASE_DATA.MSISDN MASTER_MSISDN,BASE_DATA.SUBSCRIBER_ID MASTER_SUBSCRIBER_ID,BASE_DATA.REFILL_TYPE_ID FROM(SELECT /*+ parallel(sdp_acc,4) parallel(air_acc,4) parallel(SCL,4) parallel(csa,4)*/  SDP_ACC.SERVED_MSISDN MSISDN,

      SDP_ACC.SUBSCRIBER_ID,  SDP_ACC.SERVICE_CLASS_ID,  AIR_ACC.VOUCHER_GROUP_ID,-- Dws_Time.Get_Financialtime_From_UTC(SDP_ACC.UTC_TIMESTAMP) refill_date,  sdp_acc.local_timestamp refill_date,  AIR_ACC.NOMINAL_TRANSACTION_AMOUNT ,  CSO.CSO_USERNAME,  sdp_acc.ORIGINAL_NODE_ID,

    SDP_acc.ACCOUNT_EVENT_ID,AIR_ACC.EXTERNAL_DATA_1,

  • 8/18/2019 Dws Data Export Filter Body

    48/146

    AIR_ACC.EXTERNAL_DATA_2, sdp_acc.ORIGINAL_TRANSACTION_ID, TT.TRANSACTION_CODE, sdp_acc.ORIGINAL_TIMESTAMP, SDP_ACC.TIME_HOUR_ID, SDP_ACC.UTC_TIMESTAMP, SDP_ACC.DWS_CREATION_DATE, SDP_ACC.ORGIN_NODE_ORIGINAL_TIMESTAMP, MKT.MARKET_LEVEL_3, MKT.MARKET_ID, AIR_ACC.REFILL_TYPE_ID

      FROM  SDP_ACCOUNT_EVENTS sdp_acc,  AIR_ACCOUNT_EVENTS air_acc,  CUSTOMER_SERVICE_OPERATORS CSO,  TRANSACTION_TYPES TT,  SUBSCRIBERS_CHANGE_LOG SCL,  MARKETS MKT,  CRS_SUBSCRIBER_ALLOCATIONS csa where

    csa.subscriber_id = sdp_acc.subscriber_idand csa.START_TIME_UTC < sdp_acc.UTC_TIMESTAMPand csa.END_TIME_UTC >= sdp_acc.UTC_TIMESTAMP

      AND air_acc.ACCOUNT_EVENT_ID=sdp_acc.ACCOUNT_EVENT_ID

      AND air_acc.time_hour_id = sdp_acc.time_hour_id  AND AIR_ACC.CDR_TYPE_ID=2002  AND VOUCHER_SERIAL_NUMBER IS NULL  AND SDP_ACC.CSO_ID=CSO.CSO_ID(+)  AND SDP_ACC.TRANSACTION_TYPE_ID=TT.TRANSACTION_TYPE_ID(+)-- AND Dws_Time.date2thid(ma.ALLOCATION_START_TIME_UTC) = air_acc.TIME_HOUR_ ID AND sdp_acc.TIME_HOUR_ID>=p_from_time_hour_id  AND sdp_acc.TIME_HOUR_ID= p_from_time_hour_id  AND air_acc.TIME_HOUR_ID =from_thid_to_date

      AND UTC_TIMESTAMP0  AND ACC_BAL.CASH_ACCOUNT_ID=0  AND acc_bal.time_hour_id >= p_from_time_hour_id  AND acc_bal.time_hour_id < p_to_time_hour_id) acc_balWHERE base_data.account_event_id=acc_bal.account_event_id(+)AND acc_bal.UTC_TIMESTAMP=BASE_DATA.UTC_TIMESTAMP

  • 8/18/2019 Dws Data Export Filter Body

    49/146

    AND BASE_DATA.SUBSCRIBER_ID=acc_bal.ACCOUNT_ID;

    ELSIF TYPE='D' THEN 

    EXECUTE IMMEDIATE 'truncate table wrk_de_pay_da_stg';

      dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export pay DA (CS40) to stage for period: ' || p_from_time_hour_id || ' - ' || p_to_time_hour_id);

     INSERT /*+ append */ INTO WRK_DE_PAY_DA_STG(EVENT_ID, MARKET_ID, JOURNAL_TYPE_ID, DA_ID,DA_AMOUNT, CAMPAIGN_ID, BALANCE_BEFORE_EVENT, BALANCE_AFTER_EVENT) SELECTBASE_DATA.ACCOUNT_EVENT_ID,BASE_DATA.MARKET_ID,AJE.AIR_JOURNAL_TYPE_ID,AJE.CASH_ACCOUNT_ID DA_ID,AMOUNT DA_AMOUNT,CAMPAIGN_ID,ACC_BAL.BALANCE_BEFORE_EVENT,ACC_BAL.BALANCE_AFTER_EVENT FROM

    (SELECT /*+ parallel(sdp_acc,4) parallel(air_acc,4) parallel(SCL,4) parallel(csa,4)*/

     SDP_ACC.ACCOUNT_EVENT_ID, sdp_acc.time_hour_id, scl.MARKET_ID

      FROM-- MSISDN_ALLOCATIONS ma,  SDP_ACCOUNT_EVENTS sdp_acc,  AIR_ACCOUNT_EVENTS air_acc,  SUBSCRIBERS_CHANGE_LOG SCL,  CRS_SUBSCRIBER_ALLOCATIONS csa where

    csa.subscriber_id = sdp_acc.subscriber_idand csa.START_TIME_UTC < sdp_acc.UTC_TIMESTAMPand csa.END_TIME_UTC >= sdp_acc.UTC_TIMESTAMP

      AND air_acc.ACCOUNT_EVENT_ID=sdp_acc.ACCOUNT_EVENT_ID  AND air_acc.time_hour_id = sdp_acc.time_hour_id-- AND ma.SUBSCRIBER_ID=sdp_acc.SUBSCRIBER_ID  AND AIR_ACC.CDR_TYPE_ID=2002  AND VOUCHER_SERIAL_NUMBER IS NULL-- AND ma.ALLOCATION_START_TIME_UTC sdp_acc.UTC_TIMESTAMP AND sdp_acc.TIME_HOUR_ID>=p_from_time_hour_id  AND sdp_acc.TIME_HOUR_ID= p_from_time_hour_id

      AND air_acc.TIME_HOUR_ID

  • 8/18/2019 Dws Data Export Filter Body

    50/146

      AND BASE_DATA.ACCOUNT_EVENT_ID=ACC_BAL.ACCOUNT_EVENT_ID  AND AJE.CASH_ACCOUNT_ID=ACC_BAL.CASH_ACCOUNT_ID  AND base_data.time_hour_id = aje.time_hour_id  AND base_data.time_hour_id = acc_bal.time_hour_id  AND aje.time_hour_id >= p_from_time_hour_id  AND aje.time_hour_id < p_to_time_hour_id  AND acc_bal.time_hour_id >= p_from_time_hour_id  AND acc_bal.time_hour_id < p_to_time_hour_id  AND AJE.CASH_ACCOUNT_ID>0  AND AJE.AIR_JOURNAL_TYPE_ID NOT IN (6,8)  AND ACC_BAL.CASH_ACCOUNT_ID >0;

    END IF;

    COMMIT;

      dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export pay (CS40) to stage finished');

      dbms_application_info.set_module(module_name => NULL,  action_name => NULL);

    END export_pay_static_for_thid;

    -- Added by ealphan------------------------------------------------------------------ procedure: export_pay-- purpose: wrapper function for export_pay_for_thid to handle conversions of dates to thids (time_hour_id:s)-----------------------------------------------------------------procedure export_pay(  p_from_time varchar2  , p_to_time varchar2  , p_date_format varchar2)isbegin

      log_time_info(p_from_time, p_to_time, p_date_format);

      export_pay_for_thid(  dws_time.date2thid(dws_time.get_utc_from_financialtime(to_date(p_from_time, p_date_format)))  , dws_time.date2thid(dws_time.get_utc_from_financialtime(to_date(p_to_time, p_date_format))));

    end;

    -----------------------------------------------------------------

    -- procedure: export_pay_for_thid-- purpose: export payment data for given time interval (in time_hour_id) to staging table wrk_de_pay_stg-----------------------------------------------------------------procedure export_pay_for_thid(  p_from_time_hour_id varchar2,  p_to_time_hour_id varchar2)ism_air_from_thid air_account_events.time_hour_id%type;m_air_to_thid air_account_events.time_hour_id%type;

  • 8/18/2019 Dws Data Export Filter Body

    51/146

    from_thid_to_date date;to_thid_to_date date;

    begin

      dbms_application_info.set_module(module_name => 'dws_data_export',  action_name => 'export_pay');

      execute immediate 'truncate table wrk_de_pay_stg';

      dws_logging.logevent(p_event_code => 2022, p_add_txt => 'export pay to stage for period: ' || p_from_time_hour_id || ' - ' || p_to_time_hour_id);

      /*  increase the timespan for sdp events by 1 day in the beginning at and the end.  sometimes sdp and air events for the same refill etc. can differ some seconds in time.  by adding an extra day we can take care of this but still use partition pruning.

    */  m_air_from_thid := dws_time.move_thid_days(p_from_time_hour_id,-1);  m_air_to_thid := dws_time.move_thid_days(p_to_time_hour_id,1);

     from_thid_to_date :=dws_time.thid2date(p_from_time_hour_id);

     to_thid_to_date :=dws_time.thid2date(p_to_time_hour_id); insert /*+ append */ into wrk_de_pay_stg

    selectbase_data.msisdn,base_data.VOUCHER_SERIAL_NUMBER,base_data.activation_date,base_data.refill_date,base_data.voucher_group_id,cso.cso_username,base_data.subscriber_id,base_data.NOMINAL_TRANSACTION_AMOUNT,base_data.ORIGINAL_NODE_ID,

    base_data.ORIGINAL_TRANSACTION_ID,base_data.external_data_2,acl.SERVICE_CLASS_ID,scl.market_id,sdp_jrn.CURRENCY_TYPE,sdp_jrn.DA1_AMOUNT,sdp_jrn.DA2_AMOUNT,sdp_jrn.DA3_AMOUNT,sdp_jrn.DA4_AMOUNT,sdp_jrn.DA5_AMOUNT,sdp_jrn.DA6_AMOUNT,sdp_jrn.DA7_AMOUNT,sdp_jrn.DA8_AMOUNT,

    sdp_jrn.DA9_AMOUNT,sdp_jrn.DA10_AMOUNTfrom (select /*+ parallel(sdp_acc,6) parallel(air_acc,6) parallel(csa,4)*/

     ma.MSISDN, VOUCHER_SERIAL_NUMBER, dws_time.get_financialtime_from_utc(dws_cc_report.getAccActivationDate(

    ma.ACCOUNT_ID)) activation_date,-- HJ81277 - local timestamp is available in sdp_account_events table from CP6 onwards. no need for a function call.

  • 8/18/2019 Dws Data Export Filter Body

    52/146

      sdp_acc.local_timestamp refill_date, VOUCHER_GROUP_ID, NOMINAL_TRANSACTION_AMOUNT , cso_id, ma.SUBSCRIBER_ID, air_acc.ACCOUNT_EVENT_ID, ma.ACCOUNT_ID, sdp_acc.ORIGINAL_NODE_ID, sdp_acc.ORIGINAL_TRANSACTION_ID, air_acc.external_data_2 from (select ma.msisdn,

      ma.account_id,  ma.allocation_start_time_utc,  ma.allocation_end_time_utc,  ma.subscriber_id,  row_number() over (partition by ma.subscriber_id order by ma.allocation_ start_time_utc desc) rno  from msisdn_allocations ma) ma,

     sdp_account_events sdp_acc, air_account_events air_acc,

      CRS_SUBSCRIBER_ALLOCATIONS csa where

    csa.subscriber_id = sdp_acc.subscriber_id

    and csa.START_TIME_UTC < sdp_acc.UTC_TIMESTAMPand csa.END_TIME_UTC >= sdp_acc.UTC_TIME