Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
58 views68 pages

02 Abap2 090715081258 Phpapp02

Uploaded by

mandamadhukar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views68 pages

02 Abap2 090715081258 Phpapp02

Uploaded by

mandamadhukar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 68

ABAP Chapter 2

Report Statement

Write & Format Statement

Flow Control in ABAP

Manipulating Character Data

Report Driven : Page Report (i!t


"ea#er$

List Processing
Report
"ea#er
Report
i!ting
(Bo#%$

Report Statement
Report Statement
* Syntax
REPORT <report name>
[NO STANDARD PAGE HEADING]
[LINESI!E no of columns]
[LINE"O#NT no of lines[$no of footer%]]&
REPORT 'test( NO STANDARD PAGE HEADING&
REPORT 'test LINESI!E ()* LINE"O#NT +,$*%&
sy-ins'

Text Element : Title&Headers
Text Element : Title&Headers

Text Element

Title and Headers


List Header
Column Header
This is test program by Prapoj
Column Column
#1 #
Report !test"
#rite $Hello #orld%"

Creating i!t!

ABAP !tatement that create li!t

WR&'(

S)&P

*&+(

'he complete report li!t will


appear! automaticall% at the en#
o, the proce!!ing -loc.

&ist 'u((er
&ist 'u((er
)ialog #P

Tas*Handler
)ynpro Pro+essor
,',P Pro+essor
Local Memory
Memory Space
)' -nter(a+e
List Buffer
WRITE,SKIP
,ULINE

#R-TE Statement
#R-TE Statement
* Write data
WRITE Hello World.
WRITE: OK, Test data.
WRITE: /15(1! "#$%E&'HI(KL)NOP*.
WRITE /+ Test data.

'rea*ing to a .e/ &ine
'rea*ing to a .e/ &ine
, Wr-te data
WRITE: / &-rst L-.e, %ata 1,
/ Se/o.d L-.e, %ata +,
/(+! T0-rd L-.e, %ata 1,
/15 &o2rt0 L-.e, %ata 3.
s45
/ol.o

Text Symbol
Text Symbol

Text E-e.ent

Text Sy./o-s

Text Symbol Text



Text
Text 1
Report !test"
#rite: Text01112
Text011"
111
11

'e/t S%m-ol
6r-te: / Te7t51.
6r-te: / Te7t51.
6r-te: / Te7t51.
6r-te: / Te7t51.
6r-te: / Te7t51.

Column Position
Column Position
DATA co-no ty0e I 1a-2e (3&
4rite5 6, 7He--o89 at co-no 7:or-;8&
4rite5 at 6co-no 7O<8&

3ptions o( the #R-TE Statement
3ptions o( the #R-TE Statement
4 #rite Syntax
#R-TE var 5.306ER37
5.30S-8.7
5.308R39P-.87
5.308,P7
5)EC-:,&S no of decimals7

Suppressing 'lan*s;.306ER3<
Suppressing 'lan*s;.306ER3<
* No !ero
DATA5 n2./er$(3% T=PE N >AL#E *)&
:RITE5 n2./er9 n2./er NO!ERO&

Suppressing .umber;= > 0< Sign
Suppressing .umber;= > 0< Sign
* No Sign
DATA5 1?integer T=PE I >AL#E (&
:RITE5 1?integer9 1?integer NOSIGN&

.308R39P-.8
.308R39P-.8
* No gro20ing
DATA5 1?integer T=PE I >AL#E (*3333&
:RITE5 1?integer9 1?integer NOGRO#PING&

.308,P
.308,P
* No ga0
:RITE5 7He--o8 NOGAP9 7:or-;8&

)EC-:,&S
)EC-:,&S
* Deci.a-s
DATA5 1?0ac@ T=PE P DE"IAALS B
>AL#E 7(*)B&,+CD8&
:RITE5 1?0ac@9 1?0ac@ DE"IAALS *&

?ormatting 3ptions
?ormatting 3ptions
* Eor.at o0tions oF :RITE state.ent
* LEETG#STIEIED For Integer ;ata
* RIGHTG#STIEIED For "Haracter ;ata
* "ENTERED
Data t.0($*3% 1a-2e 7test8&
:RITE5 t.0( "ENTERED&
test

-nserting 'lan* &ines;S@-P<
-nserting 'lan* &ines;S@-P<
,S8-9 State:e.t
SKIP.
WRITE: Hello World, s45l-..o.
SKIP.
WRITE: Test 1.
SKIP 5.
WRITE: Test +.
SKIP TO LINE +.
WRITE T0-s -s l-.e +.

-nserting Hori!ontal &ines;9&-.E<
-nserting Hori!ontal &ines;9&-.E<
, Ul-.e
WRITE: Hello World.
WRITE: /5(15! s452l-.e, s45;l-.e.
ULINE /5(15!.
ULINE.
WRITE: / T0-s -s a. 2.derl-.e.
ULINE /(1<!.

?rame
?rame
uline: >;AB<"
/rite: >1 sy0Cline2 DColumn #1D2
1B sy0Cline2 DColumn #D2
E1 sy0Cline2 DColumn #ED2
AB sy0Cline"
uline: >;AB<"


(/erci!e &
s45dat2:
s452=e-t

?3R:,T Statement
?3R:,T Statement
EORAAT [INTENSIEIED]
[INTENSIEIED OEE]
["OLOR <color>]
["OLOR OEE]
[HOTSPOT ON]
[HOTSPOT OEE]
[RESET]


?3R:,T Statement
?3R:,T Statement
&OR)"T $OLOR 1.
WRITE: / Hello World, Test $OLOR >.
&OR)"T $OLOR O&&.


?3R:,T C3&3R
?3R:,T C3&3R
&OR)"T $OLOR /ol?0ead-.@. A/olor 1
&OR)"T $OLOR /ol?.or:al. A/olor +
&OR)"T $OLOR /ol?total. A/olor 1
&OR)"T $OLOR /ol?8e4. A/olor 3
&OR)"T $OLOR /ol?9os-t-;e. A/olor 5
&OR)"T $OLOR /ol?.e@at-;e. A/olor B
&OR)"T $OLOR /ol?@ro29. A/olor >
&OR)"T $OLOR /ol?Ca/[email protected]. A/olor oD

(/erci!e &

&nclu#e Program

0ou can create a program with program t%pe include


program in the program attri-ute

&nclu#e program #o not have to have an intro#uctor%


!tatement

During the !%nta/ chec. an# #uring program generation -%


the ABAP compiler1 the &+C*D( !tatement i! replace# -%
the !ource te/t o, the #e2ne# inclu#e program

Data tmp(34$5
Data tmp3 t%pe i5
Data tmp2 t%pe p5
Data tmp65
I./l2de Pro@ra: :
EIN$LU%E1
REPORT ztest1.
INCLUDE zinclude1.

REPORT ztest2.
INCLUDE zinclude1.


, %-s9la4 I/o. or S4:Col -. L-st
IN$LU%E FLISTG.
WRITE: / P0o.e :, SH)?PHONE "S SH)#OL.
WRITE: / "lar: :, I$ON?"L"R) "S I$ON.
WRITE: / 'ree. L-@0t :,
I$ON?'REEN?LI'HT "S I$ON HOTSPOT.
&OR)"T HOTSPOT ON.
WRITE: / Hello "#"P, H-I.
&OR)"T HOTSPOT O&&.
Symbols and -+ons
Symbols and -+ons

Flow Control in ABAP

?lo/ Control in ,',P
?lo/ Control in ,',P

'ran+hing FFG -?2 C,SE"

&ooping FFG )32 #H-&E"



-? Statement
-? Statement
IE <Condition>&
<State.ent I-oc@>
ELSEIE <Condition>&
<State.ent I-oc@>
ELSEIE <Condition>&
<State.ent I-oc@>
ELSE&
<State.ent I-oc@>
ENDIE&

-? Statement
-? Statement
I& s45:a.dt J 1.
WRITE: / T0-s -s Prod2/t-o. $l-e.t.
ELSEI& s45:a.dt J <.
WRITE: / T0-s -s %e;elo9:e.t $l-e.t.
ELSE.
WRITE: / T0-s -s Test $l-e.t.
EN%I&.

C,SE Statement
C,SE Statement
"ASE <feld>&
:HEN <value1>&
<State.ent I-oc@>
:HEN <value2>&
<State.ent I-oc@>
&&&
:HEN OTHERS&
<State.ent I-oc@>
END"ASE&

C,SE Statement
C,SE Statement

$"SE s45:a.dt.
WHEN 1.
WRITE: / Prod2/t-o. $l-e.t.
WHEN <.
WRITE: / %e;elo9:e.t $l-e.t.
WHEN OTHERS.
WRITE: / Test $l-e.t.
EN%$"SE.

)3 Statement
)3 Statement
DO&
:RITE syin;ex&
IE syin;ex J )&
EKIT&
ENDIE&
:RITE5 syin;ex&
ENDDO&

C3.T-.9E Statement
C3.T-.9E Statement
DO , TIAES&
IE syin;ex J )&
"ONTIN#E&
ENDIE&
:RITE5 syin;ex&
ENDDO&

CHEC@ Statement
CHEC@ Statement
DO B TIAES&
"HE"< syin;ex IET:EEN * AND )&
:RITE5 syin;ex&
ENDDO&

#H-&E Statement
#H-&E Statement
DATA5 co2nt T=PE I 1a-2e (&
:HILE co2nt <> B&
:RITE5 syin;ex&
co2nt J co2nt L (&
END:HILE&

&ogi+al Expressions
&ogi+al Expressions
>9GT
<9LT
>J9 J>9 GE
<J9 J<9 LE
J9 EM
<>9 ><9 NE
IET:EEN 1a-2e( AND 1a-2e*
IS INITIAL


,rithmeti+ 3perators
,rithmeti+ 3perators
L 9 9 * 9 6 9 **
DI>
AOD
Exa.0-e 5
N 6 * J B&,
N DI> * J B&3
N AOD * J (
SMRT$ * % J (&B(
* ** B J (+

Chara+ter String 3perator
Chara+ter String 3perator
iF 7AAII8 co 7AI8&
iF 7AI"D8 co 7AI"8&
iF 7AK"!8 ca 7AI8&
iF 7AI"D8 ca 7K=!8&
iF 7AI"D8 c0 7LI*8&
T
F
T
F
T

Manipulating Character
Data

:anipulating Chara+ter )ata
:anipulating Chara+ter )ata
, S2Cstr-.@s 6-t0 oDsets
%"T" t:9(1! K"LUE "#$%E&'HI(.
%"T" t:91(+!.
WRITE: t:9L1(>!,
t:9L1(3!,
t:9L(<!,
t:9L>(1!.
)OKE t:9L3(+! TO t:91.
)E?8H-H
'C)E
,'C)E?8H
H-H

SH-?T Statement
SH-?T Statement
, SHI&T State:e.t
%"T" t:9(5! K"LUE 1+135.
SHI&T t:9.
SHI&T t:9 #H + PL"$ES.
SHI&T t:9 #H + PL"$ES $IR$UL"R.
SHI&T t:9 UP TO 1.
SHI&T t:9 UP TO 1 RI'HT.
SHI&T t:9 UP TO 1 RI'HT $IR$UL"R.
SHI&T t:9 RI'HT %ELETIN' TR"ILIN' SP"$E.
SHI&T t:9 LE&T %ELETIN' LE"%IN' SP"$E.

EABI
EABII
EAB1
II1E
EABII
AB1E

SH-?T
SH-?T
, S0-Mt
%"T" .a:e(1! K"LUE "le7a.der #-ll $0arles.
SHI&T .a:e UP TO #-ll.
WRITE: / .a:e.

'ill Charles



SE,RCH
SE,RCH$Non Case-
sensitive)
, Sear/0
%"T" t:9(5! K"LUE "#$%E.
SE"R$H t:9 &OR $.
%"T" t:91(1! K"LUE T-ll #-ll.
SE"R$H t:91 &OR #-ll.
I& SH5SU#R$ J .
WRITE: / SH5&%POS.
EN%I&.


TR,.S&,TE
TR,.S&,TE
, Tra.slate
%"T" t:9(5! K"LUE aC/ .
TR"NSL"TE t:9 TO UPPER $"SE.
TR"NSL"TE t:9 TO LOWER $"SE.
TR"NSL"TE t:9 USIN' .
TR"NSL"TE t:9 USIN' a".

REP&,CE
REP&,CE
, Re9la/e
%"T" t:9(+! K"LUE I 6as a Co4.
REPL"$E 6as WITH a: INTO t:9.
I& s45s2Cr/ J .
6r-te Re9la/e OK.
ELSE.
6r-te $a..ot N.d data to Ce re9la/ed.
EN%I&.


RemoCing Spa+es;C3.)E.SE<
RemoCing Spa+es;C3.)E.SE<
, $o.de.se
%"T": t:9(+! K"LUE I a: a Co4.
$ON%ENSE t:9.
$ON%ENSE t:9 NO5'"PS.
- am a boy
-amaboy

Con+atenation String;C3.C,TE.,TE<
Con+atenation String;C3.C,TE.,TE<
, $o./ate.ate
%"T": t:91(+! K"LUE "#,
t:9+(1! K"LUE $%E,
t:91(1!.
$ON$"TEN"TE t:91 t:9+ INTO t:91.
$ON$"TEN"TE t:91 t:9+ INTO t:91
SEP"R"TE% #H .
,'C)E
,' C)E

Split
Split
* S0-it
DATA: na.e$)3% 1a-2e 7Da1i;9 GoHn9 Peter89
one$(3%9 t4o$(3%9 tHree$)3%&
s0-it na.e at 798 into one t4o tHree&

#or*ing /ith )ate Jariables
#or*ing /ith )ate Jariables
, %ate
%"T" toda4 THPE %.
toda4 J s45dat2:.
WRITE: toda4,
Hear : , toda4L(3!,
)o.t0 :, toda4L3(+!,
%a4 : , toda4LB(+!.
!%7
#atum84(9$

#R-TE K T3 K
#R-TE K T3 K
DATA5 to;ay T=PE D9 t.0$(3%&
to;ay J sy;at2.&
t.0 J to;ay&
:RITE t.0&
:RITE to;ay TO t.0&
:RITE t.0&
"LEAR to;ay&
:RITE to;ay NO!ERO TO t.0&
:RITE t.0&

-nCalid )ate
-nCalid )ate
DATA5 to;ay T=PE D&
to;ay J 7*33+()*(8&
to;ay J to;ay L 3&
iF to;ay is initia-&
4rite5 6 7in1a-i; ;ate8&
e-se&
4rite5 6 to;ay&
en;iF&

Built7in Function!

ABAP provi#e! a lot o, -uilt7in


,unction!

A Built7in ,unction calculate! a return


value ,rom an argument

a-! : A-!olute value o, argument

!ign : 8;7 !ign o, argument

!<rt : S<uare root

str-en : +um-er o, character! in arg

/!trlen : +um-er o, -%te! in arg



STR&E. 'uilt0in ?un+tion
STR&E. 'uilt0in ?un+tion
%"T": t:9(+! K"LUE Test Str-.@,
/o2.t THPE I.
/o2.t J strle.( t:9 !.
WRITE /o2.t.

STR&E. 'uilt0in ?un+tion Example
STR&E. 'uilt0in ?un+tion Example
%"T": t:9(+! K"LUE 77a7,
/.tle. THPE I.
/.tle. J strle.( t:9 !.
/.tle. J /.tle. O +.
-M t:9L/.tle.(1! J a. A/.tle. GJ
6r-te: / OK.
e.d-M.

#R-TE $
#R-TE $
*IF 4e nee; tHe 4or; -i@e tHis I8. a /oy
WRITE: I88. a /oy8.

(/erci!e

$reate 9ro@ra: to d-s9la4 /2rre.t


:o.t0 -. te7t Mor e7a:9le O/toCer

Report Driven : Page
Report

Application Driven
Programming
REPORT 'test&
DATA5 to;ay T=PE D&
to;ay J 7*33+()*(8&
to;ay J to;ay L 3&
IE to;ay IS INITIAL&
:RITE5 6 7in1a-i; ;ate8&
ELSE&
:RITE5 6 to;ay&
ENDIE&

(vent Driven Programming
R(P=R' >te!t5
DA'A to#a% '0P( D5
TOPOEPAGE&
?ABAP statement@
ENDOEPAGE&
?ABAP statement@
STARTOESELE"TION&
?ABAP statement@

Report )riCen &ist Header
Report )riCen &ist Header
REPORT =test NO ST"N%"R% P"'E HE"%IN'.
TOP5O&5P"'E.
&OR)"T $OLOR 1.
WRITE: /5 User Na:e, +5 Pro@ra: Na:e.
ULINE.
ST"RT5O&5SELE$TION.
WRITE: /5 s452.a:e, +5 s45re9-d.

Report )riCen Page ?ooter
Report )riCen Page ?ooter
REPORT =test .o sta.dard 9a@e 0ead-.@ LINE5$OUNT 1(+!.
TOP5O&5P"'E.
&OR)"T $OLOR 1.
WRITE: / Pa@e :, [email protected].
ULINE.
EN%5O&5P"'E.
ULINE.
WRITE: / To Ce /o.t-.2e o. .e7t 9a@eP .
ST"RT5O&5SELE$TION.
%O + TI)ES.
WRITE: / s45-.de7.
EN%%O.

T3P03?0P,8E
T3P03?0P,8E
REPORT 'test no stan;ar; 0age Hea;ing&
TOPOEPAGE&
EORAAT "OLOR (&
:RITE5 6 ORe0ort Hea;erO&
#LINE&
STARTOESELE"TION&
DO (33 TIAES&
:RITE5 6 syin;ex&
ENDDO&

ABAP Program Structure
Re0ort 'test&
*Data ;ec-aration
;ata &&&
;ata /egin oF &&&
*To0oFPage e1ent
to0oF0age&
*En;oFPage e1ent
en;oF0age&
*StartoFse-ection
StartoFse-ection&

ABAP Practice

(/erci!e &&
s45dat2:
s452=e-t
s45re9-d
s45
2.a:e

You might also like