As long as you have both LIBA and LIBB in your library list, the compiler and execution of the program will process the files correctly for you.
…unless you have FILEB in LIBA, or FILEA in LIBB. Then you need to define which library you want to use for each file. This can be done in a few different ways.
First, write a CL program that uses the OVRDBF command before calling your RPG program. The OVRDBF command allows you to specify the library where you want your RPG program to find its files.
Another way is to use the EXTFILE keyword on the file specifications in the RPG program. The EXTFILE keyword specifies which file, in which library, is opened. The value can be a literal or a variable. You can specify the value in any of the following forms: