cancel
Showing results for 
Search instead for 
Did you mean: 

Portal seems to cache RFC results

Former Member
0 Kudos
306

Hi,

we are calling an RFC in an R/3 4.6C server from an

EP6 SP9 (sneak preview) using JCA. The call is succesful,

but the portal seems to cache the call results; i.e. if

we change the data returned by the RFC the portal receives

the old values. If we restart the portal the returned data

changes, but only on the first call.

I suppose there is some setting for caching RFC results,

but I am not able to find it.

Thanks in advance.

Mattia

Accepted Solutions (1)

Accepted Solutions (1)

former_member188556
Active Contributor
0 Kudos

Hi Mattia

If you are changing the RFC in the backend, u need 2 restart the J2EE server for changtes to reflect.

If only the values or i/o parameters are changed, u have <b>invalidate</b> the <b>output node</b> of the RFC like <b>wdcontext.nodeoutput.invalidate()</b>

Regards

Bobu

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

it is as easy as cancelling RFC session coming

from the portal (using SM04 on the R/3) after

changing the BAPI.

Regards

Mattia

Former Member
0 Kudos

Hi Mattia

I have seen this problem outside the Portal execution (like ordinary JCO calls, webdynpro). The behaviour is it returns old data plus new data(sometimes only old data). This happens when the internal table in the RFMs are not refreshed and they cache the data if the session is persistent. If your new call is made over the same connection that the old call was made , then this behaviour can be seen. Check your RFM code and see if the export/import tables and internal tables are refreshed properly.

Just a guess.....

Regards

Pran

Former Member
0 Kudos

Hi Mattia,

the http cache of the j2ee engine will only cache static content like css files, js files, etc.

Well, I don't know why your results are cached, but before I restart the whole engine, I would try to reboot the connector first.

You can do this in the Visual Adminitstrator.

->server

->services

->connector container

->click the sap connector

->click the Stop Button

->click the Start Button

It's not a solution, but maybe a tipp

regards, Karsten

Former Member
0 Kudos

Hi Karsten,

good suggestion, I did not think of it. Unfortunately

the portal seems to hang after the connector container

has been restarted.

Regards

Mattia

Former Member
0 Kudos

Hi,

I must add that I am not using a Web Dynpro but a plain

portal component based on PageProcessorComponent/JSPDynPage.

Your suggestion looks related to a Web Dynpro context and I have no idea how to apply it to my case.

Regards

Mattia

former_member188556
Active Contributor
0 Kudos

hi Mattia

I was having a doubt on that...

Any way check this now...

Try to clear the HTTP cache on server use <b>Visual Administrator -> Server -> Services -> HTTP provider -> Clear cache</b>.

Hope this is your case.

Expecting rewards on success

Regards

Bobu

Former Member
0 Kudos

Hi,

unfortunately clearing the HTTP cache does not

solve the problem. I will stick with restarting

the portal on each function module change.

Thanks fro trying!

Mattia

former_member188556
Active Contributor
0 Kudos

hi

but almost the same scenario was made ok by that solution only...

any way...let me check with it again...

Regards

Bobu

Former Member
0 Kudos

Post your code.That helps me or Experienced like prakash or Detlev to solve it for sure.

Regards,

Former Member
0 Kudos

Here it is:

BAPI:

FUNCTION zep_test.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  EXPORTING
*"     VALUE(RETURN) LIKE  BAPIRET2 STRUCTURE  BAPIRET2
*"  TABLES
*"      T_AVVISI STRUCTURE  ZLIST_AVVISI
*"----------------------------------------------------------------------

  DATA:
      l_wa_avvisi   LIKE LINE OF t_avvisi
      .

  CLEAR return.
  CLEAR t_avvisi.
  REFRESH t_avvisi.

*  l_wa_avvisi-cdl    = 'E'.
*  l_wa_avvisi-avvisi = 1.
*  APPEND l_wa_avvisi TO t_avvisi.
*  l_wa_avvisi-avvisi = 7.
*  APPEND l_wa_avvisi TO t_avvisi.
*  l_wa_avvisi-avvisi = 8.
*  APPEND l_wa_avvisi TO t_avvisi.
*  l_wa_avvisi-avvisi = 55.
*  APPEND l_wa_avvisi TO t_avvisi.
*  l_wa_avvisi-avvisi = 7.
*  APPEND l_wa_avvisi TO t_avvisi.
*  l_wa_avvisi-avvisi = 1.
*  APPEND l_wa_avvisi TO t_avvisi.

  l_wa_avvisi-cdl    = 'R'.
  l_wa_avvisi-avvisi = 12.
  APPEND l_wa_avvisi TO t_avvisi.
  l_wa_avvisi-avvisi = 30.
  APPEND l_wa_avvisi TO t_avvisi.
  l_wa_avvisi-avvisi = 1.
  APPEND l_wa_avvisi TO t_avvisi.
  l_wa_avvisi-avvisi = 5.
  APPEND l_wa_avvisi TO t_avvisi.
  l_wa_avvisi-avvisi = 10.
  APPEND l_wa_avvisi TO t_avvisi.
  l_wa_avvisi-avvisi = 27.
  APPEND l_wa_avvisi TO t_avvisi.

  l_wa_avvisi-cdl    = 'M'.
  l_wa_avvisi-avvisi = 13.
  APPEND l_wa_avvisi TO t_avvisi.
  l_wa_avvisi-avvisi = 7.
  APPEND l_wa_avvisi TO t_avvisi.
  l_wa_avvisi-avvisi = 8.
  APPEND l_wa_avvisi TO t_avvisi.
  l_wa_avvisi-avvisi = 10.
  APPEND l_wa_avvisi TO t_avvisi.
  l_wa_avvisi-avvisi = 2.
  APPEND l_wa_avvisi TO t_avvisi.
  l_wa_avvisi-avvisi = 34.
  APPEND l_wa_avvisi TO t_avvisi.

  return-type = 'S'.
ENDFUNCTION.

The component is a variation of the jca.SampleComponent.par I found either on SDN or in a note (sorry, I can't seem to find it anymore). I only

changed the doJca method (below).

public void doJca(IPortalComponentRequest request, IPortalRequestEvent event) {

    System.out.println("doJca()");

    Context ctx = null;
//    IConnectionFactory connectionFactory = null;
    IConnection client = null;
    ConnectionProperties prop = null;
    String rfm_name = "ZEP_TEST";

    String system_alias = request.getParameter("system");
    
    if (system_alias == null) {
			app.putValue(
				"error",
				"Couldn't establish a connection with a target system " + system_alias + ".");
			return;    
    }
    
    System.out.println("system_alias = " + system_alias);

    app.putValue("error", "");
    app.putValue("exportParams", "");
    app.putValue("system_alias", system_alias);

    try {

      // Obtain the initial JNDI context
      //   ctx = new InitialContext();
      // Perform JNDI lookup to obtain connection factory
      //   connectionFactory = (IConnectionFactory) ctx.lookup("EISConnections/SAPFactory");
      //   IConnectionSpec spec = connectionFactory.getConnectionSpec();
      //
      //   ((Map) spec).put("client", "100");
      //	 ((Map) spec).put("UserName", "");
      //	 ((Map) spec).put("Password", "");
      //	 ((Map) spec).put("logonmethod", "UIDPW");
      //	 ((Map) spec).put("Language", "EN");
      //	 ((Map) spec).put("ashost", "");
      //	 ((Map) spec).put("sysnr", "01");
      //	 IConnection client = connectionFactory.getConnectionEx(spec);

      IConnectorGatewayService cgService =
        (IConnectorGatewayService) request.getService(IConnectorService.KEY);

      try {
				prop = new ConnectionProperties(request.getLocale(), request.getUser());
      } catch (Exception e) {
				app.putValue(
					"error",
					"Couldn't establish a connection with the user " + request.getUser() + "." + e);
				return;      
      }

      try {
				client = cgService.getConnection(system_alias, prop);
      } catch (Exception e) {
                StringWriter wr = new StringWriter();
                e.printStackTrace(new PrintWriter(wr));
				app.putValue(
					"error",
					"Couldn't establish a connection with a target system " + system_alias + "." + wr.toString());
				return;
      }
			
      /* 
       * Start Interaction
       * */
      IInteraction interaction = client.createInteractionEx();
      System.out.println("Starting Interaction...");
      IInteractionSpec interactionSpec = interaction.getInteractionSpec();
      interactionSpec.setPropertyValue("Name", rfm_name);

      /*
       * CCI api only has one datatype: Record
       * */
      RecordFactory recordFactory = interaction.getRecordFactory();
      MappedRecord importParams = recordFactory.createMappedRecord("CONTAINER_OF_IMPORT_PARAMS");

      IFunctionsMetaData functionsMetaData = client.getFunctionsMetaData();
      IFunction function = functionsMetaData.getFunction(rfm_name);

      if (function == null) {
        app.putValue(
          "error",
          "Couldn't find " + rfm_name + " in a target system " + system_alias + ".");
        return;
      }

      /*
       * How to invoke Function modules
       * */
      System.out.println("Invoking... " + function.getName());
      MappedRecord exportParams = (MappedRecord) interaction.execute(interactionSpec, importParams);

      app.putValue("exportParams", exportParams);

      /*
       * How to get structure values
       * */
      IRecord exportStructure = (IRecord) exportParams.get("RETURN");
      String columnOne = exportStructure.getString("TYPE");
      String columnTwo = exportStructure.getString("NUMBER");
      String columnThree = exportStructure.getString("MESSAGE");

      System.out.println("  RETURN-TYPE    = " + columnOne);
      System.out.println("  RETURN-CODE    = " + columnTwo);
      System.out.println("  RETURN-MESSAGE =" + columnThree);

      /*
       * How to get table values
       * */
      IRecordSet exportTable = (IRecordSet) exportParams.get("T_AVVISI");

      exportTable.beforeFirst(); // Moves the cursor before the first row. 
      while (exportTable.next()) {
        String column_1 = exportTable.getString("CDL");
        String column_2 = String.valueOf(exportTable.getInt("AVVISI"));
        System.out.println("  COMPANYCODE_LIST-COMP_CODE = " + column_1);
        System.out.println("  COMPANYCODE_LIST-COMP_NAME = " + column_2);
      }

      /*
       * Closing the connection
       * */
       interaction.getConnection().close();
      client.close();

    } catch (ConnectorException e) {
      app.putValue("error", e.toString());
      System.out.println("Caught an exception: n" + e);
      throw new RuntimeException(e);
    } catch (Exception e) {
      app.putValue("error", e.toString());
      System.out.println("Caught an exception: n" + e);
      throw new RuntimeException(e);
    }

  }

When I uncomment the commented section in the BAPI

(or I comment out some more of it), the result displayed

by the iView does not change until I restart the portal.

Thanks in advance!

Mattia