how to call a sub-gms file inside the main gms file

Not sure I understand, but you can call GAMS recursively during compilation. Assume B.gms creates AAA.inc while compiling A.gms. Hence in A.gms you have:

$call gams B.gms lo=%gams.lo%
$if errorlevel 1 $abort problems running gams B.gms. Check B.lst for details

$include AAA.inc

-Michael