You have already asked a variant of this question here, and I thought you got a good number of responses. I don't know why exactly you would need all or most sub-optimal alignments, but this I do know - most people are interested only in optimal alignments. That's why there are efficient algorithms for optimal alignments, and I am guessing not so for suboptimal alignments.
I already suggested to you here a small program for global alignments, which is short and I think easy to understand. If you know how to modify the code, it should be easily adaptable to get what you want. Frankly, I don't think you will find a ready solution that outputs sub-optimal alignment because that's not a goal of either alignment or sequence search programs. They do create all the alignments as part of the process, but they do not report sub-optimal alignment because in most cases they are not needed.