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

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

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

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


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_/ISDFPS/NOUPS_HEADER_X ASSIGNING </ISDFPS/NOUPS_HEADER_X>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
</ISDFPS/NOUPS_HEADER_X>-NOTIF_NO = 1.
</ISDFPS/NOUPS_HEADER_X>-PLANPLANT = 1.
</ISDFPS/NOUPS_HEADER_X>-LOC_ACC = 1.
</ISDFPS/NOUPS_HEADER_X>-EQUIPMENT = 1.
</ISDFPS/NOUPS_HEADER_X>-EQUIPMENT_DESC = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_/ISDFPS/NOUPS_HEADER_X-EQUIPMENT_CREATE, sy-vline,
WA_/ISDFPS/NOUPS_HEADER_X-ASSEMBLY, sy-vline,
WA_/ISDFPS/NOUPS_HEADER_X-ASSEMBLY_DESC, sy-vline,
WA_/ISDFPS/NOUPS_HEADER_X-BREAKDOWN, sy-vline,
WA_/ISDFPS/NOUPS_HEADER_X-STRMLFNDATE, sy-vline,
WA_/ISDFPS/NOUPS_HEADER_X-ENDMLFNDATE, sy-vline.
ENDLOOP. *Add any further fields from structure WA_/ISDFPS/NOUPS_HEADER_X 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/NOUPS_HEADER_X 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/NOUPS_HEADER_X INTO WA_/ISDFPS/NOUPS_HEADER_X. *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 NOTIF_NO CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_/ISDFPS/NOUPS_HEADER_X-NOTIF_NO IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_/ISDFPS/NOUPS_HEADER_X-NOTIF_NO.
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_/ISDFPS/NOUPS_HEADER_X_STR,
NOTIF_NO TYPE STRING,
PLANPLANT TYPE STRING,
LOC_ACC TYPE STRING,
EQUIPMENT TYPE STRING,
EQUIPMENT_DESC TYPE STRING,
EQUIPMENT_CREATE TYPE STRING,
ASSEMBLY TYPE STRING,
ASSEMBLY_DESC TYPE STRING,
BREAKDOWN TYPE STRING,
STRMLFNDATE TYPE STRING,
ENDMLFNDATE TYPE STRING,
STRMLFNTIME TYPE STRING,
ENDMLFNTIME TYPE STRING,
DOWNTIME TYPE STRING,
UNIT TYPE STRING,
ISOCODE_UNIT TYPE STRING,
PLANGROUP TYPE STRING,
MNTPLAN TYPE STRING,
MNTCALL_NO TYPE STRING,
MAINTITEM TYPE STRING,
NOTIF_TYPE TYPE STRING,
SHORT_TEXT TYPE STRING,
PRIOTYPE TYPE STRING,
PRIORITY TYPE STRING,
NOTIFTIME TYPE STRING,
NOTIF_DATE TYPE STRING,
REPORTEDBY TYPE STRING,
DESSTDATE TYPE STRING,
DESSTTIME TYPE STRING,
DESENDDATE TYPE STRING,
DESENDTM TYPE STRING,
ORDERID TYPE STRING,
MATERIAL TYPE STRING,
MATL_DESC TYPE STRING,
CUST_NO TYPE STRING,
OBJECT_NO TYPE STRING,
COMPDATE TYPE STRING,
COMPTIME TYPE STRING,
CATPROFILE TYPE STRING,
LONG_TEXT TYPE STRING,
PRILANG TYPE STRING,
REFDATE TYPE STRING,
REFTIME TYPE STRING,
SALES_ORD TYPE STRING,
PURCH_NO_C TYPE STRING,
PURCH_DATE TYPE STRING,
DIVISION TYPE STRING,
SALES_ORG TYPE STRING,
DISTR_CHAN TYPE STRING,
ADDR_NUMBER TYPE STRING,
CAT_TYPE TYPE STRING,
CODE_GROUP TYPE STRING,
CODING TYPE STRING,
PM_WKCTR TYPE STRING,
SERIALNO TYPE STRING,
DELETE_FLAG TYPE STRING,
DEVICEDATA TYPE STRING,
SALES_OFFICE TYPE STRING,
SALES_GRP TYPE STRING,
NOTIFTMEZ TYPE STRING,
FUNCT_LOC TYPE STRING,
FUNCLOC_DISP TYPE STRING,
FUNCLOC_DESC TYPE STRING,
FUNCLOC_CREATE TYPE STRING,
ABCINDIC TYPE STRING,
SORTFIELD TYPE STRING,
MAINTPLANT TYPE STRING,
MAINTLOC TYPE STRING,
MAINTROOM TYPE STRING,
PLSECTN TYPE STRING,
PP_WKCTR TYPE STRING,
BUS_AREA TYPE STRING,
CO_AREA TYPE STRING,
COSTCENTER TYPE STRING,
WBS_ELEMENT TYPE STRING,
ASSET_NO TYPE STRING,
SUB_NUMBER TYPE STRING,
STDGORD TYPE STRING,
STLMTORDER TYPE STRING,
COMP_CODE TYPE STRING,
SALES_ORG_LOC_ACC TYPE STRING,
DIVISION_LOC_ACC TYPE STRING,
DIST_CHAN_LOC_ACC TYPE STRING,
ADDR_NO_LOC_ACC TYPE STRING,
DOC_NUMBER TYPE STRING,
ITM_NUMBER TYPE STRING,
SCENARIO TYPE STRING,
REFOBJECTTYPE TYPE STRING,
REFOBJECTKEY TYPE STRING,
REFRELTYPE TYPE STRING,
XA_STAT_PROF TYPE STRING,
MN_WK_CTR TYPE STRING,
PLANT TYPE STRING,
/ISDFPS/OBJECT_NO TYPE STRING,
LOGSYSTEM TYPE STRING,
/ISDFPS/MEQUI TYPE STRING,END OF T_EKKO_STR. DATA: WA_/ISDFPS/NOUPS_HEADER_X_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/NOUPS_HEADER_X_STR-NOTIF_NO sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-PLANPLANT sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-LOC_ACC sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-EQUIPMENT sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-EQUIPMENT_DESC sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-EQUIPMENT_CREATE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-ASSEMBLY sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-ASSEMBLY_DESC sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-BREAKDOWN sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-STRMLFNDATE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-ENDMLFNDATE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-STRMLFNTIME sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-ENDMLFNTIME sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-DOWNTIME sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-UNIT sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-ISOCODE_UNIT sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-PLANGROUP sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-MNTPLAN sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-MNTCALL_NO sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-MAINTITEM sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-NOTIF_TYPE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-SHORT_TEXT sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-PRIOTYPE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-PRIORITY sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-NOTIFTIME sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-NOTIF_DATE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-REPORTEDBY sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-DESSTDATE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-DESSTTIME sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-DESENDDATE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-DESENDTM sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-ORDERID sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-MATERIAL sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-MATL_DESC sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-CUST_NO sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-OBJECT_NO sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-COMPDATE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-COMPTIME sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-CATPROFILE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-LONG_TEXT sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-PRILANG sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-REFDATE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-REFTIME sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-SALES_ORD sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-PURCH_NO_C sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-PURCH_DATE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-DIVISION sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-SALES_ORG sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-DISTR_CHAN sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-ADDR_NUMBER sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-CAT_TYPE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-CODE_GROUP sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-CODING sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-PM_WKCTR sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-SERIALNO sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-DELETE_FLAG sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-DEVICEDATA sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-SALES_OFFICE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-SALES_GRP sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-NOTIFTMEZ sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-FUNCT_LOC sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-FUNCLOC_DISP sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-FUNCLOC_DESC sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-FUNCLOC_CREATE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-ABCINDIC sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-SORTFIELD sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-MAINTPLANT sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-MAINTLOC sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-MAINTROOM sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-PLSECTN sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-PP_WKCTR sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-BUS_AREA sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-CO_AREA sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-COSTCENTER sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-WBS_ELEMENT sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-ASSET_NO sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-SUB_NUMBER sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-STDGORD sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-STLMTORDER sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-COMP_CODE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-SALES_ORG_LOC_ACC sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-DIVISION_LOC_ACC sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-DIST_CHAN_LOC_ACC sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-ADDR_NO_LOC_ACC sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-DOC_NUMBER sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-ITM_NUMBER sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-SCENARIO sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-REFOBJECTTYPE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-REFOBJECTKEY sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-REFRELTYPE sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-XA_STAT_PROF sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-MN_WK_CTR sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-PLANT sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-/ISDFPS/OBJECT_NO sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-LOGSYSTEM sy-vline
WA_/ISDFPS/NOUPS_HEADER_X_STR-/ISDFPS/MEQUI sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.