What is the difference between like and similar string in ABAP?

I have one doubt. Can I find out what is the difference between LIKE and LIKE LINE OF in ABAP? I saw somewhere that when they announce a workspace, they announce.

 wa LIKE it_one wa LIKE LINE OF it_one 
+6
source share
2 answers

LIKE LINE OF means that the variable will be of the table row type.

LIKE means that the variable will be exactly the same as the seat after this keyword.

Example

 TYPES: BEGIN OF t_my_example_structure, my_example_field1 TYPE i, my_example_field2 TYPE n, END OF t_my_example_structure. TYPES tt_my_example_structure TYPE STANDARD TABLE OF t_my_example_structure. DATA: l_tab_my_example TYPE tt_my_example_structure. * has structure of row of l_tab_my_example so in this case t_my_example_structure. DATA: l_str_my_example LIKE LINE OF l_tab_my_example. * is exactly the same table type as l_tab_my_example so in this case tt_my_example_structure. DATA: l_tab_like_my_example LIKE l_tab_my_example. * I use it often for LOOP AT <tab> ASSIGNING <fs>. FIELD-SYMBOLS: <fs_str_my_example> LIKE LINE OF l_tab_my_example. 
+4
source

Well, the difference is that you pass the table to the routine using USING or TABLES.

In the first case, you get a table without , so WA_LIKE will also be a table.

In the second case, IT_DATA will be a table with a heading : this calls IT_DATA actually means IT_DATA as a structure or IT_DATA[] as a table, depending on the context. Particulary, DATA ... LIKE IT_DATA will refer to the header, not the entire internal table.

You can verify this with the debugger:

 DATA T_DATA TYPE STRING_TABLE. PERFORM TEST_01 USING T_DATA. PERFORM TEST_02 TABLES T_DATA. FORM TEST_01 USING IT_DATA TYPE STRING_TABLE. DATA : WA_LIKE LIKE IT_DATA "This is a Table , WA_LINE LIKE LINE OF IT_DATA. BREAK-POINT. ENDFORM. FORM TEST_02 TABLES IT_DATA TYPE STRING_TABLE. DATA : WA_LIKE LIKE IT_DATA "This is a String , WA_LINE LIKE LINE OF IT_DATA. BREAK-POINT. ENDFORM. 
+1
source

Source: https://habr.com/ru/post/972745/


All Articles