Vous êtes sur la page 1sur 8

ABAP Commands

Assignment Operations
Assignment Operator: <fn> = ... <f3> = <f2> = <f1>. Equivalent to MOVE. Executed from right to left. MOVE TO: MOVE <f1> TO <f2>. Follows the Conversion ules. !ee also MOVE PE CE"#A$E for character string. MOVE-CORRES O!"#!$: MOVE-CORRES O!"#!$ <fstring1> TO <fstring2>. #his statement assigns the contents of com%onents of field string fstring& to those com%onents of field string fstring' which have the same names. %R#TE TO: %R#TE <f1> TO <f2> &<options>'. (oes "O# follow the Conversion ules. #he target field is inter%reted as a t)%e C field. O%tion * all Formatting O%tions exce%t +"(E and "O*$AP. Alwa)s chec,s the settings in the user-s master record. e.g. whether the decimal %oint a%%ears as a %eriod /.0 or a comma /.0. Spe(if)ing t*e So+r(e fie,- at R+ntime .it* %R#TE TO: %R#TE /<f1>0 TO <f2>. #he s)stem %laces the value of the data o12ect assigned to 3f&4 in 3f'4. E1amp,e:
DATA: NAME(10) VALUE 'SOURCE', SOURCE(10) VALUE 'Antony', TARGET(10). ... WRITE (NAME) TO TARGET. WRITE: TARGET. Thi !"o#$%& th& o$t!$t: Antony

C2EAR: C2EAR <f>3<fstring> &%#T4 <g>3!522'. esets the contents to initial values /or to a first 1)te of 3g4 or to 5-66-0. 6REE: 6REE <f>3<fstring>. 7i,e C7EA . resets the contents to initial values. Also releases an) resources connected with the data o12ect. #his ma) 1e relevant with internal ta1les. structures with ta1ular com%onents as well as ta1le wor, areas.

ABAP #raining

Page & of 8

ABAP Commands

Numerical Operations
COM 5TE: &COM 5TE' <n> = <e1pression>. 5sing Mat*emati(a, 6+n(tions: &COM 5TE' <n> = <f+n(tion>/ <m> 0. #he 1lan,s 1etween the %arentheses and the argument 3m4 are o1ligator). Functions for all "umeric (ata #)%es9 AB!. !:$". CE:7. F7OO . # +"C. F AC. Floating*Point functions9 CO!. !:". #A". ACO!. A!:". A#A". CO!;. !:";. #A";. E5P. 7O$. 7O$&6. !< #. 7asi( Arit*meti( Operations: Operation 5sing e1pression Addition !u1traction Multi%lication (ivision :nteger division <p> = <n> 9 <m>. <p> = <n> - <m>. <p> = <n> : <m>. <p> = <n> < <m>. <p> = <n> "#V <m>.

5sing 8e).orA"" <n> TO <m>. S57TRACT <n> 6ROM <m>. M52T# 2; <m> 7; <n>. "#V#"E <m> 7; <n>. -

emainder of division <p> = <n> MO" <m>.

Ex%onentiation <p> = <n> :: <m>. =hen using mathematical ex%ressions. %lease note that the o%erators >. *. ?. ??. and @. as well as o%ening and closing %arentheses. are ABAP@A words and must therefore 1e %receded and followed 1) 1lan,s. A""-CORRES O!"#!$ <fstring1> TO <fstring2>= S57TRACT-CORRES O!"#!$ <fstring1> 6ROM <fstring2>= M52T# 2;-CORRES O!"#!$ <fstring2> 7; <fstring1>= "#V#"E-CORRES O!"#!$ <fstring2> 7; <fstring1>: !ee MOVE*CO E!PO"(:"$. A--ing Se>+en(es of 6ie,-s: &. A"" <n1> T4E! <n2> 5!T#2 <n?> $#V#!$ <m>. B m C n& > n' > ... > nD. '. A"" <n1> T4E! <n2> 5!T#2 <n?> TO <m>. B m C m > n& > n' > ... > nD. E. A"" <n1> T4E! <n2> 5!T#2 <n?> ... ACCOR"#!$ TO <se,> $#V#!$3TO <m>. 3sel4 is generated 1) !E7EC#*OP#:O"! or A"$E.. A. A"" <n1> 6ROM <m1> TO <m?> $#V#!$ <m>. 3n&4 is the first in a sequence of consecutive fields. 3m&4 and 3mD4 contain the num1ers of the first and last fields in this sequence.

ABAP #raining

Page ' of 8

ABAP Commands Operators re(e-en(e: #he order of evaluation is9 &. ex%ressions in %arentheses '. functions E. ?? /ex%onentiation0 A. ?. @ . MO(. (:V /multi%lications. divisions0 F. >. * /additions. su1tractions0

Character Strings Operations


"ote to the Character !trings O%erations. All the o%erations mar,ed with @:@ %rocess the o%erands regardless of t)%e as t)%e C * no internal conversion is %erformed. S4#6T : : S4#6T <(> &7; <n> 2ACES' &2E6T3R#$4T3C#RC52AR'. 3n4 can 1e a varia1le. must 1e 46 /no actions if 360. default is &. 7EF# is default. S4#6T <(> 5 TO <str> &2E6T3R#$4T3C#RC52AR'. 3str4 is a su1string to search in 3str4 and can 1e a varia1le. 7EF# is default. :f 3str4 is not found in 3c4. S;-S57RC is set to A and 3c4 is not shifted. Otherwise. S;-S57RC is set to 6. S4#6T <(> 2E6T "E2ET#!$ 2EA"#!$ <str>. S4#6T <(> R#$4T "E2ET#!$ TRA#2#!$ <str>. 3str4 can 1e a varia1le. RE 2ACE : : RE 2ACE <str1> %#T4 <str2> #!TO <(> &2E!$T4 <,en>'. !earches the field 3c4 for the first occurrence of the first 3len4 %ositions of the %attern 3str&4. :f no length is s%ecified. it searches for the %attern 3str&4 in its full length. #hen. the statement re%laces the first occurrence of the %attern 3str&4 in field 3c4 with the string 3str'4. :f a length 3len4 was s%ecified. onl) the relevant %art of the %attern is re%laced. S;-S57RC C 69 string re%lacedG S;-S57RC C A9 string not re%laced.. 3str&4. 3str'4. and 3len4 can 1e varia1les. TRA!S2ATE : : TRA!S2ATE <(> TO 5 ER CASE. TRA!S2ATE <(> TO 2O%ER CASE. #o convert also umlauts the %rofile %arameter a1a%@localeHct)%e must 1e set and character set must 1e found. TRA!S2ATE <(> 5S#!$ <str>. 3str4 contains %airs of letters. where the &st letter of each %air is re%laced 1) the 'nd letter. Can 1e a varia1le. TRA!S2ATE <(> 6ROM CO"E A$E <g1> TO CO"E A$E <g2>. TRA!S2ATE <(> 6ROM CO"E A$E <g>. TRA!S2ATE <(> TO CO"E A$E <g>. Conversion ta1les 3g&4 and 3g'4 must exist. otherwise untime error. +se transaction !PA( to maintain conversion ta1les #CP66 * #CP6'. !ome ABAP #raining Page E of 8

ABAP Commands conversion com1inations maintained at untime for %erformance reason /e.g. -&&&6- * ;P. -6&66- * EBC(:C /:BM 'IA00. :. P. F. 5 fields remain unchanged. TRA!S2ATE <(> 6ROM !5M7ER 6ORMAT <!1> TO !5M7ER 6ORMAT <!2>. TRA!S2ATE <(> 6ROM !5M7ER 6ORMAT <!>. TRA!S2ATE <(> TO !5M7ER 6ORMAT <!>. "um1er format 3"4 can 1e -6666- /;P. !:":5.:BM0 or -6&6&- /(EC al%ha O!F0. Function module !J!#EMHFO MA# dis%la)s s)stem code %age and num1er format. CO!VERT: CO!VERT TEAT <(> #!TO SORTA72E CO"E <s(>. !ource 3c4 must 1e C or = t)%e. #arget 3sc4 should 1e of t)%e 5 and at least &K times /for C0 or A times /for =0 as long as source. #he method of conversion de%ends on the text environment of the running ABAP@A %rogram. #he text environment is defined in the user-s master record or. as an exce%tion. can 1e set via !E# 7OCA7E 7A"$+A$E. #he %ur%ose of this statement is to create an accom%an)ing field 3sc4 for a character field 3c4. which can serve as an al%ha1etical Binar) sort ,e) for 3c4. which is "O# de%endent of %latform*s%ecific internal coding of the individual letters. OVER2A; : : OVER2A; <(1> %#T4 <(2> &O!2; <str>'. Overla)s all %ositions in 3c&4 containing letters which occur in 3str4 with the contents of 3c'4. :f omit O"7J 3str4. onl) S ACEs are overwritten. S;-S57RC C 6 9 at least one character was re%lacedG S;-S57RC C A 9 other cases. SEARC4 : : SEARC4 <(> 6OR <str> &<options>'. !earches 3c4 for the character string in 3str4. :f successful. S;-S57RC C 6 and S;-6" OS C offset. Otherwise S;-S57RC C A. attern: @str@ : Character string /trailing 1lan,s are ignored0G @.str .@ : An) character string 1etween %eriodsG @:str@ : =ord ending with LstrLG @str:@ : =ord 1eginning with LstrL. Options: A77REV#ATE" : !earches for a word containing the character string s%ecified in 3str4. where the characters might 1e se%arated 1) other characters. #he first letter of the word and the string 3str4 must 1e the sameG START#!$ AT <n1> : "ote. S;-6" OS C offset starting at 3n&4 as wellG E!"#!$ AT <n2>

ABAP #raining

Page A of 8

ABAP Commands

A!" MARC : Mar,s converting to u%%ercase.

CO!"E!SE : : CO!"E!SE <(> &!O-$A S'. emoves leading 1lan,s. e%laces other sequences of 1lan,s with one 1lan, or removes all 1lan,s if "O*$AP!. STR2E! : : &COM 5TE' <n> = STR2E!/ <(> 0. CO!CATE!ATE : : CO!CATE!ATE <(1> ... <(n> #!TO <(> &SE ARATE" 7; <s>'. #railing 1lan,s ignored. S;-S57RC C 6 9 OMG S;-S57RC C A 9 result has to 1e truncated. S 2#T : : S 2#T <(> AT <-e,imiter> #!TO <(1> ... <(n>. #o %lace all fragments in different target fields. )ou must s%ecif) enough target fields. Otherwise. the last target field is filled with the rest of the field 3c4 and still contains delimiters. S;-S57RC C 6 9 All target fields are long enough and no fragment has to 1e truncated. Otherwise S;-S57RC C A. S 2#T <(> AT <-e,imiter> #!TO TA72E <itaB>. For each %art of the character string. the s)stem adds a new ta1le line. MOVE ERCE!TA$E: MOVE <(1> TO <(2> ERCE!TA$E <n> &R#$4T'. 3n4 C 6...&66. PE CE"#A$E ignored when either 3c&4 or 3c'4 are not C t)%e.

ABAP #raining

Page F of 8

ABAP Commands

Logical Operations
Comparisons: ... <f1> <operator> <f2> ... A,, 6ie,- T)pes: O%erators9 "E E< 7# 7E $# $E 34 C 3 3C 4 4C 43 #he o%erands can 1e data1ase fields. internal fields. literals. or constantsG structured data t)%es /com%ared com%onent 1) com%onent and nested structures are 1ro,en down into elementar) fields0G internal ta1les. Fields of different data t)%es can 1e com%ared /if the) are converti1le0 after an automatic #)%e Conversions according to the following hierarchical rules9 One of t*e Ot*er ConDersion operan-s operanF P ( or # C an) an) an) 5 to F to P to ( or #. "ote. Com%arison 1etween ( and # not su%%orted and causes %rogram termination. to C

C " 1oth to P C*ara(ter Strings an- !+meri( Strings: Onl) for t)%es C and ". Case- Trai,ing Op. Meaning Tr+e if sensitiDe 7,an8s Contains Onl) 3f&4 contains included onl) characters from 3f'4

S;-6" OS if tr+e

S;-6" OS if fa,se

CO

)es

offset of the first character length of 3f&4 of 3f&4 that does not occur in 3f'4

C!

contains "ot Onl)

)es

offset of the 3f&4 contains first character characters other included of 3f&4 that length of 3f&4 than those in does not occur 3f'4 in 3f'4 N 3f&4 contains at offset of the length of 3f&4 least one first character character from of 3f&4 that

CA Contains An)

)es

ABAP #raining

Page K of 8

ABAP Commands 3f'4 contains "ot An) Contains !tring contains "o !tring occurs in 3f'4

!A

)es

offset of the 3f&4 contains no first character one character length of 3f&4 of 3f&4 that from 3f'4 occurs in 3f'4 3f&4 contains 3f'4 3f&4 does not contain 3f'4 offset of 3f'4 length of 3f&4 in 3f&4 length of 3f&4 offset of 3f'4 in 3f&4

CS !S

no no

ignored ignored

Contains Pattern

no

3f&4 contains %attern 3f'49 : * an) character stringG 9 * an) single characterG E( * the %articular character /in u%%er or lower case0G offset of 3f'4 E: * the ignored length of 3f&4 in 3f&4 L?L s)m1olG E9 * the L>L s)m1olG EE * the LOL s)m1ol itselfG

EFFF * the trailing 1lan,s. length of 3f&4 offset of 3f'4 in 3f&4

contains "o Pattern

no

3f&4 does not ignored contain %attern 3f'4

7it Str+(t+res:

ABAP #raining

Page I of 8

ABAP Commands Com%ares first 1)te of the 3f&4 with 3f'4. which should have length & 1)te /recommended use as 3f'4 t)%e 5 length &0. Operator Meaning Tr+e if O G M 1its are one 1its that are & in 3f'4. are & in 3f&4 as well 1its are Dero 1its that are & in 3f'4. are 6 in 3f&4 1its are mixed

from 1its that are & in 3f'4. at least one is & an one is 6 in 3f&4 C*e(8ing %*et*er a 6ie,- 7e,ongs to a Range: ... <f1> 7ET%EE! <f2> A!" <f3> ... it is short form of ... <f1> $E <f2> A!" <f1> 2E <f3> ... C*e(8ing for t*e #nitia, Va,+e: ... <f> #S #!#T#A2 ... true if 3f4 contains the initial value for its t)%e. :n general. an) field. elementar) or structured /field strings and internal ta1les0. contains its initial value after a C7EA 3f4 statement is executed. C*e(8ing Se,e(tion Criteria: ... <f> #! <se,> ... :f the selection criteria 3sel4 is attached to 3f4 with the !E7EC#*OP#:O"! statement the short form can 1e used9 ... <se,> ... ComBine Operators an- Operators re(e-en(e: Priorit)9 !OT A!" OR. Equal %riorit) o%erations are %rocessed from left to right. :f one of the com%onent ex%ressions is recogniDed as true or false. the remaining %art is not %erforming if total ex%ression can 1e ,nown. #herefore )ou can im%rove %erformance 1) organiDing logical ex%ressions /for exam%le. 1) %lacing com%arisons which are often false at the 1eginning of an A"( chain and ex%ensive com%arisons. such as searches for character strings. at the end0.

ABAP #raining

Page 8 of 8

Vous aimerez peut-être aussi