Nizar16, this has almost nothing to do with Rexx. The most important thing is the SQL query needed for this; the second most important thing is the reporting. I recommend that you first write a batch COBOL program that does this, then decide what functional differences there must be in your tool. When you have done this, get back to us.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day