ABAP Select data from SAP table ARBERP_S_C_QTEQOUT_RFQ_ITEM 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 ARBERP_S_C_QTEQOUT_RFQ_ITEM 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 ARBERP_S_C_QTEQOUT_RFQ_ITEM. 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 ARBERP_S_C_QTEQOUT_RFQ_ITEM 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_ARBERP_S_C_QTEQOUT_RFQ_ITEM TYPE STANDARD TABLE OF ARBERP_S_C_QTEQOUT_RFQ_ITEM,
      WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM TYPE ARBERP_S_C_QTEQOUT_RFQ_ITEM,
      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: <ARBERP_S_C_QTEQOUT_RFQ_ITEM> TYPE ARBERP_S_C_QTEQOUT_RFQ_ITEM.

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

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

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM ARBERP_S_C_QTEQOUT_RFQ_ITEM
*  INTO TABLE @DATA(IT_ARBERP_S_C_QTEQOUT_RFQ_ITEM2).
*--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_ARBERP_S_C_QTEQOUT_RFQ_ITEM INDEX 1 INTO DATA(WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_ARBERP_S_C_QTEQOUT_RFQ_ITEM ASSIGNING <ARBERP_S_C_QTEQOUT_RFQ_ITEM>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
<ARBERP_S_C_QTEQOUT_RFQ_ITEM>-MANDT = 1.
<ARBERP_S_C_QTEQOUT_RFQ_ITEM>-REQUESTFORQUOTATION = 1.
<ARBERP_S_C_QTEQOUT_RFQ_ITEM>-REQUESTFORQUOTATIONITEM = 1.
<ARBERP_S_C_QTEQOUT_RFQ_ITEM>-PURCHASINGDOCUMENTCATEGORY = 1.
<ARBERP_S_C_QTEQOUT_RFQ_ITEM>-PURCHASINGDOCUMENTITEMTEXT = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-MATERIAL, sy-vline,
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-MANUFACTURERMATERIAL, sy-vline,
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-MANUFACTURERPARTNMBR, sy-vline,
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-MANUFACTURER, sy-vline,
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-MATERIALGROUP, sy-vline,
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-LANGUAGE, sy-vline.
ENDLOOP. *Add any further fields from structure WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM 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_ARBERP_S_C_QTEQOUT_RFQ_ITEM 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_ARBERP_S_C_QTEQOUT_RFQ_ITEM INTO WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM. *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 REQUESTFORQUOTATION CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-REQUESTFORQUOTATION IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-REQUESTFORQUOTATION.
WRITE:/ 'New Value:', ld_input.

*Conversion exit MATN1, internal->external for field MATERIAL CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT' EXPORTING input = WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-MATERIAL IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-MATERIAL.
WRITE:/ 'New Value:', ld_input.

*Conversion exit MATN1, internal->external for field MANUFACTURERMATERIAL CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT' EXPORTING input = WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-MANUFACTURERMATERIAL IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-MANUFACTURERMATERIAL.
WRITE:/ 'New Value:', ld_input.

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

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

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

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

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

*Conversion exit CUNIT, internal->external for field ORDERQUANTITYUNIT CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT' EXPORTING input = WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-ORDERQUANTITYUNIT IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-ORDERQUANTITYUNIT.
WRITE:/ 'New Value:', ld_input.

*Conversion exit CUNIT, internal->external for field BASEUNIT CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT' EXPORTING input = WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-BASEUNIT IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-BASEUNIT.
WRITE:/ 'New Value:', ld_input.

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

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

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

*Conversion exit SXIDN, internal->external for field EMAILADDRESS CALL FUNCTION 'CONVERSION_EXIT_SXIDN_OUTPUT' EXPORTING input = WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-EMAILADDRESS IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM-EMAILADDRESS.
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_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR,
MANDT TYPE STRING,
REQUESTFORQUOTATION TYPE STRING,
REQUESTFORQUOTATIONITEM TYPE STRING,
PURCHASINGDOCUMENTCATEGORY TYPE STRING,
PURCHASINGDOCUMENTITEMTEXT TYPE STRING,
MATERIAL TYPE STRING,
MANUFACTURERMATERIAL TYPE STRING,
MANUFACTURERPARTNMBR TYPE STRING,
MANUFACTURER TYPE STRING,
MATERIALGROUP TYPE STRING,
LANGUAGE TYPE STRING,
INCOTERMSCLASSIFICATIONNAME TYPE STRING,
MATERIALGROUPTEXT TYPE STRING,
PLANT TYPE STRING,
PLANTNAME TYPE STRING,
MANUALDELIVERYADDRESSID TYPE STRING,
REFERENCEDELIVERYADDRESSID TYPE STRING,
ITEMDELIVERYADDRESSID TYPE STRING,
INCOTERMSCLASSIFICATION TYPE STRING,
INCOTERMSTRANSFERLOCATION TYPE STRING,
INCOTERMSLOCATION1 TYPE STRING,
INCOTERMSLOCATION2 TYPE STRING,
SCHEDULELINEDELIVERYDATE TYPE STRING,
SCHEDULELINEORDERQUANTITY TYPE STRING,
ORDERQUANTITYUNIT TYPE STRING,
ORDERITEMQTYTOBASEQTYNMRTR TYPE STRING,
ORDERITEMQTYTOBASEQTYDNMNTR TYPE STRING,
BASEUNIT TYPE STRING,
PURCHASEREQUISITION TYPE STRING,
PURCHASEREQUISITIONITEM TYPE STRING,
DELIVERYADDRESS TYPE STRING,
MANDT TYPE STRING,
ADDRESSID TYPE STRING,
FULLNAME TYPE STRING,
CAREOFNAME TYPE STRING,
CITYNAME TYPE STRING,
POSTALCODE TYPE STRING,
STREETNAME TYPE STRING,
HOUSENUMBER TYPE STRING,
HOUSENUMBERSUPPLEMENTTEXT TYPE STRING,
BUILDING TYPE STRING,
FLOOR TYPE STRING,
COUNTRY TYPE STRING,
CORRESPONDENCELANGUAGE TYPE STRING,
COUNTRYNAME TYPE STRING,
LANGUAGE TYPE STRING,
REGION TYPE STRING,
REGIONNAME TYPE STRING,
TRANSLATIONLANGUAGE TYPE STRING,
INTERNATIONALPHONENUMBER TYPE STRING,
DESTINATIONLOCATIONCOUNTRY TYPE STRING,
COUNTRYDIALINGCODE TYPE STRING,
INTERNATIONALFAXNUMBER TYPE STRING,
FAXCOUNTRY TYPE STRING,
FAXCOUNTRYDIALINGCODE TYPE STRING,
EMAILADDRESS TYPE STRING,
ROOMNUMBER TYPE STRING,END OF T_EKKO_STR. DATA: WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_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_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-MANDT sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-REQUESTFORQUOTATION sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-REQUESTFORQUOTATIONITEM sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-PURCHASINGDOCUMENTCATEGORY sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-PURCHASINGDOCUMENTITEMTEXT sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-MATERIAL sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-MANUFACTURERMATERIAL sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-MANUFACTURERPARTNMBR sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-MANUFACTURER sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-MATERIALGROUP sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-LANGUAGE sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-INCOTERMSCLASSIFICATIONNAME sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-MATERIALGROUPTEXT sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-PLANT sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-PLANTNAME sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-MANUALDELIVERYADDRESSID sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-REFERENCEDELIVERYADDRESSID sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-ITEMDELIVERYADDRESSID sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-INCOTERMSCLASSIFICATION sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-INCOTERMSTRANSFERLOCATION sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-INCOTERMSLOCATION1 sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-INCOTERMSLOCATION2 sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-SCHEDULELINEDELIVERYDATE sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-SCHEDULELINEORDERQUANTITY sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-ORDERQUANTITYUNIT sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-ORDERITEMQTYTOBASEQTYNMRTR sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-ORDERITEMQTYTOBASEQTYDNMNTR sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-BASEUNIT sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-PURCHASEREQUISITION sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-PURCHASEREQUISITIONITEM sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-DELIVERYADDRESS sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-MANDT sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-ADDRESSID sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-FULLNAME sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-CAREOFNAME sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-CITYNAME sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-POSTALCODE sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-STREETNAME sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-HOUSENUMBER sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-HOUSENUMBERSUPPLEMENTTEXT sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-BUILDING sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-FLOOR sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-COUNTRY sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-CORRESPONDENCELANGUAGE sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-COUNTRYNAME sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-LANGUAGE sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-REGION sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-REGIONNAME sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-TRANSLATIONLANGUAGE sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-INTERNATIONALPHONENUMBER sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-DESTINATIONLOCATIONCOUNTRY sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-COUNTRYDIALINGCODE sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-INTERNATIONALFAXNUMBER sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-FAXCOUNTRY sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-FAXCOUNTRYDIALINGCODE sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-EMAILADDRESS sy-vline
WA_ARBERP_S_C_QTEQOUT_RFQ_ITEM_STR-ROOMNUMBER sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.