ABAP Select data from SAP table FKK_VT_BIP_I_LOCKS 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 FKK_VT_BIP_I_LOCKS 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 FKK_VT_BIP_I_LOCKS. 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 FKK_VT_BIP_I_LOCKS 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_FKK_VT_BIP_I_LOCKS TYPE STANDARD TABLE OF FKK_VT_BIP_I_LOCKS, WA_FKK_VT_BIP_I_LOCKS TYPE FKK_VT_BIP_I_LOCKS, 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: <FKK_VT_BIP_I_LOCKS> TYPE FKK_VT_BIP_I_LOCKS. *Process all fields in table header/work area as string values PERFORM process_as_string_field_values CHANGING wa_FKK_VT_BIP_I_LOCKS. SELECT * *restrict ABAP select to first 10 rows UP TO 10 ROWS FROM FKK_VT_BIP_I_LOCKS INTO TABLE IT_FKK_VT_BIP_I_LOCKS. *Select data and declare internal table using in-line method @DATA *SELECT * * FROM FKK_VT_BIP_I_LOCKS * INTO TABLE @DATA(IT_FKK_VT_BIP_I_LOCKS2). *--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_FKK_VT_BIP_I_LOCKS INDEX 1 INTO DATA(WA_FKK_VT_BIP_I_LOCKS2). *Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL LOOP AT IT_FKK_VT_BIP_I_LOCKS ASSIGNING <FKK_VT_BIP_I_LOCKS>.*To update a field value using a field symbol simply change the value via the field symbol pointer
<FKK_VT_BIP_I_LOCKS>-VTPID = 1.
<FKK_VT_BIP_I_LOCKS>-BIPITEMREF = 1.
<FKK_VT_BIP_I_LOCKS>-BILLPLANNO = 1.
<FKK_VT_BIP_I_LOCKS>-BILLPLANITEM = 1.
<FKK_VT_BIP_I_LOCKS>-XBIPHLOCKSREAD = 1.
ENDLOOP. LOOP AT IT_FKK_VT_BIP_I_LOCKS INTO WA_FKK_VT_BIP_I_LOCKS. *Write horizonal line to screen report. WRITE:/ sy-uline. *Write selected data to screen/report before conversion. WRITE:/ sy-vline, WA_FKK_VT_BIP_I_LOCKS-BIP_I_LOCKS, sy-vline,
WA_FKK_VT_BIP_I_LOCKS-PUBLIC, sy-vline,
WA_FKK_VT_BIP_I_LOCKS-SUB_REPID, sy-vline,
WA_FKK_VT_BIP_I_LOCKS-SUB_DYNNR, sy-vline,
WA_FKK_VT_BIP_I_LOCKS-CTRL, sy-vline,
WA_FKK_VT_BIP_I_LOCKS-MARKLOCK, sy-vline.
ENDLOOP. *Add any further fields from structure WA_FKK_VT_BIP_I_LOCKS 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_FKK_VT_BIP_I_LOCKS 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_FKK_VT_BIP_I_LOCKS INTO WA_FKK_VT_BIP_I_LOCKS. *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 GPART CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_FKK_VT_BIP_I_LOCKS-GPART IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_FKK_VT_BIP_I_LOCKS-GPART.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ALPHA, internal->external for field VKONT CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_FKK_VT_BIP_I_LOCKS-VKONT IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_FKK_VT_BIP_I_LOCKS-VKONT.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ALPHA, internal->external for field SEL_GPART CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_FKK_VT_BIP_I_LOCKS-SEL_GPART IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_FKK_VT_BIP_I_LOCKS-SEL_GPART.
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_FKK_VT_BIP_I_LOCKS_STR,
VTPID TYPE STRING,
BIPITEMREF TYPE STRING,
BILLPLANNO TYPE STRING,
BILLPLANITEM TYPE STRING,
XBIPHLOCKSREAD TYPE STRING,
BIP_I_LOCKS TYPE STRING,
PUBLIC TYPE STRING,
SUB_REPID TYPE STRING,
SUB_DYNNR TYPE STRING,
CTRL TYPE STRING,
MARKLOCK TYPE STRING,
UPD_ONLINE TYPE STRING,
WMODE TYPE STRING,
DIALOG_OPTIONS TYPE STRING,
FSTAT_LOOBJ1 TYPE STRING,
FSTAT_DISP_LOOBJ1 TYPE STRING,
FSTAT_PROID TYPE STRING,
FSTAT_LOTYP TYPE STRING,
FSTAT_LOCKR TYPE STRING,
FSTAT_FDATE TYPE STRING,
FSTAT_TDATE TYPE STRING,
FSTAT_UNAME TYPE STRING,
FSTAT_ADATUM TYPE STRING,
FSTAT_AZEIT TYPE STRING,
FSTAT_COND_LOOBJ TYPE STRING,
FSTAT_ACTKEY TYPE STRING,
FSTAT_PTEXT TYPE STRING,
FSTAT_LOTXT TYPE STRING,
FSTAT_LTEXT TYPE STRING,
FSTAT_ACTKEYTEXT TYPE STRING,
FSTAT_LOCKT TYPE STRING,
X_SAVE_ACTIVE TYPE STRING,
POPUP_TITLE TYPE STRING,
X_NO_LOOBJ1_DATA TYPE STRING,
X_ENQUEUE_SET TYPE STRING,
LOOBJ1 TYPE STRING,
PROID TYPE STRING,
LOTYP TYPE STRING,
LOCKR TYPE STRING,
FDATE TYPE STRING,
TDATE TYPE STRING,
GPART TYPE STRING,
VKONT TYPE STRING,
UNIQUE_EXPANSION TYPE STRING,
UNIQUE_EXP_GPART TYPE STRING,
UNIQUE_EXP_VKONT TYPE STRING,
SEL_GPART TYPE STRING,
LOCKSET_DATA TYPE STRING,END OF T_EKKO_STR. DATA: WA_FKK_VT_BIP_I_LOCKS_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_FKK_VT_BIP_I_LOCKS_STR-VTPID sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-BIPITEMREF sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-BILLPLANNO sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-BILLPLANITEM sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-XBIPHLOCKSREAD sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-BIP_I_LOCKS sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-PUBLIC sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-SUB_REPID sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-SUB_DYNNR sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-CTRL sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-MARKLOCK sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-UPD_ONLINE sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-WMODE sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-DIALOG_OPTIONS sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_LOOBJ1 sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_DISP_LOOBJ1 sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_PROID sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_LOTYP sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_LOCKR sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_FDATE sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_TDATE sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_UNAME sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_ADATUM sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_AZEIT sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_COND_LOOBJ sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_ACTKEY sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_PTEXT sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_LOTXT sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_LTEXT sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_ACTKEYTEXT sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FSTAT_LOCKT sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-X_SAVE_ACTIVE sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-POPUP_TITLE sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-X_NO_LOOBJ1_DATA sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-X_ENQUEUE_SET sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-LOOBJ1 sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-PROID sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-LOTYP sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-LOCKR sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-FDATE sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-TDATE sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-GPART sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-VKONT sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-UNIQUE_EXPANSION sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-UNIQUE_EXP_GPART sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-UNIQUE_EXP_VKONT sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-SEL_GPART sy-vline
WA_FKK_VT_BIP_I_LOCKS_STR-LOCKSET_DATA sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.