Since you have not provided and source code and not enough specifics on your problem, it is impossible to give you an answer.
I am guessing this is something new to you and I suggest the best we can do for you is to guide you into finding informaiton that will teach you want you want to do, rather than once of use just giving you an answer.
There are many examples on the web and also options to down load code.
I did a simple Google seach and came up with pages of places for you to go and get all the information you need to learn this technique.
Search for “as400 message subfiles”