ABAP Select data from SAP table /SAPSRM/S_CLL_QTE_ITM_BROWSE 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 /SAPSRM/S_CLL_QTE_ITM_BROWSE 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 /SAPSRM/S_CLL_QTE_ITM_BROWSE. 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 /SAPSRM/S_CLL_QTE_ITM_BROWSE 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_/SAPSRM/S_CLL_QTE_ITM_BROWSE TYPE STANDARD TABLE OF /SAPSRM/S_CLL_QTE_ITM_BROWSE,
      WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE TYPE /SAPSRM/S_CLL_QTE_ITM_BROWSE,
      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: </SAPSRM/S_CLL_QTE_ITM_BROWSE> TYPE /SAPSRM/S_CLL_QTE_ITM_BROWSE.

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

SELECT *
*restrict ABAP select to first 10 rows
 UP TO 10 ROWS      
  FROM /SAPSRM/S_CLL_QTE_ITM_BROWSE
  INTO TABLE IT_/SAPSRM/S_CLL_QTE_ITM_BROWSE.

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM /SAPSRM/S_CLL_QTE_ITM_BROWSE
*  INTO TABLE @DATA(IT_/SAPSRM/S_CLL_QTE_ITM_BROWSE2).
*--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_/SAPSRM/S_CLL_QTE_ITM_BROWSE INDEX 1 INTO DATA(WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_/SAPSRM/S_CLL_QTE_ITM_BROWSE ASSIGNING </SAPSRM/S_CLL_QTE_ITM_BROWSE>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
</SAPSRM/S_CLL_QTE_ITM_BROWSE>-GUID = 1.
</SAPSRM/S_CLL_QTE_ITM_BROWSE>-PARENT = 1.
</SAPSRM/S_CLL_QTE_ITM_BROWSE>-ITM_TYPE = 1.
</SAPSRM/S_CLL_QTE_ITM_BROWSE>-QUANTITY = 1.
</SAPSRM/S_CLL_QTE_ITM_BROWSE>-VALUE = 1.
ENDLOOP.

LOOP AT IT_/SAPSRM/S_CLL_QTE_ITM_BROWSE INTO WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE.
*Write horizonal line to screen report.
  WRITE:/ sy-uline.

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE-PRICE, sy-vline,
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE-PRICE_UNIT, sy-vline,
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE-SRC_OBJECT_TYPE, sy-vline,
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE-SRC_GUID, sy-vline,
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE-DELIV_DATE, sy-vline,
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE-DELIV_TIME, sy-vline.
ENDLOOP. *Add any further fields from structure WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE 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_/SAPSRM/S_CLL_QTE_ITM_BROWSE 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_/SAPSRM/S_CLL_QTE_ITM_BROWSE INTO WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE. *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 CUNIT, internal->external for field UNIT CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT' EXPORTING input = WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE-UNIT IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE-UNIT.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field SH_LOGSYS CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE-SH_LOGSYS IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE-SH_LOGSYS.
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_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR,
GUID TYPE STRING,
PARENT TYPE STRING,
ITM_TYPE TYPE STRING,
QUANTITY TYPE STRING,
VALUE TYPE STRING,
PRICE TYPE STRING,
PRICE_UNIT TYPE STRING,
SRC_OBJECT_TYPE TYPE STRING,
SRC_GUID TYPE STRING,
DELIV_DATE TYPE STRING,
DELIV_TIME TYPE STRING,
DELIV_DAYS TYPE STRING,
ACCEPT_IND TYPE STRING,
DEDUCT_IND TYPE STRING,
SUBTYPE TYPE STRING,
PARTNER_PROD TYPE STRING,
DESCRIPTION TYPE STRING,
NUMBER_EXT TYPE STRING,
GROUPING_LEVEL TYPE STRING,
CURRENCY TYPE STRING,
PS_HL_ITEM TYPE STRING,
PS_HANDLE_ITM TYPE STRING,
PS_EXSNR TYPE STRING,
PS_CTRL_KEY TYPE STRING,
PS_IPT TYPE STRING,
PS_VALUE_RU TYPE STRING,
PS_EXLIN_IND TYPE STRING,
PS_OPT_RF_NUM_INT TYPE STRING,
PS_OPT_RF_DESC TYPE STRING,
PS_OPT_RF_ORD_PROD TYPE STRING,
PS_OPT_RF_EXLIN TYPE STRING,
PS_OPT_IND_DISP TYPE STRING,
EXPSV_ITEM_TYPE TYPE STRING,
ORIG_GUID TYPE STRING,
ITEM_PROCESS_TYP TYPE STRING,
EXLIN TYPE STRING,
NUMBER_INT TYPE STRING,
CATEGORY TYPE STRING,
CATEGORY_ID TYPE STRING,
UNIT TYPE STRING,
DEL_IND TYPE STRING,
ORDERED_PROD TYPE STRING,
PRODUCT TYPE STRING,
PRODUCT_TYPE TYPE STRING,
SRC_QUANTITY TYPE STRING,
SRC_VALUE TYPE STRING,
ITEM_TYPE_LOT TYPE STRING,
DELIV_DATE_GEN TYPE STRING,
EXPSV_ITEM_IMAGE TYPE STRING,
EXPSV_ITEM_TOOLTIP TYPE STRING,
SH_CATEGORY_GUID TYPE STRING,
SH_CATEGORY_ID TYPE STRING,
SH_LOGSYS TYPE STRING,
SH_CATEGORY_TEXT TYPE STRING,
LEAF TYPE STRING,
EXPANDED TYPE STRING,
CHILDREN_LOADED TYPE STRING,
CALC_DESCRIPTION TYPE STRING,
NOT_SELECTABLE TYPE STRING,
BREAD_CRUMB_STATE TYPE STRING,
ALLOW_RESPONSE_IMAGE TYPE STRING,
ALLOW_RESPONSE_TOLTIP TYPE STRING,
PRODUCT_SRC_SYS TYPE STRING,
SELECTED_POPIN TYPE STRING,
DUMMY_ITEM_SWB_QUOT TYPE STRING,
DUMMY_ITEM_CWB_QUOT TYPE STRING,END OF T_EKKO_STR. DATA: WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_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_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-GUID sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PARENT sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-ITM_TYPE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-QUANTITY sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-VALUE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PRICE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PRICE_UNIT sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-SRC_OBJECT_TYPE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-SRC_GUID sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-DELIV_DATE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-DELIV_TIME sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-DELIV_DAYS sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-ACCEPT_IND sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-DEDUCT_IND sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-SUBTYPE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PARTNER_PROD sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-DESCRIPTION sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-NUMBER_EXT sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-GROUPING_LEVEL sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-CURRENCY sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PS_HL_ITEM sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PS_HANDLE_ITM sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PS_EXSNR sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PS_CTRL_KEY sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PS_IPT sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PS_VALUE_RU sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PS_EXLIN_IND sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PS_OPT_RF_NUM_INT sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PS_OPT_RF_DESC sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PS_OPT_RF_ORD_PROD sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PS_OPT_RF_EXLIN sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PS_OPT_IND_DISP sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-EXPSV_ITEM_TYPE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-ORIG_GUID sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-ITEM_PROCESS_TYP sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-EXLIN sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-NUMBER_INT sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-CATEGORY sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-CATEGORY_ID sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-UNIT sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-DEL_IND sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-ORDERED_PROD sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PRODUCT sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PRODUCT_TYPE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-SRC_QUANTITY sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-SRC_VALUE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-ITEM_TYPE_LOT sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-DELIV_DATE_GEN sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-EXPSV_ITEM_IMAGE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-EXPSV_ITEM_TOOLTIP sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-SH_CATEGORY_GUID sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-SH_CATEGORY_ID sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-SH_LOGSYS sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-SH_CATEGORY_TEXT sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-LEAF sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-EXPANDED sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-CHILDREN_LOADED sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-CALC_DESCRIPTION sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-NOT_SELECTABLE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-BREAD_CRUMB_STATE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-ALLOW_RESPONSE_IMAGE sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-ALLOW_RESPONSE_TOLTIP sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-PRODUCT_SRC_SYS sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-SELECTED_POPIN sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-DUMMY_ITEM_SWB_QUOT sy-vline
WA_/SAPSRM/S_CLL_QTE_ITM_BROWSE_STR-DUMMY_ITEM_CWB_QUOT sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.