- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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
Fetch fields from table or structure in ABAP SAP
If you need to identify the fields and number of fields in a structure, then you should use runtime type services. Using runtime type services makes more sense in this case as if we have some data in our environment, then it’s not ideal to call database for fetching the same.
DATA(structure) = VALUE <your structure>( ) DATA(Descriptor) = CAST cl_abap_structdescr( cl_abap_datadescr=>describe_by_data (structure) ) DATA(Fields = LINES(Descriptor ->components )
This will give you the count of the components of the table or structure.
You can also try another option if you do not want to use runtime type services. Below query can get you’re the count
SELECT COUNT(*) INTO @data(count) FROM DD03l (// this table stores the fields information of SAP tables) WHERE tabname = <Structure name> AND AS4LOCAL = 'A'
Advertisements