ABAP Select data from SAP table FRE_SEND_OPTION_STY 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 FRE_SEND_OPTION_STY 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 FRE_SEND_OPTION_STY. 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 FRE_SEND_OPTION_STY 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_FRE_SEND_OPTION_STY TYPE STANDARD TABLE OF FRE_SEND_OPTION_STY,
      WA_FRE_SEND_OPTION_STY TYPE FRE_SEND_OPTION_STY,
      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: <FRE_SEND_OPTION_STY> TYPE FRE_SEND_OPTION_STY.

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

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

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM FRE_SEND_OPTION_STY
*  INTO TABLE @DATA(IT_FRE_SEND_OPTION_STY2).
*--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_FRE_SEND_OPTION_STY INDEX 1 INTO DATA(WA_FRE_SEND_OPTION_STY2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_FRE_SEND_OPTION_STY ASSIGNING <FRE_SEND_OPTION_STY>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
<FRE_SEND_OPTION_STY>-FRE_ACTIVE = 1.
<FRE_SEND_OPTION_STY>-FRE_RELEASE = 1.
<FRE_SEND_OPTION_STY>-FRE_RFC = 1.
<FRE_SEND_OPTION_STY>-SEND_ONCE = 1.
<FRE_SEND_OPTION_STY>-SEND_INTVL = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_FRE_SEND_OPTION_STY-SEND_INB_DIR, sy-vline,
WA_FRE_SEND_OPTION_STY-SEND_DEST, sy-vline,
WA_FRE_SEND_OPTION_STY-NUM_O_REC, sy-vline,
WA_FRE_SEND_OPTION_STY-FILESYST, sy-vline,
WA_FRE_SEND_OPTION_STY-LOGICAL_PATH_OUT, sy-vline,
WA_FRE_SEND_OPTION_STY-LOGICAL_PATH_TS, sy-vline.
ENDLOOP. *Add any further fields from structure WA_FRE_SEND_OPTION_STY 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_FRE_SEND_OPTION_STY 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_FRE_SEND_OPTION_STY INTO WA_FRE_SEND_OPTION_STY. *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_FRE_SEND_OPTION_STY_STR,
FRE_ACTIVE TYPE STRING,
FRE_RELEASE TYPE STRING,
FRE_RFC TYPE STRING,
SEND_ONCE TYPE STRING,
SEND_INTVL TYPE STRING,
SEND_INB_DIR TYPE STRING,
SEND_DEST TYPE STRING,
NUM_O_REC TYPE STRING,
FILESYST TYPE STRING,
LOGICAL_PATH_OUT TYPE STRING,
LOGICAL_PATH_TS TYPE STRING,
LOGICAL_PATH_MD TYPE STRING,
SAVE_FILES TYPE STRING,
SERVERGROUP TYPE STRING,
MAX_PARA_JOBS TYPE STRING,
TS_PER_INIT TYPE STRING,
TS_PER_NORM TYPE STRING,
WERKS_FILTER TYPE STRING,
DB_SELECT_PKG TYPE STRING,
LG_PKG_SIZE TYPE STRING,
WAIT_SECONDS TYPE STRING,
CPOCAL_DC TYPE STRING,
CPOCAL_STORE TYPE STRING,
PAST_LISTING TYPE STRING,
DIF_ACT TYPE STRING,
MCH_ACT TYPE STRING,
ARH_ACT TYPE STRING,
SGT_ACT TYPE STRING,
PROCYC_ACT TYPE STRING,
RPR_ACT TYPE STRING,
UOM_ACT TYPE STRING,
PRM_ACT TYPE STRING,
CONT_ACT TYPE STRING,
ADD_ATTEMPTS TYPE STRING,
WAIT_TIME TYPE STRING,
DIF_NUM_REC TYPE STRING,
DIF_FILTER TYPE STRING,
DIF_PAST_PERIODS TYPE STRING,
REF_PSIZE_HEAD TYPE STRING,
REF_PSIZE_MODULE TYPE STRING,
SEND_RELPRO TYPE STRING,
INIT_DC TYPE STRING,
DELTA_DC TYPE STRING,
INIT_ST TYPE STRING,
DELTA_ST TYPE STRING,
MESS_CTRL TYPE STRING,
DOCSYNC_STATUS TYPE STRING,
SEND_LAYMOD TYPE STRING,
SEND_STRUCT_ART TYPE STRING,
NO_UNAMB_CHECK TYPE STRING,
SUPPORT_LEVEL TYPE STRING,
FILE_OUT TYPE STRING,
FILE_IN TYPE STRING,
FILE_MD1 TYPE STRING,
FILE_MD2 TYPE STRING,
FILE_MD3 TYPE STRING,
FILE_MD4 TYPE STRING,
FILE_MD5 TYPE STRING,
FILE_MD6 TYPE STRING,
FILE_MD7 TYPE STRING,
FILE_MD8 TYPE STRING,
FILE_MD9 TYPE STRING,
FILE_MDL TYPE STRING,
FILE_CO TYPE STRING,
FILE_SU1 TYPE STRING,
FILE_SU2 TYPE STRING,
DIF_ACT_NO_SITES TYPE STRING,
DIF_NUM_REC2 TYPE STRING,
DIF_ID_NO_SITES TYPE STRING,
DIF_PAST_PERIOD2 TYPE STRING,
DIF_REPL_REL TYPE STRING,
DIF_DEV_PERC TYPE STRING,
DIF_EORD_USE TYPE STRING,
SU1_ACT TYPE STRING,
SU2_ACT TYPE STRING,
SU1_PACKAGE_SIZE TYPE STRING,
SU2_PACKAGE_SIZE TYPE STRING,END OF T_EKKO_STR. DATA: WA_FRE_SEND_OPTION_STY_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_FRE_SEND_OPTION_STY_STR-FRE_ACTIVE sy-vline
WA_FRE_SEND_OPTION_STY_STR-FRE_RELEASE sy-vline
WA_FRE_SEND_OPTION_STY_STR-FRE_RFC sy-vline
WA_FRE_SEND_OPTION_STY_STR-SEND_ONCE sy-vline
WA_FRE_SEND_OPTION_STY_STR-SEND_INTVL sy-vline
WA_FRE_SEND_OPTION_STY_STR-SEND_INB_DIR sy-vline
WA_FRE_SEND_OPTION_STY_STR-SEND_DEST sy-vline
WA_FRE_SEND_OPTION_STY_STR-NUM_O_REC sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILESYST sy-vline
WA_FRE_SEND_OPTION_STY_STR-LOGICAL_PATH_OUT sy-vline
WA_FRE_SEND_OPTION_STY_STR-LOGICAL_PATH_TS sy-vline
WA_FRE_SEND_OPTION_STY_STR-LOGICAL_PATH_MD sy-vline
WA_FRE_SEND_OPTION_STY_STR-SAVE_FILES sy-vline
WA_FRE_SEND_OPTION_STY_STR-SERVERGROUP sy-vline
WA_FRE_SEND_OPTION_STY_STR-MAX_PARA_JOBS sy-vline
WA_FRE_SEND_OPTION_STY_STR-TS_PER_INIT sy-vline
WA_FRE_SEND_OPTION_STY_STR-TS_PER_NORM sy-vline
WA_FRE_SEND_OPTION_STY_STR-WERKS_FILTER sy-vline
WA_FRE_SEND_OPTION_STY_STR-DB_SELECT_PKG sy-vline
WA_FRE_SEND_OPTION_STY_STR-LG_PKG_SIZE sy-vline
WA_FRE_SEND_OPTION_STY_STR-WAIT_SECONDS sy-vline
WA_FRE_SEND_OPTION_STY_STR-CPOCAL_DC sy-vline
WA_FRE_SEND_OPTION_STY_STR-CPOCAL_STORE sy-vline
WA_FRE_SEND_OPTION_STY_STR-PAST_LISTING sy-vline
WA_FRE_SEND_OPTION_STY_STR-DIF_ACT sy-vline
WA_FRE_SEND_OPTION_STY_STR-MCH_ACT sy-vline
WA_FRE_SEND_OPTION_STY_STR-ARH_ACT sy-vline
WA_FRE_SEND_OPTION_STY_STR-SGT_ACT sy-vline
WA_FRE_SEND_OPTION_STY_STR-PROCYC_ACT sy-vline
WA_FRE_SEND_OPTION_STY_STR-RPR_ACT sy-vline
WA_FRE_SEND_OPTION_STY_STR-UOM_ACT sy-vline
WA_FRE_SEND_OPTION_STY_STR-PRM_ACT sy-vline
WA_FRE_SEND_OPTION_STY_STR-CONT_ACT sy-vline
WA_FRE_SEND_OPTION_STY_STR-ADD_ATTEMPTS sy-vline
WA_FRE_SEND_OPTION_STY_STR-WAIT_TIME sy-vline
WA_FRE_SEND_OPTION_STY_STR-DIF_NUM_REC sy-vline
WA_FRE_SEND_OPTION_STY_STR-DIF_FILTER sy-vline
WA_FRE_SEND_OPTION_STY_STR-DIF_PAST_PERIODS sy-vline
WA_FRE_SEND_OPTION_STY_STR-REF_PSIZE_HEAD sy-vline
WA_FRE_SEND_OPTION_STY_STR-REF_PSIZE_MODULE sy-vline
WA_FRE_SEND_OPTION_STY_STR-SEND_RELPRO sy-vline
WA_FRE_SEND_OPTION_STY_STR-INIT_DC sy-vline
WA_FRE_SEND_OPTION_STY_STR-DELTA_DC sy-vline
WA_FRE_SEND_OPTION_STY_STR-INIT_ST sy-vline
WA_FRE_SEND_OPTION_STY_STR-DELTA_ST sy-vline
WA_FRE_SEND_OPTION_STY_STR-MESS_CTRL sy-vline
WA_FRE_SEND_OPTION_STY_STR-DOCSYNC_STATUS sy-vline
WA_FRE_SEND_OPTION_STY_STR-SEND_LAYMOD sy-vline
WA_FRE_SEND_OPTION_STY_STR-SEND_STRUCT_ART sy-vline
WA_FRE_SEND_OPTION_STY_STR-NO_UNAMB_CHECK sy-vline
WA_FRE_SEND_OPTION_STY_STR-SUPPORT_LEVEL sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_OUT sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_IN sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_MD1 sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_MD2 sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_MD3 sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_MD4 sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_MD5 sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_MD6 sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_MD7 sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_MD8 sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_MD9 sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_MDL sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_CO sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_SU1 sy-vline
WA_FRE_SEND_OPTION_STY_STR-FILE_SU2 sy-vline
WA_FRE_SEND_OPTION_STY_STR-DIF_ACT_NO_SITES sy-vline
WA_FRE_SEND_OPTION_STY_STR-DIF_NUM_REC2 sy-vline
WA_FRE_SEND_OPTION_STY_STR-DIF_ID_NO_SITES sy-vline
WA_FRE_SEND_OPTION_STY_STR-DIF_PAST_PERIOD2 sy-vline
WA_FRE_SEND_OPTION_STY_STR-DIF_REPL_REL sy-vline
WA_FRE_SEND_OPTION_STY_STR-DIF_DEV_PERC sy-vline
WA_FRE_SEND_OPTION_STY_STR-DIF_EORD_USE sy-vline
WA_FRE_SEND_OPTION_STY_STR-SU1_ACT sy-vline
WA_FRE_SEND_OPTION_STY_STR-SU2_ACT sy-vline
WA_FRE_SEND_OPTION_STY_STR-SU1_PACKAGE_SIZE sy-vline
WA_FRE_SEND_OPTION_STY_STR-SU2_PACKAGE_SIZE sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.