Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Formatted Search If Statement

Hi

I have a formatted search as below for a UDF in outgoing payment screen

Select"CardFName" From OCRD Where "CardCode" = $[OVPM."CardCode"]

The problem is that if user do not select any card code in outgoing payment which means $[OVPM."CardCode"] is null, I would like to just select all foreign name from business partner master data and allow them to select manually from the list. I tried to do the query like below but encountered error "Incorrect syntax near IF". Please kindly advise


IF IFNULL($[OVPM."CardCode"],'')  = ''

BEGIN

SELECT "CardFName" FROM OCRD

ELSE

SELECT "CardFName" FROM OCRD WHERE "CardCode" = $[OVPM."CardCode"]

END

Note: SAP B1 HANA

Regards

Yvaine

Tags:
Former Member
Former Member replied

Hi Yvaine,

Check this:

declare card NVARCHAR(50);

SELECT COALESCE($[OVPM."CardCode"],'') into card FROM "DUMMY";

IF (:card  = '') THEN

SELECT "CardFName" FROM OCRD;

ELSE

SELECT COALESCE("CardFName",'no contact') FROM OCRD WHERE "CardCode" = $[OVPM."CardCode"];

END IF;

Kind regards,

Radek

2 View this answer in context
Not what you were looking for? View more on this topic or Ask a question