ABAP Select data from SAP table ISU_BI_BILL_S_SEPA_PRENO 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 ISU_BI_BILL_S_SEPA_PRENO 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 ISU_BI_BILL_S_SEPA_PRENO. 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 ISU_BI_BILL_S_SEPA_PRENO 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_ISU_BI_BILL_S_SEPA_PRENO TYPE STANDARD TABLE OF ISU_BI_BILL_S_SEPA_PRENO,
      WA_ISU_BI_BILL_S_SEPA_PRENO TYPE ISU_BI_BILL_S_SEPA_PRENO,
      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: <ISU_BI_BILL_S_SEPA_PRENO> TYPE ISU_BI_BILL_S_SEPA_PRENO.

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

SELECT *
*restrict ABAP select to first 10 rows
 UP TO 10 ROWS      
  FROM ISU_BI_BILL_S_SEPA_PRENO
  INTO TABLE IT_ISU_BI_BILL_S_SEPA_PRENO.

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM ISU_BI_BILL_S_SEPA_PRENO
*  INTO TABLE @DATA(IT_ISU_BI_BILL_S_SEPA_PRENO2).
*--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_ISU_BI_BILL_S_SEPA_PRENO INDEX 1 INTO DATA(WA_ISU_BI_BILL_S_SEPA_PRENO2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_ISU_BI_BILL_S_SEPA_PRENO ASSIGNING <ISU_BI_BILL_S_SEPA_PRENO>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
<ISU_BI_BILL_S_SEPA_PRENO>-WA_SEPA_PRENO = 1.
<ISU_BI_BILL_S_SEPA_PRENO>-MANDT = 1.
<ISU_BI_BILL_S_SEPA_PRENO>-PNNUM = 1.
<ISU_BI_BILL_S_SEPA_PRENO>-PNHKF = 1.
<ISU_BI_BILL_S_SEPA_PRENO>-GPART = 1.
ENDLOOP.

LOOP AT IT_ISU_BI_BILL_S_SEPA_PRENO INTO WA_ISU_BI_BILL_S_SEPA_PRENO.
*Write horizonal line to screen report.
  WRITE:/ sy-uline.

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_ISU_BI_BILL_S_SEPA_PRENO-ORI_GPART, sy-vline,
WA_ISU_BI_BILL_S_SEPA_PRENO-PNEXD, sy-vline,
WA_ISU_BI_BILL_S_SEPA_PRENO-PNSTA, sy-vline,
WA_ISU_BI_BILL_S_SEPA_PRENO-MNDID, sy-vline,
WA_ISU_BI_BILL_S_SEPA_PRENO-BETRW, sy-vline,
WA_ISU_BI_BILL_S_SEPA_PRENO-BETRW_ACT, sy-vline.
ENDLOOP. *Add any further fields from structure WA_ISU_BI_BILL_S_SEPA_PRENO 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_ISU_BI_BILL_S_SEPA_PRENO 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_ISU_BI_BILL_S_SEPA_PRENO INTO WA_ISU_BI_BILL_S_SEPA_PRENO. *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 PNNUM CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ISU_BI_BILL_S_SEPA_PRENO-PNNUM IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISU_BI_BILL_S_SEPA_PRENO-PNNUM.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field GPART CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ISU_BI_BILL_S_SEPA_PRENO-GPART IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISU_BI_BILL_S_SEPA_PRENO-GPART.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field ORI_GPART CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ISU_BI_BILL_S_SEPA_PRENO-ORI_GPART IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISU_BI_BILL_S_SEPA_PRENO-ORI_GPART.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field PNXREF CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ISU_BI_BILL_S_SEPA_PRENO-PNXREF IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISU_BI_BILL_S_SEPA_PRENO-PNXREF.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ISOLA, internal->external for field SND_LANGUAGE CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_ISU_BI_BILL_S_SEPA_PRENO-SND_LANGUAGE IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISU_BI_BILL_S_SEPA_PRENO-SND_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_ISU_BI_BILL_S_SEPA_PRENO_STR,
WA_SEPA_PRENO TYPE STRING,
MANDT TYPE STRING,
PNNUM TYPE STRING,
PNHKF TYPE STRING,
GPART TYPE STRING,
ORI_GPART TYPE STRING,
PNEXD TYPE STRING,
PNSTA TYPE STRING,
MNDID TYPE STRING,
BETRW TYPE STRING,
BETRW_ACT TYPE STRING,
WAERS TYPE STRING,
LAUFD_CRE TYPE STRING,
LAUFI_CRE TYPE STRING,
PAYNO TYPE STRING,
DOC1R TYPE STRING,
DOC1T TYPE STRING,
CPUDT TYPE STRING,
CPUTM TYPE STRING,
COTYP TYPE STRING,
COKEY TYPE STRING,
PNXREF TYPE STRING,
PYBUK TYPE STRING,
ERNAM TYPE STRING,
AENAM TYPE STRING,
AEDAT TYPE STRING,
AETIM TYPE STRING,
ZIBAN TYPE STRING,
EMBVT TYPE STRING,
XCREA TYPE STRING,
WA_MANDATE TYPE STRING,
MGUID TYPE STRING,
MNDID TYPE STRING,
MVERS TYPE STRING,
SIGN_CITY TYPE STRING,
SIGN_DATE TYPE STRING,
PAY_TYPE TYPE STRING,
VAL_FROM_DATE TYPE STRING,
VAL_TO_DATE TYPE STRING,
STATUS TYPE STRING,
B2B TYPE STRING,
REASON_CODE TYPE STRING,
ERNAM TYPE STRING,
ERDAT TYPE STRING,
ERTIM TYPE STRING,
CHG_REASON TYPE STRING,
ORIGIN TYPE STRING,
ORIGIN_REC_CRDID TYPE STRING,
ORIGIN_MNDID TYPE STRING,
GLOCK TYPE STRING,
GLOCK_VAL_FROM TYPE STRING,
GLOCK_VAL_TO TYPE STRING,
ANWND TYPE STRING,
ORI_ERNAM TYPE STRING,
ORI_ERDAT TYPE STRING,
ORI_ERTIM TYPE STRING,
REF_TYPE TYPE STRING,
REF_ID TYPE STRING,
REF_DESC TYPE STRING,
SND_TYPE TYPE STRING,
SND_ID TYPE STRING,
SND_NAME1 TYPE STRING,
SND_NAME2 TYPE STRING,
SND_STREET TYPE STRING,
SND_HOUSENUM TYPE STRING,
SND_POSTAL TYPE STRING,
SND_CITY TYPE STRING,
SND_COUNTRY TYPE STRING,
SND_IBAN TYPE STRING,
SND_BIC TYPE STRING,
SND_DIR_NAME TYPE STRING,
SND_LANGUAGE TYPE STRING,
SND_DIR_ID TYPE STRING,
SND_DEBTOR_ID TYPE STRING,
REC_TYPE TYPE STRING,
REC_ID TYPE STRING,
REC_NAME1 TYPE STRING,
REC_NAME2 TYPE STRING,
REC_CRDID TYPE STRING,
REC_STREET TYPE STRING,
REC_HOUSENUM TYPE STRING,
REC_POSTAL TYPE STRING,
REC_CITY TYPE STRING,
REC_COUNTRY TYPE STRING,
REC_DIR_NAME TYPE STRING,
REC_DIR_ID TYPE STRING,
FIRSTUSE_DATE TYPE STRING,
FIRSTUSE_DOCTYPE TYPE STRING,
FIRSTUSE_DOCID TYPE STRING,
LASTUSE_DATE TYPE STRING,
LASTUSE_DOCTYPE TYPE STRING,
LASTUSE_DOCID TYPE STRING,
FIRSTUSE_PAYRUN TYPE STRING,
VERSION_CHG TYPE STRING,
ORGF1 TYPE STRING,
ORGF2 TYPE STRING,
ORGF3 TYPE STRING,
ORGF4 TYPE STRING,
REC_ID_CRDID TYPE STRING,
/SAPF15/F15_BW TYPE STRING,
/SAPF15/F15_KZ TYPE STRING,
/SAPF15/GUID TYPE STRING,
CONTRACT_ID TYPE STRING,
CONTRACT_DESC TYPE STRING,
BANK_CRDTR TYPE STRING,
LAUFD TYPE STRING,
LAUFI TYPE STRING,
LIMIT_AMOUNT TYPE STRING,
LIMIT_CURR TYPE STRING,
LIMIT_NUMBER TYPE STRING,
LIMIT_UNIT TYPE STRING,
LIMIT_START_DATE TYPE STRING,END OF T_EKKO_STR. DATA: WA_ISU_BI_BILL_S_SEPA_PRENO_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_ISU_BI_BILL_S_SEPA_PRENO_STR-WA_SEPA_PRENO sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-MANDT sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-PNNUM sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-PNHKF sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-GPART sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ORI_GPART sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-PNEXD sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-PNSTA sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-MNDID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-BETRW sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-BETRW_ACT sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-WAERS sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-LAUFD_CRE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-LAUFI_CRE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-PAYNO sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-DOC1R sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-DOC1T sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-CPUDT sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-CPUTM sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-COTYP sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-COKEY sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-PNXREF sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-PYBUK sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ERNAM sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-AENAM sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-AEDAT sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-AETIM sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ZIBAN sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-EMBVT sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-XCREA sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-WA_MANDATE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-MGUID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-MNDID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-MVERS sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SIGN_CITY sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SIGN_DATE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-PAY_TYPE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-VAL_FROM_DATE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-VAL_TO_DATE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-STATUS sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-B2B sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REASON_CODE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ERNAM sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ERDAT sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ERTIM sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-CHG_REASON sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ORIGIN sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ORIGIN_REC_CRDID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ORIGIN_MNDID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-GLOCK sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-GLOCK_VAL_FROM sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-GLOCK_VAL_TO sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ANWND sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ORI_ERNAM sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ORI_ERDAT sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ORI_ERTIM sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REF_TYPE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REF_ID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REF_DESC sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_TYPE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_ID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_NAME1 sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_NAME2 sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_STREET sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_HOUSENUM sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_POSTAL sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_CITY sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_COUNTRY sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_IBAN sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_BIC sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_DIR_NAME sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_LANGUAGE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_DIR_ID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-SND_DEBTOR_ID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_TYPE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_ID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_NAME1 sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_NAME2 sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_CRDID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_STREET sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_HOUSENUM sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_POSTAL sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_CITY sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_COUNTRY sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_DIR_NAME sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_DIR_ID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-FIRSTUSE_DATE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-FIRSTUSE_DOCTYPE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-FIRSTUSE_DOCID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-LASTUSE_DATE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-LASTUSE_DOCTYPE sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-LASTUSE_DOCID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-FIRSTUSE_PAYRUN sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-VERSION_CHG sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ORGF1 sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ORGF2 sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ORGF3 sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-ORGF4 sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-REC_ID_CRDID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-/SAPF15/F15_BW sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-/SAPF15/F15_KZ sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-/SAPF15/GUID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-CONTRACT_ID sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-CONTRACT_DESC sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-BANK_CRDTR sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-LAUFD sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-LAUFI sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-LIMIT_AMOUNT sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-LIMIT_CURR sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-LIMIT_NUMBER sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-LIMIT_UNIT sy-vline
WA_ISU_BI_BILL_S_SEPA_PRENO_STR-LIMIT_START_DATE sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.