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

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

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

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


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_/ISDFPS/E1WOUPS_HEADER ASSIGNING </ISDFPS/E1WOUPS_HEADER>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
</ISDFPS/E1WOUPS_HEADER>-ORDERID = 1.
</ISDFPS/E1WOUPS_HEADER>-ORDER_TYPE = 1.
</ISDFPS/E1WOUPS_HEADER>-PLANPLANT = 1.
</ISDFPS/E1WOUPS_HEADER>-SCENARIO = 1.
</ISDFPS/E1WOUPS_HEADER>-BUS_AREA = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_/ISDFPS/E1WOUPS_HEADER-MN_WK_CTR, sy-vline,
WA_/ISDFPS/E1WOUPS_HEADER-PLANT, sy-vline,
WA_/ISDFPS/E1WOUPS_HEADER-PMACTTYPE, sy-vline,
WA_/ISDFPS/E1WOUPS_HEADER-PLANGROUP, sy-vline,
WA_/ISDFPS/E1WOUPS_HEADER-SYSTCOND, sy-vline,
WA_/ISDFPS/E1WOUPS_HEADER-FUNCT_LOC, sy-vline.
ENDLOOP. *Add any further fields from structure WA_/ISDFPS/E1WOUPS_HEADER 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_/ISDFPS/E1WOUPS_HEADER 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_/ISDFPS/E1WOUPS_HEADER INTO WA_/ISDFPS/E1WOUPS_HEADER. *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_/ISDFPS/E1WOUPS_HEADER_STR,
ORDERID TYPE STRING,
ORDER_TYPE TYPE STRING,
PLANPLANT TYPE STRING,
SCENARIO TYPE STRING,
BUS_AREA TYPE STRING,
MN_WK_CTR TYPE STRING,
PLANT TYPE STRING,
PMACTTYPE TYPE STRING,
PLANGROUP TYPE STRING,
SYSTCOND TYPE STRING,
FUNCT_LOC TYPE STRING,
EQUIPMENT TYPE STRING,
SERIALNO TYPE STRING,
MATERIAL TYPE STRING,
ASSEMBLY TYPE STRING,
DEVICEDATA TYPE STRING,
MAINTPLANT TYPE STRING,
LOCATION TYPE STRING,
MAINTROOM TYPE STRING,
PLSECTN TYPE STRING,
LOC_WK_CTR TYPE STRING,
ABCINDIC TYPE STRING,
SORTFIELD TYPE STRING,
PROFIT_CTR TYPE STRING,
RESPCCTR TYPE STRING,
FUNC_AREA TYPE STRING,
SUPERIOR_NETWORK TYPE STRING,
SUPERIOR_ACTIVITY TYPE STRING,
WBS_ELEM TYPE STRING,
PROCESSING_GROUP TYPE STRING,
TAXJURCODE TYPE STRING,
LOC_COMP_CODE TYPE STRING,
ASSET_NO TYPE STRING,
SUB_NUMBER TYPE STRING,
LOC_BUS_AREA TYPE STRING,
COSTCENTER TYPE STRING,
LOC_WBS_ELEM TYPE STRING,
STANDORDER TYPE STRING,
SETTLORDER TYPE STRING,
SALESORG TYPE STRING,
DISTR_CHAN TYPE STRING,
DIVISION TYPE STRING,
ORDPLANID TYPE STRING,
START_DATE TYPE STRING,
FINISH_DATE TYPE STRING,
BASICSTART TYPE STRING,
BASIC_FIN TYPE STRING,
PRIORITY TYPE STRING,
REVISION TYPE STRING,
VERSION TYPE STRING,
SCHED_TYPE TYPE STRING,
AUTOSCHED TYPE STRING,
CAP_REQMTS TYPE STRING,
SCHEDULING_EXACT_BREAK_TIMES TYPE STRING,
MRP_RELEVANT TYPE STRING,
SALES_ORD TYPE STRING,
S_ORD_ITEM TYPE STRING,
CALC_MOTIVE TYPE STRING,
INVEST_PROFILE TYPE STRING,
SCALE TYPE STRING,
INV_REASON TYPE STRING,
ENVIR_INVEST TYPE STRING,
ESTIMATED_COSTS TYPE STRING,
CURRENCY TYPE STRING,
CURRENCY_ISO TYPE STRING,
CSTG_SHEET TYPE STRING,
OVERHEAD_KEY TYPE STRING,
RES_ANAL_KEY TYPE STRING,
SHORT_TEXT TYPE STRING,
ASSEMBLY_EXTERNAL TYPE STRING,
ASSEMBLY_GUID TYPE STRING,
ASSEMBLY_VERSION TYPE STRING,
MATERIAL_EXTERNAL TYPE STRING,
MATERIAL_GUID TYPE STRING,
MATERIAL_VERSION TYPE STRING,
NOTIF_NO TYPE STRING,
TECO_REF_DATE TYPE STRING,
TECO_REF_TIME TYPE STRING,
CALID TYPE STRING,
/ISDFPS/OBJECT_NO TYPE STRING,
/ISDFPS/MEQUI TYPE STRING,
/ISDFPS/WBS_EXT TYPE STRING,
/ISDFPS/LOC_WBS_EXT TYPE STRING,
/ISDFPS/LOGSYS TYPE STRING,
AKKNZ TYPE STRING,
PLNTY TYPE STRING,
PLNNR TYPE STRING,
PLNAL TYPE STRING,
MAUFNR TYPE STRING,
LEAD_AUFNR TYPE STRING,
KALSN TYPE STRING,
WARPL TYPE STRING,
ABNUM TYPE STRING,
WAPOS TYPE STRING,
/ISDFPS/MHIO_ADDATE TYPE STRING,
/ISDFPS/MHIO_ADTIME TYPE STRING,
/ISDFPS/USERMODE TYPE STRING,
/ISDFPS/FTRMI TYPE STRING,END OF T_EKKO_STR. DATA: WA_/ISDFPS/E1WOUPS_HEADER_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_/ISDFPS/E1WOUPS_HEADER_STR-ORDERID sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-ORDER_TYPE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-PLANPLANT sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SCENARIO sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-BUS_AREA sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-MN_WK_CTR sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-PLANT sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-PMACTTYPE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-PLANGROUP sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SYSTCOND sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-FUNCT_LOC sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-EQUIPMENT sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SERIALNO sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-MATERIAL sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-ASSEMBLY sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-DEVICEDATA sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-MAINTPLANT sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-LOCATION sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-MAINTROOM sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-PLSECTN sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-LOC_WK_CTR sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-ABCINDIC sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SORTFIELD sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-PROFIT_CTR sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-RESPCCTR sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-FUNC_AREA sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SUPERIOR_NETWORK sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SUPERIOR_ACTIVITY sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-WBS_ELEM sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-PROCESSING_GROUP sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-TAXJURCODE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-LOC_COMP_CODE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-ASSET_NO sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SUB_NUMBER sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-LOC_BUS_AREA sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-COSTCENTER sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-LOC_WBS_ELEM sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-STANDORDER sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SETTLORDER sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SALESORG sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-DISTR_CHAN sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-DIVISION sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-ORDPLANID sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-START_DATE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-FINISH_DATE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-BASICSTART sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-BASIC_FIN sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-PRIORITY sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-REVISION sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-VERSION sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SCHED_TYPE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-AUTOSCHED sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-CAP_REQMTS sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SCHEDULING_EXACT_BREAK_TIMES sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-MRP_RELEVANT sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SALES_ORD sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-S_ORD_ITEM sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-CALC_MOTIVE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-INVEST_PROFILE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SCALE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-INV_REASON sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-ENVIR_INVEST sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-ESTIMATED_COSTS sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-CURRENCY sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-CURRENCY_ISO sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-CSTG_SHEET sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-OVERHEAD_KEY sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-RES_ANAL_KEY sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-SHORT_TEXT sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-ASSEMBLY_EXTERNAL sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-ASSEMBLY_GUID sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-ASSEMBLY_VERSION sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-MATERIAL_EXTERNAL sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-MATERIAL_GUID sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-MATERIAL_VERSION sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-NOTIF_NO sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-TECO_REF_DATE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-TECO_REF_TIME sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-CALID sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-/ISDFPS/OBJECT_NO sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-/ISDFPS/MEQUI sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-/ISDFPS/WBS_EXT sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-/ISDFPS/LOC_WBS_EXT sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-/ISDFPS/LOGSYS sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-AKKNZ sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-PLNTY sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-PLNNR sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-PLNAL sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-MAUFNR sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-LEAD_AUFNR sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-KALSN sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-WARPL sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-ABNUM sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-WAPOS sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-/ISDFPS/MHIO_ADDATE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-/ISDFPS/MHIO_ADTIME sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-/ISDFPS/USERMODE sy-vline
WA_/ISDFPS/E1WOUPS_HEADER_STR-/ISDFPS/FTRMI sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.