Interface RfcInterface

  • All Known Subinterfaces:
    XbpInterface

    public interface RfcInterface
    RFC Interface
    
      {
        import com.redwood.scheduler.api.connector.sap.rfc.scripting.RfcConnectionManager;
        import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.RfcInterface;
        import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.RfcWork;
        import com.redwood.scheduler.api.model.SAPSystem;
        {
          Partition part = jcsSession.getPsrtitionByName("MyPartition");
          SAPSystem sapSystem = jcsSession.getSAPSystemByName(part, "NSP");
          RfcConnectionManager rfcConnectionManager = new RfcConnectionManager(sapSystem);
    
          rfcConnectionManager.callRfc(new RfcWork()
          {
            public void performWork(final RfcInterface xbp)
            {
              //…
            }
          });
        }
      }
    
     
    Reading an SAP database table using readTable:
    
      import com.redwood.scheduler.api.connector.sap.rfc.scripting.RfcConnectionManager;
      import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.RfcInterface;
      import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.RfcWork;
      Import com.redwood.scheduler.api.connector.sap.rfc.scripting.TableRow;
      import com.redwood.scheduler.api.model.SAPSystem;
    
      import java.util.Iterator;
      {
        SAPSystem sapSystem = jcsSession.getSAPSystemByName("NSP");
        RfcConnectionManager rfcConnectionManager = new RfcConnectionManager(sapSystem);
    
        rfcConnectionManager.callRfc(new RfcWork()
        {
          public void performWork(final RfcInterface xbp)
          {
            String[] cols = new String[] { "BUKRS", "BUTXT", "WAERS" };
            String[] wClauses = new String[] { , };
            Iterator<TableRow> it = xbp.readTable("T001", "|", cols, wClauses, -1, 20);
            it.forEachRemaining(tr ->
            {
               jcsOut.println(tr.toString());
            });
           }
         });
      }
    
     
    Calling BDC Transactions using BdcDynpro:
    
      import com.redwood.scheduler.api.connector.sap.rfc.scripting.RfcConnectionManager;
      import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.RfcInterface;
      import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.RfcWork;
      import com.redwood.scheduler.api.connector.sap.rfc.scripting.BdcDynpro;
      import com.redwood.scheduler.api.connector.sap.rfc.scripting.BdcReturn;
      import com.redwood.scheduler.api.connector.sap.rfc.scripting.BdcDynproFactory;
      import com.redwood.scheduler.api.model.SAPSystem;
      {
        SAPSystem sapSystem = jcsSession.getSAPSystemByName("NSP");
        RfcConnectionManager rfcConnectionManager = new RfcConnectionManager(sapSystem);
    
        rfcConnectionManager.callRfc(new RfcWork()
        {
          public void performWork(final RfcInterface xbp)
          {
            BdcDynpro[] bdcDynpro = new BdcDynpro[1];
            bdcDynpro[0] = BdcDynproFactory.createBdcDynpro("SAPLSUU5", "0050");
            bdcDynpro[0].addValue("BDC_OKCODE", "=SHOW");
            bdcDynpro[0].addValue("USR-02-BNAME", "USER");
            BdcReturn bdcReturn = xbp.callTransaction("SU01", bdcDynpro);
    
            BdcMessage[] msgs = bdcReturn.getMessages();
            for (BdcMessage msg : msgs)
            {
              jcsOut.println(msg.getMessageV1() + " " + msg.getMessageType() + " " + bdcReturn.getReturnCode());
            }
          }
         });
      }
    
     
    • Method Detail

      • getSystemInfo

        SAPSystemInfo getSystemInfo()
        Get the details of the SAP system as returned by the function module RFC_SYSTEM_INFO
        Returns:
        details of the SAP system
      • hasRedwoodTransports

        boolean hasRedwoodTransports()
        Check if Redwood transport are loaded and licensed.
        Returns:
        trueif Redwood transport are loaded and licensed, false otherwise
      • readTable

        Iterator<TableRow> readTable​(String tableName,
                                     String delimiter,
                                     String[] columns,
                                     String[] whereClauses,
                                     int rowSkip,
                                     int rowCount)
        Read the contents of the given SAP ABAP table
        Parameters:
        tableName - name of the ABAP table
        delimiter - column delimiter. Default is |.
        columns - array with column names that should be retrieved. All columns are retrieved if the array is empty or null.
        whereClauses - array with where clauses for the query statement. No where clauses are applied if the array is empty or null.
        rowSkip - number of rows to skip from the beginning of the result set, or -1 to get the complete result set
        rowCount - number of rows to retrieve, or -1 to retrieve all rows
        Returns:
        Iterator with the table rows of type TableRow
      • callTransaction

        BdcReturn callTransaction​(String transactionName,
                                  BdcDynpro[] bdcData)
        Call a transaction
        Parameters:
        transactionName - name of the transaction to call
        bdcData - data that is passed to the input fields of the transaction
        Returns:
        BdcReturn object with the return code of the transaction call and all messages that were sent
      • getUserDetails

        UserDetails getUserDetails​(String userName)
        Get user details
        Parameters:
        userName -
        Returns:
        UserDetails object containing details of the user in question
      • getMessageText

        String getMessageText​(String language,
                              String msgid,
                              String msgno,
                              String v1,
                              String v2,
                              String v3,
                              String v4)
        Retrieve the message text based on it's id and number similar to the ABAP keyword MESSAGE. Example: xbp.getMessage("EN", "XM", "086", "01.08.2009", "01.09.2009", "3", "Rfc") returns "Reorganization of the log for Rfc (except from 16.09.2009 to 16.09.2009, audit 3)"
        Parameters:
        language -
        msgid -
        msgno -
        v1 -
        v2 -
        v3 -
        v4 -
        Returns:
        message text
      • getMessageText

        String getMessageText​(BdcMessage message)
        Retrieve the message text based BdcMessage reply from a transaction call
        Parameters:
        message - message as it came back from a transaction call
        Returns:
        message text
      • getTimeZone

        TimeZone getTimeZone()
        Gets the time zone of the SAP system
        Returns:
        TimeZone of the SAP system
      • createRfcFunctionModule

        <T extends RfcFunctionModule> T createRfcFunctionModule​(Class<T> functionModule)
        Create an RFC-enabled function module context which can be used to call the function module
        Parameters:
        functionModule - function module to call
        Returns:
        RfcFunctionModule context
      • attach

        <T extends RfcFunctionModule> void attach​(T functionModule)
        Attaches an RFC-enabled detached function module context which can be used to call the function module
        Parameters:
        functionModule - function module to call
      • createTransactionId

        String createTransactionId()
        Create a transaction id for an IDOC
        Returns:
        transaction id
      • confirmTransactionId

        void confirmTransactionId​(String tid)
        Confirm a transaction id
        Parameters:
        tid - transaction id to confirm
      • sendIDoc

        void sendIDoc​(IDoc idoc,
                      String tid)
        Send an IDOC using a transaction id
        Parameters:
        idoc - IDOC to send
        tid - transaction id
      • getSapSystem

        String getSapSystem()
        Get SAP system Instance
        Returns:
        SAP system Instance
      • getSapSystemPartition

        String getSapSystemPartition()
        Get Partition of the SAP system
        Returns:
        partition of the SAP system
      • getSapClient

        String getSapClient()
        Get default client of the SAP system
        Returns:
        default client of the SAP system
      • getSapUser

        String getSapUser()
        Get SAP user
        Returns:
        SAP user
      • getSapBusinessKey

        BusinessKey getSapBusinessKey()
        Get business key of the SAP system
        Returns:
        business key of the SAP system