ABAP Select data from SAP table CCIHS_FALHIOT 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 CCIHS_FALHIOT 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 CCIHS_FALHIOT. 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 CCIHS_FALHIOT 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_CCIHS_FALHIOT TYPE STANDARD TABLE OF CCIHS_FALHIOT,
      WA_CCIHS_FALHIOT TYPE CCIHS_FALHIOT,
      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: <CCIHS_FALHIOT> TYPE CCIHS_FALHIOT.

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

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

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM CCIHS_FALHIOT
*  INTO TABLE @DATA(IT_CCIHS_FALHIOT2).
*--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_CCIHS_FALHIOT INDEX 1 INTO DATA(WA_CCIHS_FALHIOT2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_CCIHS_FALHIOT ASSIGNING <CCIHS_FALHIOT>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
<CCIHS_FALHIOT>-MARKFLG = 1.
<CCIHS_FALHIOT>-SELEFLG = 1.
<CCIHS_FALHIOT>-LINENO = 1.
<CCIHS_FALHIOT>-LINEMOD = 1.
<CCIHS_FALHIOT>-CHCOFLG = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_CCIHS_FALHIOT-LOCKMOD, sy-vline,
WA_CCIHS_FALHIOT-INTRFLG, sy-vline,
WA_CCIHS_FALHIOT-MANDT, sy-vline,
WA_CCIHS_FALHIOT-RECN, sy-vline,
WA_CCIHS_FALHIOT-ACTN, sy-vline,
WA_CCIHS_FALHIOT-VALFR, sy-vline.
ENDLOOP. *Add any further fields from structure WA_CCIHS_FALHIOT 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_CCIHS_FALHIOT 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_CCIHS_FALHIOT INTO WA_CCIHS_FALHIOT. *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 ALPHA, internal->external for field RECN CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_CCIHS_FALHIOT-RECN IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_CCIHS_FALHIOT-RECN.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field ACTN CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_CCIHS_FALHIOT-ACTN IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_CCIHS_FALHIOT-ACTN.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field AENNR CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_CCIHS_FALHIOT-AENNR IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_CCIHS_FALHIOT-AENNR.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field OWNID CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_CCIHS_FALHIOT-OWNID IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_CCIHS_FALHIOT-OWNID.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field RECNROOT CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_CCIHS_FALHIOT-RECNROOT IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_CCIHS_FALHIOT-RECNROOT.
WRITE:/ 'New Value:', ld_input.

*Conversion exit CHRID, internal->external for field FAID CALL FUNCTION 'CONVERSION_EXIT_CHRID_OUTPUT' EXPORTING input = WA_CCIHS_FALHIOT-FAID IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_CCIHS_FALHIOT-FAID.
WRITE:/ 'New Value:', ld_input.

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

*Conversion exit ALPHA, internal->external for field RECNTIA CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_CCIHS_FALHIOT-RECNTIA IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_CCIHS_FALHIOT-RECNTIA.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field RECNTWAH CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_CCIHS_FALHIOT-RECNTWAH IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_CCIHS_FALHIOT-RECNTWAH.
WRITE:/ 'New Value:', ld_input.

*Conversion exit CHRID, internal->external for field WAID CALL FUNCTION 'CONVERSION_EXIT_CHRID_OUTPUT' EXPORTING input = WA_CCIHS_FALHIOT-WAID IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_CCIHS_FALHIOT-WAID.
WRITE:/ 'New Value:', ld_input.

*Conversion exit CHRID, internal->external for field IALID CALL FUNCTION 'CONVERSION_EXIT_CHRID_OUTPUT' EXPORTING input = WA_CCIHS_FALHIOT-IALID IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_CCIHS_FALHIOT-IALID.
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_CCIHS_FALHIOT_STR,
MARKFLG TYPE STRING,
SELEFLG TYPE STRING,
LINENO TYPE STRING,
LINEMOD TYPE STRING,
CHCOFLG TYPE STRING,
LOCKMOD TYPE STRING,
INTRFLG TYPE STRING,
MANDT TYPE STRING,
RECN TYPE STRING,
ACTN TYPE STRING,
VALFR TYPE STRING,
VALTO TYPE STRING,
AENNR TYPE STRING,
DELFLG TYPE STRING,
PARKFLG TYPE STRING,
CRDAT TYPE STRING,
CRNAM TYPE STRING,
UPDDAT TYPE STRING,
UPDNAM TYPE STRING,
SRSID TYPE STRING,
OWNID TYPE STRING,
RECNROOT TYPE STRING,
FAID TYPE STRING,
FATYPE TYPE STRING,
FAPLANT TYPE STRING,
FASTATUS TYPE STRING,
FAINITSTATUS TYPE STRING,
MTNLANGU TYPE STRING,
FALOC TYPE STRING,
OBJNR TYPE STRING,
FATRANSFLG TYPE STRING,
FATRANSDEC TYPE STRING,
RECNTIA TYPE STRING,
TRANSDAT TYPE STRING,
TRANSTIME TYPE STRING,
TRANSNAM TYPE STRING,
FATALFLG TYPE STRING,
FAFIRSTRFLG TYPE STRING,
FADAT TYPE STRING,
FATIME TYPE STRING,
FAHELPER TYPE STRING,
FAHELPERFLG TYPE STRING,
FATRTOHC TYPE STRING,
FATRFRHC TYPE STRING,
EVDAT TYPE STRING,
EVTIME TYPE STRING,
RECNTWAH TYPE STRING,
ACLOC TYPE STRING,
ACLOCDESC TYPE STRING,
FRTRMT TYPE STRING,
FRTRMTFLG TYPE STRING,
INTNOTE TYPE STRING,
INTNOTEFLG TYPE STRING,
EXTNOTE TYPE STRING,
EXTNOTEFLG TYPE STRING,
FRTRMTGRP TYPE STRING,
OFFJOBDAT TYPE STRING,
OFFJOBTIME TYPE STRING,
IPABSSUBTYPE TYPE STRING,
IPABSBEGDAT TYPE STRING,
IPABSENDDAT TYPE STRING,
IPABSSEQNUM TYPE STRING,
IPABSESTDAYS TYPE STRING,
IPABSDAYS TYPE STRING,
IPABSCALDAYS TYPE STRING,
IPRSWBEGDAT TYPE STRING,
IPRSWENDDAT TYPE STRING,
IPRSWDAYS TYPE STRING,
IPRSWCALDAYS TYPE STRING,
FAHELPERGRP TYPE STRING,
FATIMEZONE TYPE STRING,
EVTIMEZONE TYPE STRING,
OFFJOBTIMEZONE TYPE STRING,
IAREPORTFLG TYPE STRING,
PRIVCONCFLG TYPE STRING,
EMERGRMFLG TYPE STRING,
INPATFLG TYPE STRING,
IPDEATHDATE TYPE STRING,
UNCONSCIOUS TYPE STRING,
RESUSCITATION TYPE STRING,
HOSPITALIZATION TYPE STRING,
FATYPETXT TYPE STRING,
FALOCTXT TYPE STRING,
STTXT TYPE STRING,
WAID TYPE STRING,
WANAM TYPE STRING,
FAHELPERNAM TYPE STRING,
FATRTOHCTXT TYPE STRING,
FATRFRHCTXT TYPE STRING,
ACLOCTXT TYPE STRING,
QUESFLG TYPE STRING,
FAPLANTTXT TYPE STRING,
FASHSTATNAM TYPE STRING,
FASTATNAM TYPE STRING,
IALID TYPE STRING,
KEYDRAWNFLG TYPE STRING,
TYESFLG TYPE STRING,
TNOFLG TYPE STRING,
TDINITFLG TYPE STRING,
TDYESFLG TYPE STRING,
TDNOFLG TYPE STRING,
FRTRMTNAM TYPE STRING,
MTNLANGUTXT TYPE STRING,
FAHELPERGRPTXT TYPE STRING,
FRTRMTGRPTXT TYPE STRING,
SRV_NUMBER TYPE STRING,END OF T_EKKO_STR. DATA: WA_CCIHS_FALHIOT_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_CCIHS_FALHIOT_STR-MARKFLG sy-vline
WA_CCIHS_FALHIOT_STR-SELEFLG sy-vline
WA_CCIHS_FALHIOT_STR-LINENO sy-vline
WA_CCIHS_FALHIOT_STR-LINEMOD sy-vline
WA_CCIHS_FALHIOT_STR-CHCOFLG sy-vline
WA_CCIHS_FALHIOT_STR-LOCKMOD sy-vline
WA_CCIHS_FALHIOT_STR-INTRFLG sy-vline
WA_CCIHS_FALHIOT_STR-MANDT sy-vline
WA_CCIHS_FALHIOT_STR-RECN sy-vline
WA_CCIHS_FALHIOT_STR-ACTN sy-vline
WA_CCIHS_FALHIOT_STR-VALFR sy-vline
WA_CCIHS_FALHIOT_STR-VALTO sy-vline
WA_CCIHS_FALHIOT_STR-AENNR sy-vline
WA_CCIHS_FALHIOT_STR-DELFLG sy-vline
WA_CCIHS_FALHIOT_STR-PARKFLG sy-vline
WA_CCIHS_FALHIOT_STR-CRDAT sy-vline
WA_CCIHS_FALHIOT_STR-CRNAM sy-vline
WA_CCIHS_FALHIOT_STR-UPDDAT sy-vline
WA_CCIHS_FALHIOT_STR-UPDNAM sy-vline
WA_CCIHS_FALHIOT_STR-SRSID sy-vline
WA_CCIHS_FALHIOT_STR-OWNID sy-vline
WA_CCIHS_FALHIOT_STR-RECNROOT sy-vline
WA_CCIHS_FALHIOT_STR-FAID sy-vline
WA_CCIHS_FALHIOT_STR-FATYPE sy-vline
WA_CCIHS_FALHIOT_STR-FAPLANT sy-vline
WA_CCIHS_FALHIOT_STR-FASTATUS sy-vline
WA_CCIHS_FALHIOT_STR-FAINITSTATUS sy-vline
WA_CCIHS_FALHIOT_STR-MTNLANGU sy-vline
WA_CCIHS_FALHIOT_STR-FALOC sy-vline
WA_CCIHS_FALHIOT_STR-OBJNR sy-vline
WA_CCIHS_FALHIOT_STR-FATRANSFLG sy-vline
WA_CCIHS_FALHIOT_STR-FATRANSDEC sy-vline
WA_CCIHS_FALHIOT_STR-RECNTIA sy-vline
WA_CCIHS_FALHIOT_STR-TRANSDAT sy-vline
WA_CCIHS_FALHIOT_STR-TRANSTIME sy-vline
WA_CCIHS_FALHIOT_STR-TRANSNAM sy-vline
WA_CCIHS_FALHIOT_STR-FATALFLG sy-vline
WA_CCIHS_FALHIOT_STR-FAFIRSTRFLG sy-vline
WA_CCIHS_FALHIOT_STR-FADAT sy-vline
WA_CCIHS_FALHIOT_STR-FATIME sy-vline
WA_CCIHS_FALHIOT_STR-FAHELPER sy-vline
WA_CCIHS_FALHIOT_STR-FAHELPERFLG sy-vline
WA_CCIHS_FALHIOT_STR-FATRTOHC sy-vline
WA_CCIHS_FALHIOT_STR-FATRFRHC sy-vline
WA_CCIHS_FALHIOT_STR-EVDAT sy-vline
WA_CCIHS_FALHIOT_STR-EVTIME sy-vline
WA_CCIHS_FALHIOT_STR-RECNTWAH sy-vline
WA_CCIHS_FALHIOT_STR-ACLOC sy-vline
WA_CCIHS_FALHIOT_STR-ACLOCDESC sy-vline
WA_CCIHS_FALHIOT_STR-FRTRMT sy-vline
WA_CCIHS_FALHIOT_STR-FRTRMTFLG sy-vline
WA_CCIHS_FALHIOT_STR-INTNOTE sy-vline
WA_CCIHS_FALHIOT_STR-INTNOTEFLG sy-vline
WA_CCIHS_FALHIOT_STR-EXTNOTE sy-vline
WA_CCIHS_FALHIOT_STR-EXTNOTEFLG sy-vline
WA_CCIHS_FALHIOT_STR-FRTRMTGRP sy-vline
WA_CCIHS_FALHIOT_STR-OFFJOBDAT sy-vline
WA_CCIHS_FALHIOT_STR-OFFJOBTIME sy-vline
WA_CCIHS_FALHIOT_STR-IPABSSUBTYPE sy-vline
WA_CCIHS_FALHIOT_STR-IPABSBEGDAT sy-vline
WA_CCIHS_FALHIOT_STR-IPABSENDDAT sy-vline
WA_CCIHS_FALHIOT_STR-IPABSSEQNUM sy-vline
WA_CCIHS_FALHIOT_STR-IPABSESTDAYS sy-vline
WA_CCIHS_FALHIOT_STR-IPABSDAYS sy-vline
WA_CCIHS_FALHIOT_STR-IPABSCALDAYS sy-vline
WA_CCIHS_FALHIOT_STR-IPRSWBEGDAT sy-vline
WA_CCIHS_FALHIOT_STR-IPRSWENDDAT sy-vline
WA_CCIHS_FALHIOT_STR-IPRSWDAYS sy-vline
WA_CCIHS_FALHIOT_STR-IPRSWCALDAYS sy-vline
WA_CCIHS_FALHIOT_STR-FAHELPERGRP sy-vline
WA_CCIHS_FALHIOT_STR-FATIMEZONE sy-vline
WA_CCIHS_FALHIOT_STR-EVTIMEZONE sy-vline
WA_CCIHS_FALHIOT_STR-OFFJOBTIMEZONE sy-vline
WA_CCIHS_FALHIOT_STR-IAREPORTFLG sy-vline
WA_CCIHS_FALHIOT_STR-PRIVCONCFLG sy-vline
WA_CCIHS_FALHIOT_STR-EMERGRMFLG sy-vline
WA_CCIHS_FALHIOT_STR-INPATFLG sy-vline
WA_CCIHS_FALHIOT_STR-IPDEATHDATE sy-vline
WA_CCIHS_FALHIOT_STR-UNCONSCIOUS sy-vline
WA_CCIHS_FALHIOT_STR-RESUSCITATION sy-vline
WA_CCIHS_FALHIOT_STR-HOSPITALIZATION sy-vline
WA_CCIHS_FALHIOT_STR-FATYPETXT sy-vline
WA_CCIHS_FALHIOT_STR-FALOCTXT sy-vline
WA_CCIHS_FALHIOT_STR-STTXT sy-vline
WA_CCIHS_FALHIOT_STR-WAID sy-vline
WA_CCIHS_FALHIOT_STR-WANAM sy-vline
WA_CCIHS_FALHIOT_STR-FAHELPERNAM sy-vline
WA_CCIHS_FALHIOT_STR-FATRTOHCTXT sy-vline
WA_CCIHS_FALHIOT_STR-FATRFRHCTXT sy-vline
WA_CCIHS_FALHIOT_STR-ACLOCTXT sy-vline
WA_CCIHS_FALHIOT_STR-QUESFLG sy-vline
WA_CCIHS_FALHIOT_STR-FAPLANTTXT sy-vline
WA_CCIHS_FALHIOT_STR-FASHSTATNAM sy-vline
WA_CCIHS_FALHIOT_STR-FASTATNAM sy-vline
WA_CCIHS_FALHIOT_STR-IALID sy-vline
WA_CCIHS_FALHIOT_STR-KEYDRAWNFLG sy-vline
WA_CCIHS_FALHIOT_STR-TYESFLG sy-vline
WA_CCIHS_FALHIOT_STR-TNOFLG sy-vline
WA_CCIHS_FALHIOT_STR-TDINITFLG sy-vline
WA_CCIHS_FALHIOT_STR-TDYESFLG sy-vline
WA_CCIHS_FALHIOT_STR-TDNOFLG sy-vline
WA_CCIHS_FALHIOT_STR-FRTRMTNAM sy-vline
WA_CCIHS_FALHIOT_STR-MTNLANGUTXT sy-vline
WA_CCIHS_FALHIOT_STR-FAHELPERGRPTXT sy-vline
WA_CCIHS_FALHIOT_STR-FRTRMTGRPTXT sy-vline
WA_CCIHS_FALHIOT_STR-SRV_NUMBER sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.