티스토리 뷰

03 ) 시스템 변수


본 게시물은 SAP 혁신성장 청년인재 양성과정에서 교육받는 교육생이 정리 목적으로 포스팅하는 것으로,

전문성 및 실용성이 다소 떨어지거나 정보가 부정확 할 수 있으니 참고 목적으로만 읽어주시기 바랍니다.

 

 

시스템 변수

 

 시스템 변수란 ABAP 프로그램에서 제공되는 변수로, 프로그램 안에서 처리되는 프로세스 혹은 발생되는 이벤트에 대한 내역을 값으로 담고 있는 변수를 말한다.  시스템 변수에는 프로그램 및 트랜잭션의 내역을 담고 있거나, 세션이나 날짜, 시간, 메세지 제어, 리스트 프로세싱 등 다양한 시스템적인 요소를 담고 있다. 시스템적인 요소들은 프로그래밍을 하는데 있어 꼭 필요하고 유용하기 때문에 이번 파트에서는 유용하고 자주쓰이는 시스템 변수들을 잠시 알아가는 시간을 가져보도록 하겠다.

 

 

 

시스템변수 직접 살펴보기

 

 시스템변수는 Data Dictionary (SE11) 테이블 'SYST' 에서 참고할 수 있다.

 

SYST 테이블에서 시스템 변수의 설명과 타입들이 나와있으니 참고바란다.

 

 테이블 안의 컴포넌트 값에 'SY-'를 앞에 붙이면 해당 값들을 참조할 수 있다. (ex. SY-INDEX)

 

 

더 자세히 살펴보고싶으면 ABAP HELP (Ctrl + F8) "System Fields" 를 검색하여 찾아볼 수 있다.

 

 


 

 여기서는 자주 쓰이고 유용한 시스템변수 몇 개만 살펴보고 넘어가도록 하겠다. 자주 쓰이는 만큼 외워두면 편리하다.

 

SY-SUBRC

 - SELECT, READ, LOOP 문에서의 성공 여부를 체크한다. 예외처리에서 많이 쓰이며  SY-SUBRC 값이 0이면 성공이고 이 외의 값은 실패이다. 값이 4이면 NOT FOUND, 이 외의 값은 EXCEPTIONS 에서 지정해 줄 수 있다.

 

SY-INDEX

 - LOOP 안에서 현재 수행되는 인덱스의 값을 알려주는 시스템 변수이다. 첫 번째 실행에서 1의 값을 가진다.

 이중 이상의 LOOP 구조일 경우 SY-INDEX 값은 해당 루프 안의 인덱스 값을 가진다. (보통 프로그래밍 언어의 이중 루프문에서 i와 j를 생각하면 쉽다.)

 

SY-DATUM

 - 현재 시스템의 DATE 값을 가져온다. (TYPE : D)

 

SY-UZEIT

 - 현재 시스템의 TIME 값을 가져온다. (TYPE : T)

 

SY-UNAME

 - 현재 로그인한 ID값을 가져온다.

 

SY-TCODE

 - 현재 프로그램의 트랜잭션 코드를 가져온다.

 

SY-TABIX

 - Internal Table의 현재 행의 Index값을 참조한다.

 

SY-UCOMM

 - 메뉴에서 선택된 명령버튼(ICON)의 FUNCTION CODE를 참조한다.

 

SY-DBCNT

 - DB에서 쿼리에 응답된 전체 행의 개수(ROW)의 값을 가진다.

 

SY-PAGNO

 -  리스트에서 현재 페이지 값을 가져온다.

 

SY-LSIND

 - 수행되는 WINDOW 리스트의 LEVEL INDEX를 가져온다.

 

SY-CPAGE

 - 현재 표시된 화면의 PAGE 번호를 가져온다.

 

SY-STARO

 - 현재 표시된 화면에 있는 첫 번째 ROW 를 가져온다.

 

SY-STACO

 - 현재 표시된 화면에 있는 첫 번째 COLUMN을 가져온다.

 

 

 

 


 

이하는 다른 분이 정리한 시스템 변수들을 발췌해 놓은 표이다. (출처 : https://m.cafe.daum.net/proskill/Pffg/124)

 

Common

SY-SUBRC

X(4)

Return code. 0 : OK

 

Program and Transaction

SY-REPID

C(8)

Program : Name of ABAP/4 program

SY-CPROG

C(8)

Runtime : Main program

SY-TCODE

C(4)

Session : Current transaction code

SY-SLSET

C(14)

Name of selection set (variant)

SY-BATCH

C(1)

‘X’ à Background active (transaction is running in a batch environment in background mode)

SY-BINPT

C(1)

'X' => Batch Input (Background or Foreground) active, that is transaction is not called by online user.

SY-CALLD

C(1)

'X' => Call Mode Active (transaction is called from another transaction).

SY-DYNNR

C(4)

Number of current screen.

SY-DATAR

C(1)

Flag: Data Received. That is user has modified or entered new data on the screen (can by used in PAI for user actions analysis).

 

Session

SY-LANGU

C(1)

Sap logon language key

SY-UNAME

C(12)

Session : SAP user from SAP logon.

SY-HOST

C(8)

Host

SY-SAPRL

C(4)

R/3 System, system release.

SY-SYSID

C(8)

R/3 System, system Id.

 

Date and Time

SY-DATUM

D

System: Date. YYYYMMDD. (Application Server)

SY-UZEIT

T

System: Time. HHMMSS. (Application Server)

SY-DATLO

D

Local date of user

SY-TIMLO

D

Local time of user

SY-ZONLO

D

Time zone of user

SY-FDAYW

X(1)

Factory Calendar Date: Number of week day.

 

Character String Processing

SY-FDPOS

C(4)

Comparisons with Character Strings and Numeric Strings: Offset or string length.

SEARCH string statement: Offset of found substring.

SEARCH internal table statement: Offset of found substring in the table line.

 

 

Messages Handling

SY-MSGID

C(2)

Message Id.

SY-MSGTY

C(1)

Message Type

SY-MSGNO

N(3)

Message Number.

SY-MSGV1…

SY-MSGV4

C(50)

Message Variables.

SY-MSGLI

C(60)

Message Line. If after calling a method of an OLE2 Object sy-subrc=1 (that is system error occured while communicating with the presentation server), then this field should contain short description of the error.

 

Lists Processing – Current parameters of the report

SY-LINSZ

X(4)

Current line size of the report. (한 페이지의 가로 길이. Report문의 LINE-SIZE에서 지정한 컬럼 수)

SY-LINCT

X(4)

Current page length of the report (한 페이지마다의 라인 수. Report문의 LINE-COUNT에서 지정한 라인 수)

SY-VLINE

C(1)

Current vertical line character (‘|’)

SY-ULINE

C(255)

Current horizontal line characters (‘-…-‘)

SY-TVAR0…

SY-TVAR9

C(20)

Current placeholders in the list header (usually &0…$9)

Lists Processing – Parameters of the current window

SY-SCOLS

X(4)

Line size of the current window. (현재 페이지의 컬럼 수)

SY-SROWS

X(4)

Number of lines in the current window. (현재 페이지의 라인 수)

List Processing – List Status

SY-TITLE

C(70)

Title of the current list. (Window의 title bar에 보여지는 제목)

SY-PFKEY

C(8)

F key status of the displayed list.

SY-LSIND

X(4)

Index of list created by current event (basic list = 0, 1st details list = 1, …). (현재 출력 화면의 Detail Depth – 화면을 display할 때마다 1씩 증가)

List Processing – Information about the list from which the event was triggered

SY-LISTI

X(4)

Index of the list level from which the event was triggered (index of this list). Usually SY-LSIND – 1.

SY-UCOMM

C(70)

Function code that triggered the event.

SY-LILLI

X(4)

Absolute number in the displayed list of the line from which the event was triggered. (화면상에서 선택된 라인 index)

SY-LISEL

C(255)

Contents of the line from which the event was triggered. (화면상에서 선택된 라인의 내용)

SY-CUROW

X(4)

Position of the line in the WINDOW from which the event was triggered (counting starts with 1). (화면상에서 마지막 커서가 위치한 라인 index)

SY-CUCOL

X(4)

Position of the column in the WINDOW from which the event was triggered (counting starts with 2). (화면상에서 마지막 커서가 위치한 컬럼 index)

SY-CPAGE

X(4)

Page number of the 1st displayed page of the list from which the event was triggered. (사용자가 화면을 조작할 때 화면 최상단의 페이지 번호, 현재 화면상의 페이지 번호)

SY-STARO

X(4)

Number of the 1st line of the 1st page displayed of the list from which the event was triggered (counting starts with 1). Possibly, a page header occupies this line.

SY-STACO

X(4)

Number of the 1st column displayed in the list from which the event was triggered (counting starts with 1).

List Processing – Current output position

SY-PAGNO

X(4)

Current page number. 화면에 리스트를 생성할 때 현재 페이지 번호

SY-LINNO

X(4)

Line number on the current page of the current output position.

SY-COLNO

X(4)

Column of the current output position.

 

Internal Tables Processing : After DESCRIBE TABLE, LOOP AT, and READ TABLE

SY-TABIX

X(4)

Current index (after APPEND, COLLECT, READ TABLE operations, while LOOP processing).

SY-FDPOS

X(4)

SEARCH internal table statement: Offset of found substring in the table line.

SY-TFILL

X(4)

Current number of lines

SY-TLENG

X(4)

Current length of lines

SY-TOCCU

X(4)

Initial main memory allocated to the internal table

 

Loops Processing

SY-INDEX

X(4)

Current index (in DO, WHILE blocks).

 

Open SQL

SY-DBCNT

X(4)

Number of lines affected or already been processed by the SQL operation. (테이블에서 데이터를 select하고 난 후 select된 데이터 건수)

 

Screens Processing

SY-STEPL

X(4)

Index of the screen table row that is currently being processed. Has a meaning only inside LOOP...ENDLOOP (looping through currently displayed rows of screen table and calling PBO/PAI modules).

SY-LOOPC

X(4)

Total number of screen table lines currently displayed on the screen.

 

Printing to Spool

SY-PEXPI

N(1)

Print parameters, spool retention period

SY-PRIMM

C(1)

Print parameters, print immediately

SY-PRREL

C(1)

Print parameters, delete after printing

SY-PRBIG

C(1)

Print parameters, selection cover page

SY-PRNEW

C(1)

Print parameters, new spool request

SY-PDEST

C(4)

Print parameters, output device

SY-PLIST

C(12)

Print parameters, name of spool request

SY-PRDSN

C(6)

Print parameters, name of spool dataset

SY-CALLR

C(8)

Print list, ID for print dialog function (e.g. NEW-PAGE)

SY-PTITL

C(70)

Print parameters, title of print program

SY-PRREC

C(12)

Print parameters, recipient

SY-PRTXT

C(68)

Print parameters, text for cover page

SY-PRABT

C(12)

Print parameters, department on cover page

SY-PAART

C(16)

Print parameters, print formatting

SY-PRCOP

N(3)

Print parameters, number of copies

SY-SPONO

N(10)

Print list, spool number

출처 : https://m.cafe.daum.net/proskill/Pffg/124



댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함