![]() DATA: lt_matnr TYPE STANDARD TABLE OF matnr. The data can be accessed only by TABLE_LINE. When declaring a table of type any data element, the table cannot be read using the field name like in the below example. Read Table – Assigning Field Symbol – Inline Declaration: READ TABLE lt_cust ASSIGNING FIELD-SYMBOL() Read Table – Assigning Field Symbol – Explicit Declaration: "Field-Symbols declared inside angle brackets do not show in HTML Read the internal table’s one particular row’s single field using index into a variable. Read the internal table’s one full row using index into a work area. Read the internal table’s one particular row’s single field into a variable. READ TABLE lt_cust INTO DATA(ls_cust) "Old Style Yes it is a bit difficult at first, but you will get used to it. But this 7.4 syntax does not set any sy-subrc value for failure, but instead throws an exception, which has to be caught like below, or will throw a dump. When a READ TABLE fails, the ‘sy-subrc’ value is set accordingly as 4, 8 etc. Read the internal table’s one full row into a work area. READ TABLE lt_cust WITH KEY name = 'Abilash' "Old Style Read Table With Key – Transporting No Fields:įor checking if the a row with a particular condition exists in the internal table. Lt_custz = VALUE #( ( name = 'ZAbilash' vehcat = 'Car' The below coding shows how to fill up an internal table where the table is declared explicitly, ie. ( name = 'Santhosh' vehcat = 'Motorcycle'ĭebugger screenshot of the above filled internal table: Base Internal Table for Demo DATA: lt_cust_old TYPE STANDARD TABLE OF ty_cust, "Old StyleĭATA(lt_cust) = VALUE tt_ty_cust( ( name = 'Abilash' vehcat = 'Car' Here the internal table ‘LT_CUST’ is an inline declaration. This is similar to appending data from a work area to an internal table. Tt_ty_cust TYPE SORTED TABLE OF ty_cust WITH NON-UNIQUE KEY name vehcat.Īdd Records to an internal table using VALUE Keyword: Types Declaration – For building the internal table TYPES: BEGIN OF ty_cust, The first block of coding populates an internal table which will be the base for all the coding below. ![]() I have provided screenshots from the ABAP debugger in some places for some visual orientation. I have tried to give the complete coding including declarations, so that you can copy paste it and execute it. I am planning on updating this blog regularly with more usage as I come across them. Making sense from SAP Help is not one of my strong points. Everything here is from this famous blog, but in a way that I had worked for my easy understanding. The coding is from my exercises in understanding the newer syntax and keywords of ABAP 740 and trying to push them into my daily usage. Read about more such ABAP expressions and exciting new syntaxes: ABAP Expressions (7.This is my bit of ABAP 740 coding. SELECT * FROM sflight INTO TABLE it_flights. DATA : it_flights TYPE SORTED TABLE OF sflight Binary Search in new READ syntaxĪdvertisements Before I end this post, an important question is – what about BINARY SEARCH? Well, use sorted table and binary search would be used implicitly. So do not use this just to avoid using try-catch but use it only when there is an actual need. Here, you have to be careful as the variable/structure will be blank in case the read fails. ls_flight = VALUE #( it_flights OPTIONAL ). In the scenarios where handling the case where READ failed is not at all required, you can skip the try-catch using the OPTIONAL keyword. In this case, the exception is not required to be handled but a sy-subrc check works just fine. The result of the expression can be assigned to a fiel d symbol as well. It can be used in IF blocks IF it_flights-planetype = 'A319'. data(plane_type) = it_flights-planetype.Ģ. A field from the result can be used with – the field name. AdvertisementsĪs this is an expression and not a statement, it can be used at any operand position, which was impossible with the READ TABLE statement.ġ. ![]() You can handle the SY-SUBRC 0 cases in CATCH block. The control will move to CATCH block when READ fails. Raises an exception CX_SY_ITAB_LINE_NOT_FOUND when the read expression fails "Write read expressions in TRY-CATCH blocks.important thing to note here is that the new expression If you are trying out the above code example – please add the below code block before these statements. One free key READ TABLE it_flights INTO ls_flight WITH KEY carrid = 'SQ'Ĭonnid = '0026'. Read with free key READ TABLE it_flights INTO ls_flight Variable READ TABLE it_flights INTO ls_flight INDEX lv_idx. ![]() Number READ TABLE it_flights INTO ls_flight INDEX 1. It is possible to use inline data declaration here to create an internal table and work area but it is declared explicitly at the top so that we can focus on the READ TABLE syntax Context Before ABAP 7.40 From ABAP 7.40 Read with index ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |