2.12.3 Assign a unique reference number to a FAB form
Add a reference number to each instance of a form that you create when using the ‘New Form’ option on the FAB landing page.
The assumption is that you do not assign a reference number to a form when action is DRAFT. Use the below information when action is SUBMIT.
Step-by-step guide
First setup a number range within SAP.
Create a number range object
Use SAP tcode SNRO.
Give your number range object a name e.g.ZFABNR.
Save and place on a transport. The object is now created and you must now setup the the number range using the Ranges button followed by the Intervals button.
Enter a starting and ending number range and save.
3. Setup a service to use the number range object.
You need to have a service that you can call from your FAB application that will pick up and increment the number in the range and increment it for you. Create your service and use function module NUMBER_GET_NEXT to get the next number that can be used.
In the Gateway Model Class define an Entity.
4. Define the a type in the Gateway Model Class.
5. Define the NextNum type in the Gateway Data Class.
6. Create a GET_NETXNUM method in the Gateway Data Class
In the GET_NEXTNUM method call the SAP function NUMBER_GET_NEXT using the object defined using tcode SNRO.
To test the service use tcode /IWFND/MAINT_SERVICE and
URL /sap/opu/odata/sap/ZTS_IQX_SH/NextNum.
You can now incorporate this service into your FAB application. Each time you call the service it provides you with the next number so that it can be stored in a variable defined within your form eg. ReferenceNo.
The most likely place for you to incorporate this service is in FAB Implementation Class Method PERFORM_ACTIONS_FOR_STATUS_CHG when the action is SUBMIT.
Related articles