I'm facing a major problem with a statement "If Q[Role=GMS_AG-11.2_GUIXT_PG22_AM]". It works when I test it in our development system and also in our test system. For some other users, it works in the development system as well, but not when they use our test system. What could be the reason?

The reason is probably the following: the if Q[Role=..] statement uses the function BAPI_USER_GET_DETAIL in order to read the user roles. This works only if the RFC user is allowed to access the user master record, which depends on the user group stored in this master record. So it can work for some users in some systems, but not for others. Please grant the right authorization to the RFC user, as described in our documentation menu item "RFC" (first menu); it then will work for all targeted users.