ABAP Select data from SAP table /SMFND/IBQ_D_INB_H_UPD_STR 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 /SMFND/IBQ_D_INB_H_UPD_STR 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 /SMFND/IBQ_D_INB_H_UPD_STR. 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 /SMFND/IBQ_D_INB_H_UPD_STR 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_/SMFND/IBQ_D_INB_H_UPD_STR TYPE STANDARD TABLE OF /SMFND/IBQ_D_INB_H_UPD_STR, WA_/SMFND/IBQ_D_INB_H_UPD_STR TYPE /SMFND/IBQ_D_INB_H_UPD_STR, 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: </SMFND/IBQ_D_INB_H_UPD_STR> TYPE /SMFND/IBQ_D_INB_H_UPD_STR. *Process all fields in table header/work area as string values PERFORM process_as_string_field_values CHANGING wa_/SMFND/IBQ_D_INB_H_UPD_STR. SELECT * *restrict ABAP select to first 10 rows UP TO 10 ROWS FROM /SMFND/IBQ_D_INB_H_UPD_STR INTO TABLE IT_/SMFND/IBQ_D_INB_H_UPD_STR. *Select data and declare internal table using in-line method @DATA *SELECT * * FROM /SMFND/IBQ_D_INB_H_UPD_STR * INTO TABLE @DATA(IT_/SMFND/IBQ_D_INB_H_UPD_STR2). *--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_/SMFND/IBQ_D_INB_H_UPD_STR INDEX 1 INTO DATA(WA_/SMFND/IBQ_D_INB_H_UPD_STR2). *Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL LOOP AT IT_/SMFND/IBQ_D_INB_H_UPD_STR ASSIGNING </SMFND/IBQ_D_INB_H_UPD_STR>.*To update a field value using a field symbol simply change the value via the field symbol pointer
</SMFND/IBQ_D_INB_H_UPD_STR>-MANDT = 1.
</SMFND/IBQ_D_INB_H_UPD_STR>-TRANSACTION_GUID = 1.
</SMFND/IBQ_D_INB_H_UPD_STR>-RECORD_ID = 1.
</SMFND/IBQ_D_INB_H_UPD_STR>-OBJECT_TYPE = 1.
</SMFND/IBQ_D_INB_H_UPD_STR>-OBJECT_KEY = 1.
ENDLOOP. LOOP AT IT_/SMFND/IBQ_D_INB_H_UPD_STR INTO WA_/SMFND/IBQ_D_INB_H_UPD_STR. *Write horizonal line to screen report. WRITE:/ sy-uline. *Write selected data to screen/report before conversion. WRITE:/ sy-vline, WA_/SMFND/IBQ_D_INB_H_UPD_STR-OBJECT_GROUP, sy-vline,
WA_/SMFND/IBQ_D_INB_H_UPD_STR-OBJECT_GROUP_1, sy-vline,
WA_/SMFND/IBQ_D_INB_H_UPD_STR-OBJECT_ID, sy-vline,
WA_/SMFND/IBQ_D_INB_H_UPD_STR-EXT_TRANS_ID, sy-vline,
WA_/SMFND/IBQ_D_INB_H_UPD_STR-DEP_OBJECT_TYPE, sy-vline,
WA_/SMFND/IBQ_D_INB_H_UPD_STR-DEP_OBJECT_KEY, sy-vline.
ENDLOOP. *Add any further fields from structure WA_/SMFND/IBQ_D_INB_H_UPD_STR 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_/SMFND/IBQ_D_INB_H_UPD_STR 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_/SMFND/IBQ_D_INB_H_UPD_STR INTO WA_/SMFND/IBQ_D_INB_H_UPD_STR. *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 LOGSYS CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_/SMFND/IBQ_D_INB_H_UPD_STR-LOGSYS IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_/SMFND/IBQ_D_INB_H_UPD_STR-LOGSYS.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ISOLA, internal->external for field REQ_LANGU CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_/SMFND/IBQ_D_INB_H_UPD_STR-REQ_LANGU IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_/SMFND/IBQ_D_INB_H_UPD_STR-REQ_LANGU.
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_/SMFND/IBQ_D_INB_H_UPD_STR_STR,
MANDT TYPE STRING,
TRANSACTION_GUID TYPE STRING,
RECORD_ID TYPE STRING,
OBJECT_TYPE TYPE STRING,
OBJECT_KEY TYPE STRING,
OBJECT_GROUP TYPE STRING,
OBJECT_GROUP_1 TYPE STRING,
OBJECT_ID TYPE STRING,
EXT_TRANS_ID TYPE STRING,
DEP_OBJECT_TYPE TYPE STRING,
DEP_OBJECT_KEY TYPE STRING,
DEP_TRANS_ID TYPE STRING,
DEP_TRANS_GUID TYPE STRING,
DEP_OBJECT_ID TYPE STRING,
FLAG_REQ_KEYMAP TYPE STRING,
FLAG_LOCAL_KEY TYPE STRING,
FLAG_LOCAL_ITEM TYPE STRING,
FLAG_REQ_REVIEW TYPE STRING,
OBJTYP_REF TYPE STRING,
OBJKEY_REF TYPE STRING,
OBJECT_ID_REF TYPE STRING,
REQ_PROC_MODE TYPE STRING,
REQ_USER_ID TYPE STRING,
REQ_USER_GUID TYPE STRING,
TRANSACTION_TIME TYPE STRING,
TIME_ZONE TYPE STRING,
MOBILE_APP TYPE STRING,
LOGSYS TYPE STRING,
REQ_TYPE TYPE STRING,
REQ_OBJECT TYPE STRING,
REQ_OBJECT_MTHD TYPE STRING,
REQ_DO_ID TYPE STRING,
REQ_DO_MTHD_TYPE TYPE STRING,
TRANSACTION_TYPE TYPE STRING,
REF_ATTR_1 TYPE STRING,
REF_ATTR_2 TYPE STRING,
TRANSACTION_GRP TYPE STRING,
SYS_COMP TYPE STRING,
TRANS_MERGE_MODE TYPE STRING,
INSTANCE_GUID TYPE STRING,
ITEM_GUID TYPE STRING,
MESSAGE_GUID TYPE STRING,
ORIG_USER_GUID TYPE STRING,
REQ_LANGU TYPE STRING,
TRANS_STATUS TYPE STRING,
EXPIRATION_TS TYPE STRING,
PROCESS_TS TYPE STRING,
COMPLETE_TS TYPE STRING,
CANCEL_TS TYPE STRING,
CHECK_OUT_TS TYPE STRING,
DATA_EDIT_TS TYPE STRING,
ERROR_TS TYPE STRING,
IBQ_QUEUE_ID TYPE STRING,
CHECK_OUT_USER TYPE STRING,
REASON_CODE TYPE STRING,
CHECK_IN_MESSAGE TYPE STRING,
CREATED_BY TYPE STRING,
CREATED_TS TYPE STRING,
CHANGED_BY TYPE STRING,
CHANGED_TS TYPE STRING,
QRFC_QUEUE TYPE STRING,
UPDKZ TYPE STRING,END OF T_EKKO_STR. DATA: WA_/SMFND/IBQ_D_INB_H_UPD_STR_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_/SMFND/IBQ_D_INB_H_UPD_STR_STR-MANDT sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-TRANSACTION_GUID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-RECORD_ID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-OBJECT_TYPE sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-OBJECT_KEY sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-OBJECT_GROUP sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-OBJECT_GROUP_1 sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-OBJECT_ID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-EXT_TRANS_ID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-DEP_OBJECT_TYPE sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-DEP_OBJECT_KEY sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-DEP_TRANS_ID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-DEP_TRANS_GUID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-DEP_OBJECT_ID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-FLAG_REQ_KEYMAP sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-FLAG_LOCAL_KEY sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-FLAG_LOCAL_ITEM sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-FLAG_REQ_REVIEW sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-OBJTYP_REF sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-OBJKEY_REF sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-OBJECT_ID_REF sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-REQ_PROC_MODE sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-REQ_USER_ID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-REQ_USER_GUID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-TRANSACTION_TIME sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-TIME_ZONE sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-MOBILE_APP sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-LOGSYS sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-REQ_TYPE sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-REQ_OBJECT sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-REQ_OBJECT_MTHD sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-REQ_DO_ID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-REQ_DO_MTHD_TYPE sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-TRANSACTION_TYPE sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-REF_ATTR_1 sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-REF_ATTR_2 sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-TRANSACTION_GRP sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-SYS_COMP sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-TRANS_MERGE_MODE sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-INSTANCE_GUID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-ITEM_GUID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-MESSAGE_GUID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-ORIG_USER_GUID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-REQ_LANGU sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-TRANS_STATUS sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-EXPIRATION_TS sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-PROCESS_TS sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-COMPLETE_TS sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-CANCEL_TS sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-CHECK_OUT_TS sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-DATA_EDIT_TS sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-ERROR_TS sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-IBQ_QUEUE_ID sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-CHECK_OUT_USER sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-REASON_CODE sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-CHECK_IN_MESSAGE sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-CREATED_BY sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-CREATED_TS sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-CHANGED_BY sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-CHANGED_TS sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-QRFC_QUEUE sy-vline
WA_/SMFND/IBQ_D_INB_H_UPD_STR_STR-UPDKZ sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.