0% found this document useful (0 votes)
96 views1 page

ABAP - Using of Generic Data Elements (Sample) - Code Gallery - SCN Wiki

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views1 page

ABAP - Using of Generic Data Elements (Sample) - Code Gallery - SCN Wiki

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

11/8/2019 ABAP - Using of generic data elements (sample) - Code Gallery - SCN Wiki

Getting Started Store

Community WIKI SAP Community Welcome, Guest Login Register Search the Community

Code Gallery

ABAP - Using of generic data elements (sample)


Created by Waldemar Schakiel, last modified on Apr 05, 2016

Author: Waldemar Schakiel


Submitted: 5th April 2016

Description

Here is a sample for using generic data elements. This example displays the content of any table that was given as Parameter.

REPORT zgeneric_elements.
PARAMETERS:
p_tabnam TYPE tabname.

DATA:
lr_table TYPE REF TO data,
lx_error TYPE REF TO cx_root.

FIELD-SYMBOLS:
<lt_table> TYPE ANY TABLE.

TRY.
CREATE DATA lr_table TYPE TABLE OF (p_tabnam).
ASSIGN lr_table->* TO <lt_table>.

SELECT * FROM (p_tabnam) INTO TABLE <lt_table>.

LOOP AT <lt_table> ASSIGNING FIELD-SYMBOL(<ls_table>).


DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <ls_table> TO FIELD-SYMBOL(<lv_field>).

IF sy-subrc = 0.
WRITE: <lv_field>.
ELSE.
WRITE: /. " New line
EXIT.
ENDIF.
ENDDO.
ENDLOOP.

CATCH cx_sy_create_data_error cx_sy_dynamic_osql_semantics INTO lx_error.


WRITE: / 'Exception:', lx_error->get_text( ).
ENDTRY.

No labels

Contact Us SAP Help Portal


Privacy Terms of Use Legal Disclosure Copyright Cookie Preferences Follow SCN

https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=491920119 1/1

You might also like