ABAP Select data from SAP table BBPS_PDEXT_QUOT_HEADER_U 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_PDEXT_QUOT_HEADER_U 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_PDEXT_QUOT_HEADER_U. 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_PDEXT_QUOT_HEADER_U 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_PDEXT_QUOT_HEADER_U TYPE STANDARD TABLE OF BBPS_PDEXT_QUOT_HEADER_U, WA_BBPS_PDEXT_QUOT_HEADER_U TYPE BBPS_PDEXT_QUOT_HEADER_U, 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_PDEXT_QUOT_HEADER_U> TYPE BBPS_PDEXT_QUOT_HEADER_U. *Process all fields in table header/work area as string values PERFORM process_as_string_field_values CHANGING wa_BBPS_PDEXT_QUOT_HEADER_U. SELECT * *restrict ABAP select to first 10 rows UP TO 10 ROWS FROM BBPS_PDEXT_QUOT_HEADER_U INTO TABLE IT_BBPS_PDEXT_QUOT_HEADER_U. *Select data and declare internal table using in-line method @DATA *SELECT * * FROM BBPS_PDEXT_QUOT_HEADER_U * INTO TABLE @DATA(IT_BBPS_PDEXT_QUOT_HEADER_U2). *--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_PDEXT_QUOT_HEADER_U INDEX 1 INTO DATA(WA_BBPS_PDEXT_QUOT_HEADER_U2). *Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL LOOP AT IT_BBPS_PDEXT_QUOT_HEADER_U ASSIGNING <BBPS_PDEXT_QUOT_HEADER_U>.*To update a field value using a field symbol simply change the value via the field symbol pointer
<BBPS_PDEXT_QUOT_HEADER_U>-GUID = 1.
<BBPS_PDEXT_QUOT_HEADER_U>-VALUE = 1.
<BBPS_PDEXT_QUOT_HEADER_U>-TOTAL_VALUE = 1.
<BBPS_PDEXT_QUOT_HEADER_U>-APPROVAL_IND = 1.
<BBPS_PDEXT_QUOT_HEADER_U>-VPER_START = 1.
ENDLOOP. LOOP AT IT_BBPS_PDEXT_QUOT_HEADER_U INTO WA_BBPS_PDEXT_QUOT_HEADER_U. *Write horizonal line to screen report. WRITE:/ sy-uline. *Write selected data to screen/report before conversion. WRITE:/ sy-vline, WA_BBPS_PDEXT_QUOT_HEADER_U-VPER_END, sy-vline,
WA_BBPS_PDEXT_QUOT_HEADER_U-PMNTTRMS, sy-vline,
WA_BBPS_PDEXT_QUOT_HEADER_U-INCOTERM_KEY, sy-vline,
WA_BBPS_PDEXT_QUOT_HEADER_U-INCOTERM_LOC, sy-vline,
WA_BBPS_PDEXT_QUOT_HEADER_U-BID_DATE, sy-vline,
WA_BBPS_PDEXT_QUOT_HEADER_U-CTR_IND, sy-vline.
ENDLOOP. *Add any further fields from structure WA_BBPS_PDEXT_QUOT_HEADER_U 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_PDEXT_QUOT_HEADER_U 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_PDEXT_QUOT_HEADER_U INTO WA_BBPS_PDEXT_QUOT_HEADER_U. *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 TSTPS, internal->external for field BID_DATE CALL FUNCTION 'CONVERSION_EXIT_TSTPS_OUTPUT' EXPORTING input = WA_BBPS_PDEXT_QUOT_HEADER_U-BID_DATE IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_BBPS_PDEXT_QUOT_HEADER_U-BID_DATE.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ISOLA, internal->external for field DESCR_LANGUAGE CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_BBPS_PDEXT_QUOT_HEADER_U-DESCR_LANGUAGE IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_BBPS_PDEXT_QUOT_HEADER_U-DESCR_LANGUAGE.
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_PDEXT_QUOT_HEADER_U_STR,
GUID TYPE STRING,
VALUE TYPE STRING,
TOTAL_VALUE TYPE STRING,
APPROVAL_IND TYPE STRING,
VPER_START TYPE STRING,
VPER_END TYPE STRING,
PMNTTRMS TYPE STRING,
INCOTERM_KEY TYPE STRING,
INCOTERM_LOC TYPE STRING,
BID_DATE TYPE STRING,
CTR_IND TYPE STRING,
REF_DOC_NO TYPE STRING,
EXTERNAL_RANK TYPE STRING,
EXTERNAL_SCORE TYPE STRING,
DESCR_LANGUAGE TYPE STRING,
SK_COUNTRY TYPE STRING,
SK_SCENARIO1 TYPE STRING,
SK_SCENARIO2 TYPE STRING,
SK_SCENARIO3 TYPE STRING,
SK_SCENARIO4 TYPE STRING,
SK_SCENARIO5 TYPE STRING,
DUMMY_EEW_PDHSS_QUOT TYPE STRING,
PS_HIER_TEMPL TYPE STRING,
PS_NUMVRS TYPE STRING,
APCGK TYPE STRING,
APCGK_EXTEND TYPE STRING,
BAS_DATE TYPE STRING,
ADATTYP TYPE STRING,
START_DAT TYPE STRING,
DEV TYPE STRING,
INDANX TYPE STRING,
LIMIT_DAT TYPE STRING,
NUMERATOR TYPE STRING,
PS_GUAR_MIN_BID TYPE STRING,
PS_GM_LEVEL TYPE STRING,
PS_IDC_DOC TYPE STRING,
OPT_CPLX_DOC TYPE STRING,
PS_PA_ID_HDR TYPE STRING,
PS_PA_CLNG_HDR TYPE STRING,
PS_PA_CLNG_IND TYPE STRING,
PS_TNDR_COLB_ID TYPE STRING,
PS_TECH_QTE_STA TYPE STRING,
PS_WH_PRCNT_HDR TYPE STRING,
PS_WH_IND TYPE STRING,
DUMMY_EEW_PDHSC_QUOT TYPE STRING,
BI_VERSION_GUID TYPE STRING,
CURRENCY TYPE STRING,
SIG_IND TYPE STRING,
ITEM_CURR_IND TYPE STRING,
LIMIT_CTRL_FLAG TYPE STRING,
BIDDING_SYSTEM TYPE STRING,
CURRENCY_ISO TYPE STRING,
LANGU_ISO TYPE STRING,
GROSS_AMOUNT_EXT TYPE STRING,
QUOT_DEAD_EXT TYPE STRING,
REF_OBJECT_ID_EXT TYPE STRING,
ACTION_CODE TYPE STRING,
DOC_CLOSED TYPE STRING,
ITEM_LIST_COMPLETE_TRAN_IND TYPE STRING,END OF T_EKKO_STR. DATA: WA_BBPS_PDEXT_QUOT_HEADER_U_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_PDEXT_QUOT_HEADER_U_STR-GUID sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-VALUE sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-TOTAL_VALUE sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-APPROVAL_IND sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-VPER_START sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-VPER_END sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PMNTTRMS sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-INCOTERM_KEY sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-INCOTERM_LOC sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-BID_DATE sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-CTR_IND sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-REF_DOC_NO sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-EXTERNAL_RANK sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-EXTERNAL_SCORE sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-DESCR_LANGUAGE sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-SK_COUNTRY sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-SK_SCENARIO1 sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-SK_SCENARIO2 sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-SK_SCENARIO3 sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-SK_SCENARIO4 sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-SK_SCENARIO5 sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-DUMMY_EEW_PDHSS_QUOT sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PS_HIER_TEMPL sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PS_NUMVRS sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-APCGK sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-APCGK_EXTEND sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-BAS_DATE sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-ADATTYP sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-START_DAT sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-DEV sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-INDANX sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-LIMIT_DAT sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-NUMERATOR sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PS_GUAR_MIN_BID sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PS_GM_LEVEL sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PS_IDC_DOC sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-OPT_CPLX_DOC sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PS_PA_ID_HDR sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PS_PA_CLNG_HDR sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PS_PA_CLNG_IND sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PS_TNDR_COLB_ID sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PS_TECH_QTE_STA sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PS_WH_PRCNT_HDR sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-PS_WH_IND sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-DUMMY_EEW_PDHSC_QUOT sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-BI_VERSION_GUID sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-CURRENCY sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-SIG_IND sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-ITEM_CURR_IND sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-LIMIT_CTRL_FLAG sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-BIDDING_SYSTEM sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-CURRENCY_ISO sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-LANGU_ISO sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-GROSS_AMOUNT_EXT sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-QUOT_DEAD_EXT sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-REF_OBJECT_ID_EXT sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-ACTION_CODE sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-DOC_CLOSED sy-vline
WA_BBPS_PDEXT_QUOT_HEADER_U_STR-ITEM_LIST_COMPLETE_TRAN_IND sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.