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

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

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

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


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_/PF1/VDB_RECALL ASSIGNING </PF1/VDB_RECALL>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
</PF1/VDB_RECALL>-CLIENT = 1.
</PF1/VDB_RECALL>-GUID = 1.
</PF1/VDB_RECALL>-CLEARING_AREA = 1.
</PF1/VDB_RECALL>-RECALL_DATE = 1.
</PF1/VDB_RECALL>-RECALL_NO = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_/PF1/VDB_RECALL-RECALL_TYPE, sy-vline,
WA_/PF1/VDB_RECALL-RECALL_STATE, sy-vline,
WA_/PF1/VDB_RECALL-PREV_STATE, sy-vline,
WA_/PF1/VDB_RECALL-VALID_FROM, sy-vline,
WA_/PF1/VDB_RECALL-VALID_TO, sy-vline,
WA_/PF1/VDB_RECALL-PROCESS_AUTO, sy-vline.
ENDLOOP. *Add any further fields from structure WA_/PF1/VDB_RECALL 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_/PF1/VDB_RECALL 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_/PF1/VDB_RECALL INTO WA_/PF1/VDB_RECALL. *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.
ENDFORM. *&---------------------------------------------------------------------* *& Form process_as_string_field_values *&---------------------------------------------------------------------* FORM process_as_string_field_values CHANGING p_EKKO LIKE wa_EKKO. TYPES: BEGIN OF T_/PF1/VDB_RECALL_STR,
CLIENT TYPE STRING,
GUID TYPE STRING,
CLEARING_AREA TYPE STRING,
RECALL_DATE TYPE STRING,
RECALL_NO TYPE STRING,
RECALL_TYPE TYPE STRING,
RECALL_STATE TYPE STRING,
PREV_STATE TYPE STRING,
VALID_FROM TYPE STRING,
VALID_TO TYPE STRING,
PROCESS_AUTO TYPE STRING,
REASON TYPE STRING,
FLG_ORDER_RCL TYPE STRING,
FLG_LISTENER_REG TYPE STRING,
REF_PRED_RECALL_DATE TYPE STRING,
REF_PRED_RECALL_NO TYPE STRING,
IN_OUT_FORMAT TYPE STRING,
MEDIUM TYPE STRING,
CHANNEL TYPE STRING,
REF_CUST_GRP TYPE STRING,
REF_CUSTOMER TYPE STRING,
REF_CUST_SGM TYPE STRING,
RELEASE_ACTIVITY TYPE STRING,
RELEASE_STATUS TYPE STRING,
TR_AMOUNT TYPE STRING,
TR_CURR TYPE STRING,
BANKKEY TYPE STRING,
COUNTRY TYPE STRING,
ACCT_NO TYPE STRING,
ACCT_CUR TYPE STRING,
PO_DATE TYPE STRING,
PO_NO TYPE STRING,
REF_ITEM_EXT TYPE STRING,
REF_EXT_PO TYPE STRING,
HOLDER TYPE STRING,
CHEQUE_NO TYPE STRING,
AMOUNT_TO TYPE STRING,
PI_DATE TYPE STRING,
PI_NO TYPE STRING,
FLG_OI_RECALLED TYPE STRING,
IBAN TYPE STRING,
BIC TYPE STRING,
REF_IBAN TYPE STRING,
REF_BIC TYPE STRING,
REF_HOLDER TYPE STRING,
END_TO_END_ID TYPE STRING,
REF_ORDER_EXT TYPE STRING,
DUE_DATE TYPE STRING,
RECALLED_DATE TYPE STRING,
RECALLED_TIME TYPE STRING,
RECALLED_USER TYPE STRING,
MSG_NO TYPE STRING,
ADD_REASON_INFO TYPE STRING,
FLG_ACTIV_ERROR TYPE STRING,
ACTIV_COUNT TYPE STRING,
OL_DATE TYPE STRING,
OL_NO TYPE STRING,
CRUSR TYPE STRING,
CRDAT TYPE STRING,
CRTIM TYPE STRING,
CHUSR TYPE STRING,
CHDAT TYPE STRING,
CHTIM TYPE STRING,
RLUSR TYPE STRING,
RLDAT TYPE STRING,
RLTIM TYPE STRING,
ARCHIVE_STATUS TYPE STRING,
ARCHIVE_FLUD TYPE STRING,
REJECTION TYPE STRING,
KZ TYPE STRING,END OF T_EKKO_STR. DATA: WA_/PF1/VDB_RECALL_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_/PF1/VDB_RECALL_STR-CLIENT sy-vline
WA_/PF1/VDB_RECALL_STR-GUID sy-vline
WA_/PF1/VDB_RECALL_STR-CLEARING_AREA sy-vline
WA_/PF1/VDB_RECALL_STR-RECALL_DATE sy-vline
WA_/PF1/VDB_RECALL_STR-RECALL_NO sy-vline
WA_/PF1/VDB_RECALL_STR-RECALL_TYPE sy-vline
WA_/PF1/VDB_RECALL_STR-RECALL_STATE sy-vline
WA_/PF1/VDB_RECALL_STR-PREV_STATE sy-vline
WA_/PF1/VDB_RECALL_STR-VALID_FROM sy-vline
WA_/PF1/VDB_RECALL_STR-VALID_TO sy-vline
WA_/PF1/VDB_RECALL_STR-PROCESS_AUTO sy-vline
WA_/PF1/VDB_RECALL_STR-REASON sy-vline
WA_/PF1/VDB_RECALL_STR-FLG_ORDER_RCL sy-vline
WA_/PF1/VDB_RECALL_STR-FLG_LISTENER_REG sy-vline
WA_/PF1/VDB_RECALL_STR-REF_PRED_RECALL_DATE sy-vline
WA_/PF1/VDB_RECALL_STR-REF_PRED_RECALL_NO sy-vline
WA_/PF1/VDB_RECALL_STR-IN_OUT_FORMAT sy-vline
WA_/PF1/VDB_RECALL_STR-MEDIUM sy-vline
WA_/PF1/VDB_RECALL_STR-CHANNEL sy-vline
WA_/PF1/VDB_RECALL_STR-REF_CUST_GRP sy-vline
WA_/PF1/VDB_RECALL_STR-REF_CUSTOMER sy-vline
WA_/PF1/VDB_RECALL_STR-REF_CUST_SGM sy-vline
WA_/PF1/VDB_RECALL_STR-RELEASE_ACTIVITY sy-vline
WA_/PF1/VDB_RECALL_STR-RELEASE_STATUS sy-vline
WA_/PF1/VDB_RECALL_STR-TR_AMOUNT sy-vline
WA_/PF1/VDB_RECALL_STR-TR_CURR sy-vline
WA_/PF1/VDB_RECALL_STR-BANKKEY sy-vline
WA_/PF1/VDB_RECALL_STR-COUNTRY sy-vline
WA_/PF1/VDB_RECALL_STR-ACCT_NO sy-vline
WA_/PF1/VDB_RECALL_STR-ACCT_CUR sy-vline
WA_/PF1/VDB_RECALL_STR-PO_DATE sy-vline
WA_/PF1/VDB_RECALL_STR-PO_NO sy-vline
WA_/PF1/VDB_RECALL_STR-REF_ITEM_EXT sy-vline
WA_/PF1/VDB_RECALL_STR-REF_EXT_PO sy-vline
WA_/PF1/VDB_RECALL_STR-HOLDER sy-vline
WA_/PF1/VDB_RECALL_STR-CHEQUE_NO sy-vline
WA_/PF1/VDB_RECALL_STR-AMOUNT_TO sy-vline
WA_/PF1/VDB_RECALL_STR-PI_DATE sy-vline
WA_/PF1/VDB_RECALL_STR-PI_NO sy-vline
WA_/PF1/VDB_RECALL_STR-FLG_OI_RECALLED sy-vline
WA_/PF1/VDB_RECALL_STR-IBAN sy-vline
WA_/PF1/VDB_RECALL_STR-BIC sy-vline
WA_/PF1/VDB_RECALL_STR-REF_IBAN sy-vline
WA_/PF1/VDB_RECALL_STR-REF_BIC sy-vline
WA_/PF1/VDB_RECALL_STR-REF_HOLDER sy-vline
WA_/PF1/VDB_RECALL_STR-END_TO_END_ID sy-vline
WA_/PF1/VDB_RECALL_STR-REF_ORDER_EXT sy-vline
WA_/PF1/VDB_RECALL_STR-DUE_DATE sy-vline
WA_/PF1/VDB_RECALL_STR-RECALLED_DATE sy-vline
WA_/PF1/VDB_RECALL_STR-RECALLED_TIME sy-vline
WA_/PF1/VDB_RECALL_STR-RECALLED_USER sy-vline
WA_/PF1/VDB_RECALL_STR-MSG_NO sy-vline
WA_/PF1/VDB_RECALL_STR-ADD_REASON_INFO sy-vline
WA_/PF1/VDB_RECALL_STR-FLG_ACTIV_ERROR sy-vline
WA_/PF1/VDB_RECALL_STR-ACTIV_COUNT sy-vline
WA_/PF1/VDB_RECALL_STR-OL_DATE sy-vline
WA_/PF1/VDB_RECALL_STR-OL_NO sy-vline
WA_/PF1/VDB_RECALL_STR-CRUSR sy-vline
WA_/PF1/VDB_RECALL_STR-CRDAT sy-vline
WA_/PF1/VDB_RECALL_STR-CRTIM sy-vline
WA_/PF1/VDB_RECALL_STR-CHUSR sy-vline
WA_/PF1/VDB_RECALL_STR-CHDAT sy-vline
WA_/PF1/VDB_RECALL_STR-CHTIM sy-vline
WA_/PF1/VDB_RECALL_STR-RLUSR sy-vline
WA_/PF1/VDB_RECALL_STR-RLDAT sy-vline
WA_/PF1/VDB_RECALL_STR-RLTIM sy-vline
WA_/PF1/VDB_RECALL_STR-ARCHIVE_STATUS sy-vline
WA_/PF1/VDB_RECALL_STR-ARCHIVE_FLUD sy-vline
WA_/PF1/VDB_RECALL_STR-REJECTION sy-vline
WA_/PF1/VDB_RECALL_STR-KZ sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.