01.--完全报废  
02.DECLARE  
03.  
04.  l_trans_rec        fa_api_types.trans_rec_type;  
05.  l_dist_trans_rec   fa_api_types.trans_rec_type;  
06.  l_asset_hdr_rec    fa_api_types.asset_hdr_rec_type;  
07.  l_asset_retire_rec fa_api_types.asset_retire_rec_type;  
08.  l_asset_dist_tbl   fa_api_types.asset_dist_tbl_type;  
09.  l_subcomp_tbl      fa_api_types.subcomp_tbl_type;  
10.  l_inv_tbl          fa_api_types.inv_tbl_type;  
11.  
12.  l_return_status VARCHAR2(1);  
13.  l_mesg_count    NUMBER;  
14.  l_mesg          VARCHAR2(4000);  
15.  
16.BEGIN  
17.  --初始化  
18.  dbms_output.enable(1000000);  
19.  
20.  fa_srvr_msg.init_server_message;  
21.  
22.  -- Get standard who info  
23.  --资产id  
24.  l_asset_hdr_rec.asset_id := 418;  
25.  --账簿  
26.  l_asset_hdr_rec.book_type_code := 'FA_BOOK_01';  
27.  --报废成本  
28.  l_asset_retire_rec.cost_retired        := 1;  
29.  l_asset_retire_rec.calculate_gain_loss := fnd_api.g_false;  
30.  
31.  fa_retirement_pub.do_retirement(  
32.                                  -- std parameters  
33.                                  p_api_version      => 1.0,  
34.                                  p_init_msg_list    => fnd_api.g_false,  
35.                                  p_commit           => fnd_api.g_false,  
36.                                  p_validation_level => fnd_api.g_valid_level_full,  
37.                                  p_calling_fn       => NULL,  
38.                                  x_return_status    => l_return_status,  
39.                                  x_msg_count        => l_mesg_count,  
40.                                  x_msg_data         => l_mesg,  
41.                                  -- api parameters  
42.                                  px_trans_rec        => l_trans_rec,  
43.                                  px_dist_trans_rec   => l_dist_trans_rec,  
44.                                  px_asset_hdr_rec    => l_asset_hdr_rec,  
45.                                  px_asset_retire_rec => l_asset_retire_rec,  
46.                                  p_asset_dist_tbl    => l_asset_dist_tbl,  
47.                                  p_subcomp_tbl       => l_subcomp_tbl,  
48.                                  p_inv_tbl           => l_inv_tbl);  
49.  --dump messages  
50.  l_mesg_count := fnd_msg_pub.count_msg;  
51.  
52.  IF l_mesg_count > 0 THEN  
53.    
54.    l_mesg := chr(10) ||  
55.              substr(fnd_msg_pub.get(fnd_msg_pub.g_first, fnd_api.g_false),  
56.                     1,  
57.                     250);  
58.    dbms_output.put_line(l_mesg);  
59.    
60.    FOR i IN 1 .. (l_mesg_count - 1) LOOP  
61.      l_mesg := substr(fnd_msg_pub.get(fnd_msg_pub.g_next, fnd_api.g_false),  
62.                       1,  
63.                       250);  
64.      
65.      dbms_output.put_line(l_mesg);  
66.    END LOOP;  
67.    
68.    fnd_msg_pub.delete_msg();  
69.    
70.  END IF;  
71.  
72.  IF (l_return_status <> fnd_api.g_ret_sts_success) THEN  
73.    dbms_output.put_line('FAILURE');  
74.    ROLLBACK;  
75.  ELSE  
76.    dbms_output.put_line('SUCCESS');  
77.    dbms_output.put_line('RETIREMENT_ID' ||  
78.                         to_char(l_asset_retire_rec.retirement_id));  
79.  END IF;  
80.  
81.END;