SAP ABAP/기본

Structures Variable (스트럭쳐 타입)

물꼬_ 2025. 1. 26. 23:27

 Structures Variable

📍 글로벌 정의_Definition of Structures with Global Types

 

1️⃣ Structure Data의 데이터 타입은 Structure Type이다.

2️⃣ Structure Type은 여러 필드(Field)로 구성되며, 각 필드를 Component(컴포넌트)라고 부른다.

3️⃣ gs_flight 변수는 6개의 컴포넌트를 가지고 있으며, 각각의 컴포넌트에는 고유한 데이터를 저장할 수 있다.

 

 

 

사용자가 보고 있는 사진은 BC400_S_FLIGHT의 구성 필드(Component)들을 보여주는 화면이다.

 


📍 로컬 정의_Definition of Structures with Local Types

 

 

1️⃣ Local Structure Type의 변수명은 TS_로 시작하며, 여러 컴포넌트(Component)로 구성된 데이터 형식이다.

2️⃣ Elements Type의 변수명은 TV_로 시작하며, 단일 필드로 구성된 데이터 형식이다.

3️⃣ 사용자가 언급한 변수는 5개의 Components를 포함하고 있으며, 각 컴포넌트는 고유한 데이터 필드를 의미한다.

 


📍 컴포넌트 접근_Access to Structure Components


🔹 1. Structure Variable의 Component Access 방식

Structure Type 변수 안에 있는 Component(필드)에 접근하기 위해서는 다음과 같은 표기법을 사용한다.

➡️ 표기법:

Structure Variable Name - Component Name

➡️ 예시 코드:

gs_flight-carrid = 'AA'.      "항공사 코드 필드에 값 할당
gs_flight-connid = '0017'.    "항공편 번호 필드에 값 할당
gs_flight-flightdate = '2025-01-01'.  "비행 날짜 필드에 값 할당


🔹 2. Access 방식 설명

  • Structure Variable Name: Structure Type 변수의 이름
  • Component Name: 해당 변수 안에 있는 필드 이름

➡️ 구성 예시

Structure Variable Component Name Value
gs_flight carrid AA
gs_flight connid 0017
gs_flight flightdate 2025-01-01

🔹 3. 데이터 조회 및 출력 예시

WRITE: / gs_flight-carrid,    "항공사 코드 출력
       / gs_flight-connid,    "항공편 번호 출력
       / gs_flight-flightdate. "비행 날짜 출력


🔹 핵심 요약

1️⃣ Structure Variable 안의 Component에 접근하려면 Structure Variable Name - Component Name 형식으로 사용한다.

2️⃣ 이 방식은 Component에 값 할당하거나, 데이터를 조회 및 출력할 때 사용된다.

3️⃣ 예시:

gs_flight-carrid = 'AA'.
WRITE: / gs_flight-carrid.

 


📍 데이터 복사_Copies of Structure Components with the Same Name

 

MOVE-CORRESPONDING TO

기존에 있는 Structured variable 데이터를 다른 변수에 할당할 때 쓰는 구문이다.

 


📍 디버깅 모드_Structures in Debugging Mode

 

1️⃣ Program Debugging Mode에서 Structured Variable을 더블클릭하면 할당된 Components를 확인할 수 있다.

2️⃣ Change 버튼을 누르면 Value(값) 변경이 가능하다.

3️⃣ 변경한 값은 Debugging Mode에서 즉시 적용되며, 프로그램 실행 중 데이터에 영향을 미친다.