Help us understand the problem. What is going on with this article?

【PBCS】ビジネス・ルールを使用した計算処理 - 計算スクリプトの紹介②

前記事はこちら
【PBCS】ビジネス・ルールを使用した計算処理 - 計算スクリプトの紹介①

積上処理

・密次元:メンバー多→少の次元順で処理(CALC DIM)
・疎次元:メンバー少→多の次元順で処理(AGG)

【以下スクリプト例】

/*STARTCOMPONENT:SCRIPT*/
/*STARTCOMPONENT:SCRIPT*/
/**********************************************/
/* プログラム名称:BR001_積上処理          
/* 作成者:                               
/* 更新者:                                     
/* 作成日:2018/3/8                           
/* 更新日:                                     
/*--------------------------------------------
/* Ver1.0 新規作成                      
/**********************************************/
/* 環境変数 */
  SET AGGMISSG ON;    
  SET CACHE HIGH;
  SET LOCKBLOCK HIGH;
  SET UPDATECALC OFF;
  SET FRMLBOTTOMUP ON;

/* 積上処理 */
FIX ({P_Years},{P_Scenario},{P_Version})

/*    CALC DIM("Account","Period"); 
    CALC DIM("Product");
    CALC DIM("Entity");
    CALC DIM("Media");
    CALC DIM("Agency");*/

    /* 密次元 */
    CALC DIM("Account","Period");

    /* 疎次元 */
    CALC DIM("Media");
    AGG("Product");
    AGG("Entity");
    AGG("Agency");


ENDFIX
/*ENDCOMPONENT*/
/*ENDCOMPONENT*/

配賦処理

FIX ("BaseData",
 "Apr",
     "Final",
     "Yamagata",
     "No_C1"
     "FY17",
     "Marketing"
     )

/* 
 配賦元:2017マーケティング製品無し
  配賦先:2017マーケティング各製品
  配賦基準:売上実績比 
*/

"Budget" = @ALLOCATE(

            /* 配賦元 */"No_Product", 
            /* 配賦先 */@RELATIVE("ProductTotal", 0), 
            /* 配賦基準*/"FY16"->"Sales"->"Actual",
            /* 丸め誤差追加メンバ */,
            /* 配賦方式 */share,
            /* 丸めの有無 */roundAmt,
            /* 丸め桁数 */ 2);

ENDFIX

配賦処理の高速化

//①変数workに配賦値を代入
  FIX ({P_From_Account})    /*科目(配賦元)*/
    FIX ({P_From_Entity})   /*組織(配賦元)*/
        "Work"=@MDALLOCATE({P_From_Ctgr},2,@List({P_To_Account}),@List({P_To_Entity}),"Direct"->{P_Basic_Account},,share,roundAmt,0,errorsToHigh);
    ENDFIX
  ENDFIX

//②配賦先のデータに配賦結果を加算する
  FIX ({P_To_Account})  /*配賦先(科目)*/
    FIX ({P_To_Entity})     /*配賦先(組織)*/
        {P_To_Ctgr}={P_To_Ctgr}+"Work";
    ENDFIX
  ENDFIX

//③配賦先の配賦作業用メンバーのクリア
  FIX ({P_To_Account})  /*配賦先(科目)*/
    FIX ({P_To_Entity})     /*配賦先(組織)*/
        CLEARDATA "Work";
    ENDFIX
  ENDFIX

//④配賦先に配賦元のデータでマイナス値を作成する(処理後に配賦元データを0にする場合)
  FIX (@Relative({P_From_Account},0))   /*配賦元(科目)*/
    FIX (@Relative({P_From_Unit},0))    /*配賦元(組織)*/
        {P_To_Ctgr}={P_To_Ctgr}+{P_From_Ctgr}*-1;
    ENDFIX
  ENDFIX
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away