Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Convert a integer to binary

I am trying to convert a number to a binary value. The application I am dealing with has checkbox questions and multiple answers can be checked. The values in the field vary depending on the number of answers available.

Thus if there are 4 checkbox answers the values can range from 1 to 15

checkbox one value = 1

checkbox two value = 2

checkbox three value = 4

checkbox four value = 8

so if all boxes are checked, the value would be 15 in the database.

binary value of 15 would be 1111

if only one and three are checked, the value is 5 which would be 101

This would allow me to figure out the boxes that were checked for reporting.

We have some questions with 10+ check boxes (medical application)

Any ideas would be greatly appreciated (of a function you have developed)


If you have a maximum of 9 questions then add the following enclosed in * to your formula,

if you have more question you need to chnage the 9 value to the maximum number of questions

while x (not equal to symbols) 0 do

(binary:= totext(remainder(x,2),0) & binary;

x:= int(x/2));


binary:= replicatestring('0', 9 - length(binary));



0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question