본문 바로가기

SAP SCRIPT,SKILL

like type 차이

TYPE과 LIKE 차이


TYPE 은 ABAP Dictionary 에 있는 Global Type -


(Data Element, Structure Type, Table Type)을 참조하여 Data Object 를 선언할 때 사용,


 

LIKE 는 프로그램 내에 이미 선언된 Data Object -


(Variable, Structure, Internal Table)를 참조하여 동일한 형태의 Data Object 를 만드는 방법.



like table of , like 차이 

LIKE TABLE OF 는 헤더를 가지고있는 인터널테이블입니다.(internal table)  -> 여러개의 행을 가질 수있따


LIKE 만 썼을경우는 헤더가 없는 하나의 레코드만을 가지는 테이블입니다.(structure) 한행




  DATAlv_itab TYPE  zrfc_register,
            lt_str LIKE TABLE OF lv_itab
.


loop lt_str at lv_itab.


endloop.





-출처 sap-joy-


DATA - TYPE, LIKE 


Syntax


DATA var { {TYPE [LINE OF] type} 
         | {LIKE [LINE OF] dobj} } 
         [VALUE  val|{IS INITIAL}] 
         [READ-ONLY]. 


Effect


In the specification of a data type type or a data object dobj, the data type of the variable var is already fully defined before the declaration. The syntax and meaning of the additions TYPE and LIKE has exactly the same meaning as the definition of data types with TYPES, except that for DATA after TYPE a standard table type with a generic table key can be specified. In this case, a bound table type with a standard key is created.



Prior to Release 6.10, no VALUE addition was possible if the data type deep, specified using TYPE or LIKE, was a string, a reference type, a table type, or a structured type with deep components. As of Release 6.10, the VALUE addition can also be used for deep data types; however, with the limitation that a start value val can only be specified for the ABAP type string, and otherwise only IS INITIAL


Example



These statements define two data objects, both of which have the same data type as the database table spfli.


DATA: spfli_wa1 TYPE spfli, 
      spfli_wa2 LIKE spfli_wa1.