• No results found

003 - Bc401 - Abap Objects

N/A
N/A
Protected

Academic year: 2021

Share "003 - Bc401 - Abap Objects"

Copied!
439
0
0

Loading.... (view fulltext now)

Full text

(1)%&$%$32EMHFWV. %&. $%$32EMHFWV  SAP AG 2002. n. SAP R/3. n. System requirements: SAP R/3, Basis Release 6.10 or later. n. 2002/Q3. n. Material number 5005 4667.

(2) &RS\ULJKW. &RS\ULJKW6$3$*$OOULJKWVUHVHUYHG. 1RSDUWRIWKLVSXEOLFDWLRQPD\EHUHSURGXFHGRUWUDQVPLWWHGLQ DQ\IRUPRUIRUDQ\SXUSRVHZLWKRXWWKHH[SUHVVSHUPLVVLRQRI 6$3$*7KHLQIRUPDWLRQFRQWDLQHGKHUHLQPD\EHFKDQJHG ZLWKRXWSULRUQRWLFH.  SAP AG 2002. 1RWHVRQ7UDGHPDUNV n. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.. n. Microsoft®, WINDOWS®, NT®, EXCEL®, Word®, PowerPoint®, and SQL Server® are registered trademarks of Microsoft Corporation.. n. IBM®, DB2®, OS/2®, DB2/6000®, Parallel Sysplex®, MVS/ESA®, RS/6000®, AIX®, S/390®, AS/400®, OS/390®, and OS/400® are registered trademarks of IBM Corporation.. n. ORACLE® is a registered trademark of ORACLE Corporation.. n. INFORMIX®-OnLine for SAP and INFORMIX® Dynamic ServerTM are registered trademarks of Informix Software Incorporated.. n. UNIX®, X/Open®, OSF/1®, and Motif® are registered trademarks of the Open Group.. n. HTML, DHTML, XML, and XHTML are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.. n. JAVA® is a registered trademark of Sun Microsystems, Inc.. n. JAVASCRIPT® is a registered trademark of Sun Microsystems, Inc., used under license for technology developed and implemented by Netscape.. n. SAP, SAP Logo, R/2, RIVA, R/3, ABAP, SAP ArchiveLink, SAP Business Workflow, WebFlow, SAP EarlyWatch, BAPI, SAPPHIRE, Management Cockpit, mySAP.com Logo, and mySAP.com are trademarks or registered trademarks of SAP AG in Germany and several other countries all over the world. All other products mentioned are trademarks or registered trademarks of their respective companies..

(3) &RXUVH3UHUHTXLVLWHV. l 3URJUDPPLQJH[SHULHQFH. l 6$37(& P\6$37HFKQRORJ\6ROXWLRQ2YHUYLHZ

(4). l %& $%$3:RUNEHQFK)RXQGDWLRQVDQG&RQFHSWV

(5) l 3URJUDPPLQJH[SHULHQFHLQ$%$3.  SAP AG 2002.

(6) 7DUJHW*URXS. l 3DUWLFLSDQWV'HYHORSHUVFRQVXOWDQWV l 'XUDWLRQGD\V.  SAP AG 2002. 1RWHVWRWKHXVHU n. The training materials are QRWDSSURSULDWHIRUVHOIVWXG\. 7KH\FRPSOHPHQWWKHFRXUVH LQVWUXFWRU VH[SODQDWLRQV. There is space for you to write down additional information on the sheets.. n. There may not be enough time during the course to complete all the exercises. The exercises are intended as additional examples of the topics discussed during the course. Participants can also use them as an aid to enhancing their knowledge after the course has finished..

(7) &RXUVH2YHUYLHZ &RQWHQWV l &RXUVHJRDO. l &RXUVHREMHFWLYHV l &RXUVHFRQWHQW. l &RXUVHRYHUYLHZGLDJUDP l 0DLQEXVLQHVVVFHQDULR.  SAP AG 2002. © SAP AG. BC401. 1-1.

(8) &RXUVH*RDO. 7KLVFRXUVHZLOOHQDEOH\RXWR. l /HDUQWKHSULQFLSOHVRIREMHFWRULHQWHG. SURJUDPPLQJ. l /HDUQWKHVWUXFWXUHDQGDSSOLFDWLRQRI. $%$32EMHFWV.  SAP AG 2002. © SAP AG. BC401. 1-2.

(9) &RXUVH2EMHFWLYHV. $WWKHFRQFOXVLRQRIWKLVFRXUVH\RXZLOOEHDEOHWR l 'HVFULEHDQGXVHWKHPRVWLPSRUWDQWSULQFLSOHV n ,QWHUQDOWDEOHV. n &ODVVHVLQKHULWDQFHLQWHUIDFHV. n 3RO\PRUSKLVPLQKHULWDQFHDQGLQWHUIDFHV n (YHQWV. n ([FHSWLRQKDQGOLQJ. n '\QDPLFSURJUDPPLQJ. l 'HYHORSSURJUDPVLQ$%$32EMHFWV.  SAP AG 2002. © SAP AG. BC401. 1-3.

(10) &RXUVH&RQWHQW 

(11) 3UHIDFH Unit 1 Unit 2 Unit 3 Unit 4 Unit 5 Unit 6 Unit 7 Unit 8 Unit 9 Unit 10. &RXUVH2YHUYLHZ. 'DWD7\SHVDQG'DWD2EMHFWVLQ'HWDLO. 8VLQJ,QWHUQDO7DEOHV. &DOOLQJ3URJUDPVDQG3DVVLQJ'DWD. ,QWURGXFWLRQWR2EMHFW2ULHQWHG3URJUDPPLQJ $QDO\VLVDQG'HVLJQ. 3ULQFLSOHVRI2EMHFW2ULHQWHG3URJUDPPLQJ. ,QKHULWDQFH. &DVWLQJ. ,QWHUIDFHV.  SAP AG 2002. © SAP AG. BC401. 1-4.

(12) &RXUVH&RQWHQW 

(13). Unit 11 Unit 12 Unit 13 Unit 14 Unit 15. (YHQWV. *OREDO&ODVVHVDQG,QWHUIDFHV 6SHFLDO7HFKQLTXHV ([FHSWLRQ+DQGOLQJ. '\QDPLF3URJUDPPLQJ $SSHQGL[.  SAP AG 2002. © SAP AG. BC401. 1-5.

(14) &RXUVH2YHUYLHZ,QWHJUDWLRQLQ&RXUVH&RQWHQW. 

(15)      SAP AG 2002. © SAP AG. BC401. 1-6.

(16) 0DLQ%XVLQHVV6FHQDULR. l $WUDYHODJHQWPDLQWDLQVLWVFRQQHFWLRQVWR. EXVLQHVVSDUWQHUVVXFKDVDLUOLQHVFDUKLUH FRPSDQLHVDQGKRWHOV.  SAP AG 2002. © SAP AG. BC401. 1-7.

(17) 7HFKQLFDO1DPHV. l 3DFNDJH%&. l 1DPLQJFRQYHQWLRQVIRUSURJUDPREMHFWV n 'HPRQVWUDWLRQV. 6$3%&B[[['B. n 0RGHOVROXWLRQV. 6$3%&B[[[6B. n &RS\WHPSODWHV. 6$3%&B[[[7B. [[[LVWKHLQGLYLGXDOXQLWFRGH.  SAP AG 2002. n. Unit codes: Unit 2: Unit 3: Unit 4: Unit 7: Unit 8: Unit 9: Unit 10: Unit 11: Unit 12: Unit 13: Unit 14: Unit 15:. © SAP AG. DTO TAB CAL AIR INH CAS INT EVE CLS SPC EXC DYN. BC401. 1-8.

(18) 'DWD7\SHVDQG'DWD2EMHFWVLQ'HWDLO &RQWHQWV l 'DWDREMHFWVLQSURJUDPV l (OHPHQWDU\GDWDREMHFWV l 6WUXFWXUHV. l &KDUDFWHUVWULQJSURFHVVLQJLQ8QLFRGH.  SAP AG 2002. © SAP AG. BC401. 2-1.

(19) 'DWD7\SHVDQG'DWD2EMHFWVLQ'HWDLO8QLW2EMHFWLYHV. $WWKHFRQFOXVLRQRIWKLVXQLW\RXZLOOEHDEOHWR l 8VHHOHPHQWDU\GDWDREMHFWVDQGVWUXFWXUHV DSSURSULDWHO\ l 8VHQXPHULFGDWDW\SHVDSSURSULDWHO\. l 8VHDXWRPDWLFW\SHFRQYHUVLRQVDSSURSULDWHO\ l 7DNHWKHVSHFLDOIHDWXUHVRIFKDUDFWHUVWULQJ SURFHVVLQJLQ8QLFRGHLQWRDFFRXQW.  SAP AG 2002. © SAP AG. BC401. 2-2.

(20) 'DWD7\SHVDQG'DWD2EMHFWVLQ'HWDLO ,QWHJUDWLRQLQ&RXUVH&RQWHQW.  

(21)      

(22) .  . !#"!$%'& $ &!( $*).  SAP AG 2002. © SAP AG. BC401. 2-3.

(23) 'DWD7\SHVDQG'DWD2EMHFWVLQ'HWDLO 

(24). ,QWURGXFWLRQ ,QWURGXFWLRQ. (OHPHQWDU\'DWD2EMHFWV (OHPHQWDU\'DWD2EMHFWV 6WUXFWXUHV 6WUXFWXUHV. 6SHFLDO)HDWXUHVLQ8QLFRGH 6SHFLDO)HDWXUHVLQ8QLFRGH.  SAP AG 2002. © SAP AG. BC401. 2-4.

(25) 5HYLVLRQ'HILQLQJ'DWD2EMHFWV /RFDOW\SHV 7<3(6W\SHBQDPH7<3(. 3UHGHILQHG $%$3W\SHV G W L. S I Q VWULQJ F [VWULQJ [. '$7$GRBQDPH7<3(W\SHBQDPH '$7$. *OREDO W\SHV. '$7$GRBQDPHBQHZ/,.(GRBQDPH '$7$  SAP AG 2002. n. Data objects are usually defined with the '$7$statement as follows. After the name of the data object, a a fully-specified type is assigned to it using the 7<3( addition. The type is linked to the data object statically and cannot be changed at runtime.. n. There are other syntax variants available (for historical reasons). Note however, that some of these historical variants are no longer supported in ABAP Objects. For further information, refer to the keyword documentation for the '$7$ statement.. n. All types are based on predefined ABAP types, which will be discussed in greater detail in the following slide. Some of these ABAP types are fully specified and can be used to type data objects directly. Other types need to be modified to include the length, and in some cases the number of decimal places so that they are fully specified. These are the simplest examples of user-defined types.. n. You can create complex structured types of any level of complexity, based on elementary types.. n. You can also define types centrally in the $%$3'LFWLRQDU\ You can then use these JOREDOW\SHV in all appropriate Repository objects in the system.. © SAP AG. BC401. 2-5.

(26) 3UHGHILQHG$%$37\SHV 'DWD W\SH 1XPHULF. )L[HGOHQJWK. L I S. ,QWHJHU. /HQJWKLQE\WHV . )ORDWSRLQWQXPEHU . 3DFNHGQXPEHU. . &KDUDFWHUVWULQJW\SH. Q F G W. +H[DGHFLPDO. [. 9DULDEOH OHQJWK. 'HVFULSWLRQ. 1XPEHUVHTXHQFH. . 7LPH. . +H[DGHFLPDOFRGH. . &KDUDFWHUVHTXHQFH  'DWH . &KDUDFWHUVWULQJW\SHKH[DGHFLPDO. VWULQJ. [VWULQJ. &KDUDFWHUVHTXHQFH +H[DGHFLPDOFRGH. $WWULEXWHV. 'LIIHULQ •5XOHVIRUVWRUDJH •9DOXHUDQJH •$ULWKPHWLFXVHG &KDUDFWHUVWULQJRSHUDWLRQV DOORZHGIRUDOOW\SHV

(27) GDWHFDOFXODWLRQV WLPHFDOFXODWLRQV. %LWRSHUDWLRQV 5XQWLPHV\VWHPDGMXVWVOHQJWK G\QDPLFDOO\.  SAP AG 2002. n. The following ABAP types are fully specified and can be used directly to type data objects: G, W, L, I, VWULQJ, and [VWULQJ. A special feature of the VWULQJ and [VWULQJ types is that their length is adjusted dynamically at runtime. Thus, for these two types, length is not a component of the type.. n. The following ABAP types are not fully specified, so you must include additional information before you use them to define data objects: é F, Q, and [ Length needs to be added. Permitted values: to  characters. If you do not declare a length when you define a data object, the system assigns the default length of .. é S You must extend the type to include the length, and number of decimal places, Permitted length: to  bytes. If you do not declare a length when you define a data object, the system assigns the default length of  bytes (that is, 15 digits) and  decimal places.. n. The type also contains information on how the data is stored, what range of values is allowed, what operations can be performed on the data, and what sort of arithmetic is used (if the data object is suitable for use in calculations). We will deal with this topic in greater detail later in this unit.. © SAP AG. BC401. 2-6.

(28) 7\SH*URXSVLQWKH$%$3'LFWLRQDU\ 1DPHRIW\SHJURXS 8SWRFKDUDFWHUV HDFKW\SHQDPHDQG FRQVWDQWQDPH VWDUWVZLWKWKHQDPHRI WKHW\SHJURXS (DFKW\SHJURXSZKRVH W\SHVDQGFRQVWDQWV\RX ZDQWWRXVHPXVWEHVSHFLILHG LQWKH$%$3SURJUDP. 7\SHJURXS]P\WS ]P\WS 7<3(322/]P\WS &2167$176]P\WSBFRQVWBQDPH ]P\WS ]P\WS >7<3(6]P\WSBW\SHBQDPH@ ]P\WS >7<3(6]P\WSBW\SHBQDPH@ . 8VLQJDFRQVWDQW $%$3SURJUDP. 7<3(322/6]P\WS ]P\WS 7<3(322/6 ]P\WS >'$7$YDU7<3(]P\WSBW\SH@. ]P\WS ,)YDU ]P\WSBFRQVWBQDPH  (1',)  SAP AG 2002. n. You must use a type group to define global constants. The name of the type group can contain up to 5 characters.. n. You define constants in the type group using the &2167$176 statement, just as in an ABAP program. You only have to adhere to the following namespace convention: All constants (and type names) must have the name of the type group as a prefix. You can use either a global Dictionary type or a predefined ABAP type as a valid type.. n. To be able to use the types of a type group in a program, you must refer to the type group using the 7<3(322/6 statement. After this line in the program, you can then use all the constants in the type group.. n. You can also define global data types in a type group. Before SAP R/3 Basis Release 4.5, this was the only way to define complex global data types.. © SAP AG. BC401. 2-7.

(29) 'DWD7\SHVDQG'DWD2EMHFWVLQ'HWDLO 

(30). ,QWURGXFWLRQ ,QWURGXFWLRQ. (OHPHQWDU\'DWD2EMHFWV (OHPHQWDU\'DWD2EMHFWV 6WUXFWXUHV 6WUXFWXUHV. 6SHFLDO)HDWXUHVLQ8QLFRGH 6SHFLDO)HDWXUHVLQ8QLFRGH.  SAP AG 2002. © SAP AG. BC401. 2-8.

(31) ,QWHJHUVDQG,QWHJHU$ULWKPHWLF /HQJWKE\WHV. '$7$FRXQWHU7<3(L9$/8(. l l. 9DOXHUDQJH>@. LQW LQWLQWLQW. l. ,QWHJHU$ULWKPHWLF. Œ $OOLQWHUQDODX[LOLDU\ILHOGVDUHLQWHJHUV Œ ,QWHULPUHVXOWVDUHURXQGHG. $ULWKPHWLFRSHUDWLRQVIRU LQWHJHUV. LQW LQW LQW  . LQW. . . . . . . . . ,QWHJHUDX[LOLDU\YDULDEOH.  .  ',9 02' . $GGLWLRQ 6XEWUDFWLRQ 0XOWLSOLFDWLRQ 'LYLVLRQ ,QWHJHUGLYLVLRQ 5HPDLQGHULQWHJHUGLY 3RZHU.  SAP AG 2002. n. In integer arithmetic, the system always rounds to the appropriate decimal place. So, for example: '$7$LQW7<3(LLQW " result: 0 LQW " result: 1. n. Calculations performed using integer arithmetic are faster than calculations using fixed point or floating point arithmetic.. n. For further information on calculations performed on integers, refer to the keyword documentation for the &20387( statement.. © SAP AG. BC401. 2-9.

(32) 3DFNHG1XPEHUVDQG)L[HG3RLQW$ULWKPHWLF '$7$SHUFHQWDJH 

(33) 7<3(S'(&,0$/69$/8(   

(34) '(&,0$/6 /HQJWKLQE\WHV QE\WHVFRUUHVSRQGWR QGLJLWV. 1XPEHURIGHFLPDO SODFHV )L[HGSRLQWDULWKPHWLF OLNHXVLQJSDSHUDQGSHQFLO. 1XPEHU . ,QWHUQDOUHSUHVHQWDWLRQ.  . .      . +-,/. 01.32547658 9:<;>=3?@BAC236. D . 0FE. l3HUPLWWHGOHQJWKWRE\WHV WRGLJLWV

(35) l1XPEHURIGHFLPDOSODFHVQXPEHURIGLJLWVPD[ l([DPSOH/HQJWKE\WHVGHFLPDOSODFHV ë9DOXHUDQJH>@.  SAP AG 2002. n. The length of packed numbers is given in bytes. The connection between value range and length is derived from the internal representation: Each decimal digit is represented by a half-byte. The last byte is reserved for the plus or minus sign.. n. The number of decimal places is defined using the '(&,0$/6 addition. The maximum number of decimal places is either 15 or the length of the number minus 1 (that is, there must be at least one digit before the comma).. n. In user dialogs, decimal numbers are formatted according to the settings in the user master record.. n. Decimal point-aligned fixed point arithmetic is used as default for calculations. Packed numbers are thus well-suited to business calculations, where the correct rounding for the specified number of decimal places is very important. The algorithm for this arithmetic is similar to using "pencil and paper".. n. The system always uses packed numbers of maximum length for interim results.. n. You can switch off fixed point arithmetic in the program attributes. If you do, the '(&,0$/6 addition when defining a packed number only affects the output of the number. Internally, all numbers are interpreted as integers, regardless of the position of the decimal point. The fixed point arithmetic option is always selected by default. You should DOZD\V accept this value and use packed numbers for business calculations.. © SAP AG. BC401. 2-10.

(36) )ORDWLQJ3RLQW$ULWKPHWLF _. _ -. 2QO\ELWVDYDLODEOH. 1,5 = 1×20 + 1×2 1 1 =1 + 2 _   _ -3. _ . _   _ -6. -7. -10. -11. 0,15 = 1×2 + 1×2 + 1×2 + 1×2 + 1×2 + Λ 1 1 1 1 1 = + + + + + 8 128 1024 2048 Λ 64. ≈. = 0,125 + Λ = = =. 0,140625 +Λ. 2QO\IRU DSSUR[LPDWLRQV. 0,1484375 +Λ 0,1494140625 + Λ. 01499023437 Λ. =  SAP AG 2002. n. Unlike packed numbers, floating point numbers are represented using sums of binary fractions. Floating point numbers are also normalized, and both the exponent and the mantissa are stored in binary form. This representation complies with the IEEE norm for double precision floating point numbers. The floating point operations of the relevant processors are used for calculations. Since algorithms are converted to binary, inaccuracies can occur. Therefore, floating point numbers are QRW suitable for business calculations. ([DPSOH You want to calculate 7.72% of 73050 and display the result accurate to two decimal places. The answer should be 5310.74 (73050 * 0.0727 = 5310.7735). The program, however: '$7$IORDW7<3(ISDFN7<3(S'(&,0$/6 IORDW    UHVXOW( SDFN IORDW:5,7(SDFNUHVXOW. n n. <RXVKRXOGWKHUHIRUHRQO\XVHIORDWLQJSRLQWQXPEHUVIRUDSSUR[LPDWLRQV:KHQ\RXFRPSDUH QXPEHUVDOZD\VXVHLQWHUYDOVDQGDOZD\VURXQGDWWKHHQGRI\RXUFDOFXODWLRQV. The DGYDQWDJHRIIORDWLQJSRLQWQXPEHUV is the large value range: It comprises numbers from is, from 2,2250738585072014E-308 to 1,7976931348623157E+308 including both positive and negative numbers as well as zero.In addition, you must use floating point numbers for special aggregation functions of the 6(/(&7 statement.. © SAP AG. BC401. 2-11.

(37) 6XPPDU\5HFRPPHQGDWLRQVIRU8VLQJ1XPHULF 'DWD7\SHV. 5HTXLUHG ,QWHJHUVRQO\. 5HFRPPHQGHGSUHGHILQHG$%$3GDWDW\SH 7\SHL VLQFHFDOFXODWLRQVXVLQJLQWHJHUDULWKPHWLFDUH IDVWHVW. 'HFLPDOQXPEHUVIRU EXVLQHVVFDOFXODWLRQV. 7\SHS. 'HFLPDOQXPEHUVIRU URXJKFDOFXODWLRQV SHUIRUPHGRQYHU\VPDOO RUYHU\ODUJHQXPEHUV. 7\SH).  SAP AG 2002. n. 1RWH The results of the following functions have the data type I:. é Trigonometric functions:FRV, DFRV,VLQ, DVLQ, WDQ, DWDQ. é Hyperbolic functions: WDQK, VLQK, FRVK. é Exponential functions (base e): H[S. é Natural logarithms (base e): ORJ. é Logarithms (base 10): ORJ. é Square root: VTUW. © SAP AG. BC401. 2-12.

(38) $ULWKPHWLFDQG0L[HG([SUHVVLRQV l)L[HGSRLQWDULWKPHWLFLVWKHGHIDXOW l,QWHJHUDULWKPHWLFLVRQO\XVHGLIDOOWKHFRPSRQHQWVDUHLQWHJHUV l)ORDWLQJSRLQWDULWKPHWLFLVXVHGLIDWOHDVWRQHFRPSRQHQWLVDIORDWLQJSRLQWQXPEHU l$OOFRPSRQHQWVDUHFRQYHUWHGWRWKHUHOHYDQWGDWDW\SH l$IWHUWKHFDOFXODWLRQDOODUHFRQYHUWHGWRWKHUHVXOWW\SH. ([DPSOH S'(&,0$/6 U. L. L. I. F. D. . E. . . . . . (. ( . (. ,QWHULPUHVXOW. . €. →)ORDWSRLQWDULWKPHWLF ↓ ó &RQYHUVLRQDIWHUI DQGFDOFXODWLRQ. (. ↓ ì &RQYHUVLRQDIWHU S'(&,0$/6.  SAP AG 2002. n. An arithmetic expression may contain any data types that are convertible into each other and into the type of the result field.. n. The system converts all the values into one of the three numeric data types (L, S, or I), depending on the data types of the operands. The ABAP runtime system contains an arithmetic for each of the three data types. The system then performs the calculation and converts it into the data type of the result field.. n. This may mean that the same arithmetic expression leads to different results when performed on different combinations of data types.. n. It is also possible for an arithmetic expression to have RQO\FKDUDFWHUVWULQJW\SH data objects, as long as their contents are appropriate. The values are converted to numeric type objects. Bear in mind that conversions affect performance. Wherever possible, choose a data type that does QRW require runtime conversion.. n. If an arithmetic expression contains numeric literals, the choice of arithmetic depends on the size of the number: If the number is within the value range for the data type L, the numeric literal is interpreted as an integer. If the value of the literal is greater than 2147483647, it is interpreted as a packed number. ([DPSOH '$7$LQW7<3(LLQW  "result: 9 LQW  "result: 10. © SAP AG. BC401. 2-13.

(39) 3UHGHILQHG$%$37\SHVIRU&KDUDFWHU6WULQJV. 'HVFULSWLRQ /HQJWK 9DOXHUDQJH &DOFXODWLRQV )RUPDWWLQJ RSWLRQV. 7\SHW. 7\SHG. 7LPH. 'DWH. GLJLWV ++0066. GLJLWV  <<<<00'' FKDUDFWHUV. %\FORFN 7LPH DULWKPHWLF ++0066. 7\SHQ. 7\SHF 7\SHF. 6HTXHQFH )L[HGOHQJWK RIGLJLWV FKDUVWULQJ. %\*UHJRULDQ FDOHQGDU 'DWH DULWKPHWLF. 'LJLWV &RQYHUVLRQ.   FKDUDFWHUV. 7\SHVWULQJ 7\SHVWULQJ &KDUVWULQJ RIYDULDEOH OHQJWK. 9DULDEOH. 'HSHQGVRQFRGHSDJH 'HSHQGVRQFRGHSDJH &RQYHUVLRQ. &RQYHUVLRQ. %DVHGRQ XVHUGHIDXOW YDOXHV.  SAP AG 2002. n. The value range of each string depends on the code page, which contains all the supported characters in form of a table. Internally, each character is represented by a code number. When the system outputs the character, it uses the code page to convert this number. To find the code page valid in a given system, choose 7RROV →&&06→6SRRO$GPLQLVWUDWLRQ→)XOO$GPLQLVWUDWLRQ→&KDUDFWHU 6HWV.. n. The initial value of each character string with fixed length is a space character.. n. Numeric strings are represented internally as character strings. Note, however, that only digits are permissible as characters. When character strings are assigned to numeric strings, the system ignores letters and only copies the digits (right-aligned). Missing characters are filled with zeros.. n. The initial value of each character in a numeric string is a zero.. n. n n n. Only sequences of digits are valid for values of type G. These digits form a meaningful date, which complies with the Gregorian calendar. The first four digits represent the year, the next two the month and the last two the date. For performance reasons however, the object is only checked if it is an input field on a screen or selection screen. The initial value of a date is  . The formatting options are determined by the user settings.. For values of type W, a sequence of digits is only valid if it can be interpreted as a time on the 24-hour clock. The rules for interpreting the value are analogous to those used for dates.. The initial value of a time is  .. © SAP AG. BC401. 2-14.

(40) 2YHUYLHZ&KDUDFWHU6WULQJ3URFHVVLQJ. ),1'. 5(3/$&( 75$16/$7( 6+,)7 &21'(16( 29(5/$<. &21&$7(1$7(. 63/,7. %. ". GIHKJLBMN'O<PQROJCSTVUXWZY. $%$3. $%$3. $%$3. $%$3 $3 $%3 $$$$. %%$3. DEDS %$3 $3. $%$3. $%  $3 $%$3. $%&$3 $% $3. 'HVFULSWLRQDQGQRWHV. 6HDUFKLQDFKDUDFWHUVWULQJ 3RVLWLRQRIVHDUFKVWULQJ XVLQJ0$7&+2))6(7RIIDGGLWLRQ 5HSODFHILUVWRFFXUUHQFH 5HSODFH 5HSODFHDOORFFXUUHQFHV. 0RYH. 5HPRYHVSDFHFKDUDFWHUV 5HPRYH 2YHUZULWH 2YHUZULWH6SDFHVDUHRYHUZULWWHQ E\FKDUDFWHUVIURPWKHVHFRQG FKDUDFWHUVWULQJ &RQFDWHQDWH &RQFDWHQDWHVHYHUDO FKDUDFWHUVWULQJV. 6SOLWDFKDUDFWHUVWULQJ 6SOLW.  SAP AG 2002. n. n n n n n. Note for ),1'statement (search in a character string): There are special comparison operators for strings, which you can use in logical expressions in a query (,)) to search more flexibly for character sequences in a character string. For more information, see the keyword documentation for ,).. For every statement, the operands are treated like type F fields, regardless of their actual field type. No internal type conversions take place. All of the statements apart from 75$16/$7(and &21'(16(set the system field V\VXEUF. (6($5&+also sets the system field V\IGSRV with the offset of the character string found.) All of the statements apart from 6($5&+ are case-sensitive.. To find out the occupied length of a string, use the standard function 675/(1

(41) . For the 63/,7statement there is the variant 63/,7,1727$%/(<itab>, which you can use to split the character string dynamically. You do not need to specify the number of parts into which the string should be split.. © SAP AG. BC401. 2-15.

(42) $FFHVVLQJ3DUWVRI)LHOGV VWDWHPHQW!ILHOG!RII! OHQ!

(43)  3RVVLEOHZLWKDQ\ FKDUDFWHUW\SHILHOG. 5(3257 3$5$0(7(56 SDBVWU 

(44) /2:(5&$6( SDBSRV7<3(L SDBOHQ7<3(L :5,7(SDBVWUSDBSRV SDBOHQ

(45)  SDB SDBSRV SRV SDB SDBOHQ

(46) OHQ

(47). [\I\<\[5]<^[__3`a]I^Ib<\<b/\ Y/Y<Y<Y<Y/Y.  SAP AG 2002. n. In DQ\ statement that operates on a FKDUDFWHUW\SH field, you can address part of the field or structure by specifying a starting position and a number of characters. If the field lengths are different, the system either truncates the target or fills it with initial values. The source and target fields must have the type [, F, Q, G, W, or 675,1*You can also use structures. ([DPSOH 029(<field1>+<off1> <len1>

(48) 72<field2>+<off2> <len2>

(49)  This statements assigns len1> characters of field <field1> starting at offset <off1> to <len2> characters of <field2> starting at offset <off2>.. © SAP AG. BC401. 2-16.

(50) 'DWD7\SHVDQG'DWD2EMHFWVLQ'HWDLO 

(51). ,QWURGXFWLRQ ,QWURGXFWLRQ. (OHPHQWDU\'DWD2EMHFWV (OHPHQWDU\'DWD2EMHFWV 6WUXFWXUHV 6WUXFWXUHV. 6SHFLDO)HDWXUHVLQ8QLFRGH 6SHFLDO)HDWXUHVLQ8QLFRGH.  SAP AG 2002. © SAP AG. BC401. 2-17.

(52) 'HILQLQJ6WUXFWXUHVZLWK/RFDO7\SHV 'HILQLWLRQRIDVWUXFWXUHW\SH. 7<3(6 7<3(6 %(*,12) VBQDPHBW\SH %(*,12)VBQDPHBW\SH SUHQDPH 

(53) 7<3(F VXUQDPH 

(54) 7<3(F WLWOH 

(55) 7<3(F (1'2)VBQDPHBW\SH (1'2). 'HILQLWLRQRIDVWUXFWXUHZLWK LPSOLFLWW\SHFRQVWUXFWLRQ. '$7$ '$7$ %(*,12) VBQDPH %(*,12)VBQDPH SUHQDPH 

(56) 7<3(F VXUQDPH 

(57) 7<3(F WLWOH 

(58) 7<3(F (1'2)VBQDPH (1'2) VBQDPH. 'HILQLWLRQRIDVWUXFWXUHZLWK UHIHUHQFHWRDXVHUGHILQHGW\SH. '$7$ VBQDPH7<3(VBQDPHBW\SH VBQDPH VBQDPHBW\SH $OWHUQDWLYHV. 67$572)6(/(&7,21 VBQDPHSUHQDPH  6PLWK  VBQDPH VBQDPHVXUQDPH  -RKQ  VBQDPH  SAP AG 2002. n. As with elementary data objects, you can define structures in two ways:. é First, define a structure type explicitly using the 7<3(6 statement. To do this, enter the name of the structure after %(*,12) and then list the definitions of all the components. End the definition of the structure type using (1'2). You then define the structured data object with the '$7$ statement, using your own user-defined structure type.. é Define the data object directly using the '$7$ statement. The syntax is similar to the definition of a structure type. If you use this option, the corresponding structure type is defined implicitly at the same time. n. In both cases, the type is defined locally. Bear in mind that you can also use globally defined types instead.. n. You address components of structures using: structure_namecomp_name. For this reason, you should avoid using hyphens in variable names.. © SAP AG. BC401. 2-18.

(59) 'HILQLQJ1HVWHG6WUXFWXUHVZLWK/RFDO7\SHV 7<3(6 %(*,12)VBQDPHBW\SH VBQDPHBW\SH SUHQDPH 

(60) 7<3(F VXUQDPH 

(61) 7<3(F WLWOH 

(62) 7<3(F (1'2)VBQDPHBW\SH. 6WUXFWXUHW\SH VBQDPHBW\SH SUHQDPH VXUQDPH WLWOH. '$7$ %(*,12)VBDGGUHVV QDPH7<3(VBQDPHBW\SH VBQDPHBW\SH VWUHHW 

(63) 7<3(F FLW\ 

(64) 7<3(F (1'2)VBDGGUHVV. VBDGGUHVV. VBDGGUHVVQDPHVXUQDPH  6PLWK    VBDGGUHVVFLW\  /RQGRQ  . 1HVWHGVWUXFWXUH QDPH. VWUHHW FLW\. SUHQDPH VXUQDPH WLWOH. $SSOLFDWLRQ /RJLFDOVXEJURXSLQJ RIGDWD.  SAP AG 2002. n. You can define nested structures by assigning a structure type to a component ZLWKLQ a structure type.. n. You can address this substructure as a whole using the component name: structure_namesubstructure_name.. n. You can also address individual components in the VXEstructure: structure_name-substructure_name-comp_name.. n. Structures can be nested to any level you wish.. n. You can also integrate components of a dynamic type in a structure. This can either be an elementary data object of variable length (VWULQJ or [VWULQJ),an internal table, or a reference. These structures are known as GHHS structures.. n. There are constraints on how such deep structures can be used. For instance, a deep structure cannot be used DVDZKROH in the,172 clause of the 6(/(&7 statement. (Instead, each component must be listed separately). Offset operations are also not appropriate. For more information, refer to SAP Note 176336.. © SAP AG. BC401. 2-19.

(65) 8VLQJ1DPHG,QFOXGHV '$7$ %(*,12)WBOLQHW\SH VBQDPHBW\SH SUHQDPH 

(66) 7<3(F VXUQDPH 

(67) 7<3(F WLWOH 

(68) 7<3(F (1'2)VBQDPHBW\SH. 6WUXFWXUHW\SH VBQDPHBW\SH SUHQDPH VXUQDPH WLWOH. '$7$ %(*,12)VBDGGUHVV ,1&/8'(6758&785(VBQDPHBW\SH ,1&/8'(6758&785( VBQDPHBW\SH $6QDPH $6 '$7$ VWUHHW 

(69) 7<3(F FLW\ 

(70) 7<3(F (1'2)VBDGGUHVV VBDGGUHVVQDPHVXUQDPH  6PLWK    RU VBDGGUHVVVXUQDPH  6PLWK  . 6WUXFWXUHZLWKQDPHGLQFOXGH VBDGGUHVV. SUHQDPH VXUQDPH WLWOH VWUHHW FLW\. QDPH. 8VH /RJLFDOVXEJURXSGHVLUHGEXWQHVWHG VWUXFWXUHVQRWWHFKQLFDOO\SRVVLEOH.  SAP AG 2002. n. In some cases, you cannot use nested structures, for example: é Because you can only define database tables with flat line types é In situations where user dialogs with a table-type display can only contain simple structures (such as in the SAP List Viewer or Table Control). n. In situations like these, you may still want to group parts of the structure and address it as a whole. You do this using named includes: é You can include a substructure in another structure, and give this substructure a name: '$7$%(*,12)structure_name  ,1&/8'(6758&785(substructure_type$6name '$7$ (1'2)structure_name. é You can address this substructure using structure_name-name. You can address the fields in the substructure using structure_name-name-comp_name or directly using structure_name-comp_name. Technically, however, this structure is QRWnested. é If naming conflicts occur - for example, if you want to include the same substructure twice - you can append another name to the component names using 5(1$0,1*. For further information, refer to the keyword documentation for the ,1&/8'(6758&785( statement.. © SAP AG. BC401. 2-20.

(71) 'DWD7\SHVDQG'DWD2EMHFWVLQ'HWDLO 

(72). ,QWURGXFWLRQ ,QWURGXFWLRQ. (OHPHQWDU\'DWD2EMHFWV (OHPHQWDU\'DWD2EMHFWV 6WUXFWXUHV 6WUXFWXUHV. 6SHFLDO)HDWXUHVLQ8QLFRGH 6SHFLDO)HDWXUHVLQ8QLFRGH.  SAP AG 2002. © SAP AG. BC401. 2-21.

(73) 8QLFRGH2YHUYLHZ 3UHYLRXVSUREOHPV l l. 0L[WXUHRIGLIIHUHQWLQFRPSDWLEOHFKDUDFWHUVHWVLQRQHFHQWUDO V\VWHP. 'DWDH[FKDQJHEHWZHHQV\VWHPVZLWKLQFRPSDWLEOHFKDUDFWHUVHWV. D. D ". 8QLFRGH. ". ". 6. 6ROXWLRQ8QLFRGH. l 21(FRGHSDJHWKDW FRPSULVHVDOONQRZQ FKDUDFWHUV. l (YHU\FKDUDFWHULVJHQHUDOO\ GLVSOD\HGE\WZRE\WHV.  SAP AG 2002. n. To be able to work with Unicode, you must have a Unicode-compatible SAP System installed that itself has a corresponding operating system and database. The ABAP programs must also be Unicode-compatible.. n. In Unicode programs, other syntax rules apply than in non-Unicode programs. This is due to the difference between the length in bytes and the number of characters in a character set in Unicode. Existing programs are affected by a conversion to Unicode if an explicit or implicit assumption is made about the internal length of a character. To execute the relevant syntax checks, you must check 8QLFRGH&KHFNV$FWLYHunder program attributes.. n. In a Unicode system, you can only execute programs that have the Unicode flag set. If the Unicode flag is set for a program, the syntax check and program are executed in accordance with the rules described in the Unicode online help (irrespective of whether it is a Unicode or a non-Unicode system).. n. If the Unicode flag is not set, the program can only be executed in a non-Unicode system. For such programs, the Unicode-specific changes of syntax and semantics do not apply. However, you can use all language enhancements introduced in connection with the conversion to Unicode.. © SAP AG. BC401. 2-22.

(74) &KDUDFWHU7\SHDQG%\WH7\SH7\SHV &KDUDFWHUW\SHW\SHVLQ8QLFRGHSURJUDPV 2QO\FRPSRQHQWV ZLWKWKHW\SHV cndDQGt. G F. W. Q. E\WHW\SH. &KDUDFWHUW\SH VWUXFWXUHW\SHV. [VWULQJ. VWULQJ. [. 'LIIHUHQFHEHWZHHQE\WHSURFHVVLQJDQGFKDUDFWHUSURFHVVLQJ '$7$FBILHOG 

(75) 7<3(F9$/8( +8*2  [BILHOG 

(76) 7<3([9$/8( (%$  6+,)7FBILHOG%<3/$&(6>,1&+$5$&7(502'(@ 6+,)7[BILHOG%<3/$&(6,1%<7(02'(. cedfg hi j monqpsr. p}r. d~d. kdflg h5i j t<uvwx/v y1z. xvey{z||||.  SAP AG 2002. n. In Unicode programs, the following data types are interpreted as character-type: F, Q, G, W, VWULQJ as well as structure types, that directly or in substructures only contain components with types F, Q , G and W. In non-Unicode systems, a character of this type is one byte and in Unicode systems, it is as long as corresponds with the length of a character on the relevant platform. Variables of the types [and [VWULQJ are described as byte-type.. n. The character string processing (for which, previously, all arguments were implicitly interpreted as type Ffields) is separated into string processing for character-type and byte-type arguments.. n. n. In the case of the string processing for character-type arguments, the single fields must be typeF, Q, G, W, or VWULQJ; character-type structures are also permitted. If arguments of another type are transferred, this triggers a syntax or runtime error.. The ;variants of the string statement are distinguished from the character string commands by the ,1%<7(02'(addition. For the character string variants, ,1&+$5$&7(502'(is an optional addition. If the ,1%<7(02'(addition is specified, only ;fields and ;strings are permitted as arguments. If arguments of another type are transferred, this triggers a syntax or runtime error.. © SAP AG. BC401. 2-23.

(77) )XQFWLRQVDQG&RPSDULVRQ2SHUDWRUV /HQJWKLQ FKDUDFWHUV. )XQFWLRQV. &RPSDULVRQ RSHUDWRUV. &KDUDFWHUW\SHW\SH 675/(1 675/(1. &11$1613. /€<€ƒ‚ „5†{‡Fˆ<‰ŠŒ‹eCŽK‘<’“„”B€–•I—C’™˜›šB—CœCŒ˜Bž „5†{‡Fˆ<‰FŸX‹eŠCŽK‘<’“„”B€–•I—C’™˜*œ ˜/¡ ¢/£¤„†¥‡CˆI‰KЧ¦ €¨„†¥‡CˆI‰CŸŒ¡ ¡¡¡ ’©¥¢I£Œ¡. %\WHW\SHW\SH. ;675/(1. &2&$&6&3. ([DPSOHV. /HQJWKLQ E\WHV. %<7(&2%<7(&$. %<7(&6%<7(&1 %<7(1$%<7(16. /€1 €ƒ‚«ª<†–‡F¬<­1ˆ<‰ƒ‹*FŽ®/‘ ’¤ª ”B€{•I—F’™˜¯’°F±BŠ'²¥± €7Ÿ³˜Bž ˆ/­´¤K‘<’µ¬a¡ ˆI­B´·¶¹¸–ºIB»C•B’B©¼‹½ª'†7‡C¬I­KˆI‰¾Ž¿¡.  SAP AG 2002. n. n. n. n. The operators &2, &1, &$, 1$, &6, 16, &3, 13 are available for comparing the contents of character string type data objects (for syntax and semantics, see keyword documentation). As with the statements for string processing, these operators require single fields of type FQ, G, W, or VWULQJ as arguments. Again, character-type structures are also permitted.. The ;variants of the string comparison operators are distinguished from the character string variants by the %<7(- prefix. For this operation, only ; fields and fields of the type [VWULQJ are allowed as arguments. The 675/(1function only works with character-type fields and returns the length in characters. With Ffields, only the so-called occupied length is relevant, that is, unlike with strings, trailing blanks are not counted.. The ;675/(1 function is available for the length of byte sequences. For ; strings, ;675/(1 returns the current length and for ;fields, the defined length in bytes, where null bytes at the end of fields are counted.. © SAP AG. BC401. 2-24.

(78) &RPSDWLELOLW\DQG&RQYHUVLRQ À ”1’ÂÁ·BÄÃÅ¡ Ó¶¤Á ¡. :KHQDUHWZRW\SHVFRPSDWLEOH" 7ZRHOHPHQWDU\W\SHVDUHFRPSDWLEOHZKHQWKH\ KDYHH[DFWO\WKHVDPHW\SHDQGOHQJWK DQGLQWKH W\SH OHQJWK FDVHRISDFNHGQXPEHUVWKHVDPHQXPEHURI GHFLPDOSODFHV

(79)  GHFLPDOSODFHV 7ZRVWUXFWXUHW\SHVDUHFRPSDWLEOHZKHQWKH\KDYHWKH VDPHVWUXFWXUHDQGWKHLUFRPSRQHQWVDUH VDPHVWUXFWXUH FRPSRQHQWVDUHFRPSDWLEOH URZW\SHV 7ZRWDEOHW\SHVDUHFRPSDWLEOHLIWKHLUURZW\SHVDUH FRPSDWLEOH FRPSDWLEOHDQGWKHLUNH\GHILQLWLRQVDQGWDEOHW\SHV FRPSDWLEOH NH\GHILQLWLRQV WDEOHW\SHV DUHWKHVDPH. l l. 1RFRQYHUVLRQWDNHVSODFHLIW\SHFRPSDWLEOHGDWDREMHFWVDUHDVVLJQHG. ,IQRQW\SHFRPSDWLEOHGDWDREMHFWVDUHDVVLJQHGFRQYHUVLRQGRHVWDNH SODFHLIDFRQYHUVLRQUXOHLVGHILQHG.  SAP AG 2002. n. If two data types are not compatible but there is a conversion rule, the system converts the source object into the type of the target object when you assign values, perform calculations, or compare values.. n. For a full list of all conversion rules, refer to the ABAP syntax documentation for the 029( statement.. n. If there is no conversion rule defined for a particular assignment, the way in which the system reacts depends on the program context.. n. If the types of the objects involved are defined VWDWLFDOO\, a V\QWD[HUURU occurs. ([DPSOH: '$7$GDWH7<3(G9$/8(  WLPH7<3(W ),(/'6<0%2/6IVBGDWH!7<3(GIVBWLPH!7<3(W $66,*1GDWH72IVBGDWH!WLPH72IVBWLPH! IVBWLPH! IVBGDWH!. n. In the case of G\QDPLFtyping a UXQWLPHHUURU occurs, because the field symbols are not assigned types until the assignment of the data objects at runtime.. ([DPSOH:  ),(/'6<0%2/6IVBGDWH!7<3($1<IVBWLPH!7<3($1<  (Rest as above). © SAP AG. BC401. 2-25.

(80) &RQYHUVLRQ8QGHU8QLFRGH 

(81) &RQYHUVLRQEHWZHHQIODWVWUXFWXUHV. À{'”’ÇÆBÈBÉIÊK„CЧËÆBÈBÉIÊK„ŸŒ¡ 8QGHUZKDWFRQGLWLRQ LVWKLVDVVLJQPHQW SRVVLEOH". 'HFLVLYHFULWHULRQ )UDJPHQWYLHZ. O _ T J/U [ Ñ ÎÏÓÐ. ÔÎ ÒÐÕÍÎ>uÐ. ÔÎ#ÒÐ. O _ T J/U ] Ñ Î ÒÐ Ñ ÎRu Ð Ñ Î>u Ð ÍCÎÏuÐ. Ñ Î ÒÐ. Ì. Ö<ÎÏ×Ð. Ì. O _ T J/U [ O _ T J/U ] Ñ Î3wØ|Ð. $VVLJQPHQWLVSRVVLEOH⇐. ÍCÎÏuÐ. Ñ Î ÒÐ Ì. Ö<ÎÏ×Ð. &RQYHUVLRQEHWZHHQIODWVWUXFWXUHVLVSRVVLEOHLIWKHIUDJPHQWVRI WKHVRXUFHDQGWDUJHWVWUXFWXUHVPDWFKERWKLQW\SHDQGOHQJWKLQ WKHOHQJWKRIWKHVKRUWHUVWUXFWXUH  SAP AG 2002. n. For some data types there are, for technical reasons, specific alignment requirements that depend on the individual platforms. (In the memory, fields of this type must begin and end on specific addresses - for example, a memory address divisible by four.). n. Within a structure, the runtime system, if necessary, inserts bytes before or after these components with alignment requirements to achieve the alignment needed. These bytes are known as $OLJQPHQW.. n. To check whether the conversion is even permitted, the system first creates the Unicode fragment view of the structures by grouping adjacent components and alignment gaps (one group each for character-type types [F, Q, G, W], byte-type types, and types L, I, and S).. n. Adjacent character-type components of a structure are therefore only grouped together if there are no alignment gaps between these components. Adjacent byte-type components are grouped in the same way.. n. If the fragments of the source and initial structures match the type and length in the length of the shorter structure, the conversion is allowed.. n. If the target structure is longer than the source structure, the character-type components of the remainder are filled with space characters. All other components in the remainder are filled with the type-specific initial value, alignment gaps are filled with null bytes.. © SAP AG. BC401. 2-26.

(82) &RQYHUVLRQ8QGHU8QLFRGH 

(83) &RQYHUVLRQEHWZHHQVWUXFWXUHVDQGVLQJOHILHOGV. À{'”’„†¥‡C¬I­FˆB‰·BËÆÈ/É/ÊF„Œ¡. UÙBÚ*Û ÜCÝ M Ñ Î>v Ð. 8QGHUZKDWFRQGLWLRQ LVWKLVDVVLJQPHQW SRVVLEOH" 'HFLVLYHFULWHULRQ )UDJPHQWYLHZ. O _ TJ/U. Ñ ÎÏÓÐ. ÔBÎÏÒÐ. ÍCÎÏuÐ. Ñ Î ÒÐ. UÙBÚ*Û ÜÝ M O _ *T J/U. $VVLJQPHQWLVSRVVLEOH⇐.  &RQYHUVLRQEHWZHHQVWUXFWXUHVDQGVLQJOHILHOGVLVSRVVLEOHLI WKHVWUXFWXUHEHJLQVZLWKDFKDUDFWHUW\SHIUDJPHQWDQGWKLV IUDJPHQWLVDWOHDVWDVORQJDVWKHVLQJOHILHOG  SAP AG 2002. The following rules apply for the conversion of a structure to a single field and vice versa: Œ. If the single field is type F, but the structure isn’t completely character-type, the conversion is only allowed if the structure begins with a character-type group and this group is at least as long as the single field. The conversion then takes place between the first character-type group of the structure and the single field. If the structure is the target field, the character-type parts of the remainder are filled with space characters and all other components with the type-specific initial value.. Œ. The conversion is not allowed if the structure is not purely character-type and the single field is not type F.. Internal tables can be converted if their row type can be converted.. © SAP AG. BC401. 2-27.

(84) ([DPSOHRI8VLQJWKH&RQYHUVLRQ5XOHV. 3$5$0(7(56SBGDWH/,.(V\GDWXP '$7$%(*,12)VBGDWH \HDU 

(85) 7<3(Q &KDUDFWHUW\SH PRQWK 

(86) 7<3(Q VLQJOHILHOG GD\ 

(87) 7<3(Q (1'2)VBGDWH 029(SBGDWH72VBGDWH VBGDWHGD\    029(VBGDWH72SBGDWH. l l. Þ ÙMCß _ Ü. &KDUDFWHUW\SH VWUXFWXUH. O5ÙCMß _ Ü. 6LQFHWKHVWUXFWXUHVBGDWHLVSXUHO\FKDUDFWHUW\SHLWLVWUHDWHGOLNH DW\SHFGDWDREMHFWGXULQJFRQYHUVLRQ 7KLVPHDQVLWLVWUDQVIHUUHGOHIWDOLJQHGFKDUDFWHUE\FKDUDFWHU.  SAP AG 2002. n. VBGDWHis structured in such a way that the first four characters of a variable specify the year, the next two specify the month, and the last two the day. If a date is assigned to this structure using the 029( statement, the characters are then copied left-aligned. You can then determine the year, month, and day directly using the components of the structure, without having to use offsets.. © SAP AG. BC401. 2-28.

(88) 2IIVHWDQG/HQJWK$FFHVVHVDQG(OHPHQWDU\'DWD 2EMHFWV $FFHVVWRVLQJOHILHOGVVSHFLI\LQJRIIVHWDQGOHQJWK VWDWHPHQW!ILHOG!RII! OHQ!

(89) . B€ €ƒ‚à„5†–‡F¬<­ˆ<‰ƒ‹eᎏ/1‘ ’„”€•/—’â˜㠀²<€7‘äå˜Iž ª †–‡F¬<­ˆ ‰Z‹eᎏ/1‘ ’¤ª§”€•/—’☛’1°1±/Š ²–±€{ŸKæB°B£K᳘/¡. U5ÙBÚ*Û ÜÝ M. ç{»¢I/’X‚à„†¥‡C¬/­KˆI‰è1ŠŒ‹!Ž7ž ª'†¥‡C¬/­Fˆ/‰èK°-‹›ŸKŽé¡. ê ÙBÚ*Û ÜÝ M ’{°C±Š'²¥±€–ŸFæ°I£–á. l l. $%$3 . )RUFKDUDFWHUW\SHILHOGVRIIVHWDQGOHQJWKDUHLQWHUSUHWHGFKDUDFWHU E\FKDUDFWHU.  ,QWKHFDVHRIE\WHW\SHILHOGVWKHYDOXHVIRURIIVHWDQGOHQJWKDUH WDNHQLQE\WHV.  SAP AG 2002. n n. Offset/length accesses are permitted on character-type single fields, single fields with the type VWULQJ, and single fields of the types [ and [VWULQJ.. For character-type fields and type VWULQJfields, offset and length are interpreted character by character. Only with types [ and[WULQJare the values for offset and length taken in bytes.. © SAP AG. BC401. 2-29.

(90) 2IIVHWDQG/HQJWK$FFHVVHVDQG6WUXFWXUHV $FFHVVLQJVWUXFWXUHVE\VSHFLI\LQJRIIVHWDQGOHQJWK VWDWHPHQW!VWUXFWXUH!RII! OHQ!

(91) . B€ €ƒ‚ë²’Cœ1¢5©“K£ìK­IìÃF­CÉåž È¬CȈI­í‹îFŽ /‘ ’„³ž ï É­´CÁ ì1­í‹!Š/îKŽ®/‘ ’„³ž Æ'Ê1É/´CÁ ì1­í‹!Š/îKŽ®/‘ ’„³ž ÁBðC­ /‘ ’ˬž „C¬CÈ'ñ¼‹¯ŸKæCŽ /‘ ’„³ž ’©“K£ìK­IìCÃF­Ɍ¡. ò Ü ò IS ÜT Ñ Î>óØÐ Ñ ÎôweóÐ. Ñ Î3wØóÐ}Ì. Ñ ÎÏz|Ð. õ5ö fÏf Î i h'÷ Ð. ‘I’»K£/» ÀµÊ{Æ ­<†1´FÁ ì1­¹—1ºC¢5©1œ®ìK­IìCÃF­CÉèC*°FæCŽé¡. 6WUXFWXUHPXVWVWDUWZLWKDFKDUDFWHUW\SHIUDJPHQW. l. $FFHVVLVRQO\DOORZHGZLWKLQWKHFKDUDFWHUW\SHLQLWLDOSDUW. l. 2IIVHWDQGOHQJWKVSHFLILFDWLRQVDUHLQWHUSUHWHGDVFKDUDFWHUV. l.  SAP AG 2002. n. Offset and length accesses to structures are only permitted in Unicode programs if the structure is flat and the offset and length specifications only contain character-type fields from the beginning of the structure. This means, the access will cause an error if the offset and length area contains both character-type and non-character-type components.. n. If an offset/length access is allowed in a Unicode program, both offset and length specifications are interpreted as characters.. n. 5HFRPPHQGDWLRQ Only use offset and length accesses if it is necessary or useful. Bear in mind that processing component by component and using character string operations is generally safer and more readable.. © SAP AG. BC401. 2-30.

(92) 'DWD7\SHVDQG'DWD2EMHFWVLQ'HWDLO6XPPDU\. <RXDUHQRZDEOHWR. l 8VHHOHPHQWDU\GDWDREMHFWVDQGVWUXFWXUHV DSSURSULDWHO\ l 8VHQXPHULFGDWDW\SHVDSSURSULDWHO\. l 8VHDXWRPDWLFW\SHFRQYHUVLRQVDSSURSULDWHO\ l 7DNHWKHVSHFLDOIHDWXUHVRIFKDUDFWHUVWULQJ SURFHVVLQJLQ8QLFRGHLQWRDFFRXQW.  SAP AG 2002. © SAP AG. BC401. 2-31.

(93) ([HUFLVH 8QLW 'DWD7\SHVDQG'DWD2EMHFWVLQ'HWDLO. 7RSLF 'HILQLQJ'DWD7\SHVDQG'DWD2EMHFWV %DVLF6WDWHPHQWV 3URFHVVLQJ&KDUDFWHU6WULQJV. At the conclusion of these exercises, you will be able to: • Define structure types locally in the program • Define elementary and complex data objects • Split strings • Use conversion rules • Display the contents of data objects in lists In this exercise, you will use a template to create a program that receives a single data record from the database table SFLIGHT in form of a character string. The program will split the this character string into its components and display it formatted in a list. Because the focus of this exercise is not on the transfer of data as a character string, we will use a function module that will provide us with the required database. This will simulate actual cases, such as data transfer from an external system. 3URJUDP. 7HPSODWH. 0RGHOVROXWLRQ. =%&BB63/,7B675,1*. 6$3%&B'727B63/,7B675,1*. 6$3%&B'726B63/,7B675,1*. LV\RXUWZRGLJLWJURXSQXPEHU 1-1. Copy the program, 6$3%&B'727B63/,7B675,1* and give it the new name =%&BB63/,7B675,1*.. 1-2. Familiarize yourself with the main body of the program. Pay special attention to the content of the data object datastring after the function module call. Use the Debugger to do this, and/or display the character string in a list. (The function module itself is here seen as a black box. For this exercise, it is not necessary to understand its construction.). 1-3. To be able to split the character string into its components you must first remove the ## characters. Remove the two leading separators from the character string first. Then copy the initial part up to the closing separators to the auxiliary variable set_string. For this, set_string has to be defined appropriately.. © SAP AG. BC401. 2-32.

(94) 1-4. Now use the separators to split the contents of the auxiliary variable set_string into the structure wa_flight_c. The latter is typed with the local program structure type st_flight_c. You still have to comment out the components of this structure type and assign them an appropriate type.. 1-5. As a test, display the fields of the structure, wa_flight_c in a list.. 1-6. In the list displayed in exercise 1-5, you should have observed that some of the fields were displayed without formatting – for example, the PRICE field. Your next step is to change this. To do this, convert the data you have extracted by copying it to data objects with suitable types. Also, not all components of wa_flight_c are to be displayed. For this purpose, a structure wa_flight has already been defined. It is typed with the structure type st_flight. You must comment out the components of st_flight and find appropriate types for these components for the formatting. Then copy the identically-named components of the character-type structure wa_flight_c to the fields of the structure wa_flight. Display the contents of the structure wa_flight in a list. Use the appropriate formatting options for the WRITE statement for the fldate and price components.. © SAP AG. BC401. 2-33.

(95) 6ROXWLRQ 8QLW 'DWD7\SHVDQG'DWD2EMHFWVLQ'HWDLO. 7RSLF 'HILQLQJ'DWD7\SHVDQG'DWD2EMHFWV %DVLF6WDWHPHQWV 3URFHVVLQJ&KDUDFWHU6WULQJV. REPORT. sapbc401_dtos_split_string.. TYPES: BEGIN OF st_flight_c, mandt(3). TYPE c,. carrid(3). TYPE F, TYPE Q,. connid(4). TYPE Q,. fldate(8). TYPE F,. price(20). TYPE F,. currency(5). TYPE F,. planetype(10). TYPE Q,. seatsmax(10). TYPE Q,. seatsocc(10). paymentsum(22) TYPE F, seatsmax_b(10) TYPE Q, seatsocc_b(10) TYPE Q, seatsmax_f(10) TYPE Q, seatsocc_f(10) TYPE Q, END OF st_flight_c, BEGIN OF st_flight, carrid(3). TYPE c,. connid(4). TYPE n,. fldate. TYPE G,. price(9) currency(5). TYPE S'(&,0$/6, TYPE F,. planetype(10) TYPE F, seatsmax seatsocc. TYPE L, TYPE L,. END OF st_flight.. © SAP AG. BC401. 2-34.

(96) DATA: datastring. TYPE string,. VHWBVWULQJ7<3(VWULQJ wa_flight_c TYPE st_flight_c, wa_flight. TYPE st_flight.. START-OF-SELECTION. CALL FUNCTION ’BC401_GET_SEP_STRING’ * EXPORTING *. IM_NUMBER. = ’1’. *. IM_TABLE_NAME. = ’SFLIGHT’. *. IM_SEPARATOR. = ’#’. *. IM_UNIQUE. = ’X’. IMPORTING ex_string. = datastring. EXCEPTIONS no_data. = 1. OTHERS. = 2.. IF sy-subrc <> 0. MESSAGE a038(bc401). ENDIF.. 6+,)7GDWDVWULQJ%<3/$&(6 ),1'  ,1GDWDVWULQJ ,)V\VXEUF!. 0(66$*(D EF

(97)  (1',). 63/,7GDWDVWULQJ$7  ,172VHWBVWULQJGDWDVWULQJ. 63/,7VHWBVWULQJ$7  ,172 ZDBIOLJKWBFPDQGW. ZDBIOLJKWBFFDUULG ZDBIOLJKWBFFRQQLG ZDBIOLJKWBFIOGDWH ZDBIOLJKWBFSULFH. ZDBIOLJKWBFFXUUHQF\. ZDBIOLJKWBFSODQHW\SH. © SAP AG. BC401. 2-35.

(98) ZDBIOLJKWBFVHDWVPD[ ZDBIOLJKWBFVHDWVRFF. ZDBIOLJKWBFSD\PHQWVXP ZDBIOLJKWBFVHDWVPD[BE ZDBIOLJKWBFVHDWVRFFBE. ZDBIOLJKWBFVHDWVPD[BI. ZDBIOLJKWBFVHDWVRFFBI. 029(&255(6321',1*ZDBIOLJKWBF72ZDBIOLJKW WRITE: / wa_flight-carrid, wa_flight-connid, ZDBIOLJKWIOGDWH''00<<<<. ZDBIOLJKWSULFH&855(1&<ZDBIOLJKWFXUUHQF\ ZDBIOLJKWFXUUHQF\. ZDBIOLJKWSODQHW\SH ZDBIOLJKWVHDWVPD[. ZDBIOLJKWVHDWVRFF. © SAP AG. BC401. 2-36.

(99) 8VLQJ,QWHUQDO7DEOHV &RQWHQWV l ,QWURGXFWLRQDQGDGYDQWDJHVRILQWHUQDOWDEOHV l 'HILQLQJLQWHUQDOWDEOHV. l ,QWHUQDOWDEOHRSHUDWLRQV l 1RWHVRQSHUIRUPDQFH l 6SHFLDOLQWHUQDOWDEOHV.  SAP AG 2002. © SAP AG. BC401. 3-1.

(100) 8VLQJ,QWHUQDO7DEOHV8QLW2EMHFWLYHV. $WWKHFRQFOXVLRQRIWKLVXQLW\RXZLOOEHDEOHWR l 'HILQHLQWHUQDOWDEOHV. l 3HUIRUPRSHUDWLRQVRQLQWHUQDOWDEOHV. l ,GHQWLI\WDEOHNLQGVDQGXVHWKHPDSSURSULDWHO\LQ GLIIHUHQWVLWXDWLRQV.  SAP AG 2002. © SAP AG. BC401. 3-2.

(101) 8VLQJ,QWHUQDO7DEOHV,QWHJUDWLRQLQ&RXUVH &RQWHQW.     !#"!   %$'&)(*+ ,    ,-.    

(102)      ./021 3246587 4 1 27 9 4:.  SAP AG 2002. © SAP AG. BC401. 3-3.

(103) 8VLQJ,QWHUQDO7DEOHV 

(104). ,QWURGXFWLRQDQGDGYDQWDJHVRILQWHUQDOWDEOHV ,QWURGXFWLRQDQGDGYDQWDJHVRILQWHUQDOWDEOHV 'HILQLWLRQ 'HILQLWLRQ 2SHUDWLRQV 2SHUDWLRQV 6SHFLDOVLWXDWLRQV 6SHFLDOVLWXDWLRQV 1RWHVRQSHUIRUPDQFH 1RWHVRQSHUIRUPDQFH.  SAP AG 2002. © SAP AG. BC401. 3-4.

(105) 7KH,QWHUQDO7DEOHD'DWD2EMHFWRI9DULDEOH/HQJWK. (OHPHQWDU\GDWDREMHFWV. 6WUXFWXUHV. $%$3 SURJUDP. 6WDWLFGDWDREMHFWV H[FHSWIRU W\SHV675,1*;675,1*

(106). ,QWHUQDOWDEOH $WUXQWLPHWKHUXQWLPHV\VWHPDOORFDWHV PHPRU\IRUWKHOLQHVLQWKHWDEOHDVQHHGHG G\QDPLFWDEOHH[WHQVLRQ

(107).  SAP AG 2002. n. Internal tables are data objects that allow you to store datasets with a fixed structure in memory. The data is stored line by line in memory. Each line has the same structure.. n. You can also refer to each component in a line as a column in the internal table. You refer to each line in the internal table as a table line or table entry.. n. Internal tables are G\QDPLFGDWDREMHFWV - that is, they can hold any number of lines of a fixed type. The number of lines in an internal table is limited only by the capacity of the specific system with which you are working.. n. You can define the line type of an internal table to include elementary, structured, or even table types, and can be as complex as you want to make it.. © SAP AG. BC401. 3-5.

(108) $WWULEXWHVRI,QWHUQDO7DEOHV. /LQHW\SH. &$55,' &211,' ',67$1&( ',67,' /LQH LQGH[. . $$. . 0,. . /+. .  .0. . . . . /+. 4). 64. 8$. . . . .  .0  0,.  0,.  0,. . 64. ,QGH[DFFHVV. .H\DFFHVV. 7DEOHNLQG Standard table Sorted table Hashed table. .H\GHILQLWLRQ ( .H\ILHOGV ( 6HTXHQFH ( 8QLTXHQHVV  SAP AG 2002. n. Each internal table has the following attributes: é /LQHW\SH You use the line type to specify which columns are to be included in your internal table. You must assign a name and type to each column. You generally define a line type using a structure type. é .H\ Internal tables have a key, just like database tables. The key is defined by: Specifying the FROXPQV that should belong to the NH\; the VHTXHQFH; and whether or not the key should be XQLTXH or QRQ XQLTXH. Depending on how you define your internal table, the runtime system may create an DGGLWLRQDO XQLTXHNH\(the LQGH[) for some internal tables (this will be discussed in more detail later). For simplicity’s sake you can think of the index as a OLQHQXPEHU.. é 7DEOHNLQG There are three table kinds in ABAP. Each kind has different attributes, which specify whether the key is unique, how the index is managed, and how the table data is addressed internally. The table kind specifies the possible accesses. The purpose of this is to provide particular support for special access types from the runtime system (will be discussed later).. © SAP AG. BC401. 3-6.

(109) /LQN%HWZHHQ7DEOH.LQGDQG$FFHVV7\SH ,QGH[WDEOHV 7DEOHNLQG. STANDARD TABLE. +DVKHGWDEOH. SORTED TABLE. HASHED TABLE. ,QGH[DFFHVV Q. .H\DFFHVV. f% g%6h. j. g6k Y [ g6%k X TUM^ iU%l. g W ^> QTi [. mN =g T %l op n [i'8V Y SB[. 8QLTXHQHVV. ;=<>;@?BAC;ED FGA@H. AE;ED FIAJHLKM;N<I;O?PAE;CD FIACH. AJ;@D FQAEH. $FFHVVE\. R>SUTMV W XZY\[]6^8_. R`S6T'V W Xba^8X. c=^8XdSe[%W X.  SAP AG 2002. The table kind is linked to the access type as follows: n. You can only perform an index access (the fastest type of access) on STANDARD and SORTED tables.. n. The runtime system implements key accesses of SORTED and HASHED tables in a way that optimizes runtime performance. Key access of STANDARD tables is by WDEOHVFDQ - that is, comparing the field contents with the search key line by line, in a loop.. n. The runtime system implements key accesses of SORTED tables, for fully or partly qualified keys (left-aligned, no gaps, all fields filled with an "=") in a special way to optimize runtime. The same applies to partial sequential loops, where the loop condition is specified using the key fields. With the runtime-optimizing access, the runtime system keeps SORTED tables sorted by key fields, In all other cases, the system performs a WDEOHVFDQ.. n. The runtime optimizes key accesses of HASHED tables IRUIXOO\TXDOLILHGNH\VRQO\. The table entries are addressed by means of a special hash algorithm. This minimizes access time for reading single records with fully qualified keys. The access time is thus independent of the number of lines in the table. In all other cases, the system performs a WDEOHVFDQ. This means that you should only use HASHED tables if you want to access table entries using a fully-qualified key.. © SAP AG. BC401. 3-7.

(110) 8VLQJ,QWHUQDO7DEOHV 

(111). ,QWURGXFWLRQDQGDGYDQWDJHVRILQWHUQDOWDEOHV ,QWURGXFWLRQDQGDGYDQWDJHVRILQWHUQDOWDEOHV 'HILQLWLRQ 'HILQLWLRQ 2SHUDWLRQV 2SHUDWLRQV 6SHFLDOVLWXDWLRQV 6SHFLDOVLWXDWLRQV 1RWHVRQSHUIRUPDQFH 1RWHVRQSHUIRUPDQFH.  SAP AG 2002. © SAP AG. BC401. 3-8.

(112) 2YHUYLHZ7\SHVRI'HILQLWLRQVIRU,QWHUQDO7DEOHV :LWKORFDOWDEOHW\SH. ,PSOLFLWWDEOHW\SH. /RFDOWDEOHW\SH. *OREDOWDEOHW\SH. 7<3(6 ORFDOBW\SH ORFDOBW\SH. JOREDOBW\SH. 7DEOH DWWULEXWHV. ,QWHUQDOWDEOH. '$7$ WBOLVW7<3(. ORFDOBW\SH ORFDOBW\SH. :LWKJOREDOWDEOHW\SH. 7DEOH DWWULEXWHV. ,QWHUQDOWDEOH. '$7$ WBOLVW7<3( 7DEOH DWWULEXWHV. ,QWHUQDOWDEOH. '$7$ WBOLVW7<3( JOREDOBW\SH JOREDOBW\SH.  SAP AG 2002. n. There are several ways to define an internal table in ABAP: é Use the TYPES statement to define a table type. Then use this to assign a type to one or more data objects or interface variables. é Alternatively, declare the table attributes directly when you define the data object (that is, use a ERXQG type).. é The third option is to define an internal table using a global table type (defined in the ABAP Dictionary). n. The tables you define using the first or second option are visible only in the program in which you define them. Whenever you need table type visible from all programs, create a global table type (that is, use the third option).. © SAP AG. BC401. 3-9.

(113) 7KH'DWD7\SHRIDQ,QWHUQDO7DEOH /RFDOWDEOHW\SHLQWHUQDOWDEOH 7<3(6. RU. $WWULEXWHV. '$7$. QDPH7<3(WDEOHBW\SH 7<3( WDEOHBNLQG. ( 7DEOHNLQG. :,7+NH\BGHI :,7+ NH\BGHI NH\BGHI. ( .H\. 2)OLQHBW\SH 2). ( /LQHW\SH FROXPQV

(114). >,1,7,$/6,=(Q@ ,1,7,$/6,=(. ( ,QLWLDOVL]H RSWLRQDO

(115). *OREDOWDEOHW\SH. $WWULEXWHV. JOREDOBW\SH. ( 7DEOHNLQG. ,QSXWRQVFUHHQXVHG WRVSHFLI\DWWULEXWHV . ( /LQHW\SH FROXPQV

(116) ( .H\.  SAP AG 2002. n. To define a table type (explicitly or implicitly), you must give the type (or data object) a name, as well as specifying a WDEOHNLQG OLQHW\SH and NH\. n. If you are defining a local table type, enter the kind after TYPE and the line type after OF. You must list the key fields after WITH.. n. You create and edit global types in the ABAP Dictionary. If you are defining a global table type, specify the same information on the maintenance screens.. n. For table types defined in a program, you can enter the number of lines that the runtime system should reserve when it initializes the data object, after the INITIAL SIZE addition. This makes sense if you know exactly how many lines you will want in your table when you create it. However, if your table needs more lines at runtime, it will not be limited in size by this addition, since the runtime system frees the necessary memory dynamically. (Internal tables are G\QDPLF data objects).. © SAP AG. BC401. 3-10.

(117) 7DEOH$WWULEXWH/LQH7\SH /LQHW\SH /RFDOVWUXFWXUHW\SH. *OREDOVWUXFWXUHW\SH. 7<3(6 7<3(6 OLQHBW\SH %(*,12)OLQHBW\SH  (1'2)OLQHBW\SH. OLQHBW\SH. /RFDOVWUXFWXUH. '$7$ '$7$. VWUXFWXUH VWUXFWXUH7<3(. 7DEOHW\SH. QDPH7<3(WDEOHBNLQG 7<3(. QDPH/,.(WDEOHBNLQG /,.(. :,7+NH\BGHI. :,7+NH\BGHI. 2)VWUXFWXUH VWUXFWXUH 2). 2)OLQHBW\SH 2) OLQHBW\SH. >,1,7,$/6,=(Q@. >,1,7,$/6,=(Q@.  SAP AG 2002. n. To specify the line type of an internal table, you can use all the local and global data types or data objects.. n. Internal tables are most frequently used to display contents of the database tables. Normally, nonnested structured data types are used for this.. n. n. If you use a line type, you must use a statement in the form: 7<3( WDEOHBNLQG 2) line_type, where WDEOHBNLQG is the kind of table (to be discussed later) and line_type is the name of the structure type you are using.. If you use structure (data object), you must use a statement in the form: /,.( WDEOHBNLQG 2) line_type, where structure is the name of the structure object you are using.. © SAP AG. BC401. 3-11.

(118) 7DEOH$WWULEXWH7DEOH.LQGDQG.H\. 7<3(6 WDEOHBNLQG LWDEW\SH7<3(WDEOHBNLQG 2)OLQHBW\SH :,7+ NH\B NH\BGHI :,7+NH\BGHI. >,1,7,$/6,=(Q@ '$7$ WBQDPH7<3(LWDEW\SH. WDEOHBNLQG 67$1'$5'7$%/( 6257('7$%/( +$6+('7$%/(. NH\B NH\BGHI >12181,48(@^.(<FROFROQ_ '()$8/7.(<` ^81,48(_12181,48(`.(<FROFROQ 81,48(.(<FROFROQ.  SAP AG 2002. n. There are three parameters that you use to specify a table kind for your internal table: STANDARD TABLE, SORTED TABLE and HASHED TABLE. n. You specify the table key with the :,7+ NH\BGHI addition. NH\BGHI includes the names of all the key fields in order and specifies whether the key is to be UNIQUE or NON-UNIQUE.. n. The combination of the table kind and the key definition is very significant, because of the special support that certain table kinds receive with specific types of read access. You can use any of the following combinations: é For STANDARD tables: Either create a user-defined key by naming the key fields after NON-UNIQUE KEY, or specify the standard key using the WITH DEFAULT KEY addition. The standard key consists of all the fields with character-type data types (c, n, d, t, x, string, xstring). é For SORTED tables: List the key fields after WITH UNIQUE KEY or NON-UNIQUE KEY as appropriate. é For HASHED tables: List the key fields after WITH UNIQUE KEY.. n. Alternatively, use the pseudo-component table_line, if you are specifying a table without a structured line type, or if the entire table line is being used as the key. This will be discussed in more detail later in the unit.. © SAP AG. BC401. 3-12.

(119) ([DPSOH6WDQGDUG7DEOHZLWK/RFDO7\SH /LQHW\SH. 7<3(6 VBGLVWDQFHBW\ %(*,12)VBGLVWDQFHBW\ FDUULG7<3(VBFDUUBLG FRQQLG7<3(VBFRQQBLG GLVWDQFH7<3(VBGLVWDQFH GLVWLG7<3(VBGLVWLG (1'2)VBGLVWDQFHBW\. 7DEOHW\SH. 7<3(6 WWBGLVWDQFHBW\ WWBGLVWDQFHBW\7<3(67$1'$5'7$%/( 2)VBGLVWDQFHBW\ VBGLVWDQFHBW\ :,7+12181,48( .(<GLVWDQFHGLVWLG. ,QWHUQDOWDEOH. '$7$ WWBGLVWDQFHB W\ WWBGLVWDQFH7<3(WWBGLVWDQFHBW\ WWBGLVWDQFHBW\ WWBGLVWDQFH WWBGLVWDQFH. ,QWHUQDOWDEOH RIWKHWDEOHNLQG 67$1'$5'7$%/(.  SAP AG 2002. n. The above example shows the definition of an internal table (tt_distance) using a local table type (tt_distance_ty), which itself uses a local line type (s_distance_ty).. n. The internal table defined here is a STANDARD table with the line type s_distance_ty. It contains the columns carrid, connid, distance and distid.. n. The distance and distid fields are key fields. The key is not unique.. © SAP AG. BC401. 3-13.

(120) ([DPSOH6RUWHGDQG+DVKHG7DEOH 6HTXHQFH. 6RUWHGWDEOH. '$7$ GLVWDQFHBUDQF GLVWDQFHBUDQF 7<3(6257('7$%/( VBGLVWDQFHBW\ 2)VBGLVWDQFHBW\ :,7+12181,48(.(< GLVWLGGLVWDQFH.    . 6HTXHQFH. FDUULG. FRQQLG. /+ /+ $$ 40.    . 6HTXHQFH. +DVKHGWDEOH. FDUULG. '$7$ GLVWDQFHBEXIIHU GLVWDQFHBEXIIHU 7<3(+$6+('7$%/( VBGLVWDQFHBW\ 2)VBGLVWDQFHBW\ :,7+81,48(.(< FDUULGFRQQLG. . /+ $$ 40 /+. FRQQLG .    . GLVWDQFH GLVWLG .     . . .0 .0 0, 0,. GLVWDQFH GLVWLG.    . .0 0, 0, .0.  SAP AG 2002. n. The above example shows the definition of a SORTED table and a HASHED table. Both tables have the same line type as the STANDARD table on the previous slide.. n. Note that the contents of the table are in a different order. For SORTED tables, the sequence of the entries in the internal table is determined by the sequence of fields in the key definition.. © SAP AG. BC401. 3-14.

(121) 7KH6WDQGDUG7DEOH7\SH '$7$ 7<3( 7$%/( WBQDPH7<3(7$%/(. 2) 2)OLQHBW\SH ,QWHUSUHWHGE\ WKHV\VWHPDV. 'HILQLWLRQE\ VWDQGDUGWDEOHW\SH. '$7$ 7<3( 67$1'$5' 7$%/( WBQDPH7<3(67$1'$5'7$%/( 2) 2)OLQHBW\SH. :,7+'()$8/7.(< :,7+'()$8/7.(< ([DPSOH '$7$. 7<3(7$%/(2) WBVIOLJKW7<3(7$%/(2)VIOLJKW.  SAP AG 2002. n. A standard type exists for defining standard tables with bound types. (Table type STANDARD TABLE, key WITH DEFAULT KEY). When you create such a table, you can omit the STANDARD and WITH DEFAULT KEY additions, since the runtime system supplies them automatically.. n. Note however, that the standard table type exists for data objects only. If you are defining a table type that you want to use to provide a type for data objects, you must specify all its attributes completely.. n. Incomplete table types are known as JHQHULF. You can only use them to assign types to table-type interface parameters.. © SAP AG. BC401. 3-15.

(122) ,QWHUQDO7DEOHVZLWKDQ8QVWUXFWXUHG/LQH7\SH 'HILQLWLRQ '$7$. LWBILHOGV7<3(67$1'$5'7$%/(2)GGOILHOGQDPH. WDEOHB :,7+.(<WDEOHBOLQH WDEOHBOLQH. ZDBILHOG7<3(GGOILHOGQDPH. 6(/(&7ILHOGQDPH)520GGOWDEOHRIWUDQVSWDEOHV. )LOO. ,1727$%/(LWBILHOGV. :+(5(WDEQDPH  63)/, . .H\ DFFHVV. 5($'7$%/(LWBILHOGV,172ZDBILHOG. WDEOHB :,7+.(<WDEOHBOLQH WDEOHBOLQH  &,7<)520 .  SAP AG 2002. n. Use an unstructured line type if you need a single-column internal table. The slide shows an example of a single-column table with the line type field_name.. n. To declare an explicit key, you must use the pseudo-component table_line.. n. You can use internal tables with an unstructured line type in the following ABAP statement (among others): é SET PF-STATUS .. EXCLUDING itab. (deactivate function codes dynamically) é SPLIT .. INTO TABLE itab. (split a string dynamically). n. You can use a key access, for example, to ascertain whether a specific entry H[LVWV.. © SAP AG. BC401. 3-16.

(123) 8VLQJ,QWHUQDO7DEOHV 

(124). ,QWURGXFWLRQDQGDGYDQWDJHVRILQWHUQDOWDEOHV ,QWURGXFWLRQDQGDGYDQWDJHVRILQWHUQDOWDEOHV 'HILQLWLRQ 'HILQLWLRQ 2SHUDWLRQV 2SHUDWLRQV 6SHFLDOVLWXDWLRQV 6SHFLDOVLWXDWLRQV 1RWHVRQSHUIRUPDQFH 1RWHVRQSHUIRUPDQFH.  SAP AG 2002. © SAP AG. BC401. 3-17.

(125) 2YHUYLHZ7\SHVRI2SHUDWLRQ ,QWHUQDOWDEOH DVDGDWDREMHFW. 2SHUDWLRQVRQRQHRU PRUHOLQHV. (GLWLQJOLQHV LQDORRS. RU. ( &RS\. 029(

(126). &/($5

(127) .HHSPHPRU\DYDLODEOH. ( ,QLWLDOL]H. )5((

(128) 5HOHDVHPHPRU\. ( ,QLWLDOL]H. ( &RPSDUHXVLQJRSHUDWRUV !!  !. ( 6RUW 6257

(129). ( ,QVHUW ( 5HDG. ,16(57

(130) 5($'.

(131). ( &KDQJH 02',)<

(132) ( 'HOHWH. '(/(7(

(133). ( ,QVHUWVXPPDWHG. ( (GLWOLQHV. VHTXHQWLDOO\. /223 FRPPDQGEORFN (1'/223.  &2//(&7

(134). ( $UUD\)HWFK 6(/(&7 ,1727$%/(

(135)  SAP AG 2002. You can perform three different types of operations on internal tables: n. 2SHUDWLRQVRQWKHZKROHGDWDREMHFW: Elementary operations available include MOVE (copy the content line by line), CLEAR (delete the content, but keep the memory allocated), and FREE (delete the content and release the memory). You can also use all the numerical comparison operators with internal tables in logical expressions. With these operators, the number of lines is compared first and then, if necessary, the line contents. (This is recursive for deep types). For more information, refer to the documentation on internal tables. You can use the SORT statement to sort the content of STANDARD and HASHED tables. This statement allows you to sort the table by one or columns, specifying DVFHQGLQJ or GHVFHQGLQJ for each column. For more details, refer to the keyword documentation for the SORTstatement. You can use the SELECT ... INTO TABLE statement to copy the contents of database tables directly into internal tables.. n. 2SHUDWLRQVRQOLQHV: You can use the INSERT, READ, MODIFY, DELETE, and COLLECT statements to perform operations on one or more lines in the internal table. The syntax of the first four of these statements is dealt with in the slides that follow. For the syntax of the COLLECT statement, refer to the online documentation.. n. /RRSSURFHVVLQJ You can use the LOOP AT ... ENDLOOP statement to process the lines of the internal table sequentially. The exact syntax for this is dealt with in the slides that follow.. © SAP AG. BC401. 3-18.

(136) /LPLWLQJWKH6FRSHRI/LQH2SHUDWLRQV7DUJHW 5HFRUGVDQG$FFHVV7\SH 6SHFLI\VHWRIWDUJHWUHFRUGV. 7DEOHNH\ /LQHLQGH[ IRULQGH[WDEOHV

(137). Q FRQGLWLRQ!. &RQGLWLRQDSSOLHGWRDQ\QXPEHURIFROXPQV. >QQ@. ,QGH[LQWHUYDO IRULQGH[WDEOHV

(138). 6SHFLI\DFFHVVW\SHGDWDWUDQVIHUW\SH :RUNDUHD. &RS\LQJSURFHVV. 7DEOH. )LHOGV\PERO. 'LUHFWDFFHVVE\ GHUHIHUHQFHGSRLQWHU GHUHIHUHQFHGSRLQWHU. ,QVHUW XVLQJWDEOH.  SAP AG 2002. n. Almost all line operations and loop processing statements offer you several options for specifying the target set of records to be processed. You can specify these target records by declaring a key or index, by formulating a condition that applies to some of the columns, or by specifying an index interval. Your use of these options is limited only by the table kind you have chosen. Example: You cannot specify a line in a hashed table using an index.. n. When accessing table rows, you have two possibilities for a number of line operations and for loop processing: You can either copy the data into a structure with the same type as the line type of the internal table, or you can set a pointer to a table line and access the data in that line directly.. n. In particular, when you insert table lines, you can pass the data to be inserted using another internal table.. n. Note that all statements either set a return value or trigger a runtime error. If a return code has been set, it is stored in the sy-subrc field after the statement has been executed. Runtime errors are only triggered if the data passed at runtime are crucial in determining whether or not the operation can be performed. Example: You try to insert a new line into a SORTED table using an index. If you insert the new line in exactly the right place in a sorted table, the system performs the operation. If not, the system returns a runtime error.. © SAP AG. BC401. 3-19.

(139) 3UHYLHZ)LHOG6\PER,V 

References

Related documents

Edwards asserts the trial court erred in granting Kaye’s motion for summary judgment. Specifically, Edwards contends the statute of limitations on his claim was tolled, Kaye’s

A prospective study of thirty myofascial trigger points in upper trapezius were considered to determine the effectiveness of transcutaneous electrical nerve stimulation and

Use an FPGA to implement the following Boolean equation: (a) Create a Block Design File called prob_c4_1.bdf to define the logic circuit?. (b) Create a Vector Waveform File

This study aims to assess whether doctors suffering from occupational distress have an increased risk of (i) using alcohol or drugs (illicit, non-illicit); (ii) binge-eating;

● From the Start/Finish at the River House Barn, head south and cross Fig Ave into the River Campground and head EAST and connect with Main Loop trail.. ● The main loop trail will

MCLE COURSE NO: 901289748 Up to 24 HOURS | Up to 5.75 ETHICS Applies to the College of the State Bar of Texas and to the Texas Board of Legal Specialization in Criminal Appellate

In conclusion, we have used ultrafast spectroscopy techniques to measure two differ- ent types of semiconductor heterostructures. For the InAs/GaSb based short-period

We performed the same analysis as for miRNAs in order to build a lncRNA-diseasome bipartite network, where one set of nodes corresponds to the human cancer types analyzed by SWIM in