Beans cause gas due to high levels of oligosaccharide, a type of sugar that cannot be broken down by the human body. Once the oligosaccharide passes into the small intestine, bacteria that live there are able to break the sugar down, producing gas that must exit through the rectum.
A supplement for preventing gas is available in the form of an enzyme produced from Aspergillus niger called alpha-galactosidase. It can be taken to enable the body to break down these sugars before they reach the small intestine. Alpha-galactosidase is not recommended for use in people with diabetes, mold allergies or the genetic disease galactosemia.