ABAP Select data from SAP table ORA_DBA_RESUMABLE_STRUCTURE into internal table

Get Example source ABAP code based on a different SAP table
  

Below is a number of ABAP code snippets to demonstrate how to select data from SAP ORA_DBA_RESUMABLE_STRUCTURE table and store it within an internal table, including using the newer @DATA inline declaration methods. It also shows you various ways to process this data using ABAP work area, inline declaration or field symbols including executing all the relevant CONVERSION_EXIT routines specific to ORA_DBA_RESUMABLE_STRUCTURE. See here for more generic Select statement tips.

Sometimes data within SAP is stored within the database table in a different format to what it is displayed to the user. These input/output conversation FM routines are what translates the data between the two formats.

There is also a full declaration of the ORA_DBA_RESUMABLE_STRUCTURE table where each field has a char/string type for you to simply copy and paste. This allows you to use processing that is only available to these field types such as the CONCATENATE statement.

DATA: IT_ORA_DBA_RESUMABLE_STRUCTURE TYPE STANDARD TABLE OF ORA_DBA_RESUMABLE_STRUCTURE,
      WA_ORA_DBA_RESUMABLE_STRUCTURE TYPE ORA_DBA_RESUMABLE_STRUCTURE,
      GD_STR TYPE STRING.

DATA: lo_typedescr type REF TO cl_abap_typedescr.
DATA: lv_fieldname type fieldname.

FIELD-SYMBOLS: <FIELD> TYPE any.
FIELD-SYMBOLS: <ORA_DBA_RESUMABLE_STRUCTURE> TYPE ORA_DBA_RESUMABLE_STRUCTURE.

*Process all fields in table header/work area as string values
  PERFORM process_as_string_field_values CHANGING wa_ORA_DBA_RESUMABLE_STRUCTURE.

SELECT *
*restrict ABAP select to first 10 rows
 UP TO 10 ROWS      
  FROM ORA_DBA_RESUMABLE_STRUCTURE
  INTO TABLE IT_ORA_DBA_RESUMABLE_STRUCTURE.

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM ORA_DBA_RESUMABLE_STRUCTURE
*  INTO TABLE @DATA(IT_ORA_DBA_RESUMABLE_STRUCTURE2).
*--Further methods of using ABAP code to  select data from SAP database tables

*You can also declare the header/work area using the in-line DATA declaration method
READ TABLE IT_ORA_DBA_RESUMABLE_STRUCTURE INDEX 1 INTO DATA(WA_ORA_DBA_RESUMABLE_STRUCTURE2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_ORA_DBA_RESUMABLE_STRUCTURE ASSIGNING <ORA_DBA_RESUMABLE_STRUCTURE>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
<ORA_DBA_RESUMABLE_STRUCTURE>-USER_ID = 1.
<ORA_DBA_RESUMABLE_STRUCTURE>-SESSION_ID = 1.
<ORA_DBA_RESUMABLE_STRUCTURE>-INSTANCE_ID = 1.
<ORA_DBA_RESUMABLE_STRUCTURE>-COORD_INST_ID = 1.
<ORA_DBA_RESUMABLE_STRUCTURE>-COORD_SESSION_ID = 1.
ENDLOOP.

LOOP AT IT_ORA_DBA_RESUMABLE_STRUCTURE INTO WA_ORA_DBA_RESUMABLE_STRUCTURE.
*Write horizonal line to screen report.
  WRITE:/ sy-uline.

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_ORA_DBA_RESUMABLE_STRUCTURE-STATUS, sy-vline,
WA_ORA_DBA_RESUMABLE_STRUCTURE-TIMEOUT, sy-vline,
WA_ORA_DBA_RESUMABLE_STRUCTURE-START_TIME, sy-vline,
WA_ORA_DBA_RESUMABLE_STRUCTURE-SUSPEND_TIME, sy-vline,
WA_ORA_DBA_RESUMABLE_STRUCTURE-RESUME_TIME, sy-vline,
WA_ORA_DBA_RESUMABLE_STRUCTURE-NAME1, sy-vline.
ENDLOOP. *Add any further fields from structure WA_ORA_DBA_RESUMABLE_STRUCTURE you want to display... WRITE:/ sy-uline. * Aternatively use generic code to Write field values (and NAME) to screen report DO. ASSIGN COMPONENT sy-index OF STRUCTURE wa_ORA_DBA_RESUMABLE_STRUCTURE TO <field>. IF sy-subrc <> 0. EXIT. ENDIF. WRITE:/ 'Field Value', <field>, sy-vline. gd_str = <field> . lo_typedescr ?= CL_ABAP_DATADESCR=>DESCRIBE_BY_DATA( <field> ). lv_fieldname = lo_typedescr->GET_RELATIVE_NAME( ). WRITE:/ 'Field Name', lv_fieldname. ENDDO. *Redo loop but convert all fields from internal to out value LOOP AT IT_ORA_DBA_RESUMABLE_STRUCTURE INTO WA_ORA_DBA_RESUMABLE_STRUCTURE. *Write horizonal line to screen report. WRITE:/ sy-uline. *Convert all fields to display/output versions using conversion routines PERFORM convert_all_field_values CHANGING wa_EKKO. ENDLOOP. *&---------------------------------------------------------------------* *& Form convert_all_field_values *&---------------------------------------------------------------------* FORM convert_all_field_values CHANGING p_EKKO LIKE wa_EKKO. DATA: ld_input(1000) TYPE c, ld_output(1000) TYPE C.
ENDFORM. *&---------------------------------------------------------------------* *& Form process_as_string_field_values *&---------------------------------------------------------------------* FORM process_as_string_field_values CHANGING p_EKKO LIKE wa_EKKO. TYPES: BEGIN OF T_ORA_DBA_RESUMABLE_STRUCTURE_STR,
USER_ID TYPE STRING,
SESSION_ID TYPE STRING,
INSTANCE_ID TYPE STRING,
COORD_INST_ID TYPE STRING,
COORD_SESSION_ID TYPE STRING,
STATUS TYPE STRING,
TIMEOUT TYPE STRING,
START_TIME TYPE STRING,
SUSPEND_TIME TYPE STRING,
RESUME_TIME TYPE STRING,
NAME1 TYPE STRING,
NAME2 TYPE STRING,
NAME3 TYPE STRING,
NAME4 TYPE STRING,
NAME5 TYPE STRING,
NAME6 TYPE STRING,
NAME7 TYPE STRING,
NAME8 TYPE STRING,
NAME9 TYPE STRING,
NAME10 TYPE STRING,
NAME11 TYPE STRING,
NAME12 TYPE STRING,
NAME13 TYPE STRING,
NAME14 TYPE STRING,
NAME15 TYPE STRING,
NAME16 TYPE STRING,
SQL_TEXT1 TYPE STRING,
SQL_TEXT2 TYPE STRING,
SQL_TEXT3 TYPE STRING,
SQL_TEXT4 TYPE STRING,
ERROR_NUMBER TYPE STRING,
ERROR_PARAMETER1 TYPE STRING,
ERROR_PARAMETER2 TYPE STRING,
ERROR_PARAMETER3 TYPE STRING,
ERROR_PARAMETER4 TYPE STRING,
ERROR_PARAMETER5 TYPE STRING,
ERROR_MSG1 TYPE STRING,
ERROR_MSG2 TYPE STRING,
ERROR_MSG3 TYPE STRING,
ERROR_MSG4 TYPE STRING,
ERROR_MSG5 TYPE STRING,
ERROR_MSG6 TYPE STRING,
ERROR_MSG7 TYPE STRING,
ERROR_MSG8 TYPE STRING,
ERROR_MSG9 TYPE STRING,
ERROR_MSG10 TYPE STRING,
ERROR_MSG11 TYPE STRING,
ERROR_MSG12 TYPE STRING,
ERROR_MSG13 TYPE STRING,
ERROR_MSG14 TYPE STRING,
ERROR_MSG15 TYPE STRING,
ERROR_MSG16 TYPE STRING,END OF T_EKKO_STR. DATA: WA_ORA_DBA_RESUMABLE_STRUCTURE_STR type T_EKKO_STR. DATA: ld_text TYPE string. LOOP AT IT_EKKO INTO WA_EKKO. MOVE-CORRESPONDING wa_EKKO TO WA_EKKO_STR. CONCATENATE: sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-USER_ID sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-SESSION_ID sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-INSTANCE_ID sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-COORD_INST_ID sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-COORD_SESSION_ID sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-STATUS sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-TIMEOUT sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-START_TIME sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-SUSPEND_TIME sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-RESUME_TIME sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME1 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME2 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME3 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME4 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME5 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME6 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME7 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME8 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME9 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME10 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME11 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME12 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME13 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME14 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME15 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-NAME16 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-SQL_TEXT1 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-SQL_TEXT2 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-SQL_TEXT3 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-SQL_TEXT4 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_NUMBER sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_PARAMETER1 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_PARAMETER2 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_PARAMETER3 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_PARAMETER4 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_PARAMETER5 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG1 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG2 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG3 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG4 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG5 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG6 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG7 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG8 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG9 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG10 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG11 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG12 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG13 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG14 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG15 sy-vline
WA_ORA_DBA_RESUMABLE_STRUCTURE_STR-ERROR_MSG16 sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.