Skip to Content
SAP HANA

Placeholder for SQL Script in SAP HANA

Tags:

I struggled a bit copy pasting syntaxes available on the internet while trying to create a wrapper for a Calculation view which has input parameters.

I realized later that the struggle primarily was because there are 2 different syntaxes while using Placeholder for SQL script depending on the following cases

1. You want to assign a hard-coded value for the Placeholder input parameter in the wrapped sql script

2. You want to send in another input parameter from the wrapped procedure to the internal sql script

Scenario Exaggeration:

When you create a Calculation view which has Plants 1000, 1200, 1100, 1001 etc and you want the Report executor to input the Plant that he want to run the report for, you will create an input parameter say :ZIP_PLANT

Now you can create a Wrapper SQL Script that wraps this calculation view to help you either pass a hard-coded value into the Input parameter or send another input parameter to the inner Calculation view. This helps in limiting the number of fields that are exposed in your outer view and there are lots of other use cases.

Case 1:

You want to create a variant of this Calculation view so that a person responsible for Plant 1000 can run this script only for this plant.

In this case, the syntax for the PLACEHOLDER is as follows:

('PLACEHOLDER' = ('$$MoveType$$', '1000')

And your full script looks like below.

select 

       "BillingDocument",

      "BillingDocumentType",

      "Plant",

      "Material",

      "Country",

      "Region",

      SUM("TotalNetAmount") as TA

     

       from "_SYS_BIC"."I306583/ZGRPHICAL_VIEW"

('PLACEHOLDER' = ('$$ZIP_PLANT$$', '1000')


Case 2:

You want to create a variant of this Calculation view so that a person can input any of the Plants as a value to an input parameter set at this wrapper sql level. The reason to do this could be to limit the number of fields or restrict another set of input parameters however allow Plant to be selected freely.

In this case, the syntax for the PLACEHOLDER is as follows:

(PLACEHOLDER."$$ZIP_PLANT$$" => :ZIP_PLANT)

And your full script looks like below.

select 

       "BillingDocument",

      "BillingDocumentType",

      "Plant",

      "Material",

      "Country",

      "Region",

      SUM("TotalNetAmount") as TA

     

       from "_SYS_BIC"."I306583/ZGRPHICAL_VIEW"

(PLACEHOLDER."$$ZIP_PLANT$$" => :ZIP_PLANT)


Remember to set a Filter in the underlying SQL script at the Plant level and assign the Input parameter to the filter.

Individually test your underlying SQL before working on the wrapper procedure. 



Former Member

No comments