‎2008 Jan 17 4:24 PM
Is it possible to have a dynamic select statement in ABAP? If yes, please help me with a sample code for the same.
‎2008 Jan 17 4:51 PM
data: Field_List type string.
data: Where_List type string.
data: table_name type string.
concatenate 'vbeln' 'vdatu' 'kunnr' into Field_List
separated by space.
move 'vdatu >= '20070101'.
move 'vbak' to Table_name.
select Field_list from Table_name
where Where_List.
‎2008 Jan 17 4:51 PM
data: Field_List type string.
data: Where_List type string.
data: table_name type string.
concatenate 'vbeln' 'vdatu' 'kunnr' into Field_List
separated by space.
move 'vdatu >= '20070101'.
move 'vbak' to Table_name.
select Field_list from Table_name
where Where_List.
‎2008 Jan 18 4:31 AM
Hi,
The statement
SELECTION-SCREEN DYNAMIC SELECTIONS FOR NODE|TABLE node.
declares a node node of a logical database for dynamic selections in the selection include.
To use the dynamic selections in the SELECT statements of the subroutine PUT_node, you must use the data object DYN_SEL. The data object DYN_SEL is automatically generated in the logical database program as follows:
TYPE-POOLS RSDS.
DATA DYN_SEL TYPE RSDS_TYPE.
You do not have to program these lines yourself. The data object DYN_SEL is available in the database program but not in a connected executable program.
The type RSDS_TYPE of the data object is defined in the type group RSDS as follows:
TYPE-POOL RSDS.
WHERE-clauses ------------------------------
TYPES: RSDS_WHERE_TAB LIKE RSDSWHERE OCCURS 5.
TYPES: BEGIN OF RSDS_WHERE,
TABLENAME LIKE RSDSTABS-PRIM_TAB,
WHERE_TAB TYPE RSDS_WHERE_TAB,
END OF RSDS_WHERE.
TYPES: RSDS_TWHERE TYPE RSDS_WHERE OCCURS 5.
Expressions Polish notation ---------------
TYPES: RSDS_EXPR_TAB LIKE RSDSEXPR OCCURS 10.
TYPES: BEGIN OF RSDS_EXPR,
TABLENAME LIKE RSDSTABS-PRIM_TAB,
EXPR_TAB TYPE RSDS_EXPR_TAB,
END OF RSDS_EXPR.
TYPES: RSDS_TEXPR TYPE RSDS_EXPR OCCURS 10.
Selections as RANGES-tables -----------------
TYPES: RSDS_SELOPT_T LIKE RSDSSELOPT OCCURS 10.
TYPES: BEGIN OF RSDS_FRANGE,
FIELDNAME LIKE RSDSTABS-PRIM_FNAME,
SELOPT_T TYPE RSDS_SELOPT_T,
END OF RSDS_FRANGE.
TYPES: RSDS_FRANGE_T TYPE RSDS_FRANGE OCCURS 10.
TYPES: BEGIN OF RSDS_RANGE,
TABLENAME LIKE RSDSTABS-PRIM_TAB,
FRANGE_T TYPE RSDS_FRANGE_T,
END OF RSDS_RANGE.
TYPES: RSDS_TRANGE TYPE RSDS_RANGE OCCURS 10.
Definition of RSDS_TYPE
TYPES: BEGIN OF RSDS_TYPE,
CLAUSES TYPE RSDS_TWHERE,
TEXPR TYPE RSDS_TEXPR,
TRANGE TYPE RSDS_TRANGE,
END OF RSDS_TYPE.
Reward if helpful.
Regards Madhu.
‎2008 Jan 29 5:01 AM
Hi Jaspreet,
Here is a demo program
demo_select_dynamic_conditions
Also go through ABAPDOCU. Here you will find some more help.