Вы находитесь на странице: 1из 5

create or replace package body pack_gl is procedure pro_gl is ex_null exception; cursor c is select fprd,fyer,dcdt,le,leac,dim1,dbcr,amnt_home,amnt,otyp,ccur,tru n,obat,odoc,olin,osrl,ref_flag from xxdbd_baan_oracle_gl_conv_stg;

--where rownu m=1; start_date varchar2(25); end_date varchar2(25); accounting_date varchar2(25); date xxdbd_baan_oracle_gl_conv_stg.dcdt%type; accounting_period varchar2(25); segment1 xxdbd_baan_oracle_gl_conv_stg.le%type; segment2 xxdbd_baan_oracle_gl_conv_stg.dim1%type; entered_dr xxdbd_baan_oracle_gl_conv_stg.amnt%type; entered_cr xxdbd_baan_oracle_gl_conv_stg.amnt%type; accounted_dr xxdbd_baan_oracle_gl_conv_stg.amnt_home%type; accounted_cr xxdbd_baan_oracle_gl_conv_stg.amnt_home%type; reference4 varchar2(15); reference10 varchar2(25); reference25 varchar2(40); currency varchar2(10); user_je_category_name xxdbd_baan_oracle_gl_conv_stg.otyp%type; segment3 xxdbd_baan_oracle_gl_conv_stg.leac%type; chart_id number(4); set_id number(4); code_combination varchar2(30); /* Date needs to be displayed in MM/DD/RRRR format.(Date column in table dcdt) Start date needs to be 01st of fprd column value and year is fyer. End date needs to be last date of fprd column value and year is fyer. Accounting date needs to be if date column is less than start date then accounti ng date will be start date, if date column value is grater than end date then accou nting date will be end date else accounting date will be date. Accounting period value will be MON-YY of the accounting date.*/ begin for i in c loop begin start_date := to_date('01'||'/'||i.fprd||'/'||i.fyer,'dd/mm/yyyy'); dbms_output.put_line('start_date'||start_date); end_date := last_day(to_date('01'||'/'||i.fprd||'/'||i.fyer,'dd/mm/yyyy')); dbms_output.put_line('end_date'|| end_date); date := to_char(to_date(substr(i.dcdt,1,length(i.dcdt)-1),'mm/dd/yyyy')); dbms_output.put_line('date'||date); if date < start_date then accounting_date := start_date; elsif date > end_date then accounting_date := end_date; else accounting_date := date; end if; dbms_output.put_line('accounting_date'|| accounting_date); accounting_period := substr(to_date( accounting_date,'dd/mm/yyyy'),4,9); dbms_output.put_line('accounting_period'|| accounting_period); end;

If table column le 210 then segment1 value will be 720 else 756 If table column dim1 is null then segment2 will be 0000 else dim1. User defined ex ception needs to raised for the dim1 null value. If leac length is 7 then only first 6 characters needs to be consider and popula te the value for segment3. Code combination will be combination of segment1,segment2 and segment3 value wit h separator.*/ begin if i.le=210 then segment1:=720; else segment1:=756; end if; dbms_output.put_line('segment1' ||segment1); end; begin if i.dim1=null then segment2:='0000'; raise ex_null; else segment2:=i.dim1; end if; dbms_output.put_line('segment2' ||segment2); exception when ex_null then dbms_output.put_line('dim1 is null'); end; begin if length(rtrim(ltrim(i.leac)))=7 then segment3:=substr(i.leac,1,6); end if; dbms_output.put_line('segment3' ||segment3); code_combination := segment1||segment2||segment3; dbms_output.put_line('code_combination'||code_combination); end; begin if i.dbcr=1 then entered_dr:=i.amnt; elsif i.amnt=0 then entered_dr:=null; end if; dbms_output.put_line('entered_dr'||entered_dr); end; /* If dbcr value is 2 then entered_cr value will be amnt column value. If amnt has 0 then null value will be displayed for the entered_cr column value*/ begin if i.dbcr=2 then entered_cr:=i.amnt; elsif i.amnt=0 then entered_dr:=null; end if; dbms_output.put_line('entered_cr '||entered_cr||','||'entered_d' ||entered_dr); end;

/*

/*if dbcr value is 1 then if amnt_home value not equal to 0 and amnt value not equ al to 0 then accounted_dr value will be amnt_home*/ begin if i.dbcr=1 then if i.amnt_home<>0 and i.amnt<>0 then accounted_dr:=i.amnt_home; end if; end if; dbms_output.put_line('accounted_dr' ||accounted_dr); end; /* If dbcr value is 1 then if amnt_home value not equal to 0 and amnt value equal t o 0 then accounted_dr value will be amnt_home and entered_dr value will be 0 */ begin if i.dbcr=1 then if i.amnt_home<>0 and i.amnt=0 then accounted_dr:=i.amnt_home; entered_dr:=0; end if; end if; dbms_output.put_line('accounted_dr' ||accounted_dr); end; /* If dbcr value is 1 then if amnt_home value is 0 then accounted_dr value will be null*/ begin if i.dbcr=1 then if i.amnt_home=0 then accounted_dr:=null; end if; end if; dbms_output.put_line('accounted_dr' ||accounted_dr); end; /* If dbcr value is 2 then if amnt_home value not equal to 0 and amnt value not equ al to 0 then accounted_cr value will be amnt_home*/ begin if i.dbcr=2 then if i.amnt_home<>0 and i.amnt<>0 then accounted_cr:=i.amnt_home; end if; end if; dbms_output.put_line('accounted_cr' ||accounted_cr); end; /* If dbcr value is 2 then if amnt_home value not equal to 0 and amnt value equal t o 0 then accounted_cr value will be amnt_home and entered_cr value will be 0 */ begin if i.dbcr=2 then if i.amnt_home<>0 and i.amnt<=0 then accounted_cr:=i.amnt_home; end if; end if; dbms_output.put_line('accounted_cr' ||accounted_cr);

end; /* If dbcr value is 2 then if amnt_home value is 0 then accounted_cr value will be null.*/ begin if i.dbcr=2 then if i.amnt_home=0 then accounted_cr:=null; end if; end if; dbms_output.put_line('accounted_cr' ||accounted_cr); end; /* If otyp value is LML then reference4 value will be combination of otyp,ccur and odoc values*/ begin if i.otyp = 'lml' then reference4 := i.otyp||i.ccur||to_char(i.odoc); end if; dbms_output.put_line('reference4' || reference4); end; /* If dim1 value is null then reference10 value will be combination of le and lea c values If dim1 value is not null then reference10 value will be combination of lea,leac and dim1 values. Reference25 is the combination of trun,obat,otyp,odoc,olin,osrl,leac values.*/ begin if i.dim1 = null then reference10:=i.le||i.leac; else reference10:= i.le ||i.leac||i.dim1; end if; reference25 := i.trun||i.obat||i.otyp||i.odoc||i.olin||i.osrl||i.leac; dbms_output.put_line('reference10'||reference10); dbms_output.put_line('reference25'||reference25); end; /* User_je_category_name it should be preceded with ZA for the table column otyp.*/ begin user_je_category_name := 'ZA'||i.otyp; dbms_output.put_line( 'user_je_category_name'||user_je_category_name); end; begin if i.ccur<>'ZAR' then currency:='Corporate'; else currency:='ZAR'; end if; dbms_output.put_line('currency' ||currency); end; end loop; end; /* Chart of account id needs to be extracted from gl_set_of_books table for 'ZA Statutory ZAR' name. Set of book id value needs to be extracted from gl_set_of_books table for 'ZA Statutory ZAR' name.*/ /*chart_id varchar2(30); book_id varchar2(30);

cursor a is select chart_of_accounts_id,set_of_books_id from gl_sets_of_books wh ere rownum=1 and short_name like 'ZA Statutory ZAR'; begin for i in a loop chart_id:=i.chart_of_accounts_id; book_id:=i.set_of_books_id; dbms_output.put_line('chart_of_accounts_id'||book_id); dbms_output.put_line('chart_of_accounts_id'||chart_id); end loop; end;*/ /*begin update xxdbd_baan_oracle_gl_conv_stg set ref_flag:='s' */ end pack_gl; /

Вам также может понравиться