Skip to Content
-1

Sql Code Convert to SAP Hana

Hello I am new in SAP HANA and I have this T-SQL code:

if(@IsBes='E')begin

               if((select top 1 U_bBesYontem from OHEM where empID=@EmpId)='O') begin

                     set @Bes=@Brut*(select top 1 U_bBesOran from OHEM where empID=@EmpId)/100

                  end

               if((select top 1 U_bBesYontem from OHEM where empID=@EmpId)='T') begin

                     set @Bes=(select top 1 U_bBesTutar from OHEM where empID=@EmpId)

                  end

         end`

And I am trying this code for SAP HANA

IF (:IsBes = 'E') THEN 
          IF ((SELECT TOP 1 “U_bBesYontem" 
FROM 
     OHEM 
WHERE 
"empID" = :EmpId) = 'O') 
THEN 
Bes := :Brut * (SELECT TOP 1 "U_bBesOran" 
     FROM OHEM 
      WHERE 
         "empID" = :EmpId) / 100;
    END IF;
    IF ((SELECT TOP 1 "U_bBesYontem" 
 FROM OHEM 
 WHERE "empID" = :EmpId) = 'T') THEN 
         SELECT (SELECT TOP 1 "U_bBesTutar" 
        FROM OHEM 
        WHERE "empID" = :EmpId) INTO Bes 
 FROM DUMMY;
    END IF;
    END IF;
And tried lots of code variations but I always end up getting this error:

SAP DBTech JDBC: [7]: feature not supported:
 Sub-query is not supported in a nested procedure call: 
 line 47 col 28 (at pos 2273)

I am confused so Any advise??

(I used sql converter)

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 08 at 07:44 AM

    Hi,

    Try this one:

    IF (:IsBes = 'E') THEN 
    SELECT TOP 1 "U_bBesYontem" into variable1 FROM OHEM WHERE "empID" = :EmpId
       IF (:variable1 = 'O') 
        THEN 
            SELECT TOP 1 "U_bBesOran" into variable2 FROM OHEM 
            WHERE "empID" = :EmpId
            Bes := :Brut * (:variable2 / 100);
       END IF;
        IF (:variable1 = 'T') 
         THEN 
            SELECT TOP 1 "U_bBesTutar" INTO Bes FROM OHEM 
            WHERE "empID" = :EmpId;
        END IF;
    END IF;
    Add comment
    10|10000 characters needed characters exceeded