메뉴 건너뛰기

SAP 한국 커뮤니티

LIKE와 TYPE의 차이

sapjoy 2006.12.06 09:19 조회 수 : 19705 추천:44

*결론은 큰 차이가 없으나, OO 개념에서는 LIK만 지원된다.
예를 들어 ALV에서 인터널 테이블을 TYPE으로 선언하면
필드 카탈로그가 작동하지 않는다.

For all practical purposes there are the same. The only additional advantage with types is that you can define your own types(including complex ones) in the data dictionary and reuse them accross various programs.

But within a program if two variables are defined one using LIKE and another using TYPE, both referring to the same field, then there is no difference.

If I include a type pool within a program, then I can define my variables only using TYPE to refer to any type defined in that pool. I cannot use LIKE in this scenario. Also, if I want to use native types like C, N, etc, I cannot use LIKE there either. I can use LIKE ABC only if ABC is in the database or if ABC is defined previously in the same program.

I can use TYPE ABC, if ABC is defined in database as a TYPE and included in the program with the statement TYPE-POOLS. I can use it, if it is the native types. I can use it, if it is already defined in the dictionary as a structure/table or structure/table field, or even if it is defined as a data element or a domain. So I can declare a variable V_BUKRS TYPE BUKRS, but I cannot define a variable V_BUKRS LIKE BUKRS.

But if I intend to use V_BUKRS to store company code, I will prefer to declare it as V_BUKRS LIKE T001-BUKRS, only because if tomorrow for some reason, the definition of T001-BUKRS changes to a data element for example, BUKRS_N(say DEC 4) instead of the data element BUKRS(CHAR 4) that it refers to now, I don't have to change my programs because I am referring to the table field and inhereting its properties. Whereas, had I declared my V_BUKRS TYPE BUKRS and the table now changed to BUKRS_N, I will be forced to change my program as there will be a type incompatability.
번호 제목 글쓴이 날짜 조회 수
547 ABAP TUNNING sapjoy 2012.03.12 234722
546 New function vs Old function(obsolete) sapjoy 2014.03.31 127562
545 테이블Active시 (Warnings Occurred During Activation) 안나오게하는방법 [6] 양키 2012.03.29 99696
544 자주 사용하는 String 조작 명령어 [7] 양키(이경환) 2015.01.13 34650
543 collect 구문 [4] sapjoy 2006.12.03 27029
542 사용자 패스워드 변경 함수, 창 [11] sapjoy 2009.12.21 25768
541 R/3 용어 정의 Definitions [4] sapjoy 2007.01.23 23898
540 BAPI_PR_CREATE 구매요청 생성시에 사용하세요 [2] 노름마치 2007.12.10 23697
539 SELECT statement D.Y.Kim 2007.07.20 23646
538 문자열에 있는 값이 숫자만으로 되어있는지 문자가 포함됐는지 체크하는 함수 [3] 꿀단지 2011.10.11 19881
» LIKE와 TYPE의 차이 [13] sapjoy 2006.12.06 19705
536 숫자입력 체크(Numeric character check) [1] 양키(이경환) 2014.01.28 19584
535 SDN -> SCN 변경되면서 Contents별로 바뀐 LINK 모음 [13] Wise 멘토 2012.07.06 19045
534 ABAP 핵심정리 [23] SARA 2007.03.14 17332
533 ALV LIST 진행시 LAYOUT 속성값 [18] kwon09 2007.04.11 17308
532 ABAP 구문 총정리 [39] file Wise 멘토 2008.11.24 17152
531 인터널 테이블 라인수 lines [8] sapjoy 2014.01.20 17117
530 FOR ALL ENTRIES IN 구문 사용시 select 필드 선택시 주의사항. [7] 나침반친구 2007.03.13 16974
529 SYST 시스템 변수 정리 [5] 아밥뽀 2014.08.23 16928
528 프로그램 정보(프로그램 리스트, PROGRAM LIST, PROGRAM TABLE) [3] sapjoy 2007.02.23 16728