ABAP Select data from SAP table FSCYT_S_ET 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 FSCYT_S_ET 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 FSCYT_S_ET. 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 FSCYT_S_ET 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_FSCYT_S_ET TYPE STANDARD TABLE OF FSCYT_S_ET,
      WA_FSCYT_S_ET TYPE FSCYT_S_ET,
      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: <FSCYT_S_ET> TYPE FSCYT_S_ET.

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

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

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM FSCYT_S_ET
*  INTO TABLE @DATA(IT_FSCYT_S_ET2).
*--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_FSCYT_S_ET INDEX 1 INTO DATA(WA_FSCYT_S_ET2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_FSCYT_S_ET ASSIGNING <FSCYT_S_ET>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
<FSCYT_S_ET>-MANDANT = 1.
<FSCYT_S_ET>-MODID = 1.
<FSCYT_S_ET>-CYTID = 1.
<FSCYT_S_ET>-PARTNER = 1.
<FSCYT_S_ET>-BANKL = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_FSCYT_S_ET-BANKS, sy-vline,
WA_FSCYT_S_ET-ACEXT, sy-vline,
WA_FSCYT_S_ET-CURRENCY, sy-vline,
WA_FSCYT_S_ET-DIFCHR, sy-vline,
WA_FSCYT_S_ET-IBAN, sy-vline,
WA_FSCYT_S_ET-CYTPR, sy-vline.
ENDLOOP. *Add any further fields from structure WA_FSCYT_S_ET 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_FSCYT_S_ET 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_FSCYT_S_ET INTO WA_FSCYT_S_ET. *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 ALPHA, internal->external for field PARTNER CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_FSCYT_S_ET-PARTNER IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_FSCYT_S_ET-PARTNER.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field STPFL CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_FSCYT_S_ET-STPFL IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_FSCYT_S_ET-STPFL.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field STBNR CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_FSCYT_S_ET-STBNR IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_FSCYT_S_ET-STBNR.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field TAXNR CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_FSCYT_S_ET-TAXNR IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_FSCYT_S_ET-TAXNR.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field TIDTY CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_FSCYT_S_ET-TIDTY IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_FSCYT_S_ET-TIDTY.
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_FSCYT_S_ET_STR,
MANDANT TYPE STRING,
MODID TYPE STRING,
CYTID TYPE STRING,
PARTNER TYPE STRING,
BANKL TYPE STRING,
BANKS TYPE STRING,
ACEXT TYPE STRING,
CURRENCY TYPE STRING,
DIFCHR TYPE STRING,
IBAN TYPE STRING,
CYTPR TYPE STRING,
OBEGR TYPE STRING,
BUDAT TYPE STRING,
ERTID TYPE STRING,
SWAERS TYPE STRING,
STORNOKZ TYPE STRING,
OBEGRREF TYPE STRING,
STPFL TYPE STRING,
ACCNT TYPE STRING,
SJAHR TYPE STRING,
STBERT TYPE STRING,
STBERTW TYPE STRING,
STBTR TYPE STRING,
STBTRW TYPE STRING,
DLTFA TYPE STRING,
DLTBG TYPE STRING,
CBART TYPE STRING,
AWAERS TYPE STRING,
HZINSBE TYPE STRING,
HZINSPZ TYPE STRING,
SZINSBE TYPE STRING,
SZINSPZ TYPE STRING,
VADAT TYPE STRING,
FAELL TYPE STRING,
PERABDAT TYPE STRING,
PERBIDAT TYPE STRING,
WKNNR TYPE STRING,
SDART TYPE STRING,
STBNR TYPE STRING,
EXTID TYPE STRING,
DSTFA TYPE STRING,
ANUSR TYPE STRING,
ANDAT TYPE STRING,
ANUHR TYPE STRING,
ANHER TYPE STRING,
AEUSR TYPE STRING,
AEDAT TYPE STRING,
AEUHR TYPE STRING,
AEHER TYPE STRING,
BUKRS TYPE STRING,
BEBASIS TYPE STRING,
BEWAERS TYPE STRING,
BESTZAHL TYPE STRING,
BANKLZ TYPE STRING,
BANKKO TYPE STRING,
NORDER TYPE STRING,
BEWART TYPE STRING,
DEPNR TYPE STRING,
DPUNR TYPE STRING,
BESTZAHL_LONG TYPE STRING,
EXRATE TYPE STRING,
ERTL TYPE STRING,
JBNR TYPE STRING,
VTYP TYPE STRING,
ACCNT_REF TYPE STRING,
DFSADV TYPE STRING,
DLTBTR TYPE STRING,
MIGGRP TYPE STRING,
OBEGR_TYP TYPE STRING,
ITEM_REF TYPE STRING,
ITEM_REV_REF TYPE STRING,
WHTAX TYPE STRING,
EXTPR TYPE STRING,
SJAHRV TYPE STRING,
ETREF TYPE STRING,
PAR_CLAS TYPE STRING,
BTNR TYPE STRING,
TAXNR TYPE STRING,
TIDTY TYPE STRING,
TAXGRP TYPE STRING,
F_AMOUNT TYPE STRING,
VQSGV TYPE STRING,
VQSKT TYPE STRING,
DAYS_NUMB TYPE STRING,
DAYS_BASE TYPE STRING,
SBRUTTO TYPE STRING,
GV_CAT TYPE STRING,
STBTR5 TYPE STRING,
REGIO TYPE STRING,
BUPR_TYPE_CODE TYPE STRING,
GRACE_PERIOD TYPE STRING,END OF T_EKKO_STR. DATA: WA_FSCYT_S_ET_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_FSCYT_S_ET_STR-MANDANT sy-vline
WA_FSCYT_S_ET_STR-MODID sy-vline
WA_FSCYT_S_ET_STR-CYTID sy-vline
WA_FSCYT_S_ET_STR-PARTNER sy-vline
WA_FSCYT_S_ET_STR-BANKL sy-vline
WA_FSCYT_S_ET_STR-BANKS sy-vline
WA_FSCYT_S_ET_STR-ACEXT sy-vline
WA_FSCYT_S_ET_STR-CURRENCY sy-vline
WA_FSCYT_S_ET_STR-DIFCHR sy-vline
WA_FSCYT_S_ET_STR-IBAN sy-vline
WA_FSCYT_S_ET_STR-CYTPR sy-vline
WA_FSCYT_S_ET_STR-OBEGR sy-vline
WA_FSCYT_S_ET_STR-BUDAT sy-vline
WA_FSCYT_S_ET_STR-ERTID sy-vline
WA_FSCYT_S_ET_STR-SWAERS sy-vline
WA_FSCYT_S_ET_STR-STORNOKZ sy-vline
WA_FSCYT_S_ET_STR-OBEGRREF sy-vline
WA_FSCYT_S_ET_STR-STPFL sy-vline
WA_FSCYT_S_ET_STR-ACCNT sy-vline
WA_FSCYT_S_ET_STR-SJAHR sy-vline
WA_FSCYT_S_ET_STR-STBERT sy-vline
WA_FSCYT_S_ET_STR-STBERTW sy-vline
WA_FSCYT_S_ET_STR-STBTR sy-vline
WA_FSCYT_S_ET_STR-STBTRW sy-vline
WA_FSCYT_S_ET_STR-DLTFA sy-vline
WA_FSCYT_S_ET_STR-DLTBG sy-vline
WA_FSCYT_S_ET_STR-CBART sy-vline
WA_FSCYT_S_ET_STR-AWAERS sy-vline
WA_FSCYT_S_ET_STR-HZINSBE sy-vline
WA_FSCYT_S_ET_STR-HZINSPZ sy-vline
WA_FSCYT_S_ET_STR-SZINSBE sy-vline
WA_FSCYT_S_ET_STR-SZINSPZ sy-vline
WA_FSCYT_S_ET_STR-VADAT sy-vline
WA_FSCYT_S_ET_STR-FAELL sy-vline
WA_FSCYT_S_ET_STR-PERABDAT sy-vline
WA_FSCYT_S_ET_STR-PERBIDAT sy-vline
WA_FSCYT_S_ET_STR-WKNNR sy-vline
WA_FSCYT_S_ET_STR-SDART sy-vline
WA_FSCYT_S_ET_STR-STBNR sy-vline
WA_FSCYT_S_ET_STR-EXTID sy-vline
WA_FSCYT_S_ET_STR-DSTFA sy-vline
WA_FSCYT_S_ET_STR-ANUSR sy-vline
WA_FSCYT_S_ET_STR-ANDAT sy-vline
WA_FSCYT_S_ET_STR-ANUHR sy-vline
WA_FSCYT_S_ET_STR-ANHER sy-vline
WA_FSCYT_S_ET_STR-AEUSR sy-vline
WA_FSCYT_S_ET_STR-AEDAT sy-vline
WA_FSCYT_S_ET_STR-AEUHR sy-vline
WA_FSCYT_S_ET_STR-AEHER sy-vline
WA_FSCYT_S_ET_STR-BUKRS sy-vline
WA_FSCYT_S_ET_STR-BEBASIS sy-vline
WA_FSCYT_S_ET_STR-BEWAERS sy-vline
WA_FSCYT_S_ET_STR-BESTZAHL sy-vline
WA_FSCYT_S_ET_STR-BANKLZ sy-vline
WA_FSCYT_S_ET_STR-BANKKO sy-vline
WA_FSCYT_S_ET_STR-NORDER sy-vline
WA_FSCYT_S_ET_STR-BEWART sy-vline
WA_FSCYT_S_ET_STR-DEPNR sy-vline
WA_FSCYT_S_ET_STR-DPUNR sy-vline
WA_FSCYT_S_ET_STR-BESTZAHL_LONG sy-vline
WA_FSCYT_S_ET_STR-EXRATE sy-vline
WA_FSCYT_S_ET_STR-ERTL sy-vline
WA_FSCYT_S_ET_STR-JBNR sy-vline
WA_FSCYT_S_ET_STR-VTYP sy-vline
WA_FSCYT_S_ET_STR-ACCNT_REF sy-vline
WA_FSCYT_S_ET_STR-DFSADV sy-vline
WA_FSCYT_S_ET_STR-DLTBTR sy-vline
WA_FSCYT_S_ET_STR-MIGGRP sy-vline
WA_FSCYT_S_ET_STR-OBEGR_TYP sy-vline
WA_FSCYT_S_ET_STR-ITEM_REF sy-vline
WA_FSCYT_S_ET_STR-ITEM_REV_REF sy-vline
WA_FSCYT_S_ET_STR-WHTAX sy-vline
WA_FSCYT_S_ET_STR-EXTPR sy-vline
WA_FSCYT_S_ET_STR-SJAHRV sy-vline
WA_FSCYT_S_ET_STR-ETREF sy-vline
WA_FSCYT_S_ET_STR-PAR_CLAS sy-vline
WA_FSCYT_S_ET_STR-BTNR sy-vline
WA_FSCYT_S_ET_STR-TAXNR sy-vline
WA_FSCYT_S_ET_STR-TIDTY sy-vline
WA_FSCYT_S_ET_STR-TAXGRP sy-vline
WA_FSCYT_S_ET_STR-F_AMOUNT sy-vline
WA_FSCYT_S_ET_STR-VQSGV sy-vline
WA_FSCYT_S_ET_STR-VQSKT sy-vline
WA_FSCYT_S_ET_STR-DAYS_NUMB sy-vline
WA_FSCYT_S_ET_STR-DAYS_BASE sy-vline
WA_FSCYT_S_ET_STR-SBRUTTO sy-vline
WA_FSCYT_S_ET_STR-GV_CAT sy-vline
WA_FSCYT_S_ET_STR-STBTR5 sy-vline
WA_FSCYT_S_ET_STR-REGIO sy-vline
WA_FSCYT_S_ET_STR-BUPR_TYPE_CODE sy-vline
WA_FSCYT_S_ET_STR-GRACE_PERIOD sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.