ABAP Select data from SAP table RPM_TS_RESOURCE_MSP 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 RPM_TS_RESOURCE_MSP 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 RPM_TS_RESOURCE_MSP. 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 RPM_TS_RESOURCE_MSP 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_RPM_TS_RESOURCE_MSP TYPE STANDARD TABLE OF RPM_TS_RESOURCE_MSP, WA_RPM_TS_RESOURCE_MSP TYPE RPM_TS_RESOURCE_MSP, 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: <RPM_TS_RESOURCE_MSP> TYPE RPM_TS_RESOURCE_MSP. *Process all fields in table header/work area as string values PERFORM process_as_string_field_values CHANGING wa_RPM_TS_RESOURCE_MSP. SELECT * *restrict ABAP select to first 10 rows UP TO 10 ROWS FROM RPM_TS_RESOURCE_MSP INTO TABLE IT_RPM_TS_RESOURCE_MSP. *Select data and declare internal table using in-line method @DATA *SELECT * * FROM RPM_TS_RESOURCE_MSP * INTO TABLE @DATA(IT_RPM_TS_RESOURCE_MSP2). *--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_RPM_TS_RESOURCE_MSP INDEX 1 INTO DATA(WA_RPM_TS_RESOURCE_MSP2). *Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL LOOP AT IT_RPM_TS_RESOURCE_MSP ASSIGNING <RPM_TS_RESOURCE_MSP>.*To update a field value using a field symbol simply change the value via the field symbol pointer
<RPM_TS_RESOURCE_MSP>-UNIQUE_ID = 1.
<RPM_TS_RESOURCE_MSP>-EMPLOYEE_ID = 1.
<RPM_TS_RESOURCE_MSP>-DESCRIPTION = 1.
<RPM_TS_RESOURCE_MSP>-CALENDAR_ID = 1.
<RPM_TS_RESOURCE_MSP>-TEAM_ID = 1.
ENDLOOP. LOOP AT IT_RPM_TS_RESOURCE_MSP INTO WA_RPM_TS_RESOURCE_MSP. *Write horizonal line to screen report. WRITE:/ sy-uline. *Write selected data to screen/report before conversion. WRITE:/ sy-vline, WA_RPM_TS_RESOURCE_MSP-ROLE_ID, sy-vline,
WA_RPM_TS_RESOURCE_MSP-ROLE_TEMPLATE_ID, sy-vline,
WA_RPM_TS_RESOURCE_MSP-PROJ_TEMPLATE_ID, sy-vline,
WA_RPM_TS_RESOURCE_MSP-ACTUAL_COST, sy-vline,
WA_RPM_TS_RESOURCE_MSP-ACTUAL_OT_COST, sy-vline,
WA_RPM_TS_RESOURCE_MSP-ACTUAL_OT_WORK, sy-vline.
ENDLOOP. *Add any further fields from structure WA_RPM_TS_RESOURCE_MSP 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_RPM_TS_RESOURCE_MSP 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_RPM_TS_RESOURCE_MSP INTO WA_RPM_TS_RESOURCE_MSP. *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_RPM_TS_RESOURCE_MSP_STR,
UNIQUE_ID TYPE STRING,
EMPLOYEE_ID TYPE STRING,
DESCRIPTION TYPE STRING,
CALENDAR_ID TYPE STRING,
TEAM_ID TYPE STRING,
ROLE_ID TYPE STRING,
ROLE_TEMPLATE_ID TYPE STRING,
PROJ_TEMPLATE_ID TYPE STRING,
ACTUAL_COST TYPE STRING,
ACTUAL_OT_COST TYPE STRING,
ACTUAL_OT_WORK TYPE STRING,
ACTUAL_WORK TYPE STRING,
AVAILABLE_FROM TYPE STRING,
AVAILABLE_TO TYPE STRING,
BASELINE_COST TYPE STRING,
BASELINE_WORK TYPE STRING,
OVERTIME_COST TYPE STRING,
OVERTIME_WORK TYPE STRING,
COMPLETION TYPE STRING,
REGULAR_WORK TYPE STRING,
REMAINING_WORK TYPE STRING,
PLANNED_WORK TYPE STRING,
PLANNED_COST TYPE STRING,
COST1 TYPE STRING,
COST2 TYPE STRING,
COST3 TYPE STRING,
COST4 TYPE STRING,
COST5 TYPE STRING,
DATE1 TYPE STRING,
DATE2 TYPE STRING,
DATE3 TYPE STRING,
DATE4 TYPE STRING,
DATE5 TYPE STRING,
FINISH1 TYPE STRING,
FINISH2 TYPE STRING,
FINISH3 TYPE STRING,
FINISH4 TYPE STRING,
FINISH5 TYPE STRING,
FLAG1 TYPE STRING,
FLAG2 TYPE STRING,
FLAG3 TYPE STRING,
FLAG4 TYPE STRING,
FLAG5 TYPE STRING,
NUMBER1 TYPE STRING,
NUMBER2 TYPE STRING,
NUMBER3 TYPE STRING,
NUMBER4 TYPE STRING,
NUMBER5 TYPE STRING,
START1 TYPE STRING,
START2 TYPE STRING,
START3 TYPE STRING,
START4 TYPE STRING,
START5 TYPE STRING,
TEXT1 TYPE STRING,
TEXT2 TYPE STRING,
TEXT3 TYPE STRING,
TEXT4 TYPE STRING,
TEXT5 TYPE STRING,END OF T_EKKO_STR. DATA: WA_RPM_TS_RESOURCE_MSP_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_RPM_TS_RESOURCE_MSP_STR-UNIQUE_ID sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-EMPLOYEE_ID sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-DESCRIPTION sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-CALENDAR_ID sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-TEAM_ID sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-ROLE_ID sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-ROLE_TEMPLATE_ID sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-PROJ_TEMPLATE_ID sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-ACTUAL_COST sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-ACTUAL_OT_COST sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-ACTUAL_OT_WORK sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-ACTUAL_WORK sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-AVAILABLE_FROM sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-AVAILABLE_TO sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-BASELINE_COST sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-BASELINE_WORK sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-OVERTIME_COST sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-OVERTIME_WORK sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-COMPLETION sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-REGULAR_WORK sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-REMAINING_WORK sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-PLANNED_WORK sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-PLANNED_COST sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-COST1 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-COST2 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-COST3 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-COST4 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-COST5 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-DATE1 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-DATE2 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-DATE3 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-DATE4 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-DATE5 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-FINISH1 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-FINISH2 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-FINISH3 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-FINISH4 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-FINISH5 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-FLAG1 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-FLAG2 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-FLAG3 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-FLAG4 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-FLAG5 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-NUMBER1 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-NUMBER2 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-NUMBER3 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-NUMBER4 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-NUMBER5 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-START1 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-START2 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-START3 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-START4 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-START5 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-TEXT1 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-TEXT2 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-TEXT3 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-TEXT4 sy-vline
WA_RPM_TS_RESOURCE_MSP_STR-TEXT5 sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.