Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
appalanaidu_uppada
Product and Topic Expert
Product and Topic Expert
15,052

Introduction:


SAP Cloud Integration offers Number Ranges to insert unique sequence numbers as part of the inbound or outbound messages. This is one of the highly recommended requirement in EDI message processing. A number sequence is created to help the trading partners to detect and avoid duplicate, missing or out of sequence interchange transmissions.

From July 2018 release of Cloud Integration, Number Ranges are available for consumption for all customers. Earlier, Number Ranges were available only with Enterprise licensed tenants.

In this blog, I will explain in detail on how to configure and consume Number Ranges with few examples of EDI inbound and outbound messages.

Configuring Number Ranges:


To configure Number Ranges, navigate to Monitor->Manage Stores->Number Ranges as shown in the below screenshot.



 

Usecase 1: Using Number Ranges in an EDI outbound scenario:


       Consider an outbound scenario where you receive an IDoc from the ERP and convert it to an ANSI X12 message. Finally sending the converted EDI document to a trading partner. Let’s call the partner as “ABC Industries”.

Consider you have a requirement to generate a new Interchange Control Number each time you are sending an ANSI X12 message.
Create a Number Range:

       Let’s create a Number Range for generating a unique Interchange Control Number, each time an IDoc is converted to an ANSI X12 message.

In this example, I created a Number Range called “ABCIndustries_ICN_IDocToX12” with a field length of 9 (As per ANSI X12 message standard the Interchange Control Number ISA12 field should always be of 9 characters) as shown the below diagram.



 



NOTE:  Interchange Control Number in ANSI X12
Create a Header of Type Number Range in the Integration Flow:

You can consume the Number Ranges in a content modifier as shown in the below diagram. Here I selected the type of the header as “Number Range” and used the number range that I created before ( i.e, ABCIndustries_ICN_IDocToX12 )  as the value .



NOTE:  You can also consume the number ranges in exchange properties as well.

This header will always generate a new unique value each time the integration flow is executed and the next Interchange Control Number is incremented by 1.

Usecase 2: Using Number Ranges with a Correlation:


a) Consider an inbound scenario where you receive a Bulk EDI document with multiple messages ( e.g: 850 ) .Now, you want to maintain the same Interchange Control Number value for all split individual messages. To achieve this requirement, I would declare the header value in the content modifier as

                  ABCIndustries_ICN_X12ToIDoc:${header.SAP_EDI_Interchange_Control_Number}

b)  Let’s consider another scenario, where an AS2 sender adapter retries sending messages to the receiver due to processing failures. In such cases, you do not want to increment the Number Range value for each retry, then declare the value of the header as

               ABCIndustries_ICN_X12ToIDoc:${header. SAP_MessageProcessingLogID}


 Summary:


    We learnt about creating and using Number Ranges in different EDI scenarios. Though the examples show the cases related to EDI message processing, you can use the number ranges wherever you need to generate unique sequence number in your integration scenario.
13 Comments
0 Kudos
Thanks for the Blog Appala Naidu.

I couldn't see the same option "Number range" on my CPI tenant which is of version 2.41.9.
appalanaidu_uppada
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hello Naresh,

Are you talking about Content Modifier ?

If yes, please use Web UI to see the option.

Thanks,

Appala
0 Kudos
I was asking about the "Number Range" tile under Monitoring tab.
appalanaidu_uppada
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hello Naresh,

It should be there under Manage Stores.

Please re-check.

Thanks,

Appala
0 Kudos
Now I could see. Thanks.
Pecoros
Explorer
0 Kudos
Hi,

Number range is nice and easy to use at header level, but how could we use it in a mapping (as customer function if required) to get a new number for each item  for exemple ?

I have a requirement to generate a number which should be unique, and number range might be the best solution.

Any suggestion is welcome.

Thanks.

Pierre
appalanaidu_uppada
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Pierre,

As of now, we do not have such function available.We would add this functionality in the near future.

Meanwhile, you can create a custom function in mapping to consume the header from content modifier.

Thanks,

Appala

Pecoros
Explorer
0 Kudos
Hi Appala

 

Thanks fo your quick reply. In fact the trick to use the header is not really applicable in my case as I may need many numbers during the mapping (depends on message content) so it can't be one header value...

I just hope this near futur is not too far.

Regards,

Pierre
nerevar
Participant
0 Kudos
Hello there,

How to I use number range in a message mapping? for example to generation multiple unique invoice request ID in ByDesign?

Thanks
Harish_Kintali
Product and Topic Expert
Product and Topic Expert
Dear Community Members,

In case you are not aware of the possibility to handle number ranges from groovy directly, refer this  link

import com.sap.it.api.ITApiFactory;
import com.sap.it.api.nrc.NumberRangeConfigurationService;
import com.sap.it.api.nrc.exception.NumberRangeConfigException;



do number ranges also work when two processes in parallel access the same number range? How is it decided which process gets the next value?
santoshsk926
Explorer
0 Kudos
Hello Appala Naidu,

I am using Web UI but still couldn't see Number range in Content Modifier header. Can you please help?



Number Range option not available in Content Modifier


 

Thanks,

Santosh Lingamallu.
peter_munt4
Participant
0 Kudos

It is possible update them in an iFlow.   I am doing a OAUTH2 Client Authentication - The GET works - The PUT does not.   

The SAP Help Message Stores | SAP Help Portal and and the API Hub Try Out | Message Stores | SAP Business Accelerator Hub

Both suggest that it is possible even though they do not mention a Role Template that suits this.   I get an Forbidden error

I have noticed that my Service Instance for the api plan has a configuration that is missing I think the ability to do this - but these are the Role Templates they mention in the SAP Help - just not mention of anything to do with updating.

{
"grant-types": [
"client_credentials"
],
"redirect-uris": [],
"roles": [
"DataStorePayloadsRead",
"DataStoresAndQueuesRead",
"DataStoresAndQueuesConfig",
"MonitoringDataRead"
],
"token-validity": 43200
}

 

I've also tried this via POSTMAN and get the same error [it has a x-csrf_token set (from a GET call with header X-CSRF-Token = Fetch and has the same Token as per the GET and GET for CSRF which works ]

I am doing a PUT on https://<my sap int host>/api/v1/NumberRanges('BankStatementNumber')   with a JSON payload 

{"CurrentValue":"26",
"Name":"BankStatementNumber",
"MinValue":"0",
"MaxValue":"999999999",
"Description":"Used in iFlow for Import Bank Statement BAI Format from File Server to S4HC",
"Rotate":"true",
"FieldLength":"9"}