ABAP Select data from SAP table FTPS_HRS_RFC_BOOK_EXPORT 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 FTPS_HRS_RFC_BOOK_EXPORT 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 FTPS_HRS_RFC_BOOK_EXPORT. 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 FTPS_HRS_RFC_BOOK_EXPORT 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_FTPS_HRS_RFC_BOOK_EXPORT TYPE STANDARD TABLE OF FTPS_HRS_RFC_BOOK_EXPORT,
      WA_FTPS_HRS_RFC_BOOK_EXPORT TYPE FTPS_HRS_RFC_BOOK_EXPORT,
      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: <FTPS_HRS_RFC_BOOK_EXPORT> TYPE FTPS_HRS_RFC_BOOK_EXPORT.

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

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

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM FTPS_HRS_RFC_BOOK_EXPORT
*  INTO TABLE @DATA(IT_FTPS_HRS_RFC_BOOK_EXPORT2).
*--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_FTPS_HRS_RFC_BOOK_EXPORT INDEX 1 INTO DATA(WA_FTPS_HRS_RFC_BOOK_EXPORT2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_FTPS_HRS_RFC_BOOK_EXPORT ASSIGNING <FTPS_HRS_RFC_BOOK_EXPORT>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
<FTPS_HRS_RFC_BOOK_EXPORT>-TRANSACTION_NUMBER = 1.
<FTPS_HRS_RFC_BOOK_EXPORT>-PROPERTIES_OUT = 1.
<FTPS_HRS_RFC_BOOK_EXPORT>-ERROR = 1.
<FTPS_HRS_RFC_BOOK_EXPORT>-MESSAGE = 1.
<FTPS_HRS_RFC_BOOK_EXPORT>-CODE = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_FTPS_HRS_RFC_BOOK_EXPORT-SUBSYSTEM, sy-vline,
WA_FTPS_HRS_RFC_BOOK_EXPORT-MESSAGE, sy-vline,
WA_FTPS_HRS_RFC_BOOK_EXPORT-RESULT, sy-vline,
WA_FTPS_HRS_RFC_BOOK_EXPORT-REFERENCE_OUT, sy-vline,
WA_FTPS_HRS_RFC_BOOK_EXPORT-GROUP_CODE, sy-vline,
WA_FTPS_HRS_RFC_BOOK_EXPORT-CODE, sy-vline.
ENDLOOP. *Add any further fields from structure WA_FTPS_HRS_RFC_BOOK_EXPORT 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_FTPS_HRS_RFC_BOOK_EXPORT 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_FTPS_HRS_RFC_BOOK_EXPORT INTO WA_FTPS_HRS_RFC_BOOK_EXPORT. *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_FTPS_HRS_RFC_BOOK_EXPORT_STR,
TRANSACTION_NUMBER TYPE STRING,
PROPERTIES_OUT TYPE STRING,
ERROR TYPE STRING,
MESSAGE TYPE STRING,
CODE TYPE STRING,
SUBSYSTEM TYPE STRING,
MESSAGE TYPE STRING,
RESULT TYPE STRING,
REFERENCE_OUT TYPE STRING,
GROUP_CODE TYPE STRING,
CODE TYPE STRING,
HRS_SYSTEM TYPE STRING,
HOTEL_OFFER TYPE STRING,
DISTANCE TYPE STRING,
HOTEL_OFFER_DETAIL TYPE STRING,
CANCEL_TIME TYPE STRING,
HOUR TYPE STRING,
MINUTE TYPE STRING,
CANCEL_DAY TYPE STRING,
DAY TYPE STRING,
YEAR TYPE STRING,
MONTH TYPE STRING,
AVAILABILITY TYPE STRING,
HOTEL TYPE STRING,
REFERENCE TYPE STRING,
RENOVATION_YEAR TYPE STRING,
CHILD_DISCOUNT TYPE STRING,
SERVICE TYPE STRING,
SERVICE_TEXT TYPE STRING,
COSTRUCT_YEAR TYPE STRING,
CHILD_DIS_RATE TYPE STRING,
SENIOR_DISCOUNT TYPE STRING,
ADD_BED_PRICE TYPE STRING,
CATEGORY TYPE STRING,
SENIOR_DIS_TYPE TYPE STRING,
PHONE TYPE STRING,
BUS_VAC2_TO TYPE STRING,
DAY TYPE STRING,
YEAR TYPE STRING,
MONTH TYPE STRING,
CURE_TAXI TYPE STRING,
TIP_TEXT TYPE STRING,
FAX TYPE STRING,
POSTAL_CODE TYPE STRING,
NAME TYPE STRING,
BUS_VAC2_FROM TYPE STRING,
DAY TYPE STRING,
YEAR TYPE STRING,
MONTH TYPE STRING,
ADD_BED_TYPE TYPE STRING,
CITY TYPE STRING,
CHILD_FREE_MAX_AGE TYPE STRING,
NUM_OF_ROOMS TYPE STRING,
NOTE TYPE STRING,
LANGUAGE TYPE STRING,
DISTANCE TYPE STRING,
AREA_CODE TYPE STRING,
GEO_POSITION TYPE STRING,
LONGITUDE TYPE STRING,
ACCURACY TYPE STRING,
LATITUDE TYPE STRING,
CHILD_DIS_TYPE TYPE STRING,
RECEPTION_TO TYPE STRING,
HOUR TYPE STRING,
MINUTE TYPE STRING,
HOTEL_NUMBER TYPE STRING,
STREET TYPE STRING,
BREAKFAST_TYPE TYPE STRING,
BREAKFAST_PRICE TYPE STRING,
CURRENCY TYPE STRING,
VALUE TYPE STRING,
NO_FRACTION TYPE STRING,
NAME2 TYPE STRING,
EQUIPMENT TYPE STRING,
TAX TYPE STRING,
BUS_VACATION_TO TYPE STRING,
DAY TYPE STRING,
YEAR TYPE STRING,
MONTH TYPE STRING,
HOTEL_COUNTRY TYPE STRING,
ADD_BED_BREAKF TYPE STRING,
RECEPTION2_TO TYPE STRING,
HOUR TYPE STRING,
MINUTE TYPE STRING,
DISTRICT TYPE STRING,
RECEPTION2_FROM TYPE STRING,
HOUR TYPE STRING,
MINUTE TYPE STRING,
CURRENCY TYPE STRING,
SENIOR_DIS_RATE TYPE STRING,
TIP_MARK TYPE STRING,
INFO TYPE STRING,
TAX_TEXT TYPE STRING,
CHAIN TYPE STRING,
RECEPTION_FROM TYPE STRING,
HOUR TYPE STRING,
MINUTE TYPE STRING,
BUS_VACATION_FROM TYPE STRING,
DAY TYPE STRING,
YEAR TYPE STRING,
MONTH TYPE STRING,
AV_PRICE TYPE STRING,
DIRECTION TYPE STRING,
HOTEL_REQUEST TYPE STRING,
CC_REQUIRED TYPE STRING,
BOOKING_NUMBER TYPE STRING,
BOOKING_PWD TYPE STRING,
SOAP_FAULT TYPE STRING,
FAULTCODE TYPE STRING,
FAULTSTRING TYPE STRING,
FAULTACTOR TYPE STRING,END OF T_EKKO_STR. DATA: WA_FTPS_HRS_RFC_BOOK_EXPORT_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_FTPS_HRS_RFC_BOOK_EXPORT_STR-TRANSACTION_NUMBER sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-PROPERTIES_OUT sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-ERROR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-MESSAGE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CODE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-SUBSYSTEM sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-MESSAGE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-RESULT sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-REFERENCE_OUT sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-GROUP_CODE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CODE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-HRS_SYSTEM sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-HOTEL_OFFER sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-DISTANCE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-HOTEL_OFFER_DETAIL sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CANCEL_TIME sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-HOUR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-MINUTE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CANCEL_DAY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-DAY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-YEAR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-MONTH sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-AVAILABILITY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-HOTEL sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-REFERENCE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-RENOVATION_YEAR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CHILD_DISCOUNT sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-SERVICE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-SERVICE_TEXT sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-COSTRUCT_YEAR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CHILD_DIS_RATE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-SENIOR_DISCOUNT sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-ADD_BED_PRICE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CATEGORY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-SENIOR_DIS_TYPE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-PHONE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-BUS_VAC2_TO sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-DAY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-YEAR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-MONTH sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CURE_TAXI sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-TIP_TEXT sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-FAX sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-POSTAL_CODE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-NAME sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-BUS_VAC2_FROM sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-DAY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-YEAR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-MONTH sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-ADD_BED_TYPE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CITY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CHILD_FREE_MAX_AGE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-NUM_OF_ROOMS sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-NOTE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-LANGUAGE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-DISTANCE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-AREA_CODE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-GEO_POSITION sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-LONGITUDE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-ACCURACY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-LATITUDE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CHILD_DIS_TYPE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-RECEPTION_TO sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-HOUR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-MINUTE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-HOTEL_NUMBER sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-STREET sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-BREAKFAST_TYPE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-BREAKFAST_PRICE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CURRENCY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-VALUE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-NO_FRACTION sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-NAME2 sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-EQUIPMENT sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-TAX sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-BUS_VACATION_TO sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-DAY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-YEAR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-MONTH sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-HOTEL_COUNTRY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-ADD_BED_BREAKF sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-RECEPTION2_TO sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-HOUR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-MINUTE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-DISTRICT sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-RECEPTION2_FROM sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-HOUR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-MINUTE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CURRENCY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-SENIOR_DIS_RATE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-TIP_MARK sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-INFO sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-TAX_TEXT sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CHAIN sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-RECEPTION_FROM sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-HOUR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-MINUTE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-BUS_VACATION_FROM sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-DAY sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-YEAR sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-MONTH sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-AV_PRICE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-DIRECTION sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-HOTEL_REQUEST sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-CC_REQUIRED sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-BOOKING_NUMBER sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-BOOKING_PWD sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-SOAP_FAULT sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-FAULTCODE sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-FAULTSTRING sy-vline
WA_FTPS_HRS_RFC_BOOK_EXPORT_STR-FAULTACTOR sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.