ABAP Select data from SAP table ISUPDMNDDMND 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 ISUPDMNDDMND 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 ISUPDMNDDMND. 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 ISUPDMNDDMND 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_ISUPDMNDDMND TYPE STANDARD TABLE OF ISUPDMNDDMND,
      WA_ISUPDMNDDMND TYPE ISUPDMNDDMND,
      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: <ISUPDMNDDMND> TYPE ISUPDMNDDMND.

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

SELECT *
*restrict ABAP select to first 10 rows
 UP TO 10 ROWS      
  FROM ISUPDMNDDMND
  INTO TABLE IT_ISUPDMNDDMND.

*Select data and declare internal table using in-line method @DATA
*SELECT *
*  FROM ISUPDMNDDMND
*  INTO TABLE @DATA(IT_ISUPDMNDDMND2).
*--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_ISUPDMNDDMND INDEX 1 INTO DATA(WA_ISUPDMNDDMND2).


*Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL
LOOP AT IT_ISUPDMNDDMND ASSIGNING <ISUPDMNDDMND>.
*To update a field value using a field symbol simply change the value via the field symbol pointer
<ISUPDMNDDMND>-MANDT = 1.
<ISUPDMNDDMND>-REQUIREMENTDOCUMENTNUMBER = 1.
<ISUPDMNDDMND>-REQUIREMENTDOCUMENTITEM = 1.
<ISUPDMNDDMND>-REQUESTEDDATE = 1.
<ISUPDMNDDMND>-PRODUCTAVAILABILITYDATE = 1.
ENDLOOP.

LOOP AT IT_ISUPDMNDDMND INTO WA_ISUPDMNDDMND.
*Write horizonal line to screen report.
  WRITE:/ sy-uline.

*Write selected data to screen/report before conversion.
  WRITE:/ sy-vline,   WA_ISUPDMNDDMND-DELIVEREDQUANTITYINBASEUNIT, sy-vline,
WA_ISUPDMNDDMND-REQUESTEDRQMTQTYINBASEUNIT, sy-vline,
WA_ISUPDMNDDMND-CONFIRMEDRQMTQTYINBASEUNIT, sy-vline,
WA_ISUPDMNDDMND-REQUIREMENTTYPE, sy-vline,
WA_ISUPDMNDDMND-REQUIREMENTTYPENAME, sy-vline,
WA_ISUPDMNDDMND-ORDERTYPE, sy-vline.
ENDLOOP. *Add any further fields from structure WA_ISUPDMNDDMND 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_ISUPDMNDDMND 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_ISUPDMNDDMND INTO WA_ISUPDMNDDMND. *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 REQUIREMENTDOCUMENTNUMBER CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-REQUIREMENTDOCUMENTNUMBER IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-REQUIREMENTDOCUMENTNUMBER.
WRITE:/ 'New Value:', ld_input.

*Conversion exit AUART, internal->external for field ORDERTYPE CALL FUNCTION 'CONVERSION_EXIT_AUART_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-ORDERTYPE IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-ORDERTYPE.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field SOLDTOPARTY CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-SOLDTOPARTY IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-SOLDTOPARTY.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field SHIPTOPARTY CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-SHIPTOPARTY IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-SHIPTOPARTY.
WRITE:/ 'New Value:', ld_input.

*Conversion exit PARVW, internal->external for field PARTNERFUNCTION CALL FUNCTION 'CONVERSION_EXIT_PARVW_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-PARTNERFUNCTION IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-PARTNERFUNCTION.
WRITE:/ 'New Value:', ld_input.

*Conversion exit MATN1, internal->external for field MATERIAL CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-MATERIAL IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-MATERIAL.
WRITE:/ 'New Value:', ld_input.

*Conversion exit CUNIT, internal->external for field BASEUNIT CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-BASEUNIT IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-BASEUNIT.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field SHIPPINGGROUPNUMBER CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-SHIPPINGGROUPNUMBER IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-SHIPPINGGROUPNUMBER.
WRITE:/ 'New Value:', ld_input.

*Conversion exit MATN1, internal->external for field CROSSPLANTCONFIGURABLEPRODUCT CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-CROSSPLANTCONFIGURABLEPRODUCT IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-CROSSPLANTCONFIGURABLEPRODUCT.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field ARUNPRIORITYVALUE CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-ARUNPRIORITYVALUE IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-ARUNPRIORITYVALUE.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field ARUNDEMANDGROUPPRIORITY CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-ARUNDEMANDGROUPPRIORITY IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-ARUNDEMANDGROUPPRIORITY.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field PURCHASINGDOCUMENT CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-PURCHASINGDOCUMENT IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-PURCHASINGDOCUMENT.
WRITE:/ 'New Value:', ld_input.

*Conversion exit ALPHA, internal->external for field SUPPLIER CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ISUPDMNDDMND-SUPPLIER IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ISUPDMNDDMND-SUPPLIER.
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_ISUPDMNDDMND_STR,
MANDT TYPE STRING,
REQUIREMENTDOCUMENTNUMBER TYPE STRING,
REQUIREMENTDOCUMENTITEM TYPE STRING,
REQUESTEDDATE TYPE STRING,
PRODUCTAVAILABILITYDATE TYPE STRING,
DELIVEREDQUANTITYINBASEUNIT TYPE STRING,
REQUESTEDRQMTQTYINBASEUNIT TYPE STRING,
CONFIRMEDRQMTQTYINBASEUNIT TYPE STRING,
REQUIREMENTTYPE TYPE STRING,
REQUIREMENTTYPENAME TYPE STRING,
ORDERTYPE TYPE STRING,
SALESORGANIZATION TYPE STRING,
DISTRIBUTIONCHANNEL TYPE STRING,
REQUESTEDDELIVERYDATE TYPE STRING,
SHIPPINGCONDITION TYPE STRING,
SOLDTOPARTY TYPE STRING,
SHIPTOPARTY TYPE STRING,
COMPANYCODE TYPE STRING,
ARUNSUPPLYASSGMTRELEASERULE TYPE STRING,
PARTNERFUNCTION TYPE STRING,
SALESDOCUMENTITEMCATEGORY TYPE STRING,
DIVISION TYPE STRING,
MATERIAL TYPE STRING,
MATERIALGROUP TYPE STRING,
BASEUNIT TYPE STRING,
DELIVERYGROUP TYPE STRING,
ITEMBILLINGBLOCKREASON TYPE STRING,
NETAMOUNT TYPE STRING,
DOCUMENTCURRENCY TYPE STRING,
PLANT TYPE STRING,
STORAGELOCATION TYPE STRING,
SHIPPINGPOINT TYPE STRING,
NETPRICEAMOUNT TYPE STRING,
NETPRICEQUANTITY TYPE STRING,
REQUIREMENTSEGMENT TYPE STRING,
PRODUCTSEASONYEAR TYPE STRING,
PRODUCTSEASON TYPE STRING,
PRODUCTCOLLECTION TYPE STRING,
PRODUCTTHEME TYPE STRING,
FASHIONCANCELDATE TYPE STRING,
SHIPPINGGROUPRULE TYPE STRING,
SHIPPINGGROUPNUMBER TYPE STRING,
CUSTOMERGROUP TYPE STRING,
SALESDISTRICT TYPE STRING,
SUPASSGMTORDSTATUS TYPE STRING,
FASHIONCANCELDATEHORIZON TYPE STRING,
OPENDEMANDQUANTITY TYPE STRING,
CROSSPLANTCONFIGURABLEPRODUCT TYPE STRING,
ORDERTYPENAME TYPE STRING,
ISBUSINESSPURPOSECOMPLETED TYPE STRING,
PURCHASEORDERBYCUSTOMER TYPE STRING,
DELIVERYBLOCKREASON TYPE STRING,
PRODUCTCHARACTERISTIC1 TYPE STRING,
PRODUCTCHARACTERISTIC2 TYPE STRING,
PRODUCTCHARACTERISTIC3 TYPE STRING,
ORGANIZATIONDIVISION TYPE STRING,
SALESOFFICE TYPE STRING,
ARUNAPPLICATIONTYPE TYPE STRING,
ARUNPRIORITYVALUE TYPE STRING,
ARUNDEMANDGROUPPRIORITY TYPE STRING,
PURCHASINGDOCUMENTITEM TYPE STRING,
PURCHASINGDOCUMENT TYPE STRING,
SUPPLIER TYPE STRING,END OF T_EKKO_STR. DATA: WA_ISUPDMNDDMND_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_ISUPDMNDDMND_STR-MANDT sy-vline
WA_ISUPDMNDDMND_STR-REQUIREMENTDOCUMENTNUMBER sy-vline
WA_ISUPDMNDDMND_STR-REQUIREMENTDOCUMENTITEM sy-vline
WA_ISUPDMNDDMND_STR-REQUESTEDDATE sy-vline
WA_ISUPDMNDDMND_STR-PRODUCTAVAILABILITYDATE sy-vline
WA_ISUPDMNDDMND_STR-DELIVEREDQUANTITYINBASEUNIT sy-vline
WA_ISUPDMNDDMND_STR-REQUESTEDRQMTQTYINBASEUNIT sy-vline
WA_ISUPDMNDDMND_STR-CONFIRMEDRQMTQTYINBASEUNIT sy-vline
WA_ISUPDMNDDMND_STR-REQUIREMENTTYPE sy-vline
WA_ISUPDMNDDMND_STR-REQUIREMENTTYPENAME sy-vline
WA_ISUPDMNDDMND_STR-ORDERTYPE sy-vline
WA_ISUPDMNDDMND_STR-SALESORGANIZATION sy-vline
WA_ISUPDMNDDMND_STR-DISTRIBUTIONCHANNEL sy-vline
WA_ISUPDMNDDMND_STR-REQUESTEDDELIVERYDATE sy-vline
WA_ISUPDMNDDMND_STR-SHIPPINGCONDITION sy-vline
WA_ISUPDMNDDMND_STR-SOLDTOPARTY sy-vline
WA_ISUPDMNDDMND_STR-SHIPTOPARTY sy-vline
WA_ISUPDMNDDMND_STR-COMPANYCODE sy-vline
WA_ISUPDMNDDMND_STR-ARUNSUPPLYASSGMTRELEASERULE sy-vline
WA_ISUPDMNDDMND_STR-PARTNERFUNCTION sy-vline
WA_ISUPDMNDDMND_STR-SALESDOCUMENTITEMCATEGORY sy-vline
WA_ISUPDMNDDMND_STR-DIVISION sy-vline
WA_ISUPDMNDDMND_STR-MATERIAL sy-vline
WA_ISUPDMNDDMND_STR-MATERIALGROUP sy-vline
WA_ISUPDMNDDMND_STR-BASEUNIT sy-vline
WA_ISUPDMNDDMND_STR-DELIVERYGROUP sy-vline
WA_ISUPDMNDDMND_STR-ITEMBILLINGBLOCKREASON sy-vline
WA_ISUPDMNDDMND_STR-NETAMOUNT sy-vline
WA_ISUPDMNDDMND_STR-DOCUMENTCURRENCY sy-vline
WA_ISUPDMNDDMND_STR-PLANT sy-vline
WA_ISUPDMNDDMND_STR-STORAGELOCATION sy-vline
WA_ISUPDMNDDMND_STR-SHIPPINGPOINT sy-vline
WA_ISUPDMNDDMND_STR-NETPRICEAMOUNT sy-vline
WA_ISUPDMNDDMND_STR-NETPRICEQUANTITY sy-vline
WA_ISUPDMNDDMND_STR-REQUIREMENTSEGMENT sy-vline
WA_ISUPDMNDDMND_STR-PRODUCTSEASONYEAR sy-vline
WA_ISUPDMNDDMND_STR-PRODUCTSEASON sy-vline
WA_ISUPDMNDDMND_STR-PRODUCTCOLLECTION sy-vline
WA_ISUPDMNDDMND_STR-PRODUCTTHEME sy-vline
WA_ISUPDMNDDMND_STR-FASHIONCANCELDATE sy-vline
WA_ISUPDMNDDMND_STR-SHIPPINGGROUPRULE sy-vline
WA_ISUPDMNDDMND_STR-SHIPPINGGROUPNUMBER sy-vline
WA_ISUPDMNDDMND_STR-CUSTOMERGROUP sy-vline
WA_ISUPDMNDDMND_STR-SALESDISTRICT sy-vline
WA_ISUPDMNDDMND_STR-SUPASSGMTORDSTATUS sy-vline
WA_ISUPDMNDDMND_STR-FASHIONCANCELDATEHORIZON sy-vline
WA_ISUPDMNDDMND_STR-OPENDEMANDQUANTITY sy-vline
WA_ISUPDMNDDMND_STR-CROSSPLANTCONFIGURABLEPRODUCT sy-vline
WA_ISUPDMNDDMND_STR-ORDERTYPENAME sy-vline
WA_ISUPDMNDDMND_STR-ISBUSINESSPURPOSECOMPLETED sy-vline
WA_ISUPDMNDDMND_STR-PURCHASEORDERBYCUSTOMER sy-vline
WA_ISUPDMNDDMND_STR-DELIVERYBLOCKREASON sy-vline
WA_ISUPDMNDDMND_STR-PRODUCTCHARACTERISTIC1 sy-vline
WA_ISUPDMNDDMND_STR-PRODUCTCHARACTERISTIC2 sy-vline
WA_ISUPDMNDDMND_STR-PRODUCTCHARACTERISTIC3 sy-vline
WA_ISUPDMNDDMND_STR-ORGANIZATIONDIVISION sy-vline
WA_ISUPDMNDDMND_STR-SALESOFFICE sy-vline
WA_ISUPDMNDDMND_STR-ARUNAPPLICATIONTYPE sy-vline
WA_ISUPDMNDDMND_STR-ARUNPRIORITYVALUE sy-vline
WA_ISUPDMNDDMND_STR-ARUNDEMANDGROUPPRIORITY sy-vline
WA_ISUPDMNDDMND_STR-PURCHASINGDOCUMENTITEM sy-vline
WA_ISUPDMNDDMND_STR-PURCHASINGDOCUMENT sy-vline
WA_ISUPDMNDDMND_STR-SUPPLIER sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.