小说网站 搜小说 无限网 烟雨红尘 小说爱好者 免费小说 免费小说网站

固定资产的调整分配接口

转自huan.gu专栏;http://blog.csdn.net/gh320/article/details/17059863

01./*(注意点:1:只能在不同的行之间进行调整  
02.2:调整之后的数量之和应和调整之前一样,否则报错)*/  
03.DECLARE  
04.  l_return_status  VARCHAR2(1);  
05.  l_msg_count      NUMBER := 0;  
06.  l_msg_data       VARCHAR2(4000);  
07.  l_trans_rec      fa_api_types.trans_rec_type;  
08.  l_asset_hdr_rec  fa_api_types.asset_hdr_rec_type;  
09.  l_asset_dist_tbl fa_api_types.asset_dist_tbl_type;  
10.  temp_str         VARCHAR2(512);  
11.BEGIN  
12.  --初始化  
13.  fnd_profile.put('PRINT_DEBUG', 'Y');  
14.  dbms_output.enable(1000000);  
15.  fa_srvr_msg.init_server_message;  
16.  fa_debug_pkg.initialize;  
17.  -- fill in asset information  
18.  --资产id  
19.  l_asset_hdr_rec.asset_id := 418;  
20.  --资产账簿  
21.  l_asset_hdr_rec.book_type_code := 'FA_BOOK_01';  
22.  
23.  -- transaction date must be filled in if performing  
24.  -- prior period transfer  
25.  --l_trans_rec.transaction_date_entered := to_date('01-JAN-1999 10:54:22', 'dd-mon-yyyy hh24:mi:ss');  
26.  
27.  --清空资产分配记录中的数据  
28.  l_asset_dist_tbl.delete;  
29.  /*  
30.  fill in distribution data for existing distribution lines  
31.  affected by this transfer txn. Note: You need to fill in  
32.  only affected distribution lines.  
33.  For source distribution, you must fill in either existing  
34.  distribution id or 2 columns(expense_ccid,location_ccid) or  
35.  3-tuple columns(assigned_to,expense_ccid,and location_ccid)  
36.  depending on the makeup of the particular distribution  
37.  of the asset.  
38.  */  
39.  l_asset_dist_tbl(1).distribution_id := 22001; -----存在的调整之前的行ID  
40.  l_asset_dist_tbl(1).transaction_units := -1; ----调整数量  
41.  /*  
42.    either above 2 lines or below 4 lines must be provided  
43.    for source distribution:  
44.  --调整的数量  
45.    l_asset_dist_tbl(1).transaction_units := -2;  
46.  --员工id  
47.    l_asset_dist_tbl(1).assigned_to := 11;  
48.  --费用账户id  
49.    l_asset_dist_tbl(1).expense_ccid :=15338;  
50.  --地点组合id  
51.    l_asset_dist_tbl(1).location_ccid := 3; */  
52.  -- fill in dist info for destination distribution  
53.  l_asset_dist_tbl(2).transaction_units := 2; ----调整之后新建的行数量  
54.  l_asset_dist_tbl(2).assigned_to := 61; ---调整给谁  
55.  l_asset_dist_tbl(2).expense_ccid := 14001; --CODE_COMBINATION_ID;  ----费用账户  
56.  l_asset_dist_tbl(2).location_ccid := 1; --LOCATION_ID;    -----地点  
57.  
58.  l_trans_rec.who_info.last_updated_by   := 1330; --FND_GLOBAL.USER_ID;  
59.  l_trans_rec.who_info.last_update_login := 14001; --FND_GLOBAL.LOGIN_ID;  
60.  
61.  fa_transfer_pub.do_transfer(1.0,  
62.                              fnd_api.g_false,  
63.                              fnd_api.g_false,  
64.                              fnd_api.g_valid_level_full,  
65.                              NULL,  
66.                              l_return_status,  
67.                              l_msg_count,  
68.                              l_msg_data,  
69.                              l_trans_rec,  
70.                              l_asset_hdr_rec,  
71.                              l_asset_dist_tbl);  
72.  IF (l_return_status != fnd_api.g_ret_sts_success) THEN  
73.    
74.    dbms_output.put_line('TRANSFER failed!.');  
75.    l_msg_count := fnd_msg_pub.count_msg;  
76.    
77.    IF (l_msg_count > 0) THEN  
78.      temp_str := substr(fnd_msg_pub.get(fnd_msg_pub.g_first,  
79.                                         fnd_api.g_false),  
80.                         1,  
81.                         512);  
82.      dbms_output.put_line('Error: ' || temp_str);  
83.      FOR i IN 1 .. (l_msg_count - 1) LOOP  
84.        temp_str := substr(fnd_msg_pub.get(fnd_msg_pub.g_next,  
85.                                           fnd_api.g_false),  
86.                           1,  
87.                           512);  
88.        dbms_output.put_line('Error: ' || temp_str);  
89.      END LOOP;  
90.    END IF;  
91.  ELSE  
92.    dbms_output.put_line('TRANSFER completed successfully!');  
93.    dbms_output.put_line('THID = ' ||  
94.                         to_char(l_trans_rec.transaction_header_id));  
95.  END IF;  
96.  fnd_msg_pub.delete_msg();  
97.  
98.END;  


 

posted on 2013-12-06 21:16  王小航  阅读(262)  评论(0编辑  收藏  举报

导航