This article relates to GRIB edition 2

Problem

Setting the fixed surface keys in the wrong order can lead to incorrect values.

Solution

The keys in Section 4 that relate to fixed surface properties should be set such that the two "type" keys
  typeOfFirstFixedSurface
  typeOfSecondFixedSurface
are set before the scale keys.

For example:

Example C code
codes_handle* h = ...;
...
codes_set_long(h, "typeOfFirstFixedSurface", 106); // Depth below land surface (m)
codes_set_long(h, "typeOfSecondFixedSurface", 106);

codes_set_long(h, "scaledValueOfFirstFixedSurface", 3);
codes_set_long(h, "scaleFactorOfFirstFixedSurface", 2);
codes_set_long(h, "scaledValueOfSecondFixedSurface", 5);
codes_set_long(h, "scaleFactorOfSecondFixedSurface", 2);

This should also be done when you define a "concept" like paramId, shortName etc in the definition files paramId.def, shortName.def etc. For example:

Example from paramId.def
...
#Mean sea water temperature in the upper 300 m
'151127' = {
	 discipline = 10 ;
	 parameterCategory = 4 ;
	 parameterNumber = 15 ;
	 typeOfFirstFixedSurface = 160 ;
	 typeOfSecondFixedSurface = 160 ;
	 scaledValueOfFirstFixedSurface = 0 ;
	 scaleFactorOfFirstFixedSurface = 0 ;
	 scaledValueOfSecondFixedSurface = 300 ;
	 scaleFactorOfSecondFixedSurface = 0 ;
}
...