1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

1
Posted at

前記事はこちら
【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
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?