ABAP Select data from SAP table IJITOUTBCGHTP 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 IJITOUTBCGHTP 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 IJITOUTBCGHTP. 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 IJITOUTBCGHTP 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_IJITOUTBCGHTP TYPE STANDARD TABLE OF IJITOUTBCGHTP, WA_IJITOUTBCGHTP TYPE IJITOUTBCGHTP, 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: <IJITOUTBCGHTP> TYPE IJITOUTBCGHTP. *Process all fields in table header/work area as string values PERFORM process_as_string_field_values CHANGING wa_IJITOUTBCGHTP. SELECT * *restrict ABAP select to first 10 rows UP TO 10 ROWS FROM IJITOUTBCGHTP INTO TABLE IT_IJITOUTBCGHTP. *Select data and declare internal table using in-line method @DATA *SELECT * * FROM IJITOUTBCGHTP * INTO TABLE @DATA(IT_IJITOUTBCGHTP2). *--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_IJITOUTBCGHTP INDEX 1 INTO DATA(WA_IJITOUTBCGHTP2). *Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL LOOP AT IT_IJITOUTBCGHTP ASSIGNING <IJITOUTBCGHTP>.*To update a field value using a field symbol simply change the value via the field symbol pointer
<IJITOUTBCGHTP>-MANDT = 1.
<IJITOUTBCGHTP>-INTERNALJITCALLNUMBER = 1.
<IJITOUTBCGHTP>-COMPGRPNUMBER = 1.
<IJITOUTBCGHTP>-JITCALLCOMPGRPUUID = 1.
<IJITOUTBCGHTP>-PARENTDRAFTKEY = 1.
ENDLOOP. LOOP AT IT_IJITOUTBCGHTP INTO WA_IJITOUTBCGHTP. *Write horizonal line to screen report. WRITE:/ sy-uline. *Write selected data to screen/report before conversion. WRITE:/ sy-vline, WA_IJITOUTBCGHTP-COMPGRPNUMBERFOREDIT, sy-vline,
WA_IJITOUTBCGHTP-COMPGRPMATL, sy-vline,
WA_IJITOUTBCGHTP-JITINTPROCESSINGSTATUS, sy-vline,
WA_IJITOUTBCGHTP-JITINTSTATUSUPDTDON, sy-vline,
WA_IJITOUTBCGHTP-REQUIREMENTDATETIME, sy-vline,
WA_IJITOUTBCGHTP-JITSUPPLYDATETIME, sy-vline.
ENDLOOP. *Add any further fields from structure WA_IJITOUTBCGHTP 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_IJITOUTBCGHTP 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_IJITOUTBCGHTP INTO WA_IJITOUTBCGHTP. *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 INTERNALJITCALLNUMBER CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_IJITOUTBCGHTP-INTERNALJITCALLNUMBER IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_IJITOUTBCGHTP-INTERNALJITCALLNUMBER.
WRITE:/ 'New Value:', ld_input.
*Conversion exit MATN1, internal->external for field COMPGRPMATL CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT' EXPORTING input = WA_IJITOUTBCGHTP-COMPGRPMATL IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_IJITOUTBCGHTP-COMPGRPMATL.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ALPHA, internal->external for field JITCONTROLCYCLE CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_IJITOUTBCGHTP-JITCONTROLCYCLE IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_IJITOUTBCGHTP-JITCONTROLCYCLE.
WRITE:/ 'New Value:', ld_input.
*Conversion exit MATN1, internal->external for field VEHICLEMODEL CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT' EXPORTING input = WA_IJITOUTBCGHTP-VEHICLEMODEL IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_IJITOUTBCGHTP-VEHICLEMODEL.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ALPHA, internal->external for field JITPLANNEDORDERNUMBER CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_IJITOUTBCGHTP-JITPLANNEDORDERNUMBER IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_IJITOUTBCGHTP-JITPLANNEDORDERNUMBER.
WRITE:/ 'New Value:', ld_input.
*Conversion exit MATN1, internal->external for field MATERIAL CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT' EXPORTING input = WA_IJITOUTBCGHTP-MATERIAL IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_IJITOUTBCGHTP-MATERIAL.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ALPHA, internal->external for field SUPPLIER CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_IJITOUTBCGHTP-SUPPLIER IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_IJITOUTBCGHTP-SUPPLIER.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ALPHA, internal->external for field BUSINESSPARTNER CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_IJITOUTBCGHTP-BUSINESSPARTNER IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_IJITOUTBCGHTP-BUSINESSPARTNER.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ALPHA, internal->external for field BUSINESSPARTNER1 CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_IJITOUTBCGHTP-BUSINESSPARTNER1 IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_IJITOUTBCGHTP-BUSINESSPARTNER1.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ALPHA, internal->external for field BUSINESSPARTNER2 CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_IJITOUTBCGHTP-BUSINESSPARTNER2 IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_IJITOUTBCGHTP-BUSINESSPARTNER2.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ALPHA, internal->external for field SCHEDULINGAGREEMENT CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_IJITOUTBCGHTP-SCHEDULINGAGREEMENT IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_IJITOUTBCGHTP-SCHEDULINGAGREEMENT.
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_IJITOUTBCGHTP_STR,
MANDT TYPE STRING,
INTERNALJITCALLNUMBER TYPE STRING,
COMPGRPNUMBER TYPE STRING,
JITCALLCOMPGRPUUID TYPE STRING,
PARENTDRAFTKEY TYPE STRING,
COMPGRPNUMBERFOREDIT TYPE STRING,
COMPGRPMATL TYPE STRING,
JITINTPROCESSINGSTATUS TYPE STRING,
JITINTSTATUSUPDTDON TYPE STRING,
REQUIREMENTDATETIME TYPE STRING,
JITSUPPLYDATETIME TYPE STRING,
PLANT TYPE STRING,
PLANTNAME TYPE STRING,
JITACTIONCTRL TYPE STRING,
REPLENISHMENTSTRATEGY TYPE STRING,
STORAGELOCATION TYPE STRING,
WAREHOUSENUMBER TYPE STRING,
JITSOURCEWAREHOUSENUMBER TYPE STRING,
JITOUTBSTOCKTRANSFERSTS TYPE STRING,
JITCONTROLCYCLE TYPE STRING,
PRODUCTIONSUPPLYAREA TYPE STRING,
RESPONSIBLE TYPE STRING,
EWMWAREHOUSE TYPE STRING,
JITOUTBDESTINATIONSTORLOC TYPE STRING,
CREATEDBYUSER TYPE STRING,
CREATIONDATETIME TYPE STRING,
JITLIFECYCLESTATUS TYPE STRING,
JITLIFECYCLESTATUSCRITICALITY TYPE STRING,
JITCALLTYPE TYPE STRING,
VEHICLEIDENTIFICATIONNUMBER TYPE STRING,
VEHICLEMODEL TYPE STRING,
JITINTSEQUENCENUMBER TYPE STRING,
LASTCHANGEDATETIME TYPE STRING,
LASTCHANGEDBYUSER TYPE STRING,
JITCALLIMMEDIATEREQUEST TYPE STRING,
JITMISSINGPARTFLAG TYPE STRING,
JITMISSINGPRTCRITICALITY TYPE STRING,
JITCALLPRIORITYTYPE TYPE STRING,
JITCALLPRIORITYID TYPE STRING,
JITCALLPROCESSINGLOGID TYPE STRING,
SOURCESTORAGEBIN TYPE STRING,
SOURCESTORAGETYPE TYPE STRING,
STORAGEBIN TYPE STRING,
STORAGETYPE TYPE STRING,
REPLNMTPLANNINGPROCEDURE TYPE STRING,
JITPLANNINGPROCEDURETEXT TYPE STRING,
DELIVERYSTATUS TYPE STRING,
JITPLANNEDORDERNUMBER TYPE STRING,
JITVEHICLESEQDATETIME TYPE STRING,
JITEXTSEQUENCENUMBER TYPE STRING,
REQUESTEDDELIVERYDATETIME TYPE STRING,
DELIVERYCREATIONDATE TYPE STRING,
JITCALLHASALERT TYPE STRING,
MATERIAL TYPE STRING,
JITREPLENISHMENTLEADTIMEVALUE TYPE STRING,
PRODUCTIONSUPPLYAREANAME TYPE STRING,
WAREHOUSENAME TYPE STRING,
JITEXTERNALREPLENISHMENT TYPE STRING,
JITINTERNALREPLENISHMENT TYPE STRING,
ISSUINGORRECEIVINGSTORAGELOC TYPE STRING,
AUTOMOTIVELOADINGPOINT TYPE STRING,
SUPPLIER TYPE STRING,
SUPPLIERNAME TYPE STRING,
BUSINESSPARTNER TYPE STRING,
BUSINESSPARTNER1 TYPE STRING,
BUSINESSPARTNER2 TYPE STRING,
SCHEDULINGAGREEMENT TYPE STRING,END OF T_EKKO_STR. DATA: WA_IJITOUTBCGHTP_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_IJITOUTBCGHTP_STR-MANDT sy-vline
WA_IJITOUTBCGHTP_STR-INTERNALJITCALLNUMBER sy-vline
WA_IJITOUTBCGHTP_STR-COMPGRPNUMBER sy-vline
WA_IJITOUTBCGHTP_STR-JITCALLCOMPGRPUUID sy-vline
WA_IJITOUTBCGHTP_STR-PARENTDRAFTKEY sy-vline
WA_IJITOUTBCGHTP_STR-COMPGRPNUMBERFOREDIT sy-vline
WA_IJITOUTBCGHTP_STR-COMPGRPMATL sy-vline
WA_IJITOUTBCGHTP_STR-JITINTPROCESSINGSTATUS sy-vline
WA_IJITOUTBCGHTP_STR-JITINTSTATUSUPDTDON sy-vline
WA_IJITOUTBCGHTP_STR-REQUIREMENTDATETIME sy-vline
WA_IJITOUTBCGHTP_STR-JITSUPPLYDATETIME sy-vline
WA_IJITOUTBCGHTP_STR-PLANT sy-vline
WA_IJITOUTBCGHTP_STR-PLANTNAME sy-vline
WA_IJITOUTBCGHTP_STR-JITACTIONCTRL sy-vline
WA_IJITOUTBCGHTP_STR-REPLENISHMENTSTRATEGY sy-vline
WA_IJITOUTBCGHTP_STR-STORAGELOCATION sy-vline
WA_IJITOUTBCGHTP_STR-WAREHOUSENUMBER sy-vline
WA_IJITOUTBCGHTP_STR-JITSOURCEWAREHOUSENUMBER sy-vline
WA_IJITOUTBCGHTP_STR-JITOUTBSTOCKTRANSFERSTS sy-vline
WA_IJITOUTBCGHTP_STR-JITCONTROLCYCLE sy-vline
WA_IJITOUTBCGHTP_STR-PRODUCTIONSUPPLYAREA sy-vline
WA_IJITOUTBCGHTP_STR-RESPONSIBLE sy-vline
WA_IJITOUTBCGHTP_STR-EWMWAREHOUSE sy-vline
WA_IJITOUTBCGHTP_STR-JITOUTBDESTINATIONSTORLOC sy-vline
WA_IJITOUTBCGHTP_STR-CREATEDBYUSER sy-vline
WA_IJITOUTBCGHTP_STR-CREATIONDATETIME sy-vline
WA_IJITOUTBCGHTP_STR-JITLIFECYCLESTATUS sy-vline
WA_IJITOUTBCGHTP_STR-JITLIFECYCLESTATUSCRITICALITY sy-vline
WA_IJITOUTBCGHTP_STR-JITCALLTYPE sy-vline
WA_IJITOUTBCGHTP_STR-VEHICLEIDENTIFICATIONNUMBER sy-vline
WA_IJITOUTBCGHTP_STR-VEHICLEMODEL sy-vline
WA_IJITOUTBCGHTP_STR-JITINTSEQUENCENUMBER sy-vline
WA_IJITOUTBCGHTP_STR-LASTCHANGEDATETIME sy-vline
WA_IJITOUTBCGHTP_STR-LASTCHANGEDBYUSER sy-vline
WA_IJITOUTBCGHTP_STR-JITCALLIMMEDIATEREQUEST sy-vline
WA_IJITOUTBCGHTP_STR-JITMISSINGPARTFLAG sy-vline
WA_IJITOUTBCGHTP_STR-JITMISSINGPRTCRITICALITY sy-vline
WA_IJITOUTBCGHTP_STR-JITCALLPRIORITYTYPE sy-vline
WA_IJITOUTBCGHTP_STR-JITCALLPRIORITYID sy-vline
WA_IJITOUTBCGHTP_STR-JITCALLPROCESSINGLOGID sy-vline
WA_IJITOUTBCGHTP_STR-SOURCESTORAGEBIN sy-vline
WA_IJITOUTBCGHTP_STR-SOURCESTORAGETYPE sy-vline
WA_IJITOUTBCGHTP_STR-STORAGEBIN sy-vline
WA_IJITOUTBCGHTP_STR-STORAGETYPE sy-vline
WA_IJITOUTBCGHTP_STR-REPLNMTPLANNINGPROCEDURE sy-vline
WA_IJITOUTBCGHTP_STR-JITPLANNINGPROCEDURETEXT sy-vline
WA_IJITOUTBCGHTP_STR-DELIVERYSTATUS sy-vline
WA_IJITOUTBCGHTP_STR-JITPLANNEDORDERNUMBER sy-vline
WA_IJITOUTBCGHTP_STR-JITVEHICLESEQDATETIME sy-vline
WA_IJITOUTBCGHTP_STR-JITEXTSEQUENCENUMBER sy-vline
WA_IJITOUTBCGHTP_STR-REQUESTEDDELIVERYDATETIME sy-vline
WA_IJITOUTBCGHTP_STR-DELIVERYCREATIONDATE sy-vline
WA_IJITOUTBCGHTP_STR-JITCALLHASALERT sy-vline
WA_IJITOUTBCGHTP_STR-MATERIAL sy-vline
WA_IJITOUTBCGHTP_STR-JITREPLENISHMENTLEADTIMEVALUE sy-vline
WA_IJITOUTBCGHTP_STR-PRODUCTIONSUPPLYAREANAME sy-vline
WA_IJITOUTBCGHTP_STR-WAREHOUSENAME sy-vline
WA_IJITOUTBCGHTP_STR-JITEXTERNALREPLENISHMENT sy-vline
WA_IJITOUTBCGHTP_STR-JITINTERNALREPLENISHMENT sy-vline
WA_IJITOUTBCGHTP_STR-ISSUINGORRECEIVINGSTORAGELOC sy-vline
WA_IJITOUTBCGHTP_STR-AUTOMOTIVELOADINGPOINT sy-vline
WA_IJITOUTBCGHTP_STR-SUPPLIER sy-vline
WA_IJITOUTBCGHTP_STR-SUPPLIERNAME sy-vline
WA_IJITOUTBCGHTP_STR-BUSINESSPARTNER sy-vline
WA_IJITOUTBCGHTP_STR-BUSINESSPARTNER1 sy-vline
WA_IJITOUTBCGHTP_STR-BUSINESSPARTNER2 sy-vline
WA_IJITOUTBCGHTP_STR-SCHEDULINGAGREEMENT sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.