ABAP Select data from SAP table ISU_BI_COLL_BILL_S_PRINTACT_D 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 ISU_BI_COLL_BILL_S_PRINTACT_D 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 ISU_BI_COLL_BILL_S_PRINTACT_D. 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 ISU_BI_COLL_BILL_S_PRINTACT_D 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_ISU_BI_COLL_BILL_S_PRINTACT_D TYPE STANDARD TABLE OF ISU_BI_COLL_BILL_S_PRINTACT_D, WA_ISU_BI_COLL_BILL_S_PRINTACT_D TYPE ISU_BI_COLL_BILL_S_PRINTACT_D, 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: <ISU_BI_COLL_BILL_S_PRINTACT_D> TYPE ISU_BI_COLL_BILL_S_PRINTACT_D. *Process all fields in table header/work area as string values PERFORM process_as_string_field_values CHANGING wa_ISU_BI_COLL_BILL_S_PRINTACT_D. SELECT * *restrict ABAP select to first 10 rows UP TO 10 ROWS FROM ISU_BI_COLL_BILL_S_PRINTACT_D INTO TABLE IT_ISU_BI_COLL_BILL_S_PRINTACT_D. *Select data and declare internal table using in-line method @DATA *SELECT * * FROM ISU_BI_COLL_BILL_S_PRINTACT_D * INTO TABLE @DATA(IT_ISU_BI_COLL_BILL_S_PRINTACT_D2). *--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_ISU_BI_COLL_BILL_S_PRINTACT_D INDEX 1 INTO DATA(WA_ISU_BI_COLL_BILL_S_PRINTACT_D2). *Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL LOOP AT IT_ISU_BI_COLL_BILL_S_PRINTACT_D ASSIGNING <ISU_BI_COLL_BILL_S_PRINTACT_D>.*To update a field value using a field symbol simply change the value via the field symbol pointer
<ISU_BI_COLL_BILL_S_PRINTACT_D>-WA_PRINTACT_D = 1.
<ISU_BI_COLL_BILL_S_PRINTACT_D>-CLIENT = 1.
<ISU_BI_COLL_BILL_S_PRINTACT_D>-ACTIONNO = 1.
<ISU_BI_COLL_BILL_S_PRINTACT_D>-OBJ_TYPE = 1.
<ISU_BI_COLL_BILL_S_PRINTACT_D>-OBJ_KEY = 1.
ENDLOOP. LOOP AT IT_ISU_BI_COLL_BILL_S_PRINTACT_D INTO WA_ISU_BI_COLL_BILL_S_PRINTACT_D. *Write horizonal line to screen report. WRITE:/ sy-uline. *Write selected data to screen/report before conversion. WRITE:/ sy-vline, WA_ISU_BI_COLL_BILL_S_PRINTACT_D-FORMCLASS, sy-vline,
WA_ISU_BI_COLL_BILL_S_PRINTACT_D-LAST_DATE, sy-vline,
WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TRIG_FROM, sy-vline,
WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TRIG_TO, sy-vline,
WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TRIG_COUNT, sy-vline,
WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TRIG_DONE, sy-vline.
ENDLOOP. *Add any further fields from structure WA_ISU_BI_COLL_BILL_S_PRINTACT_D 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_ISU_BI_COLL_BILL_S_PRINTACT_D 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_ISU_BI_COLL_BILL_S_PRINTACT_D INTO WA_ISU_BI_COLL_BILL_S_PRINTACT_D. *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 ISOLA, internal->external for field TDSPRAS1 CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TDSPRAS1 IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TDSPRAS1.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ISOLA, internal->external for field TDSPRAS2 CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TDSPRAS2 IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TDSPRAS2.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ISOLA, internal->external for field TDSPRAS3 CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TDSPRAS3 IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TDSPRAS3.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ISOLA, internal->external for field TDSPRAS4 CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TDSPRAS4 IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TDSPRAS4.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ISOLA, internal->external for field TDSPRAS5 CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT' EXPORTING input = WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TDSPRAS5 IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISU_BI_COLL_BILL_S_PRINTACT_D-TDSPRAS5.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ABPSN, internal->external for field CAMPAIGN CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT' EXPORTING input = WA_ISU_BI_COLL_BILL_S_PRINTACT_D-CAMPAIGN IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISU_BI_COLL_BILL_S_PRINTACT_D-CAMPAIGN.
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_ISU_BI_COLL_BILL_S_PRINTACT_D_STR,
WA_PRINTACT_D TYPE STRING,
CLIENT TYPE STRING,
ACTIONNO TYPE STRING,
OBJ_TYPE TYPE STRING,
OBJ_KEY TYPE STRING,
FORMCLASS TYPE STRING,
LAST_DATE TYPE STRING,
TRIG_FROM TYPE STRING,
TRIG_TO TYPE STRING,
TRIG_COUNT TYPE STRING,
TRIG_DONE TYPE STRING,
MODULO TYPE STRING,
TDNAME1 TYPE STRING,
TDID1 TYPE STRING,
TDSPRAS1 TYPE STRING,
TDNAME2 TYPE STRING,
TDID2 TYPE STRING,
TDSPRAS2 TYPE STRING,
TDNAME3 TYPE STRING,
TDID3 TYPE STRING,
TDSPRAS3 TYPE STRING,
TDNAME4 TYPE STRING,
TDID4 TYPE STRING,
TDSPRAS4 TYPE STRING,
TDNAME5 TYPE STRING,
TDID5 TYPE STRING,
TDSPRAS5 TYPE STRING,
FLYERID1 TYPE STRING,
FLYERID2 TYPE STRING,
FLYERID3 TYPE STRING,
FLYERID4 TYPE STRING,
FLYERID5 TYPE STRING,
FLYERID6 TYPE STRING,
FLYERID7 TYPE STRING,
FLYERID8 TYPE STRING,
FLYERID9 TYPE STRING,
FLYERID10 TYPE STRING,
DESCRIPT TYPE STRING,
ERDAT TYPE STRING,
ERNAM TYPE STRING,
ERSAP TYPE STRING,
AEDAT TYPE STRING,
AENAM TYPE STRING,
AEUZEIT TYPE STRING,
AESAP TYPE STRING,
CAMPAIGN TYPE STRING,
T_PAR_D_LINE TYPE STRING,END OF T_EKKO_STR. DATA: WA_ISU_BI_COLL_BILL_S_PRINTACT_D_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_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-WA_PRINTACT_D sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-CLIENT sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-ACTIONNO sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-OBJ_TYPE sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-OBJ_KEY sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-FORMCLASS sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-LAST_DATE sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TRIG_FROM sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TRIG_TO sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TRIG_COUNT sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TRIG_DONE sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-MODULO sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDNAME1 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDID1 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDSPRAS1 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDNAME2 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDID2 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDSPRAS2 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDNAME3 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDID3 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDSPRAS3 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDNAME4 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDID4 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDSPRAS4 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDNAME5 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDID5 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-TDSPRAS5 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-FLYERID1 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-FLYERID2 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-FLYERID3 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-FLYERID4 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-FLYERID5 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-FLYERID6 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-FLYERID7 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-FLYERID8 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-FLYERID9 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-FLYERID10 sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-DESCRIPT sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-ERDAT sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-ERNAM sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-ERSAP sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-AEDAT sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-AENAM sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-AEUZEIT sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-AESAP sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-CAMPAIGN sy-vline
WA_ISU_BI_COLL_BILL_S_PRINTACT_D_STR-T_PAR_D_LINE sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.