1.14 Internal Table:Formulating Dynamic Where Conditions
Dynamic Where condition
In version 7.02, dynamic Where conditions can be used in Loop;
1.15 Internal Table: Defining and Using Secondary Keys
Mainly used Secondary Keys, use Non-unique sorted keys;
Sample code:
"test6 "secondary key FORM f_test6. DATA:lt_spfli TYPE TABLE OF spfli WITH UNIQUE HASHED KEY k_hash COMPONENTS carryrid connid countryfr WITH NON-UNIQUE SORTED KEY k_sort COMPONENTS carry connid. SELECT * FROM spfli INTO TABLE lt_spfli. Use when "loop LOOP AT lt_spfli INTO DATA(ls_spfli) USING KEY k_sort WHERE carrid = 'AA' AND connid = '0001'. ENDLOOP. Use when "read READ TABLE lt_spfli INTO ls_spfli WITH KEY k_sort COMPONENTS carrid = 'AA' connid = '0001'. "When the key is used to read out the record and needs to be updated, the corresponding key must be used "The value recorded by sy-tabix will be affected by the key "The transporting field needs to be specified when updating, and the key value field cannot be updated MODIFY lt_spfli USING KEY k_sort FROM ls_spfli INDEX sy-tabix TRANSPORTING countryfr. ENDFORM.
1.16 Internal Table: Processing Internal Tables Using Expressions
Sample code:
"test7 "expression access inner table FORM f_test7. DATA:lt_spfli TYPE TABLE OF spfli WITH NON-UNIQUE SORTED KEY k_sort COMPONENTS countryfr. DATA: ls_spfli LIKE LINE OF lt_spfli. DATA:lv_countryfr TYPE spfli-countryfr. SELECT * FROM spfli INTO TABLE lt_spfli. "line index starts from 1 ls_spfli = lt_spfli[ 1 ]. WRITE: / ls_spfli-carrid, ls_spfli-connid. "Match multiple records, only return the first record ls_spfli = lt_spfli[ carrid = 'AA' ]. WRITE: / ls_spfli-carrid, ls_spfli-connid. "Use key ls_spfli = lt_spfli[KEY k_sort COMPONENTS countryfr = 'DE' ]. WRITE: / ls_spfli-carrid, ls_spfli-connid. "Access structure fields lv_countryfr = lt_spfli[ carrid = 'AA' ]-countryfr. "Access lines by line index * READ TABLE lt_spfli WITH KEY k_sort COMPONENTS countryfr = 'DE' TRANSPORTING NO FIELDS. * LOOP AT lt_spfli INTO ls_spfli FROM sy-tabix. * ENDLOOP. "line_index() method "line_exists() method "need line_exists first to determine whether the access data line exists, "Then use line_index to get the data line IF line_exists( lt_spfli[ KEY k_sort COMPONENTS countryfr = 'DE' ] ). LOOP AT lt_spfli INTO ls_spfli FROM line_index( lt_spfli[ KEY k_sort COMPONENTS countryfr = 'DE' ] ). ENDLOOP. ENDIF. ENDFORM.
1.17 Internal Table: Creating Comprehensions And Reductions
Simplify internal table loop processing;
data aggregation method;
Sample code:
"test8 "Creating Comprehensions And Reductions FORM f_test8. DATA:lt_spfli TYPE TABLE OF spfli WITH NON-UNIQUE SORTED KEY s_sort COMPONENTS countryfr. DATA:lt_spfli2 TYPE TABLE OF spfli. DATA: ls_spfli LIKE LINE OF lt_spfli. TYPES: BEGIN OF s_ty1, carrid TYPE spfli-carrid, connid TYPE spfli-connid, END OF s_ty1. DATA:lt_ty1 TYPE TABLE OF s_ty1. DATA: ls_ty1 LIKE LINE OF lt_ty1. SELECT * FROM spfli INTO TABLE lt_spfli. "Use MOVE-CORRESPONDING for internal table assignment MOVE-CORRESPONDING lt_spfli TO lt_ty1. "Reserve the existing records of lt_ty1 "MOVE-CORRESPONDING lt_spfli TO lt_ty1 KEEPING TARGET LINES. "If there is a nested structure assignment "MOVE-CORRESPONDING lt_spfli TO lt_ty1 EXPANDING NESTED TABLES. "Do not use Loop, get some rows of the inner table lt_spfli2 = VALUE #( FOR wa IN lt_spfli WHERE (carrid = 'AA') ( w ) ). "Combined with dynamic where conditions, note that there should be no spaces in the brackets on both sides of where DATA:lv_carrid TYPE string VALUE 'AZ'. DATA:lv_connid TYPE string VALUE '0788'. DATA:lv_where TYPE string. lv_where = | CARRID = '{ lv_carrid }' AND CONNID = '{ lv_connid }' |. WRITE: /lv_where. lt_spfli2 = VALUE #( FOR wa IN lt_spfli WHERE (lv_where) ( w ) ). LOOP AT lt_spfli2 INTO DATA(ls_spfli2). WRITE: / ls_spfli2-carrid, ls_spfli2-connid. ENDLOOP. "Data summary through REDUCE DATA:lt_sflight TYPE TABLE OF sflight. DATA: ls_sflight LIKE LINE OF lt_sflight. TYPES: BEGIN OF s_ty2, carrid TYPE sflight-carrid, connid TYPE sflight-connid, sum_occ TYPE i, END OF s_ty2. DATA:lt_sflight2 TYPE TABLE OF s_ty2. DATA:lt_sflight3 TYPE TABLE OF s_ty2. DATA:lv_occ_total TYPE I. SELECT * FROM sflight INTO TABLE lt_sflight. "Total all seatssocc lv_occ_total = REDUCE i( INIT i = 0 FOR ls_sflight2 IN lt_sflight NEXT i = i + ls_sflight2-seatsocc ). "According to carrid, connid group summary seatsocc LOOP AT lt_sflight INTO ls_sflight GROUP BY (carrid = ls_sflight-carrid connid = ls_sflight-connid size = GROUP SIZE ) ASCENDING ASSIGNING FIELD-SYMBOL(<fs_sflight>). lt_sflight2 = VALUE #( ( carrid = <fs_sflight>-carrid connid = <fs_sflight>-connid sum_occ = REDUCE i( INIT i = 0 FOR line IN GROUP <fs_sflight> NEXT i = i + line-seatsocc ) ) ). MOVE-CORRESPONDING lt_sflight2 TO lt_sflight3 KEEPING TARGET LINES. ENDLOOP. LOOP AT lt_sflight3 ASSIGNING FIELD-SYMBOL(<fs_sflight3>). WRITE:/ <fs_sflight3>-carrid,<fs_sflight3>-connid,<fs_sflight3>-sum_occ. ENDLOOP. ENDFORM.
1.18 Internal Table: Defining and Using Meshes
By defining the foreign key relationship between tables, multi-table connection is realized, and the number of cycles during access is reduced.
But when querying, the data of multiple tables will be queried at the same time. Will there be memory overflow?
Example:
"test9 "Defining and Using Meshes "grammar: *TYPES BEGIN OF MESH mesh_type. * node { TYPE {[REF TO] table_type}|ref_type } * | { LIKE {[REF TO] itab }|dref } * [association1], * [association2], *... *TYPES END OF MESH mesh_type. "Example: DEMO_MESH* "Mesh Node "grammar: "{mesh-|<mesh>-|mesh_ref->}rnode\_associ[ ... ]\_assoc1[ ... ]\_assoc2[ ... ] "1.{mesh-|<mesh>-|mesh_ref->}rnode "rnode is the node defined in the mesh, which can be used as the start node or the end node; "2. \_associ[ source [cond] ] "Obtain the corresponding result node data through association, and you can specify the start node data filter conditions; "3.\_assoc1[[cond]]\_assoc2[[cond]] "The association can be used in chains to access data; "Mesh Association "grammar: "\_assoc[ + |*][ ... ] "| \_assoc~node[ + |*][ ... ] "| \^_assoc~node[ + |*][ ... ] ... "Example: DEMO_MESH_REFLEXIVE_ASSOC_SNGL " + ,*mainly used for self-association table tree relationship " + , get the data of all descendant nodes under the starting node; "*, contains the matching data of the start node, and obtains the data of all descendant nodes under the start node; "For example: "Course ID Advanced Course Description "ID PID DESC "1 0 t1 "2 1 t2 "3 2 t3 "4 0 t4 "5 1 t5 *TYPES: BEGIN OF line, * id TYPE i, * pid TYPE i, * desc TYPE string, * END OF line. *TYPES:t_itab TYPE SORTED TABLE OF line WITH UNIQUE KEY id * WITH NON-UNIQUE SORTED KEY by_parent * COMPONENTS pid, *TYPES: BEGIN OF MESH t_mesh, * node TYPE t_itab * ASSOCIATION _node TO node ON pid = id * USING KEY by_parent, * END OF MESH t_mesh. "Need to find all lower-level courses whose course ID is 1 "mesh-node\_node[ mesh-node[ id = id ] ] "Return: t2, t5 two records "mesh-node\_node + [ mesh-node[ id = id ] ] "Return: t2, t5, t3, t3 returns because he is a grandchild class "mesh-node\_node*[ mesh-node[ id = id ] ] "Return: t2,t5,t3,t1 t1 is returned because it meets the initial condition "Mesh Condition "grammar: "{ col1 = val1 col2 = val2 ... } "| { [USING KEY key] [WHERE log_exp] } "Set filter criteria "[USING KEY key] [WHERE log_exp] " can be used in the following syntax: "LOOP AT mesh_path... "FOR ... IN mesh_path ... "INSERT ... INTO TABLE mesh_path ... "MODIFY mesh_path. "DELETE mesh_path. "SET ASSOCIATION mesh_path... FORM f_test9. "Define MESH "Cannot use standard table "TYPES:tt_customers TYPE TABLE OF scustom. "TYPES:tt_customers TYPE STANDARD TABLE OF scustom. "TYPES:tt_customers TYPE STANDARD TABLE OF scustom " WITH NON-UNIQUE SORTED KEY k_sort COMPONENTS id name. "Need to use sorted table, hash table TYPES:tt_customers TYPE SORTED TABLE OF scustom WITH NON-UNIQUE KEY id name. TYPES:tt_books TYPE HASHED TABLE OF sbook WITH UNIQUE KEY carry connid fldate bookid. TYPES: wa_books TYPE LINE OF tt_books. "Define mesh TYPES: BEGIN OF MESH m_custom_books, customers TYPE tt_customers ASSOCIATION _sbook TO books ON customid = id, books TYPE tt_books ASSOCIATION _scutomer TO customers ON id = customid, END OF MESH m_custom_books. "You can also define multiple keys "SORT, the UNIQUE KEY of HASH must be specified TYPES:tt_scarr TYPE HASHED TABLE OF scarr WITH UNIQUE KEY carry. TYPES: tt_spfli TYPE HASHED TABLE OF spfli WITH UNIQUE KEY carry connid WITH NON-UNIQUE SORTED KEY k_sort_spfli COMPONENTS carry. TYPES:tt_sflight TYPE HASHED TABLE OF sflight WITH UNIQUE KEY carried connid fldate WITH NON-UNIQUE SORTED KEY k_sort_sflight COMPONENTS carry connid. TYPES:tt_sairport TYPE HASHED TABLE OF sairport WITH UNIQUE KEY id. "Define mesh TYPES: BEGIN OF MESH m_flights_info, scarrs TYPE tt_scarr ASSOCIATION_spfli TO spflis ON carrid = carrid USING KEY k_sort_spfli, spflis TYPE tt_spfli " and sflight direct association ASSOCIATION_sflight TO sflights ON carrid = carrid AND connid = connid USING KEY k_sort_sflight Association between " and airport ASSOCIATION _sairport TO sairports ON id = airpto, "USING KEY primary_key, sflights TYPE tt_sflight, sairports TYPE tt_sairport, END OF MESH m_flights_info. "pointer mode DATA:lm_custom_books3_ref TYPE REF TO DATA. FIELD-SYMBOLS:<fs_custom_books> TYPE m_custom_books. "Create mesh object "Method 1 DATA: lm_custom_books TYPE m_custom_books. DATA: lm_flights_info TYPE m_flights_info. ASSIGN lm_custom_books TO <fs_custom_books>. "Method 2 DATA(lm_custom_books2) = NEW m_custom_books( ). DATA(lm_custom_books2_ref) = NEW m_custom_books( VALUE m_custom_books( ) ). lm_custom_books3_ref = REF #( lm_custom_books2 ). "Fill the mesh data, so too much data will also have a memory limit? SELECT * FROM scustom INTO TABLE lm_custom_books-customers. SELECT * FROM sbook INTO TABLE @lm_custom_books-books. SELECT * FROM scarr INTO TABLE @lm_flights_info-scarrs. SELECT * FROM spfli INTO TABLE @lm_flights_info-spflis. SELECT * FROM sflight INTO TABLE @lm_flights_info-sflights. SELECT * FROM sairport INTO TABLE @lm_flights_info-sairports. "Forward and reverse data access "Forward associations, root node as the start node; "Reverse Inverse associations, root node as the end node; "forward data access "cutomers\_sbook "lt_result1 data type is consistent with the last association corresponding table "Query the book table information according to the customer table "lm_custom_books-customers\_sbook IF line_exists( lm_custom_books-customers\_sbook[ lm_custom_books-customers[ id = '00001134' ] ] ). DATA(lt_result1) = VALUE tt_books( ( lm_custom_books-customers\_sbook[ lm_custom_books-customers[ id = '00001134' ] ] ) ). " output shows LOOP AT lt_result1 ASSIGNING FIELD-SYMBOL(<fs_result1>). WRITE:/ 'result1:',<fs_result1>-passname,<fs_result1>-order_date. ENDLOOP. ENDIF. "Reverse Data Access "lt_result2 data type is consistent with the table type after ~ "Query customer information based on book table information "lm_custom_books-books\^_sbook~customers IF line_exists( lm_custom_books-books\^_sbook~customers[ lm_custom_books-books[ customid = '00001134' ] ] ). DATA(lt_result2) = VALUE tt_customers( ( lm_custom_books-books\^_sbook~customers[ lm_custom_books-books[ customid = '00001134' ] ] ) ). " output shows LOOP AT lt_result2 ASSIGNING FIELD-SYMBOL(<fs_result2>). WRITE:/ 'result2:',<fs_result2>-name,<fs_result2>-city. ENDLOOP. ENDIF. "Query book information based on customer table information "lm_custom_books-customers\^_scutomer~books IF line_exists( lm_custom_books-customers\^_scutomer~books[ lm_custom_books-customers[ id = '00001134' ] ] ). Use () in "VALUE to return the table type, "Note: If multiple records are matched, only a single record will be returned! DATA(lt_result3) = VALUE tt_books( ( lm_custom_books-customers\^_scutomer~books[ lm_custom_books-customers[ id = '00001134' ] ] ) ). "VALUE does not use (), means to return to the work area, a single record DATA(lt_result4) = VALUE wa_books( lm_custom_books-customers\^_scutomer~books[ lm_custom_books-customers[ id = '00001134' ] ] ). ENDIF. LOOP AT lt_result3 ASSIGNING FIELD-SYMBOL(<fs_result3>). WRITE:/ 'result3:',<fs_result3>-passname,<fs_result3>-order_date. ENDLOOP. WRITE:/ 'result4:',lt_result4-passname,lt_result4-order_date. "Multi-level forward association "lm_flights_info-scarrs\_spfli[]\_sflight[ ] IF line_exists( lm_flights_info-scarrs\_spfli[ lm_flights_info-scarrs[ carrid = 'AA' ] ]\_sflight[ ] ). "There are multiple sflight records, only a single one is returned DATA(lt_result5) = VALUE tt_sflight( ( lm_flights_info-scarrs\_spfli[ lm_flights_info-scarrs[ carrid = 'AA' ] ]\_sflight[ ] ) ). "Return multiple records DATA(lt_result6) = VALUE tt_sflight( FOR <fs_result6> IN lm_flights_info-scarrs\_spfli[ lm_flights_info-scarrs[ carrid = 'AA' ] ]\_sflight[ ] ( <fs_result6> ) ). ENDIF. LOOP AT lt_result5 ASSIGNING FIELD-SYMBOL(<fs_result5>). WRITE:/ 'result5:',<fs_result5>-carrid,<fs_result5>-connid,<fs_result5>-fldate. ENDLOOP. "Because the above <fs_result6> has been defined and used, "The field symbol(<fs_result6>) cannot be used here "Can't use fs_result6 directly? "LOOP AT lt_result6 ASSIGNING FIELD-SYMBOL(<fs_result6>). "LOOP AT lt_result6 ASSIGNING <fs_result6>. LOOP AT lt_result6 ASSIGNING FIELD-SYMBOL(<fs_result61>). WRITE:/ 'result6:',<fs_result61>-carrid,<fs_result61>-connid,<fs_result61>-fldate. ENDLOOP. "Multi-level reverse association "lm_flights_info-sflights\^_sflight~spflis[]\^_spfli~scarrs[] IF line_exists( lm_flights_info-sflights\^_sflight~spflis[ lm_flights_info-sflights[ carrid = 'AA' ] ]\^_spfli~scarrs[ ] ). DATA(lt_result7) = VALUE tt_scarr( FOR <fs_result7> IN lm_flights_info-sflights\^_sflight~spflis[ lm_flights_info-sflights[ carrid = 'AA' ] ]\^_spfli~scarrs[ ] ( <fs_result7> ) ). "Save the result using field symbol "Note: The return here is the workspace type ASSIGN lm_flights_info-sflights\^_sflight~spflis[ lm_flights_info-sflights[ carrid = 'AA' ] ]\^_spfli~scarrs[ ] TO FIELD-SYMBOL(<fs_result72>). ENDIF. LOOP AT lt_result7 ASSIGNING FIELD-SYMBOL(<fs_result71>). WRITE:/ 'result7:',<fs_result71>-carrid,<fs_result71>-carrname,<fs_result71>-url. ENDLOOP. WRITE:/ 'result72:',<fs_result72>-carrid,<fs_result72>-carrname,<fs_result72>-url. "Loop AT statement "LOOP AT mesh_path result. "... "ENDLOOP. LOOP AT lm_flights_info-spflis\_sflight[ lm_flights_info-spflis[ carrid = 'AA' connid = '0064' ] WHERE fldate = '20220423' "AND currency = 'USD' ] INTO DATA(ls_sflight). WRITE:/ 'Loop at:', ls_sflight-connid, ls_sflight-fldate, ls_sflight-price. ENDLOOP. "Notice: "lm_flights_info-spflis[carrid = 'AA'] "table:spfli has two matching records, connid = '0017' or '0064' "But only the first data will be returned carrid = 'AA' connid = '0017' "Then the additional condition WHERE connid = '0064' will not return any records; LOOP AT lm_flights_info-spflis\_sflight[ lm_flights_info-spflis[ carrid = 'AA' connid = '0064' ] "lm_flights_info-spflis[carrid = 'AA'] "WHERE connid = '0064' ] INTO DATA(ls_sflight1). WRITE:/ 'Loop at1:',ls_sflight1-connid,ls_sflight1-fldate,ls_sflight1-price. ENDLOOP. "lm_flights_info-scarrs\_spfli[]\_sairport[] LOOP AT lm_flights_info-scarrs\_spfli[ lm_flights_info-scarrs[ carrname = 'Alitalia' ] WHERE countryto = 'JP' ]\_sairport[ USING KEY primary_key ] INTO DATA(ls_sairport). "INTO DATA(ls_spfli). WRITE:/ 'Loop at2:',ls_sairport-id,ls_sairport-name. "WRITE:/ 'Loop at2:',ls_spfli-carrid,ls_spfli-connid. ENDLOOP. "FOR IN statement "FOR wa|<fs> IN mesh_path [let_exp] DATA: lt_sflights TYPE tt_sflight. lt_sflights = VALUE tt_sflight( FOR ls_sflights IN lm_flights_info-scarrs\_spfli[ lm_flights_info-scarrs[ carrname = 'American Airlines' ] ]\_sflight[ ] ( ls_sflights ) ). " output result LOOP AT lt_sflights INTO DATA(ls_sflights2). WRITE:/ 'FOR IN:',ls_sflights2-carrid,ls_sflights2-connid,ls_sflights2-fldate. ENDLOOP. "combined with REDUCE summary DATA(lv_sum) = REDUCE sflight-paymentsum( INIT v_sum TYPE sflight-paymentsum FOR ls_sflights3 IN lm_flights_info-scarrs\_spfli[ lm_flights_info-scarrs[ carrname = 'American Airlines' ] ]\_sflight[ ] NEXT v_sum = v_sum + ls_sflights3-paymentsum ). WRITE:/ 'FOR IN2:',lv_sum. "Define mesh TYPES: BEGIN OF s_line1, id TYPE i, desc TYPE string, END OF s_line1. TYPES: BEGIN OF s_line2, id TYPE i, name TYPE string, desc TYPE string, END OF s_line2. TYPES:tt_line1 TYPE SORTED TABLE OF s_line1 WITH NON-UNIQUE KEY id. TYPES:tt_line2 TYPE SORTED TABLE OF s_line2 WITH NON-UNIQUE KEY id WITH NON-UNIQUE SORTED KEY k_1 COMPONENTS id name. TYPES: BEGIN OF MESH m_line, line1 TYPE tt_line1 ASSOCIATION_line2 TO line2 ON id = id, line2 TYPE tt_line2, END OF MESH m_line. "INSERT statement "INSERT line_spec INTO TABLE mesh_path result. "When inserting, if the UNIQUE Key cannot insert duplicate values DATA: lm_line TYPE m_line. lm_line-line1 = VALUE #( ( id = 1 desc = 'line11' ) ( id = 2 desc = 'line12' ) ( id = 3 desc = 'line13' ) ). lm_line-line2 = VALUE #( ( id = 1 desc = 'line21' ) ( id = 2 desc = 'line22' ) ( id = 2 desc = 'line222' ) ). INSERT VALUE s_line1( desc = 'line14' ) INTO TABLE lm_line-line1. INSERT LINES OF VALUE tt_line1( ( id = 5 desc = 'line15' ) ( desc = 'line16' ) ) INTO TABLE lm_line-line1. INSERT INITIAL LINE INTO TABLE lm_line-line1. DATA: ls_line1 LIKE LINE OF lm_line-line1. LOOP AT lm_line-line1 INTO ls_line1. WRITE:/ 'Insert:', ls_line1-id, ls_line1-desc. ENDLOOP. INSERT VALUE s_line2( name = 'name1' desc = 'line24' ) INTO TABLE lm_line-line1\_line2[ lm_line-line1[ 1 ] ]. DATA: ls_line2 LIKE LINE OF lm_line-line2. LOOP AT lm_line-line2 INTO ls_line2. WRITE:/ 'Insert:', ls_line2-id, ls_line2-name, ls_line2-desc. ENDLOOP. "Modify statement "MODIFY { TABLE mesh_path [USING KEY keyname] FROM wa " [TRANSPORTING comp1 comp2 ...] result } " | { mesh_path FROM wa [TRANSPORTING comp1 comp2 ...] }. "MODIFY TABLE only modifies a single transaction that meets the conditions MODIFY TABLE lm_line-line1\_line2[ lm_line-line1[id=2]] FROM VALUE s_line2( name = 'modify1' desc = 'line66' ). MODIFY TABLE lm_line-line1\_line2[ lm_line-line1[id=0]] FROM VALUE s_line2( name = 'modify2' ) TRANSPORTING name. " output shows LOOP AT lm_line-line2 INTO ls_line2. WRITE:/ 'Modify:', ls_line2-id, ls_line2-name, ls_line2-desc. ENDLOOP. "MODIFY modify multiple items that meet the conditions MODIFY lm_line-line1\_line2[ lm_line-line1[id=2]] FROM VALUE s_line2( name = 'modify multi' ) TRANSPORTING name. " output shows LOOP AT lm_line-line2 INTO ls_line2. WRITE:/ 'Modify:', ls_line2-id, ls_line2-name, ls_line2-desc. ENDLOOP. "Delete statement "DELETE { TABLE mesh_path table_key } | { mesh_path }. * "Delete a single record * "1. Delete the 4th line in line1 with id=1 corresponding to the single line of data with id=1 in line2 * DELETE TABLE lm_line-line1\_line2[ * lm_line-line1[ 4 ] ]. * " output display * LOOP AT lm_line-line2 INTO ls_line2. * WRITE:/ 'DELETE:', ls_line2-id, ls_line2-name, ls_line2-desc. * ENDLOOP. * "2. Use TABLE KEY to delete * DELETE TABLE lm_line-line1\_line2[ *lm_line-line1[5]] * WITH TABLE KEY k_1 COMPONENTS name = 'modify multi'. * " output display * LOOP AT lm_line-line2 INTO ls_line2. * WRITE:/ 'DELETE1:',ls_line2-id,ls_line2-name,ls_line2-desc. * ENDLOOP. * "3. Use VALUE to specify the row field value to delete * DELETE TABLE lm_line-line1\_line2[ *lm_line-line1[5]] * FROM VALUE s_line2( name = 'modify multi' ) * USING KEY k_1. "Delete multiple records "1.line1 line 5 id = 2, delete all id=2 records in line2 * DELETE lm_line-line1\_line2[ * lm_line-line1[ 5 ] ]. "2.where condition delete DELETE lm_line-line1\_line2[ lm_line-line1[ 5 ] WHERE desc = 'line22' ]. "Determine whether the deletion is successful through sy-subrc IF sy-subrc = 0. WRITE:/ 'delete success'. ELSE. WRITE:/ 'delete failed'. ENDIF. "Define mesh TYPES: BEGIN OF s_1, col1 TYPE i, col2 TYPE i, END OF s_1. TYPES: BEGIN OF s_2, col1 TYPE i, col2 TYPE i, col3 TYPE i, col4 TYPE i, END OF s_2. TYPES: BEGIN OF s_3, col3 TYPE i, col4 TYPE i, END OF s_3. TYPES:tt_1 TYPE SORTED TABLE OF s_1 WITH NON-UNIQUE KEY col1 col2. TYPES:tt_2 TYPE SORTED TABLE OF s_2 WITH NON-UNIQUE KEY col1 col2. TYPES:tt_3 TYPE SORTED TABLE OF s_3 WITH NON-UNIQUE KEY col3. TYPES: BEGIN OF MESH m_1, t1 TYPE tt_1 ASSOCIATION _t2 TO t2 ON col1 = col1 AND col2 = col2, t2 TYPE tt_2 ASSOCIATION _t3 TO t3 ON col3 = col3 AND col4 = col4, t3 TYPE tt_3, END OF MESH m_1. "SET ASSOCIATION STATEMENT "SET ASSOCIATION mesh_path { = wa } | { LIKE wa } | { INITIAL }. " will only assign the domain value corresponding to the association to the corresponding field of the pre-table "If col4 is not in the association condition, the value will not be written DATA: lm_1 TYPE m_1. lm_1-t1 = VALUE #( ( col1 = 1 col2 = 11 ) ( col1 = 2 col2 = 12 ) ). lm_1-t2 = VALUE #( ( col1 = 1 col2 = 11 ) ( col1 = 2 col2 = 222 ) ). lm_1-t3 = VALUE #( ( col3 = 31 col4 = 331 ) ( col3 = 32 col4 = 332 ) ). "set association "Method 1: Set col3 and col4 of t2 according to assiciation:_t3 "The setting of this sentence is unsuccessful? "Can only be used when initializing the setting value and then needing to bring out the association value? "DATA(ls_2) = VALUE s_2( col1 = 1 col2 = 11 ). "SET ASSOCIATION lm_1-t2\_t3[ ls_2 ] = lm_1-t3[ 2 ]. INSERT INITIAL LINE INTO TABLE lm_1-t1\_t2[ VALUE s_1( col1 = 1 col2 = 12 ) ] ASSIGNING FIELD-SYMBOL(<line2>). SET ASSOCIATION lm_1-t2\_t3[ <line2> ] = lm_1-t3[ 1 ]. "Method 2: Start from node 1 to achieve the same effect "Set col3 and col4 of t2 according to assiciation:_t3 SET ASSOCIATION lm_1-t1\_t2[ VALUE s_1( col1 = 1 col2 = 11 ) ]\_t3[ ] = lm_1-t3[ 2 ]. "SET ASSOCIATION mesh_path LIKE w INSERT INITIAL LINE INTO TABLE lm_1-t1\_t2[ VALUE s_1( col1 = 1 col2 = 13 ) ] ASSIGNING FIELD-SYMBOL(<line22>). SET ASSOCIATION lm_1-t2\_t3[ <line22> ] LIKE VALUE s_2( col3 = 333 col4 = 3334 ). ENDFORM.