SAP DYNSQL_GENERATE_WHERE_CLAUSE Function Module for Dynamic SQL Generation (->ADK)









DYNSQL_GENERATE_WHERE_CLAUSE is a standard dynsql generate where clause SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Dynamic SQL Generation (->ADK) processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.


See here to view full function module documentation and code listing for dynsql generate where clause FM, simply by entering the name DYNSQL_GENERATE_WHERE_CLAUSE into the relevant SAP transaction such as SE37 or SE38.

Function Group: DYNS
Program Name: SAPLDYNS
Main Program: SAPLDYNS
Appliation area: S
Release date: 19-Nov-1997
Mode(Normal, Remote etc): Normal Function Module
Update:



Function DYNSQL_GENERATE_WHERE_CLAUSE pattern details

In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.
CALL FUNCTION 'DYNSQL_GENERATE_WHERE_CLAUSE'"Dynamic SQL Generation (->ADK)
EXPORTING
* FIELDNAME_KEY_1 = "Field Label
* FIELDNAME_KEY_2 = "Field Label
* FIELDNAME_VALUE = "Field Label
* OPERATOR = "Operator for FELD3
* PRIO_FELD = "

CHANGING
* KEY_1_IS_IN_WHERE_CLAUSE = "Return flag
* KEY_2_IS_IN_WHERE_CLAUSE = "Return flag

TABLES
* WHERE_CLAUSE = "Table with generated where-clause
CONTROL_TABLE = "Tax table
ALL_VALUES_KEY_1 = "Table with allowed values
VALUES_KEY_1 = "Table with partial quantity of values 1
ALL_VALUES_KEY_2 = "Table with allowed values
VALUES_KEY_2 = "Table with partial quantity of values 2

EXCEPTIONS
DYNSQL_TOO_LARGE = 1 WRONG_ENTRY_IN_CONTROL_TABLE = 2 KEY_VALUES_INCONSISTENT = 3 NO_ENTRY_FOUND = 4 FUNCTION_ALREADY_CALLED = 5
.



IMPORTING Parameters details for DYNSQL_GENERATE_WHERE_CLAUSE

FIELDNAME_KEY_1 - Field Label

Data type:
Optional: Yes
Call by Reference: No ( called with pass by value option)

FIELDNAME_KEY_2 - Field Label

Data type:
Optional: Yes
Call by Reference: No ( called with pass by value option)

FIELDNAME_VALUE - Field Label

Data type:
Optional: Yes
Call by Reference: No ( called with pass by value option)

OPERATOR - Operator for FELD3

Data type:
Optional: Yes
Call by Reference: No ( called with pass by value option)

PRIO_FELD -

Data type: INT4
Optional: Yes
Call by Reference: Yes

CHANGING Parameters details for DYNSQL_GENERATE_WHERE_CLAUSE

KEY_1_IS_IN_WHERE_CLAUSE - Return flag

Data type: C
Optional: Yes
Call by Reference: Yes

KEY_2_IS_IN_WHERE_CLAUSE - Return flag

Data type: C
Optional: Yes
Call by Reference: Yes

TABLES Parameters details for DYNSQL_GENERATE_WHERE_CLAUSE

WHERE_CLAUSE - Table with generated where-clause

Data type: SDIT_QRY
Optional: Yes
Call by Reference: No ( called with pass by value option)

CONTROL_TABLE - Tax table

Data type: DSQL5COL
Optional: No
Call by Reference: No ( called with pass by value option)

ALL_VALUES_KEY_1 - Table with allowed values

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

VALUES_KEY_1 - Table with partial quantity of values 1

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

ALL_VALUES_KEY_2 - Table with allowed values

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

VALUES_KEY_2 - Table with partial quantity of values 2

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

EXCEPTIONS details

DYNSQL_TOO_LARGE - Generated where clause is to great

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

WRONG_ENTRY_IN_CONTROL_TABLE - Entries in the control table not allowed

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

KEY_VALUES_INCONSISTENT - Entries in control tables are inconsistent

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

NO_ENTRY_FOUND - Internal error

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

FUNCTION_ALREADY_CALLED - Function already called

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

Copy and paste ABAP code example for DYNSQL_GENERATE_WHERE_CLAUSE Function Module

The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.

DATA:
lt_where_clause  TYPE STANDARD TABLE OF SDIT_QRY, "   
lv_fieldname_key_1  TYPE SDIT_QRY, "   
lv_dynsql_too_large  TYPE SDIT_QRY, "   
lv_key_1_is_in_where_clause  TYPE C, "   
lt_control_table  TYPE STANDARD TABLE OF DSQL5COL, "   
lv_fieldname_key_2  TYPE DSQL5COL, "   
lv_key_2_is_in_where_clause  TYPE C, "   
lv_wrong_entry_in_control_table  TYPE C, "   
lv_fieldname_value  TYPE C, "   
lt_all_values_key_1  TYPE STANDARD TABLE OF C, "   
lv_key_values_inconsistent  TYPE C, "   
lv_operator  TYPE C, "   
lt_values_key_1  TYPE STANDARD TABLE OF C, "   
lv_no_entry_found  TYPE C, "   
lv_prio_feld  TYPE INT4, "   
lt_all_values_key_2  TYPE STANDARD TABLE OF INT4, "   
lv_function_already_called  TYPE INT4, "   
lt_values_key_2  TYPE STANDARD TABLE OF INT4. "   

  CALL FUNCTION 'DYNSQL_GENERATE_WHERE_CLAUSE'  "Dynamic SQL Generation (->ADK)
    EXPORTING
         FIELDNAME_KEY_1 = lv_fieldname_key_1
         FIELDNAME_KEY_2 = lv_fieldname_key_2
         FIELDNAME_VALUE = lv_fieldname_value
         OPERATOR = lv_operator
         PRIO_FELD = lv_prio_feld
    CHANGING
         KEY_1_IS_IN_WHERE_CLAUSE = lv_key_1_is_in_where_clause
         KEY_2_IS_IN_WHERE_CLAUSE = lv_key_2_is_in_where_clause
    TABLES
         WHERE_CLAUSE = lt_where_clause
         CONTROL_TABLE = lt_control_table
         ALL_VALUES_KEY_1 = lt_all_values_key_1
         VALUES_KEY_1 = lt_values_key_1
         ALL_VALUES_KEY_2 = lt_all_values_key_2
         VALUES_KEY_2 = lt_values_key_2
    EXCEPTIONS
        DYNSQL_TOO_LARGE = 1
        WRONG_ENTRY_IN_CONTROL_TABLE = 2
        KEY_VALUES_INCONSISTENT = 3
        NO_ENTRY_FOUND = 4
        FUNCTION_ALREADY_CALLED = 5
. " DYNSQL_GENERATE_WHERE_CLAUSE




ABAP code using 7.40 inline data declarations to call FM DYNSQL_GENERATE_WHERE_CLAUSE

The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


Search for further information about these or an SAP related objects



Comments on this SAP object

What made you want to lookup this SAP object? Please tell us what you were looking for and anything you would like to be included on this page!