Parameterized function with different parameter values

Hey,
Below is my mentioned function in sequence item class:

    virtual function [0:n-1] swizzle (input [n-1:0] data);
    integer j;
    begin
    for (j=0; j < n; j=j+1) begin : reverse
        swizzle[n-1-j] = data[j]; 
    end
    end
    endfunction: swizzle

I have different n values for different inputs i.e. ranges of all the inputs varies.
and in driver class i am using this function as

req.x=req.swizzle(req.x);
req.y=req.swizzle(req.y);

where bit [7:0]x;
bit [19:0]y;
in sequence item.

I am getting compilation issues as well.
** Error: …/VIP/: Unresolved reference to ‘this’ for non-static field ‘n’.
** Error: …/VIP/: Range must be bounded by constant expressions.

In reply to Rupali Jasrotia:

As the error says, n needs to be elaboration time constants, maybe declared parameters.
Section 13.8 of LRM describes parameterized tasks and functions.