ABAP Select data from SAP table /SYCLO/HR_WF_PTARQ_REQLIST_STR 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 /SYCLO/HR_WF_PTARQ_REQLIST_STR 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 /SYCLO/HR_WF_PTARQ_REQLIST_STR. 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 /SYCLO/HR_WF_PTARQ_REQLIST_STR 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_/SYCLO/HR_WF_PTARQ_REQLIST_STR TYPE STANDARD TABLE OF /SYCLO/HR_WF_PTARQ_REQLIST_STR, WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR TYPE /SYCLO/HR_WF_PTARQ_REQLIST_STR, 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: </SYCLO/HR_WF_PTARQ_REQLIST_STR> TYPE /SYCLO/HR_WF_PTARQ_REQLIST_STR. *Process all fields in table header/work area as string values PERFORM process_as_string_field_values CHANGING wa_/SYCLO/HR_WF_PTARQ_REQLIST_STR. SELECT * *restrict ABAP select to first 10 rows UP TO 10 ROWS FROM /SYCLO/HR_WF_PTARQ_REQLIST_STR INTO TABLE IT_/SYCLO/HR_WF_PTARQ_REQLIST_STR. *Select data and declare internal table using in-line method @DATA *SELECT * * FROM /SYCLO/HR_WF_PTARQ_REQLIST_STR * INTO TABLE @DATA(IT_/SYCLO/HR_WF_PTARQ_REQLIST_STR2). *--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_/SYCLO/HR_WF_PTARQ_REQLIST_STR INDEX 1 INTO DATA(WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR2). *Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL LOOP AT IT_/SYCLO/HR_WF_PTARQ_REQLIST_STR ASSIGNING </SYCLO/HR_WF_PTARQ_REQLIST_STR>.*To update a field value using a field symbol simply change the value via the field symbol pointer
</SYCLO/HR_WF_PTARQ_REQLIST_STR>-REQUEST_ID = 1.
</SYCLO/HR_WF_PTARQ_REQLIST_STR>-FIRST_SUBM_DATE = 1.
</SYCLO/HR_WF_PTARQ_REQLIST_STR>-FIRST_SUBM_TIME = 1.
</SYCLO/HR_WF_PTARQ_REQLIST_STR>-STATUS = 1.
</SYCLO/HR_WF_PTARQ_REQLIST_STR>-STATUS_TEXT = 1.
ENDLOOP. LOOP AT IT_/SYCLO/HR_WF_PTARQ_REQLIST_STR INTO WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR. *Write horizonal line to screen report. WRITE:/ sy-uline. *Write selected data to screen/report before conversion. WRITE:/ sy-vline, WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR-REQUEST_OR_ATTABS, sy-vline,
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR-CURR_NOTICE, sy-vline,
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR-PAST_NOTICE, sy-vline,
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR-WORKITEM_ID, sy-vline,
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR-ITEM_ID, sy-vline,
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR-OPERATION, sy-vline.
ENDLOOP. *Add any further fields from structure WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR 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_/SYCLO/HR_WF_PTARQ_REQLIST_STR 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_/SYCLO/HR_WF_PTARQ_REQLIST_STR INTO WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR. *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 COSTCENTER CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR-COSTCENTER IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR-COSTCENTER.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ALPHA, internal->external for field ORDER_ID CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR-ORDER_ID IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR-ORDER_ID.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ABPSN, internal->external for field WBS_ELEMENT CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT' EXPORTING input = WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR-WBS_ELEMENT IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR-WBS_ELEMENT.
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_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR,
REQUEST_ID TYPE STRING,
FIRST_SUBM_DATE TYPE STRING,
FIRST_SUBM_TIME TYPE STRING,
STATUS TYPE STRING,
STATUS_TEXT TYPE STRING,
REQUEST_OR_ATTABS TYPE STRING,
CURR_NOTICE TYPE STRING,
PAST_NOTICE TYPE STRING,
WORKITEM_ID TYPE STRING,
ITEM_ID TYPE STRING,
OPERATION TYPE STRING,
INFOTYPE TYPE STRING,
BEGIN_TIME TYPE STRING,
END_TIME TYPE STRING,
ATTABS_HOURS TYPE STRING,
PERNR TYPE STRING,
SUBTY TYPE STRING,
OBJPS TYPE STRING,
SPRPS TYPE STRING,
ENDDA TYPE STRING,
BEGDA TYPE STRING,
SEQNR TYPE STRING,
VTKEN TYPE STRING,
ABWTG TYPE STRING,
KALTG TYPE STRING,
HRSIF TYPE STRING,
ALLDF TYPE STRING,
ABRTG TYPE STRING,
ABRST TYPE STRING,
UMSKD TYPE STRING,
UMSCH TYPE STRING,
OBJECT_TYPE TYPE STRING,
OBJ_ID TYPE STRING,
COMP_CODE TYPE STRING,
COSTCENTER TYPE STRING,
ORDER_ID TYPE STRING,
WBS_ELEMENT TYPE STRING,
LGART TYPE STRING,
VERSL TYPE STRING,
EXBEL TYPE STRING,
WTART TYPE STRING,
FAPRS TYPE STRING,
KEPAU TYPE STRING,
EXPAU TYPE STRING,
PBEG1 TYPE STRING,
PEND1 TYPE STRING,
PBEZ1 TYPE STRING,
PUNB1 TYPE STRING,
PBEG2 TYPE STRING,
PEND2 TYPE STRING,
PBEZ2 TYPE STRING,
PUNB2 TYPE STRING,
ANRTG TYPE STRING,
LFZED TYPE STRING,
KRGED TYPE STRING,
KBBEG TYPE STRING,
RMDDA TYPE STRING,
KENN1 TYPE STRING,
KENN2 TYPE STRING,
CUSTOMER01 TYPE STRING,
CUSTOMER02 TYPE STRING,
CUSTOMER03 TYPE STRING,
CUSTOMER04 TYPE STRING,
CUSTOMER05 TYPE STRING,
CUSTOMER06 TYPE STRING,
CUSTOMER07 TYPE STRING,
CUSTOMER08 TYPE STRING,
CUSTOMER09 TYPE STRING,
CUSTOMER10 TYPE STRING,
SUBTYPE_DESCRIPTION TYPE STRING,END OF T_EKKO_STR. DATA: WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_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_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-REQUEST_ID sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-FIRST_SUBM_DATE sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-FIRST_SUBM_TIME sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-STATUS sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-STATUS_TEXT sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-REQUEST_OR_ATTABS sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-CURR_NOTICE sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-PAST_NOTICE sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-WORKITEM_ID sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-ITEM_ID sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-OPERATION sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-INFOTYPE sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-BEGIN_TIME sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-END_TIME sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-ATTABS_HOURS sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-PERNR sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-SUBTY sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-OBJPS sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-SPRPS sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-ENDDA sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-BEGDA sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-SEQNR sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-VTKEN sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-ABWTG sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-KALTG sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-HRSIF sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-ALLDF sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-ABRTG sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-ABRST sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-UMSKD sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-UMSCH sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-OBJECT_TYPE sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-OBJ_ID sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-COMP_CODE sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-COSTCENTER sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-ORDER_ID sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-WBS_ELEMENT sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-LGART sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-VERSL sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-EXBEL sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-WTART sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-FAPRS sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-KEPAU sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-EXPAU sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-PBEG1 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-PEND1 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-PBEZ1 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-PUNB1 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-PBEG2 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-PEND2 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-PBEZ2 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-PUNB2 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-ANRTG sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-LFZED sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-KRGED sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-KBBEG sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-RMDDA sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-KENN1 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-KENN2 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-CUSTOMER01 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-CUSTOMER02 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-CUSTOMER03 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-CUSTOMER04 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-CUSTOMER05 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-CUSTOMER06 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-CUSTOMER07 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-CUSTOMER08 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-CUSTOMER09 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-CUSTOMER10 sy-vline
WA_/SYCLO/HR_WF_PTARQ_REQLIST_STR_STR-SUBTYPE_DESCRIPTION sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.