01 abap - basics

Upload: arnoldkat88

Post on 02-Jun-2018

242 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 01 ABAP - Basics

    1/62

    ABAP BASICS

    SAP ABAP/4 Contents

    SAP OVERVIEW & ARCHITECTURE

    What is SAP?

    Client/Server Architecture

    R/3 Architecture- Presentation Server- Application Server- Database Server

    SAP R/3 Logon & Logging of

    What is transaction coe & using transaction coe?

    !etting help in the R3 s"ste#

    Wor$ing %ith R/3 user sessions

    What is AAP & Wh" is AAP?

    ABAP/4 DEVELOPMENT WORKBENCH 'ools o( abap/) %or$bench

    Control structures

    String operations

    *ser ialog+ selection screen

    ABAP/4 DICTIONARY

    'ables in abap/) ictionar"

    Creation o( tables

    Creation o( o#ains & ata ele#ent

    Structures an vie%s Search helps

    Loc$ ob,ects

    Logical atabase

    DATA TYPES & DATA OBJECTS

    Data t"pes

    Data ob,ects

    ins o( ata ob,ects

    WRITE STATEMENT About %rite state#ent

    .or#atting output

    .or#atting options (or all ata t"pes

    .or#atting options (or all nu#eric els

    MODULARIATION TECHNI!UES

    Page 1 of 62

  • 8/10/2019 01 ABAP - Basics

    2/62

    ABAP BASICS

    Subroutines

    .unction #oules

    0nclues an #acros

    REPORTS

    Classical reportso 1vents in Classical Reports

    0nteractive reports

    o 1vents in 0nteractive Reports

    o 2enu Painter

    AL

    o List Displa"

    o !ri Displa"

    TRANSACTION PRO"RAMMIN"

    About transaction Screen painter

    2oule pool progra##ing

    1vents in 2oule pool progra##ing

    Creation o( co#ple4 transaction

    .iel chec$s

    D"na#icall" calling the screens

    Sub screens

    'able controls

    DATA TRANS#ER .ile 5anling

    o .lat le hanling

    o Se6uential le hanling

    Recoring #etho

    DC

    o Call transaction

    o Session #etho

    LS2W

    SAP SCRIPTS About sap scripts

    La"out set

    o Designing La"outs

    o arcoe printing

    o Stanar te4t creation

    o *sing Stanar te4t

    Page 2 of 62

  • 8/10/2019 01 ABAP - Basics

    3/62

  • 8/10/2019 01 ABAP - Basics

    4/62

    ABAP BASICS

    o Writing coe in user-e4its

    AL1

    o Create o( Logical S"ste#s

    o Create o( R.C Destination

    o Create Port

    o Create Partner Proleo Distribute the s"ste#s

    o Distribute 0Doc

    o Distribute the ata

    1D0

    o Create Port

    o Create Partner Prole

    o Distribute the s"ste#s

    o Distribute 0Doc

    o Distribute the ata

    AP0o AP0 14plorer

    o Diferent .unction #oules in it

    Page 4 of 62

  • 8/10/2019 01 ABAP - Basics

    5/62

    ABAP BASICS

    TABLE OF CONTENTS

    SOME FACTS ABOUT SAP 4

    WORKING WITH R/3 SYSTEMF 6

    SAP R/3 logon Scrn 6

    Logg!ng O" #

    U$!ng Tr%n$%c&!on Co' #

    G&&!ng (l) !n &( R/3 $*$&+ ,-

    Wor.!ng !&( R/3 0$r $$$!on$ ,,

    R/3 ARCHITECTURE ,,

    Cl!n& / Sr1r %rc(!&c&0r ,2

    T(r &!r %rc(!&c&0r o R/3 ,3

    ABAP/4 E5ELOPMENT WORKBENCH ,4

    ATA ICTIONARY ,6

    Ao0& %&% !c&!on%r* ,6

    A'1%n&%g$ ,6

    T%l$ !n ABAP/4 '!c&!on%r* ,7

    Cr%&!on o &%l 2-

    Cr%&!ng o+%!n 2-

    Cr%&!ng %&% El+n& 2-

    GENERAL INTROUCTION TO ABAP/4 22

    C(%r%c&r!$&!c$ o &( ABAP/4 )rogr%++!ng l%ng0%g$ 23

    REPORTS 24

    IALOG PROGRAMS 28

    ATA TYPES AN ATA OB9ECTS 26

    Page 5 of 62

  • 8/10/2019 01 ABAP - Basics

    6/62

    ABAP BASICS%&% T*)$ 26

    %&% O:c&$ 2;

    K!n'$ o %&% O:c&$ 2;

    P%r%+&r$ 27

    WRITE STATEMENT 3-

    For+%&&!ng o0&)0& 3,

    For+%&&!ng o)&!on$ or %ll '%&% &*)$ 32

    For+%&&!ng o)&!on$ or n0+r!c

  • 8/10/2019 01 ABAP - Basics

    7/62

    ABAP BASICS

    So+ F%c&$ %o0& SAP

    After the Internet, SAP R/3 is one of the hottest topics in the computer industry and the

    company that dee!oped it" It is targeted to most industries, manufacturing, retai!, oi!

    # gas, pharmaceutica!, $an%ing, insurance, te!ecommunication, &ransport, chemica!

    and so on" A!! ma'or hard(are )endors (ere fu!!y engaged to partner (ith SAP* A&,

    +--, .ompa, I+0, Sun hae supported and certied R/3 p!atform"

    SAP has !ist of ma'or consu!tants a!! oer the (or!d !i%e Anderson .onsu!ting, Price

    aterhouse .ooper # -y$rand, rnst # oung, P07 and many more"

    &he company $ehind R/3 is SAP A7, founded $y four former I+0 emp!oyees in 1892"

    &he company:s headuarters are in a!!dorf, a sma!! 7erman to(n" &he company

    name, SAP stands for SS&0S, APP-I.A&I; countries, the

    company is !isted on seera! e@changes, inc!uding the ran%furt stoc% e@change and

  • 8/10/2019 01 ABAP - Basics

    8/62

    ABAP BASICS

    OSS= ;n!ine Serice System is one of the primary sources of serice and support

    proided $y SAP" ith ;SS, customers can search the SAP information data$ase and

    nd so!utions for errors and pro$!ems (ith R/3 systems" ou can a!so su$mit your

    pro$!ems to SAP"

    Con$0l&!ng Sr1!c= (ith remote consu!ting serice customer receies immediate and

    updated technica! support and ans(ers to their uestions"

    M%!n&n%nc $r1!c= &his is the $asic and most common type of support for

    customers in technica! support and ans(ers to their uestions"

    Inor+%&!on Sr1!c=&hese are the arious information sources for receiing detai!ed

    information a$out the R/3 system, mar%eting $rochures, system documentation,

    training information and many more things"

    Pr1n&!1 $r1!c$= &he primary one is the ar!y atch Serice, (hich ensuressuccessfu! and eGicient insta!!ation of the R/3 system in a!! phases" &his serice ma%es

    regu!ar/performance chec%s and ana!yFes the system to identify potentia! pro$!ems,

    he!p system managers and SAP administrators to tune the system" Soon after the ar!y

    atch session, SAP sends the customer a report (ith the resu!t of the ana!ysis and

    recommendations for aoiding potentia! pro$!ems such as data$ase $ecoming fu!!"

    So oera!! SAP R/3 is an open c!ient/serer soft(are system, designed to manage

    $usiness information needs of an entire enterprise" &he (ho!e datao( of SAP R/3

    (or%s in an integrated (ay, (hich means the data needs to $e entered 'ust once and the

    system automatica!!y updates other !ogica!!y re!ated data"

    Page J of 62

  • 8/10/2019 01 ABAP - Basics

    9/62

    ABAP BASICSWORKING WITH R/3 $*$&+

    &he SAP R/3 presentation interface $ehaes ery simi!ar!y to any other typica! (indo(

    app!ication and is a!so %no(n as SAP7I" &he rst screen that you come across in R/3

    system is SAP !ogon screen"

    SAP R/3 logon Scrn

    &his is the rst screen that appears (hen you use SAP !ogon uti!ity" It has four e!ds

    the c!ient, the user, the pass(ord and the !anguage"

    Cl!n&= Eere you enter the c!ient num$er" &he c!ient is group of users (ho has simi!ar

    rights" It can $e group of users in a $usiness entity or a (ho!e $usiness entity or a

    (ho!e company"

    U$r= &he name of the SAP user identication" sers of the SAP system are c!ientD

    specic, (hich means that user $e!onging to one c!ient is a!id to on!y the particu!arc!ient"

    P%$$or'= It is the pass(ord that has $een assigned $y the system administrator"

    L%ng0%g= SAP R/3 system supports mu!tinationa! !anguage on the same system at

    the same time, (hich is ery usefu! for mu!tinationa! companies (ith diGerent

    $ranches in seera! countries and possi$!y using diGerent !anguages"

    Page 8 of 62

  • 8/10/2019 01 ABAP - Basics

    10/62

    ABAP BASICS

    After entering a!! the e!ds press

  • 8/10/2019 01 ABAP - Basics

    11/62

    ABAP BASICS

    Logg!ng O"

    ser can !og oG the R/3 system from any screen" &here are three (ays of !ogging oG the R/3system, (hich are as fo!!o(s*

    rom the 0enu $ar choose SS&0 -;7 ;" In this case, you get the !og oG

    dia!og $o@, (hich informs the user that any data not saed (i!! $e !ost if continuing

    (ith the !og oG procedure"

    se/

  • 8/10/2019 01 ABAP - Basics

    12/62

    ABAP BASICS

    Important transaction codes, (hich you (i!! $e using often, are*

    E'!&or$

    S39 unction +ui!der S3J A+AP/4 ditor

    S41 0enu Painter

    S51 Screen Painter

    S91 orm Painter

    !c&!on%r*

    S11 Initia! A+AP/4 dictionary maintain screen"

    Bro$r$

    SJ> ;$'ect $ro(ser"

    S16 =ata $ro(ser"

    T$&!ng Tool$

    S3> Runtime Ana!ysis

    S&>5 SN- &race

    Page 12 of 62

  • 8/10/2019 01 ABAP - Basics

    13/62

    ABAP BASICS

    G&&!ng (l) !n &( R/3 $*$&+

    R/3 inc!udes many possi$i!ities to get on!ine he!p for a!most eery e!ement of the

    system, users can get he!p for entire app!ication, for specic function, for denitions of

    arious terms used in SAP, i"e", 7!ossary, messages, screens, e!ds etc"

    ou o$tain E-P $y using any of the fo!!o(ing options*

    Hl) 0nc&!on from the R/3 (indo(, (hich is compu!sory menu item of eery R/3

    (indo("

    Icon of standard too! $ar"

    F, 0nc&!on .*@

    &he SAP system proides he!p on most e!ds that appear on the R/3 system" &o get he!p

    on particu!ar e!d, position the cursor oer it and press he!p $utton or 1 function %ey"

    Another (ay in (hich R/3 system proides he!p is (hen system disp!ays error messages

    in the status $ar" =ou$!e c!ic%ing on the status $ar sho(s additiona! information a$out

    the message"

    Page 13 of 62

  • 8/10/2019 01 ABAP - Basics

    14/62

    ABAP BASICS

    Wor.!ng !&( R/3 0$r $$$!on$

    A ery important feature proided $y SAP" In R/3 system you can (or% (ith more than

    one tas% at any gien point of time, $y means of opening sessions" ou can ca!! sessions

    as independent R/3 (indo( (here you can perform other tas%s"

    +y defau!t, a user can open NINE sessions simu!taneous!y and can (or% or moearound (ith a!! sessions at the same time" Sessions can $e c!osed at any time, (ithout

    haing to !og oG the system"

    ser can create ne( sessions from any(here as .RA& SSSI;< comes under

    SS&0 menu (hich is aai!a$!e in eery R/3 (indo("

    SYSTEM CREATE SESSION ;r /O !n co++%n'

  • 8/10/2019 01 ABAP - Basics

    15/62

    ABAP BASICS

    &his !ayer ena$!es a!! the app!ication to (or% e@act!y the same (ay no matter (hat

    operating system or data$ase, the system is insta!!ed on" It is an independent !ayer and

    ensures the integration of a!! modu!es" +esides a!! these specic 'o$s, +ASIS system

    a!so contains fo!!o(ing components and thus proides more additiona! features"

    A+AP/4 dee!opment (or%$ench, (hich in turn inc!udes many features !i%e

    repository, data dictionary, (or%$ench organiFer, (hich (i!! $e discussed in !aterpart of the topics"

    A+AP/4 !anguage, system administratie too!s, a!! these components are used to

    contro!, tune the R/3 system"

    Spoo! system manages the formatting of data for printing and passing it to the host

    spoo! system"

    0ai! system you can send and receie mai! from the outside (or!d KInternetL"

    .ommunication interface to e@terna! system from R/3 system* 0anages

    communication at the ;S !ee! K&.P/IPL, at the data$ase !ee! # $et(een

    app!ications too" KR., =I, and A-L =ata$ase interface &his component supports diGerent Re!ationa! data$ases from

    diGerent endors" &he main tas% of data$ase interface is to conert the SN- reuest

    from the SAP dee!opment enironment to the data$ase:s o(n SN- enironment"

    +ac%ground processing (ith this faci!ity you can su$mit your program for

    $ac%ground e@ecution"

    +ASIS system contains the !ayered components that faci!itate the dee!opment of

    c!ient/serer architecture"

    Cl!n& / Sr1r %rc(!&c&0r

    .!ient/Serer architecture is main!y a soft(are concept that inc!udes a set of serice

    proiders and serice reuesters" &he set of computers acts as serice proiders and is

    ca!!ed as serer" &he sets of soft(are component, (hich act as serice reuester, are

    ca!!ed as c!ient"

    In the c!ient/serer architecture, the data$ase acts !i%e a !i$rary c!er% retrieing $oo%s

    from the she!f" &he user programs hae to reuest data$ase for the data instead of

    searching for the data themse!es" &his (ay there is no ris% of the users putting the

    data out of order" If the desired data is in use, the data$ase ma%es the user (ait unti! it

    is free"

    &he ma'or adantage of the c!ient/serer architecture is that the serer is aai!a$!e for a

    num$er of c!ients and there is distri$ution of (or% $et(een the c!ients and the serer"

    &he user directs the reuest to the c!ientH the c!ient in turn understands the user:s

    reuest and redirects the reuest to the serer" &he serer retriees the data, gies it

    to c!ient"

    Page 15 of 62

  • 8/10/2019 01 ABAP - Basics

    16/62

    ABAP BASICS

    ou can hae c!ient and serer on the same machine or on diGerent machines" ach

    c!ient has a corresponding process inside the serer"

    ;ne of the most used c!ient/serer congurations (ith the R/3 system is the 3 tiered

    architecture, (hich separates a system:s computer into 3 functiona! groups*

    T(r &!r %rc(!&c&0r o R/3

    =ata$ase Serer

    App!ication Serer

    Presentation Serer

    Kn!i%e norma! .!ient/serer architecture (here you hae on!y t(o !ayers i"e", c!ient and

    serer"L

    .ommunication among the 3 tiers is accomp!ished $y standard protoco! serices !i%e

    &.P/IP or .PI. K.ommon Programming Interface .ommunicationL"

    In a$oe case data$ase serer stores the data centra!!y" +asica!!y contains data$ase

    engine and associated processes" &he data$ase !ayers contain the data$ase system

    used $y a!! serers"

    App!ication serer contains soft(are components to run the program" It contains a SAP

    %erne!, (hich can run A+AP/4 program"

    &he presentation serer is your c!ient through (hich you send your reuest to

    app!ication serer" It is a!so ca!!ed as SAP graphica! user interfaces %no(n as SAP7I

    and is aai!a$!e in (indo(s 3"1, indo(s

  • 8/10/2019 01 ABAP - Basics

    17/62

  • 8/10/2019 01 ABAP - Basics

    18/62

    ABAP BASICSFor )rogr%++!ng=

    A+AP/4 dictionary =ening, maintaining and storing the data dictionary of the SAP

    R/3 system stores a!! the dictionary o$'ects inc!uding ta$!es re!ationship and Ee!p

    information" &ransaction code for this is S11"

    A+AP/4 editor .reating and maintaining the A+AP/4 program, editing function

    modu!es, !ogica! data$ase, and screens" &ransaction code is S3J" unction !i$rary =ening and maintaining the A+AP/4 function modu!es

    &ransaction code is S39"

    Screen painter =esigning and maintaining the screens in transaction" &ransaction

    .ode is S51"

    0enu painter =esigning and maintaining the means for graphica! user interface"

    &ransaction code S41"

    For N%1!g%&!ng=

    ;$'ect $ro(ser 0anaging and organiFing the dee!opment o$'ect in a hierarchica!form" &ransaction code is SJ>"

    A+AP/4 repository information

  • 8/10/2019 01 ABAP - Basics

    19/62

    ABAP BASICS%&% !c&!on%r*

    &he A+AP/4dictionary is centra! (or%$ench repository uti!ity proiding the data

    denition and the information re!ationship that are !ater used in a!! the $usiness

    app!ication (ithin R/3

    &he A+AP/4 dictionary can $e seen as a !ogica! representation or a superior !ayer oer

    the physica! under!ying data$ase" &his data$ase must support the re!ationa! data mode!"

    &his mode! is strict!y fo!!o(ed $y data dictionary"

    Ao0& %&% !c&!on%r*

    A =ata dictionary in computing terms is the $o0rc o !nor+%&!on !n (!c( $*$&+

    '%&% !$ '

  • 8/10/2019 01 ABAP - Basics

    20/62

    ABAP BASICS

    Ac&!1%&!on o '!c&!on%r* o:c&$

    or a dictionary o$'ect to $e eGectie at runtime, that is, for a dictionary o$'ect to $e

    aai!a$!e for use (ithin a program, transaction, and so on, it must $e in actie status"

    or o$'ects to $ecome actie, R/3 inc!udes the A.&I)A&I;< function"

    hen a ta$!e or aggregated o$'ect is actiated, it is p!aced at the disposa! of the system

    as a runtime o$'ect in a (ay that ma%es it aai!a$!e uic%!y for the app!ication program

    to access re!eant information of ne( actiated o$'ects"

    hen a dictionary o$'ect is modied, that means that the o$'ect preious!y e@isted and

    actiated" ou need to reactiate the o$'ect after modication"

    hen mass actiation is performed massie!y, it might ta%e a uite a !ong time" &hen it

    shou!d $e in the $ac%ground system" &his type of actiation is %no(n as $ac%ground

    actiation"

    &he A+AP/4 =ata dictionary is the centra! component of A+AP/4 repository" A =ata

    dictionary is centra!iFed and structured source of information for $usiness app!ication"

    &he A+AP/4 dictionary is the core of the R/3 dee!opment system" It is the source of

    eery denition, (ithin R/3, from the ery $asic domain to the company data mode!" It

    is tota!!y integrated (ith other too!s of the dee!opment enironment !i%e screen

    painter, menu painter, and editor"

    Some of the main aai!a$!e functions in the A+AP/4 dictionary are as fo!!o(s*

    Add, de!ete, modify, and manage the denition of the dictionary data"

    Presere the data integrity"

    +e the centra! source of information e"g" from the dictionary you get the information

    a$out the dened re!ationship $et(een t(o ta$!es or een the directory te!!s

    (hether ta$!e is actie or empty"

    It a!so permits documentation of system data"

    In the R/3 system instead of (or%ing (ith origina! o$'ects, you (or% (ith interna!

    representation of o$'ects" ith this type of operation the system performance isenhanced and has the adantage that the dee!opment too!s, screen interpreters a!(ays

    access current data"

    hen any of the data dictionary o$'ects are used in other parts of the dee!opment

    (or%$ench for e@amp!e, in program, programmer on!y has to enter a ta$!e name or e!d

    name" &he system automatica!!y %no(s a!! the properties and information of the e!d"

    Page 2> of 62

  • 8/10/2019 01 ABAP - Basics

    21/62

    ABAP BASICS

    &o ca!! A+AP/4 dictionary, from the main menu, Tool$ ABAP/4 or.nc( '%&%

    '!c&!on%r* or n&r &r%n$%c&!on SE,,@

    %&% '!c&!on%r* o:c&$=

    T%l= is a 2= data matri@ containing ro(s and co!umns" Ro(s contain data (hi!e

    co!umn indicates e!ds" &a$!e can contain > or mu!tip!e ro(s"

    S&r0c&0r* is a s%e!eta! ie( of a ta$!e" It contains the denition of co!umns and

    don:t hae any contents" Structure is genera!!y a temp!ate $ased on (hich a ta$!e is

    created" &he $asic diGerence $et(een structure and ta$!e is that the structure does

    not e@ist at the under!ying data$ase system !ee!" Structure e@ists as denition in

    the dictionary"

    5!$=A ie( is an imaginary ta$!e" It contains data, (hich is rea!!y stored in other

    ta$!es" &he contents for the ie( are dynamica!!y generated (hen ca!!ed from

    program"

    Page 21 of 62

  • 8/10/2019 01 ABAP - Basics

    22/62

    ABAP BASICS

    %&% l+n&= is denition of the properties and type for a ta$!e e!d" It is an

    intermediate o$'ect $et(een the o$'ect type domain and the ta$!e e!d" A e!d in

    R/3 system is a!(ays associated (ith a data e!ement, (hich at the same time is

    re!ated to domain"

    o+%!n=is forma! denition of the data type from a technica! point of ie(" It sets

    the attri$utes such as data type, !ength, possi$!e a!ue range and so on"

    Loc. o:c&$= &hese types of o$'ects are used for !oc%ing the access to data$aserecords in ta$!e" &his mechanism is used to enforce data integrity that is t(o users

    cannot update the same data at the same time" ith !oc% o$'ects you can !oc% ta$!eD

    e!d or (ho!e ta$!e"

    S%rc( Hl) O:c&$= , (hich gies !ist of possi$!e a!ues for either primary %eys or

    nonDprimary %eys"

    T%l$ !n ABAP/4 '!c&!on%r*

    &a$!es are the $asic o$'ects in R/3 app!ication" &here are a!most J>>> ta$!es in R/3

    system" o!!o(ing types of ta$!es are aai!a$!e

    &ransparent ta$!es

    Poo! ta$!es

    .!uster ta$!es

    rom user point of ie(, a!! ta$!es are used to store data (hateer $e the type of ta$!e"

    &here is no diGerence in the $ehaior or operation of these ta$!es" A!! of them can $e

    managed $y using standard ;P< SN-" Eo(eer from an administrator point of ie(transparent ta$!e do e@ists (ith the same structure $oth in the dictionary as (e!! as in

    the data$ase, e@act!y (ith the same data and e!ds" hi!e other t(o are not

    transparent in the sense that they are not managea$!e direct!y using data$ase system

    too!s" ou can access these ta$!es in R/3 enironment from the A+AP/4 dictionary" ou

    cannot use natie SN- on these ta$!es" Poo! or c!uster ta$!es are !ogica! ta$!es, (hich

    are arranged as records of transparent ta$!e"

    A ta$!e is made up of ro(s and co!umns" hen the ta$!e is created, its co!umns are

    namedH data type is supp!ied for each co!umn" &here can $e on!y one data a!ue in each

    co!umn of each ro( in a ta$!e" Record or as it is ca!!ed in diGerent R=+0S is nothing

    $ut group of e!ds" hi!e a co!umn is a e!d of a ta$!e, a ta$!e is an inde@ed !e" &he

    main inde@ is ca!!ed as primary %ey, (hich can $e a sing!e e!d or com$ination of %eys

    or e!ds" A primary %ey can $e dened as a e!d, (hich indenites a sing!e uniue

    record of the ta$!e" A ta$!e cannot hae record (ith dup!icate primary %ey"

    Page 22 of 62

  • 8/10/2019 01 ABAP - Basics

    23/62

    ABAP BASICS

    In any R=+0S, ta$!es are re!ated to each other" +ut to re!ate ta$!e to each other it is

    necessary that one of the ta$!es contain some information of other ta$!e" 0ost!y ta$!es

    are re!ated to each other through primary %eys" &he primary %ey of one ta$!e, if it

    e@ists in other ta$!e then it is ca!!ed foreign %ey" &his type of data$ase management

    system means that there is some redundancy of data" +ut using norma!iFation

    procedures aai!a$!e can minimiFe it" ;ne of the most important functions of foreign

    %ey is to ensure data integrity" or e@amp!e say you hae 0P ta$!e, (hich has e!dsemp" no", emp"name, dept"code, sa!ary and you hae =P& ta$!es, (hich has dept"code

    and dept"desc" &hen in =P& ta$!e dept"code is primary %ey (hi!e dept"code in 0P

    ta$!e is foreign %ey" If you enter dept"code for particu!ar emp!oyee in 0P ta$!e the

    dept"code shou!d e@ist in =P& ta$!e" System (i!! chec% the a!ue for dept"code in

    =P& ta$!e, and if does not e@ist then (i!! ash error" In this case =P& is ca!!ed chec%

    ta$!e (hi!e 0P is foreign %ey ta$!e"

    Cr%&!on o &%l

    Steps to create a ta$!e

    .reate domain

    .reate data e!ement

    .reate actua! ta$!e

    Cr%&!ng o+%!n

    =omain as a!ready e@p!ained denes the technica! properties of a e!d such as type anda!ue range" A domain can $e created from initia! screen of data dictionary $y c!ic%ing

    on create and c!ic%ing domain Radio$utton" Parameters to $e passed are*

    =ata type* here you need to enter the data type aai!a$!e in SAP"

    ie!d !ength* ie!d !ength is the num$er of a!id position"

    )a!ue ta$!e*

  • 8/10/2019 01 ABAP - Basics

    24/62

    ABAP BASICS

    a!(ays needs to $e dened oer a domain and e!d is a!(ays dened oer a data

    e!ement" &his a!!o(s a!! e!ds (ith same technica! properties to use the same data

    e!ement"

    Parameters to $e passed (hen creating a data e!ement*

    Short te@t* 0andatory e!d"

    =omain* A mandatory e!d" If the domain does not e@ist, SAP can ta%e you direct!yto domain denition screen"

    &e@t e!ement* ou can enter description is short or !ong te@t for the e!d" &his te@t

    is used (hen

    entering data for these e!ds"

    Sae and actiate"

    Cr%&!on o %c&0%l &%l

    Parameters to $e passed for creation of ta$!e*

    Short description* 0andatory e!d"

    =e!iery c!ass* As per ser Reuirement

    &a$!e e!ds* Specify (hether primary %ey" In this case it is mandatory to

    enter data e!ement"

    =ata c!ass* sta$!ishes the physica! area of the data$ase"

    SiFe category* A!!o(s you to specify estimated space reuirement for the ta$!e"

    urther do(n under $uGering suare $o@, the system a!!o(s specifying (hether ta$!e is

    going to $e $uGered" hen a ta$!e is $uGered, it is !oaded into the ta$!e $uGer fromthe app!ication serer memory and it (i!! remain there unti! you s(itch oG or re$oot

    system"

    If the ta$!e is to $e $uGered, you need to specify the type of $uGering" u!! is for entire

    ta$!e (hi!e partia! is for on!y those records (hich are $eing accessed"

    ;nce the ta$!e is created, it has to $e generated or actiated to $e a$!e to access $y

    other o$'ects !i%e programs"

    Page 24 of 62

  • 8/10/2019 01 ABAP - Basics

    25/62

    ABAP BASICSGnr%l In&ro'0c&!on &o ABAP/4

    SAP origina!!y dee!oped the programming !anguage A+AP/4 KAdanced +usiness

    App!ication ProgrammingL for interna! use to proide $est (or%ing conditions for

    dee!opers" SAP constant!y improes the !anguage to adapt to the increasing

    reuirements of the $usiness app!ications" At present, A+AP/4 is the on!y too! for

    dee!oping app!ications at SAP"

    SAP customers use A+AP/4 for their o(n dee!opments" &he A+AP/4 =ee!opment

    or%$ench contains a!! too!s you need to create and maintain A+AP/4 programs"

    A+AP/4 programs are not comp!ied $ut generated" =uring generation, the system

    creates a soDca!!ed runtime o$'ect from the source code and the program attri$utes"

    hen you start the program, the system e@ecutes the runtime o$'ect"

    A+AP/4, a fourth generation !anguage, contains a!! usua! contro! structures and

    modu!ariFing concepts for structured programming" &he three parts of the A+AP/4

    !anguage are*

    Structure and e@ecution of A+AP/4 programs

    +asic !anguage e!ements

    Programming reports

    Programming dia!ogs

    Structure and execution of ABAP/4 programsare essentia!!y diGerent from entire!y

    seuentia! programming !anguages such as ;R&RA

  • 8/10/2019 01 ABAP - Basics

    26/62

    ABAP BASICS

    ithin the processing $!oc%s, you can use the genera! contro! statements for the

    program o(, such as I, =;S, EI-, A+AP/4 does not contain 7;&; e!ements"

    e main!y use programs that consist of a sing!e processing $!oc% on!y and, therefore,

    $ehae most !i%e!y !i%e programs of other seuentia! programming !anguages" or

    programming app!ications, the entire!y seuentia! concept is not suGicient" SAP

    distinguishes $et(een t(o genera! types of app!ication programs*

    R)or&$=ou use reports to read data$ases and represent the resu!ts in !ists" Reports

    are co!!ections of processing $!oc%s that the system ca!!s depending on eents"

    !%log )rogr%+$= ou can dia!og programs to e@ecute transactions, (hich usua!!y

    read and change data$ases" =ia!og programs are co!!ections of processing $!oc%s KsoD

    ca!!ed modu!e poo!sL that are ca!!ed $y a screen o( !ogic" &he third part of the ser:s

    7uide descri$es dia!og programming in detai!"

    R)or&$ c%n c%ll '!%log )rogr%+$ %n' 1!c 1r$%@

    In its easiest ersion, an A+AP/4 program contains one sing!e seuentia! piece of coding

    and, thus, one sing!e processing $!oc%"

    C(%r%c&r!$&!c$ o &( ABAP/4 )rogr%++!ng l%ng0%g$

    =ec!aratie e!ements for dec!aring data of diGerent type and structures"

    ;perationa! e!ements for manipu!ating data"

    .ontro! e!ements to contro! processing o("

    A+AP/4 is mu!tiD!ingua!" &e@t e!ements such as tit!es, headings, and te@t $ody arestored separate!y, independent of the program codes" &hus, you can change

    trans!ate, and maintain te@t e!ements (ithout haing no adapt the coding"

    A+AP/4 supports $usinessDre!ated data types and operations" ou can e@ecute

    ca!cu!ations using specia! data and time e!ds" &he system automatica!!y e@ecutes

    a!! necessary type conersions"

    A+AP/4 proides a num$er of functions for processing character strings"

    A+AP/4 a!!o(s you to dene and ca!! su$routines" ou can een ca!! su$routines of

    other programs" &here are diGerent (ays of ho( to pass parameters to and from the

    Su$routines"

    A+AP/4 contains a specia! type of su$routine, ca!!ed function modu!e" unction

    modu!es are stored and maintained in a centra! !i$rary" &hey hae c!ear!y dened

    data interfaces to the ca!!ing program" ou can test function modu!es in a standD

    a!one mode independent of the ca!!ing program"

    A+AP/4 contains an SN- su$set ca!!ed ;P< SN-" ;P< SN- a!!o(s you to read

    and change data$ase ta$!es independent of the under!ying data$ase system"

    Page 26 of 62

  • 8/10/2019 01 ABAP - Basics

    27/62

    ABAP BASICS

    A+AP/4 a!!o(s you to dene and process interna! ta$!es that e@ist on!y for the

    e@ecution period of the program" Interna! ta$!es eGicient!y support the usage of

    data$ase ta$!es and a!!o( you to imp!ement comp!e@ data structures in a program"

    A+AP/4 a!!o(s you to store data not on!y in data$ases $ut a!so as seuentia! !es on

    app!ication and presentation serers"

    REPORTS

    Reports are A+AP/4 programs"

    ou use reports to ea!uation data from data$ase ta$!es" &he resu!ts of such an

    ea!uation can $e disp!ayed on the screen or printed form"

    Reports are standDa!one programs"

    &he user can e@ecute reports direct!y ia the program name, for e@amp!e, $y

    choosing System ? ti!ities ? Reporting"

    A report program contains a co!!ection of processing $!oc%s for diGerent eents that

    are a!(ays triggered e@terna!!y" In a report, you can react on eents $y

    programming the corresponding processing $!oc%s or ignore the eents $y not

    (riting the corresponding processing $!oc%s" A report itse!f neer creates eents"

    Reports can use !ogica! data$ases or se!ect statements dened $y dee!oper"

    or each app!ication, SAP supp!ies !ogica! data$ases" ;r you can easi!y create

    !ogica! data$ase yourse!f"

    ent contro! of a report corresponds to a certain scheme*

    hen a report is e@ecuted, the A+AP/4 processor creates together (ith the !ogica!

    data$ase used Kif anyL a seuence of certain eents for (hich you can program

    processing $!oc%s" &he chrono!ogy of the eents is Kmore or !essL

    Steps ino!ed in creating a Report*

    ,@ Proc$$!ng &( $lc&!on $crn

    After starting a report, the se!ection screen a!!o(s the user to enter !imits or

    contro! a!ues for further report processing" &he report can contain seera!

    processing $!oc%s for eents during se!ection screen processing, for e@amp!e, for

    chec%ing the input a!ues"

    2@ R%'!ng &( '%&%%$

    After se!ection screen processing come the eents for reading the data$ase"

    ither the report reads data from re!ationa! data$ases it using the corresponding

    A+AP/4 statements Kopen SN-L or !eaes this tas% to a !ogica! data$ase" In the

    !atter case, the !ogica! data$ase creates a seuence of eents to a!!o( the report

    to copy the data"

    3@ E1%l0%&!ng '%&% %n' cr%&!ng l!$&$

    Page 29 of 62

  • 8/10/2019 01 ABAP - Basics

    28/62

    ABAP BASICS

    =uring or after reading the data$ase the report creates the output !ist" =uring !ist

    creation, seera! eents a!!o( you to !ayout the output !ist Kfor e@amp!e, !ayout the

    page headerL"

    4@ O0&)0&&!ng % l!$&

    &he !ast part of the processing seuence contro!!ed $y the A+AP/4 processor is

    the !ist output on the screen or printer" hen disp!aying the !ist on the screen,user can trigger other reports, that are interactie and are eent drien" or

    e@amp!e, $y c!ic%ing the mouse" +y programming processing $!oc%s for these

    eents, you change a norma! report to a soDca!!ed In&r%c&!1 r)or&" If a report

    does not contain eent %ey(ords, the entire coding of the report $e!ongs to a

    sing!e processing $!oc%, (hich is ca!!ed $y a standard eent" &his standard eent

    is triggered direct!y after processing the se!ection screen"

    IALOG PROGRAMS

    ou use dia!og programs to e@ecute transactions" &he users of dia!og programs in

    dia!og sessions read and change data$ase ta$!es" Apart from the actua! data

    processing K;pen SN-L, update and enueue concepts are of great importance (hen

    programming dia!ogs"

    =ia!og programs are not standD a!one

    &o e@ecute dia!og programs, they must $e !in%ed to at !east one screen that itse!f is

    !in%ed to a transaction code" &he transaction code determines the initia! screen (ith

    (hich the dia!og session starts"

    =ia!og programs are contro!!ed $y screen o( !ogic

    &he actua! A+AP/4 dia!og program is a soDca!!ed modu!e poo!" A modu!e poo!

    contains a co!!ection of dia!og modu!es that are ca!!ed $y the screen o( !ogic"

    &o each modu!e poo!, at !east one, $ut usua!!y seera! screens are a!!ocated" ach

    screen has o( !ogic" &he o( !ogic consists of P+; Kprocess +efore outputL and PAI

    Kprocess After InputL $!oc%s" &his o( !ogic does not use the A+AP/4 programming

    !anguage and the A+AP/4 ditor too!, $ut a specia! statement set and the Screen

    Painter too!, (hich you a!so use to !ayout screens" &he o( !ogic main!y contains the

    chrono!ogica!!y ordered ca!!s of the modu!es in the corresponding modu!e poo!"

    !e collection of PB" #ow logic, screen, and PA$ #ow logic is called %ynamicprogram &%ynpro'" A modu!e poo! must hae at !east one dynpro" ach screen of a

    dia!og session thus is the isi$!e part of a dynpro, to (hich a!so the o( !ogic

    $e!ongs" &he processing !ogic of a dia!og session is stored in the corresponding

    modu!e poo! in the form of A+AP/4 modu!es"

    Page 2J of 62

  • 8/10/2019 01 ABAP - Basics

    29/62

    ABAP BASICS

    &he A+AP/4 modu!es in the modu!e poo! are separated into P+; and PAI modu!es"

    &he P+; or PAI $!oc%s of the o( !ogic of each dynpro of a modu!e poo! can ca!! each

    P+; or PAI modu!e of this modu!e poo!"

    ou can use A+AP/4 statements in the processing !ogic of the modu!e poo! to contro!

    the chrono!ogy of the diGerent dynpros" After starting a dia!og session ia the

    transaction code, (hich is rm!y connected to a dynpro of the modu!e poo!, the

    screen o( !ogic passes user entries to the processing !ogic in the A+AP/4 modu!epoo!" &he processing !ogic processes the user entries Kdata$ase accessesL and, if

    reuired, denes the appropriate su$seuent screens"

    Page 28 of 62

  • 8/10/2019 01 ABAP - Basics

    30/62

    ABAP BASICS%&% T*)$ %n' %&% O:c&$

    =ata types and data o$'ects are essentia! components of the A+AP/4 type concepts"

    +oth can $e dec!ared and maintained $y user" n!i%e other programming !anguages in

    A+AP/4 you can create =A&A &PS independent!y"

    %&% T*)$

    Are pure descriptions

  • 8/10/2019 01 ABAP - Basics

    31/62

    ABAP BASICS

    %&% O:c&$

    =ata o$'ects are units created during runtime"

    =ata o$'ect cannot e@ist (ithout data type"

    ;ccupies memory space"

    K!n'$ o %&% O:c&$

    ,@ INTERNAL ATA OB9ECTS

    L!&r%l

    A !itera! has a @ed a!ue"

    @ RI&* B;R EAR=C

    5%r!%l$

    =A&A statement is used to create aria$!es

    @ =A&A*

  • 8/10/2019 01 ABAP - Basics

    32/62

    ABAP BASICS

    In program a!ue of IL,

    mnameK2>L,

    !nameK2>L,

    add1K2>L,

    add2K2>L,

    add3K2>L"

    If you hae =A&A statement !i%e a$oe, and if you need to change the !ength of a!! the

    e!ds say from 2> to 25, then you need to change a!! the e!ds i"e", going through each

    and eery statement"

    +ut consider the fo!!o(ing case (here &PS has $een used"

    &PS*strK2>L

    =A&A*fname type str,

    Page 32 of 62

  • 8/10/2019 01 ABAP - Basics

    33/62

    ABAP BASICS

    0name type str,

    -name type str,

    Add1 type str,

    Add2 type str,

    Add3 type str"

    In this case if you need to change the !ength of a!! e!ds from 2> to 25" &hen 'ustchange the !ength of S&R and change (i!! $e reected for a!! the e!ds"

    If you dene a!! the types in &PDP;;- i"e", g!o$a! denition of a!! the types, you can

    use these types any(here and in any program"

    P%r%+&r$

    Parameter statement is used to accept input from user" PARA0&R statement is used

    (hen you (ant user to enter data and depending upon (hat he enters you need to ta%eaction" &he parameter statement dec!ares the aria$!e and a!so a!!o(s system to accept

    data into that aria$!e"

    Synta@"

    Parameters* num type I"

    Eere parameter statement dec!ares the aria$!e and creates the se!ection screen on

    (hich user enters the data i"e", in this case num is dec!ared of type I and user can enter

    any num$er" ntered a!ue is stored in the same aria$!e and can $e used in program"

    =ata* m type I

    Parameters* num type I0 Q num 5

    rite* / &he num$er is:, m"

    ou can dene defau!t a!ues (ith parameter statement for e@amp!e

    Parameter* num type I defau!t 12"

    In this case (hen se!ection screen is disp!ayed the defau!t a!ue is disp!ayed" ser can

    either use same a!ue or oer(rite the a!ue"

    Parameter of type character and !ength Q 1, can $e disp!ayed as .hec%$o@ and

    Radio$utton"

    Parameter* .1 as .hec%$o@,

    .2 as .hec%$o@"

    Parameter* R1 Radio$utton group g1,

    R2 Radio$utton group g1"

    hen parameter is dened as Radio$utton, it needs to $e attached to one group" ;n!y

    one Radio$utton of one group can $e c!ic%ed"

    Page 33 of 62

  • 8/10/2019 01 ABAP - Basics

    34/62

    ABAP BASICS

    ery parameter can $e associated (ith !anguage dependent te@t that is disp!ayed on

    the se!ection screen" &his can $e done (ith the he!p of te@t e!ements"

    Page 34 of 62

  • 8/10/2019 01 ABAP - Basics

    35/62

    ABAP BASICSWRITE S&%&+n&

    &he $asic APA+/4 statement for outputting data on the screen is RI&"

    Synta@*

    RI& e!dT optionT"

    &his statement outputs the e!d fT to the current !ist in its standard output format"

    +y defau!t, the !ist is disp!ayed on the screen"

    &he e!d e!dTcan $e any aria$!e or ta$!e e!d or 'ust !itera!"

    PR;7RA0 U=0;

    RI&* /E--;:"

    hen you start this program, the system !eaes the current screen i"e", your editor

    screen and $ranches to the output screen, (hich is a!so ca!!ed as !ist screen*

    &he !ist screen has the same name as the tit!e of the program specied in the program

    attri$utes" irst !ine on the screen contains the !ist header" +y defau!t, the !ist header

    is the same as the tit!e of the program" &he current page num$er K1L appears on the

    right" &he !ist header is fo!!o(ed $y one !ine and then the output is disp!ayed"

    rite * E--;:"

    rite * ;R EAR=:

    ;n the screen, the output is norma!!y !eft 'ustied" +ut in a$oe case, $ecause (e hae

    used t(o RI& statements, the output e!ds are disp!ayed one after the other, each

    separated $y one co!umn Ki"e", one $!an%L" If there is not enough space for an output

    e!d on the current !ine, a ne( !ine is started"

    A!most a!! systemDdened e!ds are right 'ustied e@cept -;A&, I

  • 8/10/2019 01 ABAP - Basics

    36/62

    ABAP BASICS

    For+%&&!ng o0&)0&

    ou can position the output of a RI& statement on the screen $y ma%ing a format

    specication $efore the e!d name as fo!!o(s*

    Synta@*

    RI& A& V/WVposTWVK!enTLW fT,

    here

    the s!ash:/ denotes a ne( !ine,

    posT is a num$er or aria$!e denoting the position on the screen,

    !enT is a num$er or aria$!e !ong denoting the output !ength"

    or aria$!es you need to mention the A&, for direct a!ues it is not necessary"

    =A&A* -< &P I )A- 1>,

    P;S &P I )A- 11,

    &M& K1>L )A- 1234569J8>:

    RI& A& P;S K-

  • 8/10/2019 01 ABAP - Basics

    37/62

    ABAP BASICS

    &he output !oo%s as fo!!o(s*

    ;ne

    &(o

    &he system suppresses !ines that contain nothing $ut empty spaces"

    ou can use arious formatting options (ith the RI& statement"

    Synta@

    RI&YYYY e!dT optionT

    For+%&&!ng o)&!on$ or %ll '%&% &*)$

    "ption Purpose

    -&DOS&II= ;utput is !eft 'ustied".6 for

    type P e!ds"

    Page 39 of 62

  • 8/10/2019 01 ABAP - Basics

    38/62

    ABAP BASICS

    Hor!on&%l l!n$

    ou can generate horiFonta! !ines on the output screen $y using the fo!!o(ing synta@*

    Synta@

    -IK4>L SD-Ithposition"

    5r&!c%l l!n$

    ou generate ertica! !ines one the output screen $y using the fo!!o(ing synta@*

    Synta@

    RI& VA& V/W VposTWW SD)-I

  • 8/10/2019 01 ABAP - Basics

    39/62

    ABAP BASICSBr%nc($

    -i%e other higher programming !anguages, A+AP/4 proides standard %ey(ords to

    contro! the o( of a program"

    sua!!y A+AP/4 programs get e@ecuted statement $y statement" 0any times you need

    to s%ip fe( statements depending upon certain conditions i"e", you change the o( ofprogram" &his can $e done $y*

    r%nc(!ng IF? CASE

    loo)!ng O? WHILE

    Eo(eer, un!i%e other !anguage (here you hae on!y interna! contro!, ABAP/4 (%$

    !n&rn%l con&rol %n' >&rn%l con&rol o &( )rogr%+ o@

    &he !n&rn%l con&rol is steered $y standard %ey(ords as mentioned a$oe" ou

    dene this in your program code"

    &he >&rn%l con&rol is stored $y eents" ents are generated either from other

    A+AP/4 programs or from interactie user input K!i%e, for e@amp!e, using the mouse

    to c!ic% on the screenL" &he system does not necessari!y process the statements in

    the same seuence as they are !isted in an A+AP/4 program" &his ma%es A+AP/4 an

    eentDdrien programming !anguage" &he e@terna! contro! p!ays an important ro!e

    main!y for report programs"

    Br%nc(!ng !&( IF $&%&+n&

    &he I statement a!!o(s you to '!1r& &( )rogr%+ o &o % )%r&!c0l%r $&%&+n&

    $!oc%, depending on a condition" &his statement $!oc% consists of a!! the commands

    (hich occur $et(een an I statement and the ne@t -SI, -S, or

  • 8/10/2019 01 ABAP - Basics

    40/62

    ABAP BASICS

    &o introduce a!ternatie conditions, you can use -SI statements" If the rst

    condition is fa!se, the system processes the fo!!o(ing -SI statement in the same

    (ay as the I statement" -S $egins a statement $!oc% (hich is processed if none of

    the I and -SI conditions is true" &he end of the !ast statement $!oc% must a!(ays

    $e conc!uded (ith

  • 8/10/2019 01 ABAP - Basics

    41/62

    ABAP BASICS

    &he conditiona! $ranching using .AS is a shorter and simp!er form of simi!ar

    processing (ith I" hen you hae many conditions I $ecomes more comp!icated in

    such cases .AS is used"

    Page 41 of 62

  • 8/10/2019 01 ABAP - Basics

    42/62

    ABAP BASICS

    LOOPING

    Loo)!ng !&( O $&%&+n&

    If you (ant to (rite your name say for 1> times, you need to (rite RI& statement for

    1> times"

    hen you (ant to process a statement more than once, you can (rite this statement(ithin a !oop (ith the =; statement as fo!!o(s*

    Synta@

    =; 5 times"

    rite * / name"

    "

    EI- 0 1>"

    RI&* / 0"

    0 Q 0 1"

  • 8/10/2019 01 ABAP - Basics

    43/62

    ABAP BASICS

    &he system continues processing the statement $!oc% introduced $y EI- and

    conc!uded $y or unti! the system

    nds an MI&, S&;P"

    &he system e!d SYINED contains the num$er of times the !oop has $een processed"

    ou can nest EI- !oops any num$er of times and a!so com$ine them (ith other

    !oops"

    !"rnc &n O loo) %n' WHILEis that in EI-, condition is chec%ed rst

    and if condition is true then !oop is e@ecuted (hi!e in =; !oop, the !oop gets e@ecuted

    rst if you don:t hae &I0S option and then the condition is chec%ed Kif you hae anyL"

    ou can hae nested =; and EI- or =; and I or I and I or any possi$!e situation"

    Page 43 of 62

  • 8/10/2019 01 ABAP - Basics

    44/62

    ABAP BASICS

    S&r!ng O)r%&!on$

    A+AP/4 proides seera! %ey(ords for processing data o$'ects of type ., a!so %no(n as

    character strings"

    S(!& co++%n'

    &o shift the contents of a e!d, $y one position or one character you can use the SEI&statement" sing SEI& a!!o(s you to shift e!d contents, $yteD$yD$yte or characterD$yD

    character"

    ith the SEI& statement, you can e@ecute the fo!!o(ing*

    String Q E--;:"

    String 1 Q A-- ; ;:"

    String 2 Q ;R EAR=:"

    Shift string

    Shift string1 $y 2 p!aces"

    Shift string2 right"

    Shift string1 $y 2 p!aces circu!ar"

    &he output (i!! $e

    --; +y defau!t if nothing is specied then string is shifted $y one position"

    - ; ; Eere the string is shifted $y 2 p!aces"

    Z;R EAR= In this case the string is shifted to right $y one p!ace K(ith !eading

    $!an%sL EAR=;R In this case the string is shifted to the !eft so that 3 characters on the

    !eft appear on the right"

    R)l%c co++%n'

    ou use the RP-A. statement"

    Synta@

    RP-A.str!TI&Estr2TI

  • 8/10/2019 01 ABAP - Basics

    45/62

    ABAP BASICS

    Eere (ho!e string is searched for string1 and is rep!aces (ith str2"

    RP-A. #: I&E 0:

    Eere the system searches string for # and rep!aces it (ith 0:"

    TRANSLATE co++%n'

    Synta@

    &RA

  • 8/10/2019 01 ABAP - Basics

    46/62

    ABAP BASICS

    .;

  • 8/10/2019 01 ABAP - Basics

    47/62

    ABAP BASICS

    Page 49 of 62

  • 8/10/2019 01 ABAP - Basics

    48/62

    ABAP BASICS

    OPEN SL

    In the R/3 System, !ongD!ife data is stored in re!ationa! data$ase ta$!es" Structured

    Nuery -anguage KSN-L (as created for accessing re!ationa! =ata$ase" SN- has t(o

    statement types* =ata =enition -anguage K==-L statements and =ata 0anipu!ation

    -anguage K=0-L statements"

    &; inc!ude SN- statements in an A+AP/4 program, use

  • 8/10/2019 01 ABAP - Basics

    49/62

    ABAP BASICS

    Slc& $&%&+n&

    &he fo!!o(ing system e!ds p!ay an important ro!e in ;pen SN- operations*

    SYSUBRC

    As (ith other A+AP/4 statements, the return code a!ue in the system e!d SDS+R.indicates after each ;pen SN- operation (hether or not the operation (as successfu!"

    If an operation is successfu!, SDS+R. Q >" If an operation is unsuccessfu! SDS+R.

    T >

    SYBCNT

    &he a!ue in the SD=+.

  • 8/10/2019 01 ABAP - Basics

    50/62

    ABAP BASICS

    ER conditionT

    &he ER c!ause species (hich !ines are to $e read $y specifying conditions for the

    se!ection" .hoosing the -ines to $e Read"

    or Se!ecting A!! data from ta$!e*

    i"e", read a!! co!umns and a!! the ro(s from data$ase ta$!e

    Synta@

    S-.& X R;0 ta$!eT"

    KEere you are not specifying ER conditionL

    Se!ecting A!! =ata from a Sing!e -ine

    &o read a!! co!umns of a sing!e !ine from a data$ase ta$!e, use the S-.& statement as

    fo!!o(s *

    Synta@

    S-.& SI of 62

  • 8/10/2019 01 ABAP - Basics

    51/62

    ABAP BASICS

    "S0* returns the sum a!ue of the co!umn

    ".;

  • 8/10/2019 01 ABAP - Basics

    52/62

    ABAP BASICS

    c!ause" Aoid comp!e@ ER c!auses" &he system must sp!it up those into sing!e

    statements for the data$ase system"

    =o not use the !ogica!

  • 8/10/2019 01 ABAP - Basics

    53/62

    ABAP BASICS

    &o update data$ase ta$!e P=A& statement is used" &his a!!o(s you to change either

    a sing!e record or seera! records"

    ou can use P=A& (hen you %no( (hich record you (ant to change" +ut if you do

    not %no( (hether the primary %ey of the !ine you (ant to insert a!ready e@ists or not,

    you can use the 0;=I statement" &he 0;=I statement changes e@isting !ines and

    inserts !ines (hich do not e@ist"

    SightDcarrid Q 0>

    ER .ARRI= Q -E:"

    Eere price of sight (i!! get updated (ith ne( price 11>>"

    l& $&%&+n&

    &o de!ete records from a data$ase ta$!e, you use the =-& statement"

    =-& R;0 S-I7E& ER .ARRI= Q -E: A

  • 8/10/2019 01 ABAP - Basics

    54/62

    ABAP BASICS

    EDERCISES

    SIMPLE WRITE STATEMENTS

    1 rite a program, (hich generates the mode! !ist as sho(n

    se these system e!ds in your program"

    SD=A&0, SDUI&, SD*35

    $y* A+AP 1

    ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

    2 .reate a !ist as sho(n

    DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDMU .o" Pt" -td"

    =ate* &oday:s date Page

  • 8/10/2019 01 ABAP - Basics

    55/62

    ABAP BASICS

    SYMBOLS? ICONS AN FORMATTING

    1 rite a program to sho( the fo!!o(ing using system aria$!es

    Khint* use inc!ude sym$o!T and inc!ude iconT

    Sym$o!s* Icons*

    &e!ephone .hec%edH o%ay,a@ machine =e!ete,

    Eand pointing !eft,Print

    Eand pointing right,

    .aution,

    g * rite symZphone as sym$o!, te!ephone:"

    2 rite a program to sho( a string (ith diGerent $ac%ground co!ours"

    eg"

    (rite EA=R: co!or co!Zheading"

    Kco!Zheading is a$ap/4 name for grayish $!ue co!our" ;ther co!ours are

    co!Z%ey for $!uish green, co!Znorma! for $right gray, co!Z$ac%ground for

    gray, co!Zpositie for green, co!Znegatie for red, co!Zgroup for io!et and

    co!Ztota! for ye!!o(L

    3 se ormat intensied format intensied oG"

    ormat co!or co!orZnameT D format co!or oG"

    ormat inerse ormat inerse oG

    4 Sho( current time and today:s date"

    5 Sho( a a!ue 123456: as 12*34*56 using using edit mas%:"

    6 &a%e a num$er as >>>>>11:" Suppress a!! !eading Feros"

    9 Suppress a sign $efore a num$er"

    Page 55 of 62

  • 8/10/2019 01 ABAP - Basics

    56/62

    ABAP BASICS

    GENERAL PROBLEMS

    1 .reate an adding machine for num$ers"

    &he t(o a!ues to $e added must $e entered on the se!ection screen as

    parameters" ;utput the resu!t"

    2 .reate the diiding machine for num$ers"&he t(o a!ues must $e entered on the se!ection screen as parameters"

    ;utput the resu!t"

    3 .reate your output as sho(n $e!o("

    @

    @ @

    @ @ @

    @ @ @ @@ @ @ @ @

    4 rite a program to accept the t(o num$ers from the user and s(ap the a!ues"

    5 =ec!are a string echo: and design your output

    e

    e c

    e c h

    e c h oe c h

    e c

    e

    Page 56 of 62

  • 8/10/2019 01 ABAP - Basics

    57/62

    ABAP BASICS

    OENO? IFELSEIFELSEENIF? CASEENCASE

    1 rite a program (ith =o nddo !oop"

    =isp!ay suares of num$ers 1 to 1>

    1 12 4

    3 8

    2 rite a program to accept a num$er Ksay 2L from user and create a mu!tip!ication

    ta$!e"

    2 @ 1 Q 2

    2 @ 2 Q 4

    YYYY2 @ 1> Q 2>

    3 Accept a num$er from user and nd actoria! of the same" If the num$er is

    negatie then disp!ay some message"

    4 rite a program (ith =o nddo !oop for rst 2> num$ers"

    D ;utput shou!d contain on!y en num$er

    D ;dd num$ers shou!d not $e disp!ayed

    5 Accept num$ers and choice )

  • 8/10/2019 01 ABAP - Basics

    58/62

    ABAP BASICS

    STRING OPERATIONS

    1 Accept a string and determine its !ength

    2 Accept a string # num$er" rite the string that many num$er of times"

    3 Accept t(o strings and s(ap their contents"

    4 Accept t(o strings and concatenate into one string"

    5 Accept one string (ith de!imiter K , or H L and sp!it it into t(o strings"

    6 Accept a string a$cdef: and use shift stringT, shift stringT right, shift stringTup to def:"

    9 Accept a string eg" App!e" .hange rst occurrence of p: to $:"Kuse rep!ace: commandL

    J Accept a string eg" App!e" .hange a!! occurrences of p: to $:"Kuse trans!ate: commandL

    8 Accept t(o strings and compare the t(o strings using co:, ca:, cs:cp: Kout put sha!! $e true: or fa!se: for each comparison"L

    1> Accept a string A+.=:" ;utput on!y =: using oGset command"

    11 Accept rst name, !ast name and midd!e nameeg"

  • 8/10/2019 01 ABAP - Basics

    59/62

    ABAP BASICS

    ATE PROBLEMS

    1 Accept a date ear!ier to today:s date and nd the diGerence in num$er of days"

    2 Accept a date from user and disp!ay rst day of the month and !ast day of thepreious month"

    3 Accept a date from user and add si@ months to the date"

    4 Accept a date from user and conert month part to 'an:, fe$: etc", and disp!ay thisdate"

    5 rite a program to accept month" =isp!ay num$er of days in tota! month"0a%e use ofD &e@t e!ement for your se!ection screen $o@"D Se!ection te@t

    6 Accept $irth date from user and output age in years, months and days"

    Page 58 of 62

  • 8/10/2019 01 ABAP - Basics

    60/62

    ABAP BASICS

    CHECK BODES AN RAIO BUTTONS

    1 rite a program (ithD Parameter as chec%$o@esD If chec%$o@ 1 is c!ic%ed (rite c"$ 1 c!ic%ed e!se c"$ 1 not c!ic%ed"D If chec%$o@ 2 is c!ic%ed (rite c"$ 2 c!ic%ed e!se c"$ 2 not c!ic%ed"D If chec%$o@es 1 # 2 are c!ic%ed (rite c"$ 1 # c"$" 2 are c!ic%ed"D If chec%$o@es 1 # 2 are not c!ic%ed (rite c"$ 1 # c"$" 2 are not c!ic%ed"

    2 rite a program (ithD Parameters as t(o groups of Radio$uttons Kt(o Radio$uttons in each groupL"D 7ie detai!ed coding as a$oe, to sho( the Radio$uttons and groupsD se!ected

    3 rite a program (ithD Parameter as chec%$o@"D If you c!ic% the chec%$o@ then disp!ay rst day of the ne@t year"

    D If the chec%$o@ is not c!ic%ed then disp!ay !ast day of the current year"

    4" rite a program (ithD Parameter as group of 3 radio $uttonsD If rst radio $utton is c!ic%ed, disp!ay !ast day of the current month"D If second radio $utton, disp!ay rst day of the ne@t monthD If third radio $utton, disp!ay date after si@ months"

    Page 6> of 62

  • 8/10/2019 01 ABAP - Basics

    61/62

    ABAP BASICS

    SELECT STATEMENTS

    1 -ist a!! the ro(s from the ta$!e )+A"

    2 -ist sing!e ro( from the ta$!e +P"

    3 -ist up to 5 ro(s from the ta$!e +SIS"

    4 -ist a!! R=A&s" or $etter reada$i!ity create a co!umn heading in the !ist

    5 =isp!ay tota! amount for carrid -E:" K&a$!es* S-I7E&L

    6 -ist a!! the ights for (hich $oo%ing date is greater than :>1">6"1885:"

    9 -ist a!! the ights for (hich payments currency is =0:"

    J -ist a!! the ights (here carrid is $et(een -E: and SN:"

    8 Se!ect a sing!e record (here carrid Q -E:, ightDno Q >4>>: anddate Q :2J">2"188J:"

    1> =isp!ay carrid, connid, date and !uggage (eight mu!tip!ied $y 2

    11 -ist the ma@imum capacity, occupied seats and tota! of current $oo%ings for eachight in the fo!!o(ing format"

    .arrierid

    0a@" capacity ;ccupiedseats

    &ota! of current$oo%ings

    12 rom the gien fromDcity and toDcity, !ist a!! the aai!a$!e on this route*rom* fromDcityT &o* toDcityT Ksay from ran%furt to 0adrasLK&a$!es* SP-1L

    .arrierid

    =eparture&ime

    Start Airport =estination Airport

    Page 61 of 62

  • 8/10/2019 01 ABAP - Basics

    62/62

    ABAP BASICS

    OPEN SL

    1 Accept document no" from user and disp!ay particu!ars of Sa!es document"K=efau!t document no" >>1>>>>>31:LK&a$!e* )+APL

    .reated on* @@@@@

    .reated $y* @@@@@&ime* @@@@@

    2 Accept Sa!es =ocument num$er from user and disp!ay corresponding materia!no, description of that materia! and item category K&a$!e * )+APL

    3 Accept materia! no" # item category $y defau!t PP1>> and 0< respectie!y=isp!ay corresponding detai!s of sa!es document K&a$!e* )+APL

    4 =isp!ay e!ds from +P"

    =ocument type Q A+: and=ocument date Q :>5">2"188J:"A!so disp!ay num$er of records se!ected"

    5 =isp!ay .o" code, doc"no", acc"type, ta@ code"0a%e use of se!ectDoptions to gie range of document type"=isp!ay tit!e of your program at the end of program

    6 Accept doc" no from user"=isp!ay doc"no", doc"status, date of doc", doc"type"

    9 =isp!ay sing!e record for document (here date Q :>5">2"188J:, type Q A+ anddocumentno" Q >1>>>>>>>6:"

    J Accept p!ant from user eg" P-&P"=isp!ay document detai!s for that p!ant !i%e doc"no", doc"status, date of document

    etc",