Documente Academic
Documente Profesional
Documente Cultură
Usage Documentation
Applies to SAP PI B2B SP 02
CONTENTS
SUMMARY .................................................................................................................................... 2
PREREQUISIT ................................................................................................................................. 2
1
SUMMARY
The following API provides a programmable way to create, read, update, and delete operations on Number
Range Objects.
Prerequ isit
The extracted ‘.jar’ file (com.sap.aii.nro.interface.filter.jar) from the ‘PIB2BCONTENT.SCA’ archive should be
imported into the repository as an “Imported Archives” object.
A newly or an existing function library should be used with this new imported archive as a dependency.
API is part of the _nro_facade project which is available in the PIB2BTOOLKIT.sca. You can also find the ‘.jar’
file which has to be imported into repository (ESR) while creating the UDF in the PIB2BCONTENT.sca
Note
API is dependent on the Number Range Object application, make sure that the application deployed
successfully from the PIB2BTOOLKIT.sca.
The NROApiAccess interface controls the API access. There are two ways, to get an instance of the same. NRO
API Access factory is uses
2
CREATE NUMBER RANGE OBJECT
/**
*
* create a New NumberRangeObject
*
* @param numberRangeName
* Name of the Number Range Object
* @param value
* value from the Number range should start ,should be a value
* between 'minimumValue' and 'maximumValue' Pass value 0 if not required
* @param minValue
* minimum value for the number range
* @param maxValue
* maximum value for the number range
* @param valueLength
* Number of characters in number range , Pass value 0 if not
* required
* @param rotate
* 'true' If the number range should be repeated
* @param warnLevel
* Percentage value of the warnLevel, value should be in between 0 and
* 100,Pass Value 0 if not required
* @param description
* Description for the Number Range
* @return
* @throws NROApiAccessException
* Name used already exists and is not marked for delete
* @throws NROApiAccessLockException
* Lock cannot be acquired , it is the reponsibility of the client to retry.
*
*/
public INumberRangeObject createNewNumberRangeObject(String numberRangeName, long
value, long minValue, long maxValue, short valueLength, boolean rotate, int
warnLevel, String description)
throws NROApiAccessException, NROApiAccessLockException;
Note
3
READ NUMBER RANGE OB JECT
/**
* @param numberRangeName
* number range name of the existing number range object
* @return
* @throws NROApiAccessException
*/
/**
* @param numberRangeName
* Sets the number range to deleted, number range set for deleted can be reused
* by calling create/update number range api
* @return
* @throws NROApiAccessException
* Number range does not exist
* @throws NROApiAccessLockException
* Lock cannot be acquired , it is the reponsibility of the client to retry.
*/
public boolean setDeleted(String numberRangeName)
throws NROApiAccessException ,NROApiAccessLockException;
Note
The method setDeleted can throw NROApiAccessLockException when it cannot acquire lock to complete the
operation, in that case the client should retry.
Refer to the related link found at the end of this document, for detailed description of NRO.
4
UPDATE NUMBER RANGE OBJECT
/**
* update an existing NumberRangeObject
*
* @param numberRangeName
* Name of the existing Number Range Object
* @param value
* value from the Number range should start ,should be a value between
* 'minimumValue' and 'maximumValue' of the number range
* @param minValue
* minimum value for the number range
* @param maxValue
* maximum value for the number range
* @param valueLength
* Number of characters for the getNumber() method , Pass Value 0 if not
* required
* @param rotate
* 'true' If the number range should be repeated
* @param warnLevel
* Percentage value of the warnLevel, Value should be in between 0 and 100,
* Pass Value 0 if not required
* @param description
* Description for the Number Range
* @return
* @throws NROApiAccessException
* Name used does not exist.
* @throws NROApiAccessLockException
* Lock cannot be acquired , it is the reponsibility of the client to retry.
*/
Note
The method updateNumberRangeObject can throw NROApiAccessLockException when it cannot acquire lock
to complete the operation, in that case the client should retry.
Refer to the related link found at the end of this document, for detailed description of NRO.
5
UPDATE AND READ NUMBER RANGE OBJECT
This method updates the Number Range Object value by one and returns the same object. In case of high load
scenarios please use this method to avoid duplicates.
/**
* Increments the numberRangeName by one
* @param numberRangeName
* number range name of the existing number range object
* @return the updated number range object
* @throws NROApiAccessException
*/
public INumberRangeObject getAndUpdateNumberRangeObjectWithName(String
numberRangeName) throws NROApiAccessException;
Note
You use the procedure below to access the NRO API’s from an UDF:
try{
NROApiAccessRemote api = NROApiAccessFactory.createRemoteNROApiAccess();
// Here the value gets incremented by one and then the object is returned
INumberRangeObject obj = api.getAndUpdateNumberRangeObjectWithName(var1);
value = obj.getValue() - 1;
} catch (Exception ex) {
trace.addWarning("Unable to get NRO. " + ex.getMessage());
throw new RuntimeException("The values " + var1 + ", in " + container + " could not
be processed.", ex);
}
return ""+value;
Note
Use the above procedure to acquire a unique number range object when you have a high load scenario (3 – 4
messages per second)
6
Code Exa mple Two
try{
NROApiAccessRemote api = NROApiAccessFactory.createRemoteNROApiAccess();
INumberRangeObject obj = api.getNumberRangeObjectWithName(var1);
value = obj.getValue();
api.updateNumberRangeObject(
obj.getName(),
obj.getValue()+1,
obj.getMinValue(),
obj.getMaxValue(),
obj.getValueLength(),
Boolean.getBoolean(obj.getRotate()),
obj.getWarnLevel(),
obj.getDescription()
);
} catch (Exception ex) {
trace.addWarning("Unable to get NRO. " + ex.getMessage());
throw new RuntimeException("The values " + var1 + ", in " + container + " could not
be processed.", ex);
}
return ""+value;
Related Content