ABAP Select data from SAP table ICL_CLAIM_SUBRO_S_FT_PAYITEM 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 ICL_CLAIM_SUBRO_S_FT_PAYITEM 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 ICL_CLAIM_SUBRO_S_FT_PAYITEM. 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 ICL_CLAIM_SUBRO_S_FT_PAYITEM 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_ICL_CLAIM_SUBRO_S_FT_PAYITEM TYPE STANDARD TABLE OF ICL_CLAIM_SUBRO_S_FT_PAYITEM,
      WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM TYPE ICL_CLAIM_SUBRO_S_FT_PAYITEM,
      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: <ICL_CLAIM_SUBRO_S_FT_PAYITEM> TYPE ICL_CLAIM_SUBRO_S_FT_PAYITEM.

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

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

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM ICL_CLAIM_SUBRO_S_FT_PAYITEM
*  INTO TABLE @DATA(IT_ICL_CLAIM_SUBRO_S_FT_PAYITEM2).
*--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_ICL_CLAIM_SUBRO_S_FT_PAYITEM INDEX 1 INTO DATA(WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_ICL_CLAIM_SUBRO_S_FT_PAYITEM ASSIGNING <ICL_CLAIM_SUBRO_S_FT_PAYITEM>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
<ICL_CLAIM_SUBRO_S_FT_PAYITEM>-WA_FT_PAYITEM = 1.
<ICL_CLAIM_SUBRO_S_FT_PAYITEM>-CLIENT = 1.
<ICL_CLAIM_SUBRO_S_FT_PAYITEM>-ACTIONNO = 1.
<ICL_CLAIM_SUBRO_S_FT_PAYITEM>-OBJ_TYPE = 1.
<ICL_CLAIM_SUBRO_S_FT_PAYITEM>-OBJ_KEY = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-FORMCLASS, sy-vline,
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-LAST_DATE, sy-vline,
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TRIG_FROM, sy-vline,
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TRIG_TO, sy-vline,
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TRIG_COUNT, sy-vline,
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TRIG_DONE, sy-vline.
ENDLOOP. *Add any further fields from structure WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM 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_ICL_CLAIM_SUBRO_S_FT_PAYITEM 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_ICL_CLAIM_SUBRO_S_FT_PAYITEM INTO WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM. *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 ISOLA, internal->external for field TDSPRAS1 CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TDSPRAS1 IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TDSPRAS1.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ISOLA, internal->external for field TDSPRAS2 CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TDSPRAS2 IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TDSPRAS2.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ISOLA, internal->external for field TDSPRAS3 CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TDSPRAS3 IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TDSPRAS3.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ISOLA, internal->external for field TDSPRAS4 CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TDSPRAS4 IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TDSPRAS4.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ISOLA, internal->external for field TDSPRAS5 CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TDSPRAS5 IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-TDSPRAS5.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ABPSN, internal->external for field CAMPAIGN CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT' EXPORTING input = WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-CAMPAIGN IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM-CAMPAIGN.
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_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR,
WA_FT_PAYITEM TYPE STRING,
CLIENT TYPE STRING,
ACTIONNO TYPE STRING,
OBJ_TYPE TYPE STRING,
OBJ_KEY TYPE STRING,
FORMCLASS TYPE STRING,
LAST_DATE TYPE STRING,
TRIG_FROM TYPE STRING,
TRIG_TO TYPE STRING,
TRIG_COUNT TYPE STRING,
TRIG_DONE TYPE STRING,
MODULO TYPE STRING,
TDNAME1 TYPE STRING,
TDID1 TYPE STRING,
TDSPRAS1 TYPE STRING,
TDNAME2 TYPE STRING,
TDID2 TYPE STRING,
TDSPRAS2 TYPE STRING,
TDNAME3 TYPE STRING,
TDID3 TYPE STRING,
TDSPRAS3 TYPE STRING,
TDNAME4 TYPE STRING,
TDID4 TYPE STRING,
TDSPRAS4 TYPE STRING,
TDNAME5 TYPE STRING,
TDID5 TYPE STRING,
TDSPRAS5 TYPE STRING,
FLYERID1 TYPE STRING,
FLYERID2 TYPE STRING,
FLYERID3 TYPE STRING,
FLYERID4 TYPE STRING,
FLYERID5 TYPE STRING,
FLYERID6 TYPE STRING,
FLYERID7 TYPE STRING,
FLYERID8 TYPE STRING,
FLYERID9 TYPE STRING,
FLYERID10 TYPE STRING,
DESCRIPT TYPE STRING,
ERDAT TYPE STRING,
ERNAM TYPE STRING,
ERSAP TYPE STRING,
AEDAT TYPE STRING,
AENAM TYPE STRING,
AEUZEIT TYPE STRING,
AESAP TYPE STRING,
CAMPAIGN TYPE STRING,END OF T_EKKO_STR. DATA: WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_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_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-WA_FT_PAYITEM sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-CLIENT sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-ACTIONNO sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-OBJ_TYPE sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-OBJ_KEY sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-FORMCLASS sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-LAST_DATE sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TRIG_FROM sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TRIG_TO sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TRIG_COUNT sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TRIG_DONE sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-MODULO sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDNAME1 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDID1 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDSPRAS1 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDNAME2 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDID2 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDSPRAS2 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDNAME3 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDID3 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDSPRAS3 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDNAME4 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDID4 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDSPRAS4 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDNAME5 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDID5 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-TDSPRAS5 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-FLYERID1 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-FLYERID2 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-FLYERID3 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-FLYERID4 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-FLYERID5 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-FLYERID6 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-FLYERID7 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-FLYERID8 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-FLYERID9 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-FLYERID10 sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-DESCRIPT sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-ERDAT sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-ERNAM sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-ERSAP sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-AEDAT sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-AENAM sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-AEUZEIT sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-AESAP sy-vline
WA_ICL_CLAIM_SUBRO_S_FT_PAYITEM_STR-CAMPAIGN sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.