固定资产的完全报废接口

--完全报废
DECLARE

  l_trans_rec        fa_api_types.trans_rec_type;
  l_dist_trans_rec   fa_api_types.trans_rec_type;
  l_asset_hdr_rec    fa_api_types.asset_hdr_rec_type;
  l_asset_retire_rec fa_api_types.asset_retire_rec_type;
  l_asset_dist_tbl   fa_api_types.asset_dist_tbl_type;
  l_subcomp_tbl      fa_api_types.subcomp_tbl_type;
  l_inv_tbl          fa_api_types.inv_tbl_type;

  l_return_status VARCHAR2(1);
  l_mesg_count    NUMBER;
  l_mesg          VARCHAR2(4000);

BEGIN
  --初始化
  dbms_output.enable(1000000);

  fa_srvr_msg.init_server_message;

  -- Get standard who info
  --资产id
  l_asset_hdr_rec.asset_id := 418;
  --账簿
  l_asset_hdr_rec.book_type_code := 'FA_BOOK_01';
  --报废成本
  l_asset_retire_rec.cost_retired        := 1;
  l_asset_retire_rec.calculate_gain_loss := fnd_api.g_false;

  fa_retirement_pub.do_retirement(
                                  -- std parameters
                                  p_api_version      => 1.0,
                                  p_init_msg_list    => fnd_api.g_false,
                                  p_commit           => fnd_api.g_false,
                                  p_validation_level => fnd_api.g_valid_level_full,
                                  p_calling_fn       => NULL,
                                  x_return_status    => l_return_status,
                                  x_msg_count        => l_mesg_count,
                                  x_msg_data         => l_mesg,
                                  -- api parameters
                                  px_trans_rec        => l_trans_rec,
                                  px_dist_trans_rec   => l_dist_trans_rec,
                                  px_asset_hdr_rec    => l_asset_hdr_rec,
                                  px_asset_retire_rec => l_asset_retire_rec,
                                  p_asset_dist_tbl    => l_asset_dist_tbl,
                                  p_subcomp_tbl       => l_subcomp_tbl,
                                  p_inv_tbl           => l_inv_tbl);
  --dump messages
  l_mesg_count := fnd_msg_pub.count_msg;

  IF l_mesg_count > 0 THEN
  
    l_mesg := chr(10) ||
              substr(fnd_msg_pub.get(fnd_msg_pub.g_first, fnd_api.g_false),
                     1,
                     250);
    dbms_output.put_line(l_mesg);
  
    FOR i IN 1 .. (l_mesg_count - 1) LOOP
      l_mesg := substr(fnd_msg_pub.get(fnd_msg_pub.g_next, fnd_api.g_false),
                       1,
                       250);
    
      dbms_output.put_line(l_mesg);
    END LOOP;
  
    fnd_msg_pub.delete_msg();
  
  END IF;

  IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
    dbms_output.put_line('FAILURE');
    ROLLBACK;
  ELSE
    dbms_output.put_line('SUCCESS');
    dbms_output.put_line('RETIREMENT_ID' ||
                         to_char(l_asset_retire_rec.retirement_id));
  END IF;

END;

你可能感兴趣的:(接口,资产完全报废)