XBP Interface
Currently supported XBP interfaces are XBP 1.0 and higher, that is XBP 0.1 is
not supported.
{
import com.redwood.scheduler.api.connector.sap.rfc.scripting.RfcConnectionManager;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpInterface;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpWork;
import com.redwood.scheduler.api.model.SAPSystem;
{
Partition part = jcsSession.getPsrtitionByName("MyPartition");
SAPSystem sapSystem = jcsSession.getSAPSystemByName(part, "NSP");
RfcConnectionManager rfcConnectionManager = new RfcConnectionManager(sapSystem);
rfcConnectionManager.callXBP(new XbpWork()
{
public void performWork(final XbpInterface xbp)
{
//…
}
});
}
}
Selecting SAP jobs using
selectJobs
:
{
import com.redwood.scheduler.api.connector.sap.rfc.scripting.RfcConnectionManager;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpInterface;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpJobSelectionOption;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpJob;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpWork;
import com.redwood.scheduler.api.model.enumeration.SapBatchJobStatus;
import com.redwood.scheduler.api.model.SAPSystem;
import com.redwood.scheduler.api.date.DateTimeZone;
import java.util.Iterator;
{
SAPSystem sapSystem = jcsSession.getSAPSystemByName("NSP");
RfcConnectionManager rfcConnectionManager = new RfcConnectionManager(sapSystem);
rfcConnectionManager.callXBP(new XbpWork()
{
public void performWork(final XbpInterface xbp)
{
SapBatchJobStatus[] statuses = new SapBatchJobStatus[]
{
SapBatchJobStatus.Scheduled, SapBatchJobStatus.Finished
};
DateTimeZone dtz = new DateTimeZone();
dtz.truncateHour();
Iterator<XbpJob> jobs = xbp.selectJobs(XbpJobSelectionOption.All, "*", null, statuses, dtz, new DateTimeZone() );
jobs.forEachRemaining(job ->
{
jcsOut.println("SAP job #" + job.getJobcount() + " named '" + job.getJobname() +
"' has " + job.getNumberOfSteps() + " step(s).");
});
}
});
}
}
Selecting intercepted SAP jobs using
getInterceptedJobs
:
import com.redwood.scheduler.api.connector.sap.rfc.scripting.RfcConnectionManager;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpInterface;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpJobSelectionOption;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpJob;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpWork;
import com.redwood.scheduler.api.model.SAPSystem;
import java.util.Iterator;
{
SAPSystem sapSystem = jcsSession.getSAPSystemByName("NSP");
RfcConnectionManager rfcConnectionManager = new RfcConnectionManager(sapSystem);
rfcConnectionManager.callXBP(new XbpWork()
{
public void performWork(final XbpInterface xbp)
{
Iterator<XbpJob> interceptedJobs = xbp.getInterceptedJobs(XbpJobSelectionOption.All);
interceptedJobs.forEachRemaining(interceptedJob ->
{
jcsOut.println("SAP job #" + interceptedJob.getJobcount() + " has been intercepted");
});
}
});
}
Raising an SAP batch event using
raiseBatchEvent
:
import com.redwood.scheduler.api.connector.sap.rfc.scripting.RfcConnectionManager;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpInterface;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpWork;
import com.redwood.scheduler.api.model.SAPSystem;
{
SAPSystem sapSystem = jcsSession.getSAPSystemByName("NSP");
RfcConnectionManager rfcConnectionManager = new RfcConnectionManager(sapSystem);
rfcConnectionManager.callXBP(new XbpWork()
{
public void performWork(final XbpInterface xbp)
{
xbp.raiseBatchEvent("Z_TEST", "Testing this.");
}
});
}
Reading an SAP Variant using
getVariant
:
import com.redwood.scheduler.api.connector.sap.rfc.scripting.RfcConnectionManager;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpInterface;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpWork;
import com.redwood.scheduler.api.model.SAPSystem;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.AbapVariantValue;
import java.util.Iterator;
{
SAPSystem sapSystem = jcsSession.getSAPSystemByName("NSP");
RfcConnectionManager rfcConnectionManager = new RfcConnectionManager(sapSystem);
rfcConnectionManager.callXBP(new XbpWork()
{
public void performWork(final XbpInterface xbp)
{
Iterator<AbapVariantValue> abapVariantValues = xbp.getVariant("RSUSR007", "TRAINING").getValues();
abapVariantValues.forEachRemaining(val ->
{
if (val.isParameter())
{
jcsOut.println("SAP variant value " + val.getName() + " is a parameter.");
}
});
}
});
}
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.XbpInterface;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpWork;
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.callXBP(new XbpWork()
{
public void performWork(final XbpInterface 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.XbpInterface;
import com.redwood.scheduler.api.connector.sap.rfc.scripting.xbp.XbpWork;
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.callXBP(new XbpWork()
{
public void performWork(final XbpInterface 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());
}
}
});
}