ABAP Select data from SAP table E1PLPOP 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 E1PLPOP 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 E1PLPOP. 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 E1PLPOP 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_E1PLPOP TYPE STANDARD TABLE OF E1PLPOP,
      WA_E1PLPOP TYPE E1PLPOP,
      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: <E1PLPOP> TYPE E1PLPOP.

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

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

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM E1PLPOP
*  INTO TABLE @DATA(IT_E1PLPOP2).
*--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_E1PLPOP INDEX 1 INTO DATA(WA_E1PLPOP2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_E1PLPOP ASSIGNING <E1PLPOP>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
<E1PLPOP>-PLNKN = 1.
<E1PLPOP>-ZAEHL = 1.
<E1PLPOP>-VORNR = 1.
<E1PLPOP>-LTXA1 = 1.
<E1PLPOP>-ARBID = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_E1PLPOP-ARBPL, sy-vline,
WA_E1PLPOP-STEUS, sy-vline,
WA_E1PLPOP-TERM, sy-vline,
WA_E1PLPOP-LIEF, sy-vline,
WA_E1PLPOP-AUTWE, sy-vline,
WA_E1PLPOP-RUEK, sy-vline.
ENDLOOP. *Add any further fields from structure WA_E1PLPOP 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_E1PLPOP 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_E1PLPOP INTO WA_E1PLPOP. *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_E1PLPOP_STR,
PLNKN TYPE STRING,
ZAEHL TYPE STRING,
VORNR TYPE STRING,
LTXA1 TYPE STRING,
ARBID TYPE STRING,
ARBPL TYPE STRING,
STEUS TYPE STRING,
TERM TYPE STRING,
LIEF TYPE STRING,
AUTWE TYPE STRING,
RUEK TYPE STRING,
KAPA TYPE STRING,
REWORK TYPE STRING,
NOT_MES_REL TYPE STRING,
VGW01 TYPE STRING,
PAR01_LTXT TYPE STRING,
VGE01 TYPE STRING,
VGW02 TYPE STRING,
PAR02_LTXT TYPE STRING,
VGE02 TYPE STRING,
VGW03 TYPE STRING,
PAR03_LTXT TYPE STRING,
VGE03 TYPE STRING,
VGW04 TYPE STRING,
PAR04_LTXT TYPE STRING,
VGE04 TYPE STRING,
VGW05 TYPE STRING,
PAR05_LTXT TYPE STRING,
VGE05 TYPE STRING,
VGW06 TYPE STRING,
PAR06_LTXT TYPE STRING,
VGE06 TYPE STRING,
SLWID TYPE STRING,
USR00 TYPE STRING,
USR01 TYPE STRING,
USR02 TYPE STRING,
USR03 TYPE STRING,
USR04 TYPE STRING,
USE04 TYPE STRING,
USR05 TYPE STRING,
USE05 TYPE STRING,
USR08 TYPE STRING,
LTXA2 TYPE STRING,
USR09 TYPE STRING,
TXTSP TYPE STRING,
MEINH TYPE STRING,
USR10 TYPE STRING,
USR11 TYPE STRING,
UMREN TYPE STRING,
SOURCE_PLNKN TYPE STRING,
UMREZ TYPE STRING,
SOURCE_ZAEHL TYPE STRING,
BMSCH TYPE STRING,
RFGRP TYPE STRING,
RFSCH TYPE STRING,
RASCH TYPE STRING,
ZEIMB TYPE STRING,
ZMINB TYPE STRING,
ZEILM TYPE STRING,
ZLMAX TYPE STRING,
ZEILP TYPE STRING,
ZLPRO TYPE STRING,
ZWNOR TYPE STRING,
ZWMIN TYPE STRING,
ZEITN TYPE STRING,
ZTNOR TYPE STRING,
AENNR TYPE STRING,
ZEIWN TYPE STRING,
ZEIWM TYPE STRING,END OF T_EKKO_STR. DATA: WA_E1PLPOP_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_E1PLPOP_STR-PLNKN sy-vline
WA_E1PLPOP_STR-ZAEHL sy-vline
WA_E1PLPOP_STR-VORNR sy-vline
WA_E1PLPOP_STR-LTXA1 sy-vline
WA_E1PLPOP_STR-ARBID sy-vline
WA_E1PLPOP_STR-ARBPL sy-vline
WA_E1PLPOP_STR-STEUS sy-vline
WA_E1PLPOP_STR-TERM sy-vline
WA_E1PLPOP_STR-LIEF sy-vline
WA_E1PLPOP_STR-AUTWE sy-vline
WA_E1PLPOP_STR-RUEK sy-vline
WA_E1PLPOP_STR-KAPA sy-vline
WA_E1PLPOP_STR-REWORK sy-vline
WA_E1PLPOP_STR-NOT_MES_REL sy-vline
WA_E1PLPOP_STR-VGW01 sy-vline
WA_E1PLPOP_STR-PAR01_LTXT sy-vline
WA_E1PLPOP_STR-VGE01 sy-vline
WA_E1PLPOP_STR-VGW02 sy-vline
WA_E1PLPOP_STR-PAR02_LTXT sy-vline
WA_E1PLPOP_STR-VGE02 sy-vline
WA_E1PLPOP_STR-VGW03 sy-vline
WA_E1PLPOP_STR-PAR03_LTXT sy-vline
WA_E1PLPOP_STR-VGE03 sy-vline
WA_E1PLPOP_STR-VGW04 sy-vline
WA_E1PLPOP_STR-PAR04_LTXT sy-vline
WA_E1PLPOP_STR-VGE04 sy-vline
WA_E1PLPOP_STR-VGW05 sy-vline
WA_E1PLPOP_STR-PAR05_LTXT sy-vline
WA_E1PLPOP_STR-VGE05 sy-vline
WA_E1PLPOP_STR-VGW06 sy-vline
WA_E1PLPOP_STR-PAR06_LTXT sy-vline
WA_E1PLPOP_STR-VGE06 sy-vline
WA_E1PLPOP_STR-SLWID sy-vline
WA_E1PLPOP_STR-USR00 sy-vline
WA_E1PLPOP_STR-USR01 sy-vline
WA_E1PLPOP_STR-USR02 sy-vline
WA_E1PLPOP_STR-USR03 sy-vline
WA_E1PLPOP_STR-USR04 sy-vline
WA_E1PLPOP_STR-USE04 sy-vline
WA_E1PLPOP_STR-USR05 sy-vline
WA_E1PLPOP_STR-USE05 sy-vline
WA_E1PLPOP_STR-USR08 sy-vline
WA_E1PLPOP_STR-LTXA2 sy-vline
WA_E1PLPOP_STR-USR09 sy-vline
WA_E1PLPOP_STR-TXTSP sy-vline
WA_E1PLPOP_STR-MEINH sy-vline
WA_E1PLPOP_STR-USR10 sy-vline
WA_E1PLPOP_STR-USR11 sy-vline
WA_E1PLPOP_STR-UMREN sy-vline
WA_E1PLPOP_STR-SOURCE_PLNKN sy-vline
WA_E1PLPOP_STR-UMREZ sy-vline
WA_E1PLPOP_STR-SOURCE_ZAEHL sy-vline
WA_E1PLPOP_STR-BMSCH sy-vline
WA_E1PLPOP_STR-RFGRP sy-vline
WA_E1PLPOP_STR-RFSCH sy-vline
WA_E1PLPOP_STR-RASCH sy-vline
WA_E1PLPOP_STR-ZEIMB sy-vline
WA_E1PLPOP_STR-ZMINB sy-vline
WA_E1PLPOP_STR-ZEILM sy-vline
WA_E1PLPOP_STR-ZLMAX sy-vline
WA_E1PLPOP_STR-ZEILP sy-vline
WA_E1PLPOP_STR-ZLPRO sy-vline
WA_E1PLPOP_STR-ZWNOR sy-vline
WA_E1PLPOP_STR-ZWMIN sy-vline
WA_E1PLPOP_STR-ZEITN sy-vline
WA_E1PLPOP_STR-ZTNOR sy-vline
WA_E1PLPOP_STR-AENNR sy-vline
WA_E1PLPOP_STR-ZEIWN sy-vline
WA_E1PLPOP_STR-ZEIWM sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.