ABAP Select data from SAP table BBPS_QUOT_UI_GLOBAL 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 BBPS_QUOT_UI_GLOBAL 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 BBPS_QUOT_UI_GLOBAL. 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 BBPS_QUOT_UI_GLOBAL 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_BBPS_QUOT_UI_GLOBAL TYPE STANDARD TABLE OF BBPS_QUOT_UI_GLOBAL, WA_BBPS_QUOT_UI_GLOBAL TYPE BBPS_QUOT_UI_GLOBAL, 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: <BBPS_QUOT_UI_GLOBAL> TYPE BBPS_QUOT_UI_GLOBAL. *Process all fields in table header/work area as string values PERFORM process_as_string_field_values CHANGING wa_BBPS_QUOT_UI_GLOBAL. SELECT * *restrict ABAP select to first 10 rows UP TO 10 ROWS FROM BBPS_QUOT_UI_GLOBAL INTO TABLE IT_BBPS_QUOT_UI_GLOBAL. *Select data and declare internal table using in-line method @DATA *SELECT * * FROM BBPS_QUOT_UI_GLOBAL * INTO TABLE @DATA(IT_BBPS_QUOT_UI_GLOBAL2). *--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_BBPS_QUOT_UI_GLOBAL INDEX 1 INTO DATA(WA_BBPS_QUOT_UI_GLOBAL2). *Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL LOOP AT IT_BBPS_QUOT_UI_GLOBAL ASSIGNING <BBPS_QUOT_UI_GLOBAL>.*To update a field value using a field symbol simply change the value via the field symbol pointer
<BBPS_QUOT_UI_GLOBAL>-SEARCH_TYPE = 1.
<BBPS_QUOT_UI_GLOBAL>-LAST_EVENT = 1.
<BBPS_QUOT_UI_GLOBAL>-DISPLAY_CHECKLIST = 1.
<BBPS_QUOT_UI_GLOBAL>-DISPLAY_CHAT = 1.
<BBPS_QUOT_UI_GLOBAL>-RETURN_TO_CALLER = 1.
ENDLOOP. LOOP AT IT_BBPS_QUOT_UI_GLOBAL INTO WA_BBPS_QUOT_UI_GLOBAL. *Write horizonal line to screen report. WRITE:/ sy-uline. *Write selected data to screen/report before conversion. WRITE:/ sy-vline, WA_BBPS_QUOT_UI_GLOBAL-COND_ITEM_GUID, sy-vline,
WA_BBPS_QUOT_UI_GLOBAL-MODE, sy-vline,
WA_BBPS_QUOT_UI_GLOBAL-ITEM_SEL_GUID, sy-vline,
WA_BBPS_QUOT_UI_GLOBAL-ITEM_SEL, sy-vline,
WA_BBPS_QUOT_UI_GLOBAL-ABORT, sy-vline,
WA_BBPS_QUOT_UI_GLOBAL-ERROR, sy-vline.
ENDLOOP. *Add any further fields from structure WA_BBPS_QUOT_UI_GLOBAL 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_BBPS_QUOT_UI_GLOBAL 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_BBPS_QUOT_UI_GLOBAL INTO WA_BBPS_QUOT_UI_GLOBAL. *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 BIDDER_ID CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_BBPS_QUOT_UI_GLOBAL-BIDDER_ID IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_BBPS_QUOT_UI_GLOBAL-BIDDER_ID.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ALPHA, internal->external for field CONTACT_ID CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_BBPS_QUOT_UI_GLOBAL-CONTACT_ID IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_BBPS_QUOT_UI_GLOBAL-CONTACT_ID.
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_BBPS_QUOT_UI_GLOBAL_STR,
SEARCH_TYPE TYPE STRING,
LAST_EVENT TYPE STRING,
DISPLAY_CHECKLIST TYPE STRING,
DISPLAY_CHAT TYPE STRING,
RETURN_TO_CALLER TYPE STRING,
COND_ITEM_GUID TYPE STRING,
MODE TYPE STRING,
ITEM_SEL_GUID TYPE STRING,
ITEM_SEL TYPE STRING,
ABORT TYPE STRING,
ERROR TYPE STRING,
CEP TYPE STRING,
CHANGED TYPE STRING,
PARK TYPE STRING,
SAVE TYPE STRING,
SAVED TYPE STRING,
WITHDRAWN TYPE STRING,
SUB_DEADLINE_PAST TYPE STRING,
SUB_START_NOT_REACHED TYPE STRING,
CURRENT_SCREEN TYPE STRING,
OPEN_CHECKLIST TYPE STRING,
IS_AUCTION TYPE STRING,
USER_TIME_ZONE TYPE STRING,
STAY_ON_SCREEN TYPE STRING,
ITEMS_ADD TYPE STRING,
ATTRIBUTES_EXIST TYPE STRING,
OPEN_UPLOAD_FIELD TYPE STRING,
DOCUMENTS_SHOW TYPE STRING,
BACKGROUND_PROCESS TYPE STRING,
UPLOAD_IN_BACKGROUND TYPE STRING,
UPLOAD_MEMORY_ID TYPE STRING,
TEXT_REMARK TYPE STRING,
WORKER_CAT_CALL TYPE STRING,
PREV_ITEM_AVAIL TYPE STRING,
NEXT_ITEM_AVAIL TYPE STRING,
BID_ACTIV_VERSION_GUID TYPE STRING,
NEW_SRC_EXT_VERSION_NO TYPE STRING,
BOB_MODE TYPE STRING,
CONTACT_SELECTED TYPE STRING,
BIDDER_ID TYPE STRING,
BIDDER_GUID TYPE STRING,
BIDDER_FCT TYPE STRING,
CONTACT_ID TYPE STRING,
CONTACT_GUID TYPE STRING,
CONTACT_FCT TYPE STRING,
MPN_ACTIVE TYPE STRING,
BOB_CONTACT_NAME TYPE STRING,
SERVICE_URL TYPE STRING,
QUOT_NOT_CHANGEABLE TYPE STRING,
CHECK_QUOT_HEADER TYPE STRING,
CURR_ALLOW_HEADER TYPE STRING,
CURR_ALLOW_CONDITIONS TYPE STRING,
CALC_TOTAL TYPE STRING,
SUPPRESS_DIALOG TYPE STRING,
UPDATE_ALL_ITEMS TYPE STRING,
NEXT_FCODE TYPE STRING,
TOTAL_VALUE TYPE STRING,
CURRENCY TYPE STRING,
BIDINTENT_PREV TYPE STRING,
EXPSV_ITEM_TYPE TYPE STRING,
BIDINTENT_NO_EXISTS TYPE STRING,
COMPARE_METHOD TYPE STRING,
CHANGE_VERSION_EXISTS TYPE STRING,END OF T_EKKO_STR. DATA: WA_BBPS_QUOT_UI_GLOBAL_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_BBPS_QUOT_UI_GLOBAL_STR-SEARCH_TYPE sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-LAST_EVENT sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-DISPLAY_CHECKLIST sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-DISPLAY_CHAT sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-RETURN_TO_CALLER sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-COND_ITEM_GUID sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-MODE sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-ITEM_SEL_GUID sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-ITEM_SEL sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-ABORT sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-ERROR sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CEP sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CHANGED sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-PARK sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-SAVE sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-SAVED sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-WITHDRAWN sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-SUB_DEADLINE_PAST sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-SUB_START_NOT_REACHED sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CURRENT_SCREEN sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-OPEN_CHECKLIST sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-IS_AUCTION sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-USER_TIME_ZONE sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-STAY_ON_SCREEN sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-ITEMS_ADD sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-ATTRIBUTES_EXIST sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-OPEN_UPLOAD_FIELD sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-DOCUMENTS_SHOW sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-BACKGROUND_PROCESS sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-UPLOAD_IN_BACKGROUND sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-UPLOAD_MEMORY_ID sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-TEXT_REMARK sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-WORKER_CAT_CALL sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-PREV_ITEM_AVAIL sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-NEXT_ITEM_AVAIL sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-BID_ACTIV_VERSION_GUID sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-NEW_SRC_EXT_VERSION_NO sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-BOB_MODE sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CONTACT_SELECTED sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-BIDDER_ID sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-BIDDER_GUID sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-BIDDER_FCT sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CONTACT_ID sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CONTACT_GUID sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CONTACT_FCT sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-MPN_ACTIVE sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-BOB_CONTACT_NAME sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-SERVICE_URL sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-QUOT_NOT_CHANGEABLE sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CHECK_QUOT_HEADER sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CURR_ALLOW_HEADER sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CURR_ALLOW_CONDITIONS sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CALC_TOTAL sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-SUPPRESS_DIALOG sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-UPDATE_ALL_ITEMS sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-NEXT_FCODE sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-TOTAL_VALUE sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CURRENCY sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-BIDINTENT_PREV sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-EXPSV_ITEM_TYPE sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-BIDINTENT_NO_EXISTS sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-COMPARE_METHOD sy-vline
WA_BBPS_QUOT_UI_GLOBAL_STR-CHANGE_VERSION_EXISTS sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.