ABAP Select data from SAP table FC00SIULST 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 FC00SIULST 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 FC00SIULST. 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 FC00SIULST 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_FC00SIULST TYPE STANDARD TABLE OF FC00SIULST, WA_FC00SIULST TYPE FC00SIULST, 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: <FC00SIULST> TYPE FC00SIULST. *Process all fields in table header/work area as string values PERFORM process_as_string_field_values CHANGING wa_FC00SIULST. SELECT * *restrict ABAP select to first 10 rows UP TO 10 ROWS FROM FC00SIULST INTO TABLE IT_FC00SIULST. *Select data and declare internal table using in-line method @DATA *SELECT * * FROM FC00SIULST * INTO TABLE @DATA(IT_FC00SIULST2). *--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_FC00SIULST INDEX 1 INTO DATA(WA_FC00SIULST2). *Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL LOOP AT IT_FC00SIULST ASSIGNING <FC00SIULST>.*To update a field value using a field symbol simply change the value via the field symbol pointer
<FC00SIULST>-SITYP = 1.
<FC00SIULST>-SITYP_MTXT = 1.
<FC00SIULST>-RITEM = 1.
<FC00SIULST>-RITEM_STXT = 1.
<FC00SIULST>-RITEM_MTXT = 1.
ENDLOOP. LOOP AT IT_FC00SIULST INTO WA_FC00SIULST. *Write horizonal line to screen report. WRITE:/ sy-uline. *Write selected data to screen/report before conversion. WRITE:/ sy-vline, WA_FC00SIULST-ITGRP, sy-vline,
WA_FC00SIULST-ITGRP_TXT, sy-vline,
WA_FC00SIULST-SUBITMS, sy-vline,
WA_FC00SIULST-SUBITMX, sy-vline,
WA_FC00SIULST-SUBIT01, sy-vline,
WA_FC00SIULST-SUBIT02, sy-vline.
ENDLOOP. *Add any further fields from structure WA_FC00SIULST 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_FC00SIULST 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_FC00SIULST INTO WA_FC00SIULST. *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 BFIMC, internal->external for field RITEM CALL FUNCTION 'CONVERSION_EXIT_BFIMC_OUTPUT' EXPORTING input = WA_FC00SIULST-RITEM IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_FC00SIULST-RITEM.
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_FC00SIULST_STR,
SITYP TYPE STRING,
SITYP_MTXT TYPE STRING,
RITEM TYPE STRING,
RITEM_STXT TYPE STRING,
RITEM_MTXT TYPE STRING,
ITGRP TYPE STRING,
ITGRP_TXT TYPE STRING,
SUBITMS TYPE STRING,
SUBITMX TYPE STRING,
SUBIT01 TYPE STRING,
SUBIT02 TYPE STRING,
SUBIT03 TYPE STRING,
SUBIT04 TYPE STRING,
SUBIT05 TYPE STRING,
SUBIT06 TYPE STRING,
SUBIT07 TYPE STRING,
SUBIT08 TYPE STRING,
SUBIT09 TYPE STRING,
SUBIT10 TYPE STRING,
SUBIT11 TYPE STRING,
SUBIT12 TYPE STRING,
SUBIT13 TYPE STRING,
SUBIT14 TYPE STRING,
SUBIT15 TYPE STRING,
SUBIT16 TYPE STRING,
SUBIT17 TYPE STRING,
SUBIT18 TYPE STRING,
SUBIT19 TYPE STRING,
SUBIT20 TYPE STRING,
SUBIT21 TYPE STRING,
SUBIT22 TYPE STRING,
SUBIT23 TYPE STRING,
SUBIT24 TYPE STRING,
SUBIT25 TYPE STRING,
SUBIT26 TYPE STRING,
SUBIT27 TYPE STRING,
SUBIT28 TYPE STRING,
SUBIT29 TYPE STRING,
SUBIT30 TYPE STRING,
SUBIT31 TYPE STRING,
SUBIT32 TYPE STRING,
SUBIT33 TYPE STRING,
SUBIT34 TYPE STRING,
SUBIT35 TYPE STRING,
SUBIT36 TYPE STRING,
SUBIT37 TYPE STRING,
SUBIT38 TYPE STRING,
SUBIT39 TYPE STRING,
SUBIT40 TYPE STRING,END OF T_EKKO_STR. DATA: WA_FC00SIULST_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_FC00SIULST_STR-SITYP sy-vline
WA_FC00SIULST_STR-SITYP_MTXT sy-vline
WA_FC00SIULST_STR-RITEM sy-vline
WA_FC00SIULST_STR-RITEM_STXT sy-vline
WA_FC00SIULST_STR-RITEM_MTXT sy-vline
WA_FC00SIULST_STR-ITGRP sy-vline
WA_FC00SIULST_STR-ITGRP_TXT sy-vline
WA_FC00SIULST_STR-SUBITMS sy-vline
WA_FC00SIULST_STR-SUBITMX sy-vline
WA_FC00SIULST_STR-SUBIT01 sy-vline
WA_FC00SIULST_STR-SUBIT02 sy-vline
WA_FC00SIULST_STR-SUBIT03 sy-vline
WA_FC00SIULST_STR-SUBIT04 sy-vline
WA_FC00SIULST_STR-SUBIT05 sy-vline
WA_FC00SIULST_STR-SUBIT06 sy-vline
WA_FC00SIULST_STR-SUBIT07 sy-vline
WA_FC00SIULST_STR-SUBIT08 sy-vline
WA_FC00SIULST_STR-SUBIT09 sy-vline
WA_FC00SIULST_STR-SUBIT10 sy-vline
WA_FC00SIULST_STR-SUBIT11 sy-vline
WA_FC00SIULST_STR-SUBIT12 sy-vline
WA_FC00SIULST_STR-SUBIT13 sy-vline
WA_FC00SIULST_STR-SUBIT14 sy-vline
WA_FC00SIULST_STR-SUBIT15 sy-vline
WA_FC00SIULST_STR-SUBIT16 sy-vline
WA_FC00SIULST_STR-SUBIT17 sy-vline
WA_FC00SIULST_STR-SUBIT18 sy-vline
WA_FC00SIULST_STR-SUBIT19 sy-vline
WA_FC00SIULST_STR-SUBIT20 sy-vline
WA_FC00SIULST_STR-SUBIT21 sy-vline
WA_FC00SIULST_STR-SUBIT22 sy-vline
WA_FC00SIULST_STR-SUBIT23 sy-vline
WA_FC00SIULST_STR-SUBIT24 sy-vline
WA_FC00SIULST_STR-SUBIT25 sy-vline
WA_FC00SIULST_STR-SUBIT26 sy-vline
WA_FC00SIULST_STR-SUBIT27 sy-vline
WA_FC00SIULST_STR-SUBIT28 sy-vline
WA_FC00SIULST_STR-SUBIT29 sy-vline
WA_FC00SIULST_STR-SUBIT30 sy-vline
WA_FC00SIULST_STR-SUBIT31 sy-vline
WA_FC00SIULST_STR-SUBIT32 sy-vline
WA_FC00SIULST_STR-SUBIT33 sy-vline
WA_FC00SIULST_STR-SUBIT34 sy-vline
WA_FC00SIULST_STR-SUBIT35 sy-vline
WA_FC00SIULST_STR-SUBIT36 sy-vline
WA_FC00SIULST_STR-SUBIT37 sy-vline
WA_FC00SIULST_STR-SUBIT38 sy-vline
WA_FC00SIULST_STR-SUBIT39 sy-vline
WA_FC00SIULST_STR-SUBIT40 sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.