cancel
Showing results for 
Search instead for 
Did you mean: 

JCo Repository "copy"

Former Member
0 Kudos

Hello,

I'm developing a RFC-Server with JCo.

I would like to read (only once, at the beginning, when the server starts) the repository information of a function module and save them in a static Repository:


    static public class MyRepository extends JCO.BasicRepository
            implements IRepository {
        
	      
        public MyRepository(String name) {
            super(name);
        }
        
        public void FillMyRepository() {
            
            JCO.Client client = null;

            JCO.MetaData fmeta = null;
            fmeta = (MetaData) this.getFunctionInterface("HU_GET_RFC_DATA");
            if ( fmeta == null ) {
                IRepository aRepository = null;
                try {
        
                    client = JCO.createClient(
                            connClient,     // SAP client
                            connUser,       // userid
                            connPW,         // password
                            connLang,       // language
                            connHost,       // host name
                            connHostSyst ); // System number
                
                    client.connect();
                    aRepository = JCO.createRepository("aRepository", client);
                    IMetaData fInterface = (IMetaData) aRepository.getFunctionInterface("HU_GET_RFC_DATA").clone();
                    addFunctionInterfaceToCache( (MetaData) fInterface);
                    client.disconnect();        
                } catch (JCO.Exception ex) {
                    System.out.println("Caught an exception: n" + ex);
                }
            }
            
        }
        
    }

but then the Server.getFunction doesn't work correctly.

"JCO.Server could not find server function 'HU_GET_RFC_DATA'"

Do you have any idea?

Thanks and regards,

Tommaso

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Tommaso,

as far as I know, the moment you create a new Function, it is automatically stored in the Repository.

Every other call to this function ends in this function being retrieved from the JCO Repository. So I think as long as you create only one repository, any Function that you create (Function fx = createFunction("BLAHBLAH");) will be first put into the repository. Which means that only the first call to a Function might take a wee extra than later calls. You don't need to copy a Function into the repository explicitly in my opinion...

Bye,

Sameer