I agree with the others that you need to clean up your code, because it is just way too convoluted. Your "bytes Input" should probably be U8.
To demostrate the concept, you don't even use formatted strings, because (especially with SGL, you might lose significant information detouring over a decimally formatted intermediary representation of the binary values.)
Your use of a string containing %s for the upper typecast input is just silly. Since only the type is important and the value is irrelevant, you should probably wire an empty string (or leave it unwired, since string is the default). Typing a formatting statement in there does not change things, but might really confuse somebody looking at the code.
You can also avoide your "toSGL" if you wire a SGL constant to the default input.
All you probably need is a hexadecimally formatted string contro/indicator a SBL contr/indicator and a typecase operation. eliminate the middleman!
(Of course you can easiy go from SGL to string and back. Same difference)