- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Creating a variable with dynamic variable type in SAP ABAP
You can use RTTS related API to create a Standard table like RANGE which has components like 'LOW', 'HIGH', 'EQ' and 'OPTION'
data: rr_data type ref to data, rt_range_string type range of string, rs_range_string like line of rt_range_string, rt_component type abap_component_tab, rs_component type line of abap_component_tab, rt_range_components type abap_component_tab, ro_struc_descr type ref to cl_abap_structdescr, ro_table_descr type ref to cl_abap_tabledescr, ro_data_descr type ref to cl_abap_datadescr.
field-symbols
<var_value> type any, <rt_range_type> type standard table, //<rt_range_type> is your range table <rs_range_type> type any. data(var_type) = 'BU_PARTNER'. create data rr_data type (var_type). ro_struc_descr ?= cl_abap_structdescr=>describe_by_data( p_data = rs_range_string ). rt_component = ro_struc_descr->get_components( ). ro_data_descr ?= cl_abap_elemdescr=>describe_by_name( var_type ). rt_range_components = value #( for comp in rt_component ( name = comp-name type = cond #( when comp-name eq 'SIGN' or comp-name eq 'OPTION' then comp-type else ro_data_descr ) ) ). ro_struc_descr ?= cl_abap_structdescr=>create( rt_range_components ). ro_table_descr ?= cl_abap_tabledescr=>create( ro_struc_descr ). create data rr_data type handle ro_table_descr. assign rr_data->* to <rt_range_type>. create data rr_data like line of <rt_range_type>. assign rr_data->* to <rs_range_type>. assign component 'SIGN' of structure <rs_range_type> to <var_value>. <var_value> = 'I'. assign component 'OPTION' of structure <rs_range_type> to <var_value>. <var_value> = 'EQ'. assign component 'LOW' of structure <rs_range_type> to <var_value>. <var_value> = 'X1'. assign component 'HIGH' of structure <rs_range_type> to <var_value>. <var_value> = 'X2'.
- Related Articles
- Defining a variable reference in SAP ABAP
- Creating a mandatory variable in SAP HANA View
- Form a dynamic Query in SAP ABAP
- Creating Variable in UI Path
- What are variable length (Dynamic) Arrays in Java?
- Sort Datetime Type in SAP ABAP
- SAP ABAP: Using Elementary data type and reference type with keyword VALUE
- Using real Boolean type in SAP ABAP
- ABAP dump while creating an entry in SAP system using SAP JCO
- Get the type of a variable in MySQL?
- Update MongoDB variable value with variable itself?
- How do I create dynamic variable names inside a JavaScript loop?
- Create BigInteger via long type variable in Java
- Difference between Types,Types,Type-POOL and TYPE-POOLS in SAP ABAP
- How to get the variable data type in PowerShell?

Advertisements