ABAP Select data from SAP table /ACCGO/S_FEE_TD_RES_LIST_UI 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 /ACCGO/S_FEE_TD_RES_LIST_UI 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 /ACCGO/S_FEE_TD_RES_LIST_UI. 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 /ACCGO/S_FEE_TD_RES_LIST_UI 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_/ACCGO/S_FEE_TD_RES_LIST_UI TYPE STANDARD TABLE OF /ACCGO/S_FEE_TD_RES_LIST_UI,
      WA_/ACCGO/S_FEE_TD_RES_LIST_UI TYPE /ACCGO/S_FEE_TD_RES_LIST_UI,
      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: </ACCGO/S_FEE_TD_RES_LIST_UI> TYPE /ACCGO/S_FEE_TD_RES_LIST_UI.

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

SELECT *
*restrict ABAP select to first 10 rows
 UP TO 10 ROWS      
  FROM /ACCGO/S_FEE_TD_RES_LIST_UI
  INTO TABLE IT_/ACCGO/S_FEE_TD_RES_LIST_UI.

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM /ACCGO/S_FEE_TD_RES_LIST_UI
*  INTO TABLE @DATA(IT_/ACCGO/S_FEE_TD_RES_LIST_UI2).
*--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_/ACCGO/S_FEE_TD_RES_LIST_UI INDEX 1 INTO DATA(WA_/ACCGO/S_FEE_TD_RES_LIST_UI2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_/ACCGO/S_FEE_TD_RES_LIST_UI ASSIGNING </ACCGO/S_FEE_TD_RES_LIST_UI>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
</ACCGO/S_FEE_TD_RES_LIST_UI>-LIGHT = 1.
</ACCGO/S_FEE_TD_RES_LIST_UI>-FEE_ID = 1.
</ACCGO/S_FEE_TD_RES_LIST_UI>-VERSION = 1.
</ACCGO/S_FEE_TD_RES_LIST_UI>-FEE_NAME = 1.
</ACCGO/S_FEE_TD_RES_LIST_UI>-FEE_NAME_EXT = 1.
ENDLOOP.

LOOP AT IT_/ACCGO/S_FEE_TD_RES_LIST_UI INTO WA_/ACCGO/S_FEE_TD_RES_LIST_UI.
*Write horizonal line to screen report.
  WRITE:/ sy-uline.

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_/ACCGO/S_FEE_TD_RES_LIST_UI-FEE_TYPE, sy-vline,
WA_/ACCGO/S_FEE_TD_RES_LIST_UI-FEE_TYPE_TEXT, sy-vline,
WA_/ACCGO/S_FEE_TD_RES_LIST_UI-INT_DESC, sy-vline,
WA_/ACCGO/S_FEE_TD_RES_LIST_UI-EXT_DESC, sy-vline,
WA_/ACCGO/S_FEE_TD_RES_LIST_UI-STATUS, sy-vline,
WA_/ACCGO/S_FEE_TD_RES_LIST_UI-VALID_FROM, sy-vline.
ENDLOOP. *Add any further fields from structure WA_/ACCGO/S_FEE_TD_RES_LIST_UI 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_/ACCGO/S_FEE_TD_RES_LIST_UI 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_/ACCGO/S_FEE_TD_RES_LIST_UI INTO WA_/ACCGO/S_FEE_TD_RES_LIST_UI. *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.

*Conversion exit TSTLC, internal->external for field CREATED_TSTMP CALL FUNCTION 'CONVERSION_EXIT_TSTLC_OUTPUT' EXPORTING input = WA_/ACCGO/S_FEE_TD_RES_LIST_UI-CREATED_TSTMP IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_/ACCGO/S_FEE_TD_RES_LIST_UI-CREATED_TSTMP.
WRITE:/ 'New Value:', ld_input.

*Conversion exit TSTLC, internal->external for field CHANGED_TSTMP CALL FUNCTION 'CONVERSION_EXIT_TSTLC_OUTPUT' EXPORTING input = WA_/ACCGO/S_FEE_TD_RES_LIST_UI-CHANGED_TSTMP IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_/ACCGO/S_FEE_TD_RES_LIST_UI-CHANGED_TSTMP.
WRITE:/ 'New Value:', ld_input.
ENDFORM. *&---------------------------------------------------------------------* *& Form process_as_string_field_values *&---------------------------------------------------------------------* FORM process_as_string_field_values CHANGING p_EKKO LIKE wa_EKKO. TYPES: BEGIN OF T_/ACCGO/S_FEE_TD_RES_LIST_UI_STR,
LIGHT TYPE STRING,
FEE_ID TYPE STRING,
VERSION TYPE STRING,
FEE_NAME TYPE STRING,
FEE_NAME_EXT TYPE STRING,
FEE_TYPE TYPE STRING,
FEE_TYPE_TEXT TYPE STRING,
INT_DESC TYPE STRING,
EXT_DESC TYPE STRING,
STATUS TYPE STRING,
VALID_FROM TYPE STRING,
VALID_TO TYPE STRING,
ALV_CELLTAB TYPE STRING,
CALONGQ TYPE STRING,
DUPLMSG TYPE STRING,
NOT_RELEVANT TYPE STRING,
FREE_ATT1 TYPE STRING,
FREE_ATT2 TYPE STRING,
FREE_ATT3 TYPE STRING,
FREE_ATT4 TYPE STRING,
FREE_ATT5 TYPE STRING,
FREE_ATT6 TYPE STRING,
FREE_ATT7 TYPE STRING,
FREE_ATT8 TYPE STRING,
FREE_ATT9 TYPE STRING,
FREE_ATT10 TYPE STRING,
ADD_GROSS TYPE STRING,
INCLD_NS TYPE STRING,
REL_ACCRUAL TYPE STRING,
RATE_ASSIGN TYPE STRING,
NON_MODIFIABLE TYPE STRING,
ACCRUAL_PURCHASE TYPE STRING,
ACCRUAL_TIME_SALES TYPE STRING,
REL_SEP_INVOICES TYPE STRING,
REL_SEP_TIME TYPE STRING,
RATE_PERCENT TYPE STRING,
PCF_CALC_REF TYPE STRING,
REL_PP_STL TYPE STRING,
ON_FIRST_LOAD TYPE STRING,
CONTRACT_HEADER TYPE STRING,
CONTRACT_ITEM TYPE STRING,
CONTRACT_PL TYPE STRING,
NOM_ITEM TYPE STRING,
ORDER_ITEM TYPE STRING,
PO_ITEM TYPE STRING,
STO_ITEM TYPE STRING,
LDC_LOAD TYPE STRING,
LDC_UNLOAD TYPE STRING,
STLMNT_UNIT TYPE STRING,
NON_STD_STLMNT TYPE STRING,
STORAGE_AGMNT TYPE STRING,
STORAGE_STLMNT TYPE STRING,
PRE_PAYMET TYPE STRING,
SET_BASIS TYPE STRING,
SET_FUTURES TYPE STRING,
SET_FLAT TYPE STRING,
SET_FX_BASIS TYPE STRING,
SET_FX_FUTURES TYPE STRING,
SET_FX_FLAT TYPE STRING,
LIFT_BASIS TYPE STRING,
LIFT_FUTURE TYPE STRING,
LIFT_FLAT TYPE STRING,
LIFT_FX_BASIS TYPE STRING,
LIFT_FX_FUTURES TYPE STRING,
LIFT_FX_FLAT TYPE STRING,
LIFT_EQUITY_BASIS TYPE STRING,
LIFT_EQUITY_FUTURES TYPE STRING,
LIFT_EQUITY_FLAT TYPE STRING,
PRICE_ROLL_BASIS TYPE STRING,
PRICE_ROLL_FUTURES TYPE STRING,
OVERFILL TYPE STRING,
PRICING_METHOD TYPE STRING,
WEIGHT_EVENT TYPE STRING,
ANALYSIS_EVENT TYPE STRING,
UNLOAD_W_EVENT TYPE STRING,
UNLOAD_A_EVENT TYPE STRING,
CREATED_BY TYPE STRING,
CREATED_ON TYPE STRING,
CREATED_TSTMP TYPE STRING,
CHANGED_BY TYPE STRING,
CHANGED_ON TYPE STRING,
CHANGED_TSTMP TYPE STRING,
SALES_MSG_TYP TYPE STRING,
PURCH_MSG_TYP TYPE STRING,
ALLOC_MODE TYPE STRING,
APP_FIRST_UNIT TYPE STRING,
GL_SOURCE TYPE STRING,END OF T_EKKO_STR. DATA: WA_/ACCGO/S_FEE_TD_RES_LIST_UI_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_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-LIGHT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FEE_ID sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-VERSION sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FEE_NAME sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FEE_NAME_EXT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FEE_TYPE sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FEE_TYPE_TEXT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-INT_DESC sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-EXT_DESC sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-STATUS sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-VALID_FROM sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-VALID_TO sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-ALV_CELLTAB sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-CALONGQ sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-DUPLMSG sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-NOT_RELEVANT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FREE_ATT1 sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FREE_ATT2 sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FREE_ATT3 sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FREE_ATT4 sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FREE_ATT5 sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FREE_ATT6 sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FREE_ATT7 sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FREE_ATT8 sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FREE_ATT9 sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-FREE_ATT10 sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-ADD_GROSS sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-INCLD_NS sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-REL_ACCRUAL sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-RATE_ASSIGN sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-NON_MODIFIABLE sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-ACCRUAL_PURCHASE sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-ACCRUAL_TIME_SALES sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-REL_SEP_INVOICES sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-REL_SEP_TIME sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-RATE_PERCENT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-PCF_CALC_REF sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-REL_PP_STL sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-ON_FIRST_LOAD sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-CONTRACT_HEADER sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-CONTRACT_ITEM sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-CONTRACT_PL sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-NOM_ITEM sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-ORDER_ITEM sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-PO_ITEM sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-STO_ITEM sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-LDC_LOAD sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-LDC_UNLOAD sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-STLMNT_UNIT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-NON_STD_STLMNT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-STORAGE_AGMNT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-STORAGE_STLMNT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-PRE_PAYMET sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-SET_BASIS sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-SET_FUTURES sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-SET_FLAT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-SET_FX_BASIS sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-SET_FX_FUTURES sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-SET_FX_FLAT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-LIFT_BASIS sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-LIFT_FUTURE sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-LIFT_FLAT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-LIFT_FX_BASIS sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-LIFT_FX_FUTURES sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-LIFT_FX_FLAT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-LIFT_EQUITY_BASIS sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-LIFT_EQUITY_FUTURES sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-LIFT_EQUITY_FLAT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-PRICE_ROLL_BASIS sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-PRICE_ROLL_FUTURES sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-OVERFILL sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-PRICING_METHOD sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-WEIGHT_EVENT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-ANALYSIS_EVENT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-UNLOAD_W_EVENT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-UNLOAD_A_EVENT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-CREATED_BY sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-CREATED_ON sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-CREATED_TSTMP sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-CHANGED_BY sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-CHANGED_ON sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-CHANGED_TSTMP sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-SALES_MSG_TYP sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-PURCH_MSG_TYP sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-ALLOC_MODE sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-APP_FIRST_UNIT sy-vline
WA_/ACCGO/S_FEE_TD_RES_LIST_UI_STR-GL_SOURCE sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.