bTalk

Code sample

This trivial class is part of a hierarchy of internal classes which encapsulate BAPI/RFC metadata in a more accessible, object-oriented way. They are used by the <b>Talk Builder when generating Java components.

Every class in the hierarchy knows how to initialise itself with raw R/3 data. If necessary it will pass the request down to its "children" until the entire tree is initialised.
import java.util.Vector;
import com.sap.rfc.*;
import com.sap.rfc.exception.*;
class Structure extends BapiData
{
  Vector simples;

  // constructors
  Structure(String cName, String theType)
  {
    super(cName, theType);
    simples = new Vector(20, 20);
  }

  Structure(String cName, String theType, String theLength)
  {
    this(cName, theType);
    length = theLength;
  }

  public void copyRFCData(RfcData rfc)
  {
    // initialise the structure
    // with RFC data acquired from R/3
    simples.removeAllElements();

    try
    {
      Integer index = (Integer)(rfc.loTableIndex.get(type));
      ITable loTable = (ITable)(rfc.loTables.elementAt(index.intValue()));
      int nRowCount = loTable.getRowCount();

      for (int nRow = 0; nRow < nRowCount; nRow++)
      {
        IRow thisRow = loTable.getRow(nRow);

        // we have found a simpledata
        // - capture its name
        String sdName = thisRow.getSimpleField("FIELDNAME").getString();

        // - capture its type
        String sdType = thisRow.getSimpleField("EXID").getString();

        // - capture its length
        String sdLength = thisRow.getSimpleField("INTLENGTH").getString();

        // - capture its decimal precision
        String sdDecimals = thisRow.getSimpleField("DECIMALS").getString();

        // - capture its descriptive text (TBI)
        String sdParamText = "";

        // - create the object and add it to the simples collection
        SimpleData s = new SimpleData(sdName, sdType, sdLength, sdDecimals, sdParamText);
        simples.addElement(s);
      }
    }
    catch (JRfcBaseException e)
    {
      Builder.writeLn("Error copying data into structure " + cfName);
    }
  }