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

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

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

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


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_/SAPCE/IUUA_SUBSIDY_IMPORT_V1 ASSIGNING </SAPCE/IUUA_SUBSIDY_IMPORT_V1>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
</SAPCE/IUUA_SUBSIDY_IMPORT_V1>-FIO = 1.
</SAPCE/IUUA_SUBSIDY_IMPORT_V1>-ID_RAJ = 1.
</SAPCE/IUUA_SUBSIDY_IMPORT_V1>-NP_CODE = 1.
</SAPCE/IUUA_SUBSIDY_IMPORT_V1>-NP_NAME = 1.
</SAPCE/IUUA_SUBSIDY_IMPORT_V1>-CAT_V = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1-VULCOD, sy-vline,
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1-NAME_V, sy-vline,
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1-BLD, sy-vline,
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1-CORP, sy-vline,
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1-FLAT, sy-vline,
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1-RASH, sy-vline.
ENDLOOP. *Add any further fields from structure WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1 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_/SAPCE/IUUA_SUBSIDY_IMPORT_V1 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_/SAPCE/IUUA_SUBSIDY_IMPORT_V1 INTO WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1. *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_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR,
FIO TYPE STRING,
ID_RAJ TYPE STRING,
NP_CODE TYPE STRING,
NP_NAME TYPE STRING,
CAT_V TYPE STRING,
VULCOD TYPE STRING,
NAME_V TYPE STRING,
BLD TYPE STRING,
CORP TYPE STRING,
FLAT TYPE STRING,
RASH TYPE STRING,
NUMB TYPE STRING,
DAT1 TYPE STRING,
DAT2 TYPE STRING,
NM_PAY TYPE STRING,
P1 TYPE STRING,
P2 TYPE STRING,
P3 TYPE STRING,
P4 TYPE STRING,
P5 TYPE STRING,
P6 TYPE STRING,
P7 TYPE STRING,
P8 TYPE STRING,
SM1 TYPE STRING,
SM2 TYPE STRING,
SM3 TYPE STRING,
SM4 TYPE STRING,
SM5 TYPE STRING,
SM6 TYPE STRING,
SM7 TYPE STRING,
SM8 TYPE STRING,
SB1 TYPE STRING,
SB2 TYPE STRING,
SB3 TYPE STRING,
SB4 TYPE STRING,
SB5 TYPE STRING,
SB6 TYPE STRING,
SB7 TYPE STRING,
SB8 TYPE STRING,
OB1 TYPE STRING,
OB2 TYPE STRING,
OB3 TYPE STRING,
OB4 TYPE STRING,
OB5 TYPE STRING,
OB6 TYPE STRING,
OB7 TYPE STRING,
OB8 TYPE STRING,
SUMMA TYPE STRING,
NUMM TYPE STRING,
SUBS TYPE STRING,
KVT TYPE STRING,END OF T_EKKO_STR. DATA: WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_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_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-FIO sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-ID_RAJ sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-NP_CODE sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-NP_NAME sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-CAT_V sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-VULCOD sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-NAME_V sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-BLD sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-CORP sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-FLAT sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-RASH sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-NUMB sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-DAT1 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-DAT2 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-NM_PAY sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-P1 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-P2 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-P3 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-P4 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-P5 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-P6 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-P7 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-P8 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SM1 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SM2 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SM3 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SM4 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SM5 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SM6 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SM7 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SM8 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SB1 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SB2 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SB3 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SB4 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SB5 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SB6 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SB7 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SB8 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-OB1 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-OB2 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-OB3 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-OB4 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-OB5 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-OB6 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-OB7 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-OB8 sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SUMMA sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-NUMM sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-SUBS sy-vline
WA_/SAPCE/IUUA_SUBSIDY_IMPORT_V1_STR-KVT sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.