In reply to bharath123:
When you use the field automation macros with UVM_ALL_ON, that also include packing. This means that the pack(…) function will pack all of the fields you have in the order in which you “called” the macros. You’re getting 4 bytes for color (because per default enums are 32 bits), 1 byte for da and sa and 5 more bytes for data.
Because data is a dynamic array, UVM doesn’t know how much to unpack, so data doesn’t get unpacked at all. You need to pack information about the size of data. This is done by setting the use_metadata field in the packer. In your case it should be the uvm_default_packer.