ABAP Select data from SAP table CRMD_FINPROD_I 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 CRMD_FINPROD_I 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 CRMD_FINPROD_I. 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 CRMD_FINPROD_I 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_CRMD_FINPROD_I TYPE STANDARD TABLE OF CRMD_FINPROD_I,
      WA_CRMD_FINPROD_I TYPE CRMD_FINPROD_I,
      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: <CRMD_FINPROD_I> TYPE CRMD_FINPROD_I.

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

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

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM CRMD_FINPROD_I
*  INTO TABLE @DATA(IT_CRMD_FINPROD_I2).
*--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_CRMD_FINPROD_I INDEX 1 INTO DATA(WA_CRMD_FINPROD_I2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_CRMD_FINPROD_I ASSIGNING <CRMD_FINPROD_I>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
<CRMD_FINPROD_I>-CLIENT = 1.
<CRMD_FINPROD_I>-GUID = 1.
<CRMD_FINPROD_I>-RESID_VALUE_FLAG = 1.
<CRMD_FINPROD_I>-RESID_VALUE_GRP = 1.
<CRMD_FINPROD_I>-PURCHASE_OPTION = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_CRMD_FINPROD_I-CLASSIFICATION, sy-vline,
WA_CRMD_FINPROD_I-CLASSIF_LOCAL, sy-vline,
WA_CRMD_FINPROD_I-CLASSIF_LOCAL_BK, sy-vline,
WA_CRMD_FINPROD_I-CLASSIF_GROUP, sy-vline,
WA_CRMD_FINPROD_I-CLASSIF_GROUP_BK, sy-vline,
WA_CRMD_FINPROD_I-CLAS_CUSTOMER, sy-vline.
ENDLOOP. *Add any further fields from structure WA_CRMD_FINPROD_I 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_CRMD_FINPROD_I 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_CRMD_FINPROD_I INTO WA_CRMD_FINPROD_I. *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_CRMD_FINPROD_I_STR,
CLIENT TYPE STRING,
GUID TYPE STRING,
RESID_VALUE_FLAG TYPE STRING,
RESID_VALUE_GRP TYPE STRING,
PURCHASE_OPTION TYPE STRING,
CLASSIFICATION TYPE STRING,
CLASSIF_LOCAL TYPE STRING,
CLASSIF_LOCAL_BK TYPE STRING,
CLASSIF_GROUP TYPE STRING,
CLASSIF_GROUP_BK TYPE STRING,
CLAS_CUSTOMER TYPE STRING,
CLAS_GROUP_FLAG TYPE STRING,
CLAS_GROUPBK_FLG TYPE STRING,
CLASSIFI_FLAG TYPE STRING,
CLAS_LOCALBK_FLG TYPE STRING,
LEAS_CLASS TYPE STRING,
USED_FLAG TYPE STRING,
TAX_FINANC_FLAG TYPE STRING,
CHARGE_FIN_FLAG TYPE STRING,
COSTS_FIN_FLAG TYPE STRING,
SERV_FIN_FLAG TYPE STRING,
TAX_FIN_USE_FLG TYPE STRING,
CHRG_FIN_USE_FLG TYPE STRING,
COST_FIN_USE_FLG TYPE STRING,
SERV_FIN_USE_FLG TYPE STRING,
FMV_CURVE TYPE STRING,
PRICING_FIMA TYPE STRING,
SERVICE_FLAG TYPE STRING,
CHARGE_FLAG TYPE STRING,
COSTS_FLAG TYPE STRING,
RATEBLEND_FLAG TYPE STRING,
PTWACC_ROE TYPE STRING,
ATWACC_ROE TYPE STRING,
LESSOR_IRR TYPE STRING,
ACCOUNT_IRR TYPE STRING,
CUSTOMER_IRR TYPE STRING,
FIN_TRANSACTION TYPE STRING,
BUSINESS_PROCESS TYPE STRING,
CHNG_PROCESS TYPE STRING,
CHNG_PROCESS1 TYPE STRING,
KEEP_RATEPERX TYPE STRING,
LINK_TO_TC TYPE STRING,
LOOKUP_FOR_INTER TYPE STRING,
STEP_PAYMENT_F TYPE STRING,
STEP_STRUCTURE TYPE STRING,
DOWN_PAYMENT_F TYPE STRING,
REFERENCE_INTER TYPE STRING,
REFERENCE_INTE_D TYPE STRING,
FLUCTUATION_CAP TYPE STRING,
AVERAGE_DAYS TYPE STRING,
INTERIM_PERIOD TYPE STRING,
INTERIMDAYS TYPE STRING,
INTDAYSUSE TYPE STRING,
ROUND_PROFILE TYPE STRING,
CFTYPE_PROFILE TYPE STRING,
RATE_PER_K_USE TYPE STRING,
FLAT_RATE_PERX TYPE STRING,
FINOPT_EXE TYPE STRING,
PRED_HEADER_GUID TYPE STRING,
PRED_ITEM_GUID TYPE STRING,
TAX_IRR TYPE STRING,
FLATRATE_LESSOR TYPE STRING,
FLATRATE_CUSTOM TYPE STRING,
FLATRATE_CUSTALL TYPE STRING,
FLATRATE_TAX TYPE STRING,
FLATRATE_FEES TYPE STRING,
FLATRATE_CSTINCL TYPE STRING,
FLATRATE_SERVICE TYPE STRING,
KEYDAY TYPE STRING,
ONE_VIEW_FLAG TYPE STRING,
VIEW_DISTR_METH TYPE STRING,
CUSTOM_COMPL_IRR TYPE STRING,
FEES_IRR TYPE STRING,
SERVICE_IRR TYPE STRING,
CSTINCL_IRR TYPE STRING,
TAX_UPFRONT_FLAG TYPE STRING,
TAX_NO_FLAG TYPE STRING,
TAX_FINANC_GUID TYPE STRING,
UPG_TYPE TYPE STRING,
UPG_BASE_GUID TYPE STRING,
OPTION_TYPE TYPE STRING,
VALUATION TYPE STRING,
PRESTATED TYPE STRING,
BARGAIN TYPE STRING,
PRICING_PROCESS TYPE STRING,
PRICING_PROCESS1 TYPE STRING,
FINOPT_DEF TYPE STRING,
OPTION_CRE_MODE TYPE STRING,
INTCALC_METHOD TYPE STRING,
IRR_METHOD TYPE STRING,
INTCALC_M_EXT TYPE STRING,
IRR_M_EXT TYPE STRING,
RATE_FACTOR TYPE STRING,
ADGSDAYS TYPE STRING,
COMPEXPO TYPE STRING,
INTSETTLFREQ TYPE STRING,
INTSETTLFREQ_IRR TYPE STRING,
CALC_FLATRATE TYPE STRING,
PAYMSCHED_CREATE TYPE STRING,
PROCESS_PROFILE TYPE STRING,
BACKSOLVE_METHOD TYPE STRING,
BACKSOLVE_MET_PR TYPE STRING,
CALC_PROFILE TYPE STRING,
INTP_CHARGE TYPE STRING,
IRR_PROFILE TYPE STRING,
IRR_METHOD_BADI TYPE STRING,
BALSETTL_METH TYPE STRING,
CFTYPE_BALSETTL TYPE STRING,
FINV_PROFILE TYPE STRING,
INTCALC_M_INTP TYPE STRING,
USE_ACTDAYS TYPE STRING,
FIMA_ALGTYPE TYPE STRING,
RATING TYPE STRING,
BILPR TYPE STRING,END OF T_EKKO_STR. DATA: WA_CRMD_FINPROD_I_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_CRMD_FINPROD_I_STR-CLIENT sy-vline
WA_CRMD_FINPROD_I_STR-GUID sy-vline
WA_CRMD_FINPROD_I_STR-RESID_VALUE_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-RESID_VALUE_GRP sy-vline
WA_CRMD_FINPROD_I_STR-PURCHASE_OPTION sy-vline
WA_CRMD_FINPROD_I_STR-CLASSIFICATION sy-vline
WA_CRMD_FINPROD_I_STR-CLASSIF_LOCAL sy-vline
WA_CRMD_FINPROD_I_STR-CLASSIF_LOCAL_BK sy-vline
WA_CRMD_FINPROD_I_STR-CLASSIF_GROUP sy-vline
WA_CRMD_FINPROD_I_STR-CLASSIF_GROUP_BK sy-vline
WA_CRMD_FINPROD_I_STR-CLAS_CUSTOMER sy-vline
WA_CRMD_FINPROD_I_STR-CLAS_GROUP_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-CLAS_GROUPBK_FLG sy-vline
WA_CRMD_FINPROD_I_STR-CLASSIFI_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-CLAS_LOCALBK_FLG sy-vline
WA_CRMD_FINPROD_I_STR-LEAS_CLASS sy-vline
WA_CRMD_FINPROD_I_STR-USED_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-TAX_FINANC_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-CHARGE_FIN_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-COSTS_FIN_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-SERV_FIN_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-TAX_FIN_USE_FLG sy-vline
WA_CRMD_FINPROD_I_STR-CHRG_FIN_USE_FLG sy-vline
WA_CRMD_FINPROD_I_STR-COST_FIN_USE_FLG sy-vline
WA_CRMD_FINPROD_I_STR-SERV_FIN_USE_FLG sy-vline
WA_CRMD_FINPROD_I_STR-FMV_CURVE sy-vline
WA_CRMD_FINPROD_I_STR-PRICING_FIMA sy-vline
WA_CRMD_FINPROD_I_STR-SERVICE_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-CHARGE_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-COSTS_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-RATEBLEND_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-PTWACC_ROE sy-vline
WA_CRMD_FINPROD_I_STR-ATWACC_ROE sy-vline
WA_CRMD_FINPROD_I_STR-LESSOR_IRR sy-vline
WA_CRMD_FINPROD_I_STR-ACCOUNT_IRR sy-vline
WA_CRMD_FINPROD_I_STR-CUSTOMER_IRR sy-vline
WA_CRMD_FINPROD_I_STR-FIN_TRANSACTION sy-vline
WA_CRMD_FINPROD_I_STR-BUSINESS_PROCESS sy-vline
WA_CRMD_FINPROD_I_STR-CHNG_PROCESS sy-vline
WA_CRMD_FINPROD_I_STR-CHNG_PROCESS1 sy-vline
WA_CRMD_FINPROD_I_STR-KEEP_RATEPERX sy-vline
WA_CRMD_FINPROD_I_STR-LINK_TO_TC sy-vline
WA_CRMD_FINPROD_I_STR-LOOKUP_FOR_INTER sy-vline
WA_CRMD_FINPROD_I_STR-STEP_PAYMENT_F sy-vline
WA_CRMD_FINPROD_I_STR-STEP_STRUCTURE sy-vline
WA_CRMD_FINPROD_I_STR-DOWN_PAYMENT_F sy-vline
WA_CRMD_FINPROD_I_STR-REFERENCE_INTER sy-vline
WA_CRMD_FINPROD_I_STR-REFERENCE_INTE_D sy-vline
WA_CRMD_FINPROD_I_STR-FLUCTUATION_CAP sy-vline
WA_CRMD_FINPROD_I_STR-AVERAGE_DAYS sy-vline
WA_CRMD_FINPROD_I_STR-INTERIM_PERIOD sy-vline
WA_CRMD_FINPROD_I_STR-INTERIMDAYS sy-vline
WA_CRMD_FINPROD_I_STR-INTDAYSUSE sy-vline
WA_CRMD_FINPROD_I_STR-ROUND_PROFILE sy-vline
WA_CRMD_FINPROD_I_STR-CFTYPE_PROFILE sy-vline
WA_CRMD_FINPROD_I_STR-RATE_PER_K_USE sy-vline
WA_CRMD_FINPROD_I_STR-FLAT_RATE_PERX sy-vline
WA_CRMD_FINPROD_I_STR-FINOPT_EXE sy-vline
WA_CRMD_FINPROD_I_STR-PRED_HEADER_GUID sy-vline
WA_CRMD_FINPROD_I_STR-PRED_ITEM_GUID sy-vline
WA_CRMD_FINPROD_I_STR-TAX_IRR sy-vline
WA_CRMD_FINPROD_I_STR-FLATRATE_LESSOR sy-vline
WA_CRMD_FINPROD_I_STR-FLATRATE_CUSTOM sy-vline
WA_CRMD_FINPROD_I_STR-FLATRATE_CUSTALL sy-vline
WA_CRMD_FINPROD_I_STR-FLATRATE_TAX sy-vline
WA_CRMD_FINPROD_I_STR-FLATRATE_FEES sy-vline
WA_CRMD_FINPROD_I_STR-FLATRATE_CSTINCL sy-vline
WA_CRMD_FINPROD_I_STR-FLATRATE_SERVICE sy-vline
WA_CRMD_FINPROD_I_STR-KEYDAY sy-vline
WA_CRMD_FINPROD_I_STR-ONE_VIEW_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-VIEW_DISTR_METH sy-vline
WA_CRMD_FINPROD_I_STR-CUSTOM_COMPL_IRR sy-vline
WA_CRMD_FINPROD_I_STR-FEES_IRR sy-vline
WA_CRMD_FINPROD_I_STR-SERVICE_IRR sy-vline
WA_CRMD_FINPROD_I_STR-CSTINCL_IRR sy-vline
WA_CRMD_FINPROD_I_STR-TAX_UPFRONT_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-TAX_NO_FLAG sy-vline
WA_CRMD_FINPROD_I_STR-TAX_FINANC_GUID sy-vline
WA_CRMD_FINPROD_I_STR-UPG_TYPE sy-vline
WA_CRMD_FINPROD_I_STR-UPG_BASE_GUID sy-vline
WA_CRMD_FINPROD_I_STR-OPTION_TYPE sy-vline
WA_CRMD_FINPROD_I_STR-VALUATION sy-vline
WA_CRMD_FINPROD_I_STR-PRESTATED sy-vline
WA_CRMD_FINPROD_I_STR-BARGAIN sy-vline
WA_CRMD_FINPROD_I_STR-PRICING_PROCESS sy-vline
WA_CRMD_FINPROD_I_STR-PRICING_PROCESS1 sy-vline
WA_CRMD_FINPROD_I_STR-FINOPT_DEF sy-vline
WA_CRMD_FINPROD_I_STR-OPTION_CRE_MODE sy-vline
WA_CRMD_FINPROD_I_STR-INTCALC_METHOD sy-vline
WA_CRMD_FINPROD_I_STR-IRR_METHOD sy-vline
WA_CRMD_FINPROD_I_STR-INTCALC_M_EXT sy-vline
WA_CRMD_FINPROD_I_STR-IRR_M_EXT sy-vline
WA_CRMD_FINPROD_I_STR-RATE_FACTOR sy-vline
WA_CRMD_FINPROD_I_STR-ADGSDAYS sy-vline
WA_CRMD_FINPROD_I_STR-COMPEXPO sy-vline
WA_CRMD_FINPROD_I_STR-INTSETTLFREQ sy-vline
WA_CRMD_FINPROD_I_STR-INTSETTLFREQ_IRR sy-vline
WA_CRMD_FINPROD_I_STR-CALC_FLATRATE sy-vline
WA_CRMD_FINPROD_I_STR-PAYMSCHED_CREATE sy-vline
WA_CRMD_FINPROD_I_STR-PROCESS_PROFILE sy-vline
WA_CRMD_FINPROD_I_STR-BACKSOLVE_METHOD sy-vline
WA_CRMD_FINPROD_I_STR-BACKSOLVE_MET_PR sy-vline
WA_CRMD_FINPROD_I_STR-CALC_PROFILE sy-vline
WA_CRMD_FINPROD_I_STR-INTP_CHARGE sy-vline
WA_CRMD_FINPROD_I_STR-IRR_PROFILE sy-vline
WA_CRMD_FINPROD_I_STR-IRR_METHOD_BADI sy-vline
WA_CRMD_FINPROD_I_STR-BALSETTL_METH sy-vline
WA_CRMD_FINPROD_I_STR-CFTYPE_BALSETTL sy-vline
WA_CRMD_FINPROD_I_STR-FINV_PROFILE sy-vline
WA_CRMD_FINPROD_I_STR-INTCALC_M_INTP sy-vline
WA_CRMD_FINPROD_I_STR-USE_ACTDAYS sy-vline
WA_CRMD_FINPROD_I_STR-FIMA_ALGTYPE sy-vline
WA_CRMD_FINPROD_I_STR-RATING sy-vline
WA_CRMD_FINPROD_I_STR-BILPR sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.