ABAP Select data from SAP table /PF1/STR_ITEM_SEL_PARALLEL 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 /PF1/STR_ITEM_SEL_PARALLEL 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 /PF1/STR_ITEM_SEL_PARALLEL. 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 /PF1/STR_ITEM_SEL_PARALLEL 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_/PF1/STR_ITEM_SEL_PARALLEL TYPE STANDARD TABLE OF /PF1/STR_ITEM_SEL_PARALLEL, WA_/PF1/STR_ITEM_SEL_PARALLEL TYPE /PF1/STR_ITEM_SEL_PARALLEL, 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: </PF1/STR_ITEM_SEL_PARALLEL> TYPE /PF1/STR_ITEM_SEL_PARALLEL. *Process all fields in table header/work area as string values PERFORM process_as_string_field_values CHANGING wa_/PF1/STR_ITEM_SEL_PARALLEL. SELECT * *restrict ABAP select to first 10 rows UP TO 10 ROWS FROM /PF1/STR_ITEM_SEL_PARALLEL INTO TABLE IT_/PF1/STR_ITEM_SEL_PARALLEL. *Select data and declare internal table using in-line method @DATA *SELECT * * FROM /PF1/STR_ITEM_SEL_PARALLEL * INTO TABLE @DATA(IT_/PF1/STR_ITEM_SEL_PARALLEL2). *--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_/PF1/STR_ITEM_SEL_PARALLEL INDEX 1 INTO DATA(WA_/PF1/STR_ITEM_SEL_PARALLEL2). *Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL LOOP AT IT_/PF1/STR_ITEM_SEL_PARALLEL ASSIGNING </PF1/STR_ITEM_SEL_PARALLEL>.*To update a field value using a field symbol simply change the value via the field symbol pointer
</PF1/STR_ITEM_SEL_PARALLEL>-RNG_PI_DATE = 1.
</PF1/STR_ITEM_SEL_PARALLEL>-RNG_PI_NO = 1.
</PF1/STR_ITEM_SEL_PARALLEL>-RNG_PI_KIND = 1.
</PF1/STR_ITEM_SEL_PARALLEL>-RNG_FLG_POSTED = 1.
</PF1/STR_ITEM_SEL_PARALLEL>-RNG_FLG_RESERVED = 1.
ENDLOOP. LOOP AT IT_/PF1/STR_ITEM_SEL_PARALLEL INTO WA_/PF1/STR_ITEM_SEL_PARALLEL. *Write horizonal line to screen report. WRITE:/ sy-uline. *Write selected data to screen/report before conversion. WRITE:/ sy-vline, WA_/PF1/STR_ITEM_SEL_PARALLEL-RNG_PI_PRIORITY, sy-vline,
WA_/PF1/STR_ITEM_SEL_PARALLEL-RNG_FLG_INTERNAL_USE, sy-vline,
WA_/PF1/STR_ITEM_SEL_PARALLEL-RNG_FM_STATE, sy-vline,
WA_/PF1/STR_ITEM_SEL_PARALLEL-RNG_TECHNICAL_PRIORITY, sy-vline,
WA_/PF1/STR_ITEM_SEL_PARALLEL-RNG_REF_ROUTE, sy-vline,
WA_/PF1/STR_ITEM_SEL_PARALLEL-RNG_REF_CLEARING, sy-vline.
ENDLOOP. *Add any further fields from structure WA_/PF1/STR_ITEM_SEL_PARALLEL 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_/PF1/STR_ITEM_SEL_PARALLEL 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_/PF1/STR_ITEM_SEL_PARALLEL INTO WA_/PF1/STR_ITEM_SEL_PARALLEL. *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_/PF1/STR_ITEM_SEL_PARALLEL_STR,
RNG_PI_DATE TYPE STRING,
RNG_PI_NO TYPE STRING,
RNG_PI_KIND TYPE STRING,
RNG_FLG_POSTED TYPE STRING,
RNG_FLG_RESERVED TYPE STRING,
RNG_PI_PRIORITY TYPE STRING,
RNG_FLG_INTERNAL_USE TYPE STRING,
RNG_FM_STATE TYPE STRING,
RNG_TECHNICAL_PRIORITY TYPE STRING,
RNG_REF_ROUTE TYPE STRING,
RNG_REF_CLEARING TYPE STRING,
RNG_PL_CLR_DATE TYPE STRING,
RNG_PL_CLR_TIME TYPE STRING,
RNG_PI_POST_DATE TYPE STRING,
PL_CLRDATE_TIME TYPE STRING,
PL_CLR_DATE TYPE STRING,
PL_CLR_TIME TYPE STRING,
RNG_PI_PROCESS_DATE TYPE STRING,
RNG_DUE_DATE TYPE STRING,
RNG_REF_INP_PO_DATE TYPE STRING,
RNG_REF_INP_PO_NO TYPE STRING,
RNG_REF_OUTP_PO_DATE TYPE STRING,
RNG_REF_OUTP_PO_NO TYPE STRING,
RNG_REF_COLL_DATE TYPE STRING,
RNG_REF_COLL_NO TYPE STRING,
RNG_REF_COLL_SEQ_NO TYPE STRING,
RNG_TR_CURR TYPE STRING,
RNG_TR_DEBCREDIND TYPE STRING,
RNG_TR_AMOUNT TYPE STRING,
RNG_PI_COUNTRY TYPE STRING,
RNG_PI_BANKKEY TYPE STRING,
RNG_PI_BIC TYPE STRING,
RNG_PI_ACCT_NO TYPE STRING,
RNG_PI_ACCT_CUR TYPE STRING,
RNG_PI_IBAN TYPE STRING,
RNG_REF_ITEM_EXT TYPE STRING,
RNG_WORK_BASKET_ID TYPE STRING,
RNG_REF_EXT_IN TYPE STRING,
RNG_REF_EXT_OUT TYPE STRING,
RNG_AM_AREA TYPE STRING,
RNG_AM_ITEM_STATUS TYPE STRING,
RNG_TRANS_TYPE TYPE STRING,
RNG_MANDATE_ID TYPE STRING,
RNG_UCI_ID TYPE STRING,
RNG_PI_TECH_STAT TYPE STRING,
RNG_CLEARING_AREA TYPE STRING,
TAB_PI_KEY TYPE STRING,
TAB_INPUT_PO_KEY TYPE STRING,
TAB_OUTPUT_PO_KEY TYPE STRING,
TAB_COLLECTOR_KEY TYPE STRING,
RNG_GUIDS TYPE STRING,
LOGONUSER TYPE STRING,
LOGONDATE TYPE STRING,
LOGONTIME TYPE STRING,
CLEARING_AREA TYPE STRING,
AR_SOURCE TYPE STRING,
READ_FROM_BUFFER TYPE STRING,
PACK_SIZE TYPE STRING,
POST_CANCEL TYPE STRING,
TA_OWNER TYPE STRING,
PACKAGE_COUNTER TYPE STRING,
PI_COMMIT_SIZE TYPE STRING,
FLG_EH_CALLED TYPE STRING,END OF T_EKKO_STR. DATA: WA_/PF1/STR_ITEM_SEL_PARALLEL_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_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_DATE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_NO sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_KIND sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_FLG_POSTED sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_FLG_RESERVED sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_PRIORITY sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_FLG_INTERNAL_USE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_FM_STATE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_TECHNICAL_PRIORITY sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_REF_ROUTE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_REF_CLEARING sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PL_CLR_DATE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PL_CLR_TIME sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_POST_DATE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-PL_CLRDATE_TIME sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-PL_CLR_DATE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-PL_CLR_TIME sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_PROCESS_DATE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_DUE_DATE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_REF_INP_PO_DATE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_REF_INP_PO_NO sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_REF_OUTP_PO_DATE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_REF_OUTP_PO_NO sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_REF_COLL_DATE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_REF_COLL_NO sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_REF_COLL_SEQ_NO sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_TR_CURR sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_TR_DEBCREDIND sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_TR_AMOUNT sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_COUNTRY sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_BANKKEY sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_BIC sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_ACCT_NO sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_ACCT_CUR sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_IBAN sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_REF_ITEM_EXT sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_WORK_BASKET_ID sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_REF_EXT_IN sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_REF_EXT_OUT sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_AM_AREA sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_AM_ITEM_STATUS sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_TRANS_TYPE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_MANDATE_ID sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_UCI_ID sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_PI_TECH_STAT sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_CLEARING_AREA sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-TAB_PI_KEY sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-TAB_INPUT_PO_KEY sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-TAB_OUTPUT_PO_KEY sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-TAB_COLLECTOR_KEY sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-RNG_GUIDS sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-LOGONUSER sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-LOGONDATE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-LOGONTIME sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-CLEARING_AREA sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-AR_SOURCE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-READ_FROM_BUFFER sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-PACK_SIZE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-POST_CANCEL sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-TA_OWNER sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-PACKAGE_COUNTER sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-PI_COMMIT_SIZE sy-vline
WA_/PF1/STR_ITEM_SEL_PARALLEL_STR-FLG_EH_CALLED sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.