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

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

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

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


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_/ISDFPS/E1PRUPS_CRFH ASSIGNING </ISDFPS/E1PRUPS_CRFH>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
</ISDFPS/E1PRUPS_CRFH>-MANDT = 1.
</ISDFPS/E1PRUPS_CRFH>-OBJTY = 1.
</ISDFPS/E1PRUPS_CRFH>-OBJID = 1.
</ISDFPS/E1PRUPS_CRFH>-ZAEHL = 1.
</ISDFPS/E1PRUPS_CRFH>-FHMAR = 1.
ENDLOOP.

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

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_/ISDFPS/E1PRUPS_CRFH-OBJTY_V, sy-vline,
WA_/ISDFPS/E1PRUPS_CRFH-OBJID_V, sy-vline,
WA_/ISDFPS/E1PRUPS_CRFH-LOEKZ, sy-vline,
WA_/ISDFPS/E1PRUPS_CRFH-DATUV, sy-vline,
WA_/ISDFPS/E1PRUPS_CRFH-DATUB, sy-vline,
WA_/ISDFPS/E1PRUPS_CRFH-AENNR, sy-vline.
ENDLOOP. *Add any further fields from structure WA_/ISDFPS/E1PRUPS_CRFH 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/E1PRUPS_CRFH 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/E1PRUPS_CRFH INTO WA_/ISDFPS/E1PRUPS_CRFH. *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/E1PRUPS_CRFH_STR,
MANDT TYPE STRING,
OBJTY TYPE STRING,
OBJID TYPE STRING,
ZAEHL TYPE STRING,
FHMAR TYPE STRING,
OBJTY_V TYPE STRING,
OBJID_V TYPE STRING,
LOEKZ TYPE STRING,
DATUV TYPE STRING,
DATUB TYPE STRING,
AENNR TYPE STRING,
ANNAM TYPE STRING,
ANDAT TYPE STRING,
AENAM TYPE STRING,
AEDAT TYPE STRING,
BRGRU TYPE STRING,
STATUS TYPE STRING,
KZKBL TYPE STRING,
STOWK TYPE STRING,
STORT TYPE STRING,
BASEH TYPE STRING,
STEUF TYPE STRING,
STEUF_REF TYPE STRING,
FGRU1 TYPE STRING,
FGRU2 TYPE STRING,
PLANV TYPE STRING,
KTSCH TYPE STRING,
KTSCH_REF TYPE STRING,
BZOFFB TYPE STRING,
BZOFFB_REF TYPE STRING,
OFFSTB TYPE STRING,
EHOFFB TYPE STRING,
OFFSTB_REF TYPE STRING,
BZOFFE TYPE STRING,
BZOFFE_REF TYPE STRING,
OFFSTE TYPE STRING,
EHOFFE TYPE STRING,
OFFSTE_REF TYPE STRING,
MGFORM TYPE STRING,
MGFORM_REF TYPE STRING,
EWFORM TYPE STRING,
EWFORM_REF TYPE STRING,
PAR01 TYPE STRING,
PAR02 TYPE STRING,
PAR03 TYPE STRING,
PAR04 TYPE STRING,
PAR05 TYPE STRING,
PAR06 TYPE STRING,
PARU1 TYPE STRING,
PARU2 TYPE STRING,
PARU3 TYPE STRING,
PARU4 TYPE STRING,
PARU5 TYPE STRING,
PARU6 TYPE STRING,
PARV1 TYPE STRING,
PARV2 TYPE STRING,
PARV3 TYPE STRING,
PARV4 TYPE STRING,
PARV5 TYPE STRING,
PARV6 TYPE STRING,
FHWRK TYPE STRING,
MATNR TYPE STRING,
SFHNR TYPE STRING,
DOKAR TYPE STRING,
DOKNR TYPE STRING,
DOKVR TYPE STRING,
DOKTL TYPE STRING,
EQUNR TYPE STRING,
FHKTX TYPE STRING,
MMSTA TYPE STRING,
DOKST TYPE STRING,
DOKAS TYPE STRING,
DOKGV TYPE STRING,
EQSTO TYPE STRING,
EQTYP TYPE STRING,
EQWPL TYPE STRING,
EQWTX TYPE STRING,
EQPNT TYPE STRING,
EQPTX TYPE STRING,
ATNAM TYPE STRING,
ATVOR TYPE STRING,
MSEHI TYPE STRING,
ATDIM TYPE STRING,
ANZDZ TYPE STRING,
MEINS TYPE STRING,
MODKZ TYPE STRING,
MSTAE TYPE STRING,
TOOL_WC_OBJTY TYPE STRING,
TOOL_WC_OBJID TYPE STRING,
TOOL_WC_WERKS TYPE STRING,END OF T_EKKO_STR. DATA: WA_/ISDFPS/E1PRUPS_CRFH_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/E1PRUPS_CRFH_STR-MANDT sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-OBJTY sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-OBJID sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-ZAEHL sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-FHMAR sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-OBJTY_V sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-OBJID_V sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-LOEKZ sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-DATUV sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-DATUB sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-AENNR sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-ANNAM sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-ANDAT sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-AENAM sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-AEDAT sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-BRGRU sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-STATUS sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-KZKBL sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-STOWK sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-STORT sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-BASEH sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-STEUF sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-STEUF_REF sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-FGRU1 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-FGRU2 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PLANV sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-KTSCH sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-KTSCH_REF sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-BZOFFB sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-BZOFFB_REF sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-OFFSTB sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-EHOFFB sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-OFFSTB_REF sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-BZOFFE sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-BZOFFE_REF sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-OFFSTE sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-EHOFFE sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-OFFSTE_REF sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-MGFORM sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-MGFORM_REF sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-EWFORM sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-EWFORM_REF sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PAR01 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PAR02 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PAR03 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PAR04 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PAR05 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PAR06 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PARU1 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PARU2 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PARU3 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PARU4 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PARU5 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PARU6 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PARV1 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PARV2 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PARV3 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PARV4 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PARV5 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-PARV6 sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-FHWRK sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-MATNR sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-SFHNR sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-DOKAR sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-DOKNR sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-DOKVR sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-DOKTL sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-EQUNR sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-FHKTX sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-MMSTA sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-DOKST sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-DOKAS sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-DOKGV sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-EQSTO sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-EQTYP sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-EQWPL sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-EQWTX sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-EQPNT sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-EQPTX sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-ATNAM sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-ATVOR sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-MSEHI sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-ATDIM sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-ANZDZ sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-MEINS sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-MODKZ sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-MSTAE sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-TOOL_WC_OBJTY sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-TOOL_WC_OBJID sy-vline
WA_/ISDFPS/E1PRUPS_CRFH_STR-TOOL_WC_WERKS sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.