23

SAP CPI – Use SELECT Operation To Fetch All Records From Datastore

 3 years ago
source link: https://blogs.sap.com/2021/05/23/sap-cpi-use-select-operation-to-fetch-all-records-from-datastore/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Technical Articles
Posted on May 23, 2021 2 minute read

SAP CPI – Use SELECT Operation To Fetch All Records From Datastore

5 Likes 393 Views 3 Comments

Hi All,

There might be requirement to store the records temporarily in Datastore and use it later till all entries are consumed. For this article I have created two Iflows one is to store payload using WRITE operation and another Iflow is to fetch all the records from Datastore using SELECT operation in group of two. Hope this will be usefully to other who trying to achieve the same.

IFlow 1 – WRITE operation to store data. I am using ID value from incoming payload to generate entry IDs in Datastore.

IFlow1.png

write-1.png

IFlow 2 – I am using loop process call to fetch all the entries from datastore in group of 2. To avoid passing last empty records to target system I am using router. This will suppress processing of empty record.

iflow2-2.png

Below is the used condition for the loop

processLoop.png

So my loop will end whenever select step will give me empty entry or max number of iterations are reached. I am fetching records in group of 2 using SELECT operation.

select-1.png

Below is the list of entries in my datastore – DS_Books

DS_Books-2.png

Iflow 2 executed succesffuly, below are the monitoring page screenshots

Monitor1-1.png
Monitor2-2.png

I have received mail with datastore records –

mail1-2.png
mail2-1.png
mail3-1.png

Please share your thoughts if there are any other ways to achieve this.

Learning :-

  • With GET operation this is not possible, GET is used for fetching single record at a time.
  • This looks for the entry ID to fetch the data
  • If we have selected save header values during WRITE operation, this can be fetched with GET operation
    getHeader.png
  • You can download datastore record to check headerdatastoreProp.png
  • With SELECT we can group the records and can be used with loop call

!Happy Learning!

Regards,

Rashmi


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK