ABAP Select data from SAP table TPDA_TOOL_GL_SCRIPT_DATA 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 TPDA_TOOL_GL_SCRIPT_DATA 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 TPDA_TOOL_GL_SCRIPT_DATA. 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 TPDA_TOOL_GL_SCRIPT_DATA 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_TPDA_TOOL_GL_SCRIPT_DATA TYPE STANDARD TABLE OF TPDA_TOOL_GL_SCRIPT_DATA, WA_TPDA_TOOL_GL_SCRIPT_DATA TYPE TPDA_TOOL_GL_SCRIPT_DATA, 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: <TPDA_TOOL_GL_SCRIPT_DATA> TYPE TPDA_TOOL_GL_SCRIPT_DATA. *Process all fields in table header/work area as string values PERFORM process_as_string_field_values CHANGING wa_TPDA_TOOL_GL_SCRIPT_DATA. SELECT * *restrict ABAP select to first 10 rows UP TO 10 ROWS FROM TPDA_TOOL_GL_SCRIPT_DATA INTO TABLE IT_TPDA_TOOL_GL_SCRIPT_DATA. *Select data and declare internal table using in-line method @DATA *SELECT * * FROM TPDA_TOOL_GL_SCRIPT_DATA * INTO TABLE @DATA(IT_TPDA_TOOL_GL_SCRIPT_DATA2). *--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_TPDA_TOOL_GL_SCRIPT_DATA INDEX 1 INTO DATA(WA_TPDA_TOOL_GL_SCRIPT_DATA2). *Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL LOOP AT IT_TPDA_TOOL_GL_SCRIPT_DATA ASSIGNING <TPDA_TOOL_GL_SCRIPT_DATA>.*To update a field value using a field symbol simply change the value via the field symbol pointer
<TPDA_TOOL_GL_SCRIPT_DATA>-EDITOR_PRG = 1.
<TPDA_TOOL_GL_SCRIPT_DATA>-EDITOR_DYNNR = 1.
<TPDA_TOOL_GL_SCRIPT_DATA>-EDIT_CTRL = 1.
<TPDA_TOOL_GL_SCRIPT_DATA>-IT_SYNTAX_ERRORS = 1.
<TPDA_TOOL_GL_SCRIPT_DATA>-SCRIPT_ACTIVE = 1.
ENDLOOP. LOOP AT IT_TPDA_TOOL_GL_SCRIPT_DATA INTO WA_TPDA_TOOL_GL_SCRIPT_DATA. *Write horizonal line to screen report. WRITE:/ sy-uline. *Write selected data to screen/report before conversion. WRITE:/ sy-vline, WA_TPDA_TOOL_GL_SCRIPT_DATA-UPDATE_OK, sy-vline,
WA_TPDA_TOOL_GL_SCRIPT_DATA-IT_TRACE_FILES, sy-vline,
WA_TPDA_TOOL_GL_SCRIPT_DATA-SCRIPT_ATTR, sy-vline,
WA_TPDA_TOOL_GL_SCRIPT_DATA-SCRIPTNAME, sy-vline,
WA_TPDA_TOOL_GL_SCRIPT_DATA-FILE_NAME, sy-vline,
WA_TPDA_TOOL_GL_SCRIPT_DATA-SCRIPT_CLASS, sy-vline.
ENDLOOP. *Add any further fields from structure WA_TPDA_TOOL_GL_SCRIPT_DATA 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_TPDA_TOOL_GL_SCRIPT_DATA 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_TPDA_TOOL_GL_SCRIPT_DATA INTO WA_TPDA_TOOL_GL_SCRIPT_DATA. *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_TPDA_TOOL_GL_SCRIPT_DATA_STR,
EDITOR_PRG TYPE STRING,
EDITOR_DYNNR TYPE STRING,
EDIT_CTRL TYPE STRING,
IT_SYNTAX_ERRORS TYPE STRING,
SCRIPT_ACTIVE TYPE STRING,
UPDATE_OK TYPE STRING,
IT_TRACE_FILES TYPE STRING,
SCRIPT_ATTR TYPE STRING,
SCRIPTNAME TYPE STRING,
FILE_NAME TYPE STRING,
SCRIPT_CLASS TYPE STRING,
SCRIPT_COMMENT TYPE STRING,
WRITES_TRACE TYPE STRING,
NO_BREAK TYPE STRING,
BP_REACHED TYPE STRING,
WP_REACHED TYPE STRING,
SINGLE_STEP TYPE STRING,
NEW_ROLLAREA TYPE STRING,
SINGLE_RUN TYPE STRING,
SYSTDBG TYPE STRING,
CLOSEDEBF8 TYPE STRING,
SYNCBPS TYPE STRING,
EXCCREATEOBJECT TYPE STRING,
UPDATEDEBUG TYPE STRING,
BTCDEBUG TYPE STRING,
EMODESTACK TYPE STRING,
ESI TYPE STRING,
ACFLUSH TYPE STRING,
SOAAC TYPE STRING,
CHECKREADBINARY TYPE STRING,
LAYERCONTROL TYPE STRING,
OBJECT_NAME TYPE STRING,
DATATEMPERATURE TYPE STRING,
TRACE_STATUS TYPE STRING,
MARK TYPE STRING,
INDEX TYPE STRING,
USER TYPE STRING,
CDAT TYPE STRING,
CTIME TYPE STRING,
SERVER TYPE STRING,
SYSID TYPE STRING,
SKRIPT TYPE STRING,
FILENAME TYPE STRING,
FILE_SHORT TYPE STRING,
DIRECTORY TYPE STRING,
FSIZE TYPE STRING,
BP_REACHED TYPE STRING,
WP_REACHED TYPE STRING,
SINGLE_STEP TYPE STRING,
NEW_ROLLAREA TYPE STRING,
SINGLE_RUN TYPE STRING,
SIZE_SOURCE TYPE STRING,
SIZE_EVENT TYPE STRING,
SIZE_STACK TYPE STRING,
SIZE_CUSTOM TYPE STRING,
SRC_LINES TYPE STRING,
EVENT_LINES TYPE STRING,
CUSTOM_LINES TYPE STRING,
LAST_TRACE TYPE STRING,
MARK TYPE STRING,
INDEX TYPE STRING,
USER TYPE STRING,
CDAT TYPE STRING,
CTIME TYPE STRING,
SERVER TYPE STRING,
SYSID TYPE STRING,
SKRIPT TYPE STRING,
FILENAME TYPE STRING,
FILE_SHORT TYPE STRING,
DIRECTORY TYPE STRING,
FSIZE TYPE STRING,
BP_REACHED TYPE STRING,
WP_REACHED TYPE STRING,
SINGLE_STEP TYPE STRING,
NEW_ROLLAREA TYPE STRING,
SINGLE_RUN TYPE STRING,
SIZE_SOURCE TYPE STRING,
SIZE_EVENT TYPE STRING,
SIZE_STACK TYPE STRING,
SIZE_CUSTOM TYPE STRING,
SRC_LINES TYPE STRING,
EVENT_LINES TYPE STRING,
CUSTOM_LINES TYPE STRING,
DEBUGGER_ACTIVE TYPE STRING,
IT_CUSTOM_TRACE TYPE STRING,
VISIBLE_LINES_800 TYPE STRING,
EDIT_MODE TYPE STRING,END OF T_EKKO_STR. DATA: WA_TPDA_TOOL_GL_SCRIPT_DATA_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_TPDA_TOOL_GL_SCRIPT_DATA_STR-EDITOR_PRG sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-EDITOR_DYNNR sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-EDIT_CTRL sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-IT_SYNTAX_ERRORS sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SCRIPT_ACTIVE sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-UPDATE_OK sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-IT_TRACE_FILES sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SCRIPT_ATTR sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SCRIPTNAME sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-FILE_NAME sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SCRIPT_CLASS sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SCRIPT_COMMENT sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-WRITES_TRACE sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-NO_BREAK sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-BP_REACHED sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-WP_REACHED sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SINGLE_STEP sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-NEW_ROLLAREA sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SINGLE_RUN sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SYSTDBG sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-CLOSEDEBF8 sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SYNCBPS sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-EXCCREATEOBJECT sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-UPDATEDEBUG sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-BTCDEBUG sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-EMODESTACK sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-ESI sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-ACFLUSH sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SOAAC sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-CHECKREADBINARY sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-LAYERCONTROL sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-OBJECT_NAME sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-DATATEMPERATURE sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-TRACE_STATUS sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-MARK sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-INDEX sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-USER sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-CDAT sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-CTIME sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SERVER sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SYSID sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SKRIPT sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-FILENAME sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-FILE_SHORT sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-DIRECTORY sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-FSIZE sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-BP_REACHED sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-WP_REACHED sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SINGLE_STEP sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-NEW_ROLLAREA sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SINGLE_RUN sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SIZE_SOURCE sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SIZE_EVENT sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SIZE_STACK sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SIZE_CUSTOM sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SRC_LINES sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-EVENT_LINES sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-CUSTOM_LINES sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-LAST_TRACE sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-MARK sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-INDEX sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-USER sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-CDAT sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-CTIME sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SERVER sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SYSID sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SKRIPT sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-FILENAME sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-FILE_SHORT sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-DIRECTORY sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-FSIZE sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-BP_REACHED sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-WP_REACHED sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SINGLE_STEP sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-NEW_ROLLAREA sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SINGLE_RUN sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SIZE_SOURCE sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SIZE_EVENT sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SIZE_STACK sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SIZE_CUSTOM sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-SRC_LINES sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-EVENT_LINES sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-CUSTOM_LINES sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-DEBUGGER_ACTIVE sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-IT_CUSTOM_TRACE sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-VISIBLE_LINES_800 sy-vline
WA_TPDA_TOOL_GL_SCRIPT_DATA_STR-EDIT_MODE sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.