cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Getting records from SAP service layer SQLQueries endpoint using conditional parameters

asadmateenkhan
Explorer
0 Likes
579

Hi,
we are using SAP service layer and calling the endpoint /SQLQueries('test_contactemployee')/List

we have a following Sql query to get all the contact employees.

SELECT BP."CardCode", BP."CardName", CE."Name", CE."Position", CE."Address", BP."QryGroup1",
CE."Tel1" AS "Phone1", CE."Tel2" AS "Phone2", CE."Cellolar" AS "MobilePhone",
CE."Fax" AS "Fax", CE."E_MailL" AS "EMail",
(SELECT COUNT(*) FROM "OCRD" BP2 JOIN "OCPR" CE2 ON BP2."CardCode" = CE2."CardCode") AS "@odata.count"
FROM "OCRD" BP
JOIN "OCPR" CE ON BP."CardCode" = CE."CardCode"
where BP."CardCode" = :CardCode


What we want to achieve is that if :CardCode is null then retrieve all records otherwise particular BP. And same goes for other parameters. What are the possibilities?

WHERE (:CardCode IS NULL OR BP."CardCode" = :CardCode)

asadmateenkhan_1-1724231693884.png

 

 




Accepted Solutions (0)

Answers (0)