The pancreas and liver are located deep in the abdomen, just below the rib cage. Sometimes issues with these organs cause pain in the flanks. Pain may also spread to the back. As the liver and pancreas work together to help the body digest food, a problem with one organ can eventually affect the other.