Skip to Content
avatar image
Former Member

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 04, 2016 at 07:32 AM

    Hi Yvaine,

    Please refer to this webpage:

    SAP HANA SQL and System Views Reference - SAP Library

    You will find that IF statements are not supported in SAP HANA.

    You can use CASE/WHEN as alternative. Look under the topic 'Expressions' in the above web link.

    Kind Regards,

    Nick Lakasas

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Looks like I was incorrect stating that "IF statements are not supported".

      Best I read the guide I suggested 🤪

      Apologies if I caused any confusion.

      Kind Regards,

      Nick Lakasas

  • avatar image
    Former Member
    Apr 01, 2016 at 06:04 AM

    Hi Kong,

    try this,

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

    BEGIN

    SELECT "CardFName" FROM OCRD

    ELSE

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

    END

    Thanks,

    Harshal

    Add comment
    10|10000 characters needed characters exceeded