sap abap material chandra

Upload: gvrahul

Post on 03-Mar-2018

302 views

Category:

Documents


6 download

TRANSCRIPT

  • 7/26/2019 Sap Abap Material Chandra

    1/170

    31/05/2010 ABAP TUTORIAL

    SAP (Systems Applications and Products in Data Processing)

    ERP!

    Enterprise Resource Planning Money Men

    Big Company Machine Well utilization o resourcesMaterial

    Mar!eting

    Some "on ERP! "B/#$"$ % &ront en'

    (R$C)E % Bac! en'

    Some ERP Products! B$$*

    Pro'uction

    Purchasing

    Ware house

    &+/C(Manuacturing

    Company ,hipping

    -R

    ,ales .

    istriution

  • 7/26/2019 Sap Abap Material Chandra

    2/170

    R$MC(

    PE(P)E ,(&

    (R$C)E $PP,

    ,$P

    ERP!

    +t proi'es pre'eine' tales

    +t proi'es pre'eine' application programs

    *o nee' to creating . maintaining tales

    *o nee' to 4rite the programs or etches the 'ata rom 'ataase

    BAA"!

    *early 06 o 'ataase tales . source co'e are relate' to customers .en'ors7 so it is suitale or small size . mi' size companiesEg8 "i9aya Electronics

    RA#$O! *early :06 o 'ataase tales . source co'e are relate' to theinance -ence it is suitale or inancial companies ,o7 it is also suitale or smallsize an' mi' size companiesEg8 $ny automoile company

    People so%t! his is goo' or -R 'epartment ut 4ea! in relationship 4ith other'epartments ;li!e Pro'uction7 Purchasing7 Warehouse7 &+/C(7 ,hipping7 ,alesan' istriution

  • 7/26/2019 Sap Abap Material Chandra

    3/170

    AD&A"TA'ES O SAP!

    +t is tightly ;or< closely integrate' across all the mo'ules ;or< 'epartments

    ,$P is platorm in'epen'ent irrespectie o all (perating ,ystem

    ;Win'o4s7 )inu>7 ?*+@ etcchange +nrastructure +t is the ,$P Enterprise $pplication +ntegration;E$+

  • 7/26/2019 Sap Abap Material Chandra

    5/170

    J Multiplication 2J3I JJ E>ponential 2JJ3I2K3I: / iision D/2I2 Mo' ;6< Remain'er 362I1

    $omparati*e Operators!

    (perator escription E>ample L (r ) )ess than a L or a )

    LI (r )E )ess than or a LI or a )E Eual to N (r reater than a N or a NI (r E reater than or a NI or a E Eual to I (r EO Eual to a I or a EO LN (r *E *ot eual aLN or a *E Relational + Logical Operators!

    (perator escription E>ample $* an' aL an' aLc (R or aL or aLc *( not

    Operands!

    (peran's are the ariales 4hich 4e nee' to perorm particularoperation

    C I a H

    (peran's&aria,le!

    "ariale is the name gien to memory location

    -ey.ords!

    Gey4or's are use' to i'entiy the type o statementsGey4or's are ;CK2 K3 E (ecute the program 4ithout

    'epen's on any other program

    Clic! on sae ;enter

  • 7/26/2019 Sap Abap Material Chandra

    9/170

    +n C in $B$P+nt a7 7 cF Parameter8 $ ype +7,can ;Q6'7 6'T7 .a7 .cee' : character length2 he parameter cannot accept 'ata type &S3 QE&$?)T is the !ey4or' 4hich is use' to assign the 'eault alues to the

    parameter ariales,ynta>8= Parameter Lariale nameN ype LN 'eault LalueN

    Eg8 parameter $ ype + 'eault 10S ;S is your 4ish or integers8= Parameter Lariale nameN ype LN oligatory

    Eg8 parameter $ ype + oligatory

    Structure o% an ABAP program!

    -ea'er

    eclarations

    Business )ogic

    einition o Reusale Bloc!s

  • 7/26/2019 Sap Abap Material Chandra

    10/170

    7eader! (only in real time)

    000000000000000000000000000000000000000000000000000

    0 Program 8 U"E*VA30PMV$++(* JJ $uthor 8 "E*G$E,- J

    J Purpose 8 $''ition o t4o numers J J ,tart 'ate 8 02/0/10 J J &inish 'ate 8 02/0/10 J

    J Mo'iie' y 8 JJ Mo'iie' 'ate 8 JJ Copie' rom 8 *$ ;not applicale< JJ ,upplier 8 ", echnologies JJ Pac!age 8 JJ Reuest numer 8 JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ

    Declarations!

    eclarations

    "ariales ConstantsJ $$ is the !ey4or' to J C(*,$*, is the 'eclareariales Gey4or' to 'eclare the "ariales,ynta>8 = ,ynta>8=

    $$ LnN ype LN Constants LnN ype LNalueLalueNEg8 ata $ ype + Eg8 Constants $ ype + alue 10SJ4ith in the program the Jconstants ariales alues neer alueo ariale can change Change 4ith in the program

    Business Logic!

    +n $B$P usiness logic is retrieing/to get the 'ata rom a'ataase . 'isplay it in a pre'eine' ormat

    Reusa,le Bloc5s!

    Lproce'ure/unctionsN LsuroutinesN

    Common terminology +n $B$PS8L!

    ,tructure' Ouery )anguage

  • 7/26/2019 Sap Abap Material Chandra

    11/170

    ,O)

    ) M) C);ata einition )ang< ;ata manipulation )ang< ;ata Control )angecute ,E11

    ,elect the ra'io utton 'omain

    Proi'e your 'omain name ;,PR$(VA30VEi'ecute ,E11

    ,elect the ra'io utton 'ataase tale Proi'e your tale name ;,PR$(VA30VEmp1

  • 7/26/2019 Sap Abap Material Chandra

    16/170

  • 7/26/2019 Sap Abap Material Chandra

    17/170

    ,ae the 'ata element

    Chec! the 'ata element

    $ctiate the 'ata element

    Come ac!

    Repeat the same or all the iel's

    "OTE!

    1 +n the real time al4ays create the tale y using 'ata element type7ecause i 4e 4ant to estalish the relationship et4een any t4otales 4e nee' common 'omain name in oth the tales

    2 +n the irect/uilt=in type there is no 'omain concept

    oreign -ey Relationsip! 05/0/10

    &oreign !ey is a iel' in one tale ie7 connecte'4ith another tale ia7 oreign !ey relationship he purpose is to ali'ate the 'ata

    eing entere' in one tale ;oreign !ey tale< y chec!ing against list o possilealues in another tale ie7 chec! tale

    Ei' Ename Ei' EsalChec! tale

    &oreign !ey tale

    Tecnical re6uirements to esta,lis te primary + %oreign 5ey relationsip!

    he 'omain name o the oth the iel's in oth the tales must e the same

    he chec! tale iel' must e the primary iel'

    Steps to esta,lis te oreign 5ey relationsip!

    E>ecute ,E11

    ,elect the ra'io utton 'ataase tale

    Proi'e your oreign !ey tale name

    Clic! on change mo'e

    ,elect the iel' ;or 4hich iel' 4e 4ant to estalish oreign !ey

    relationship

  • 7/26/2019 Sap Abap Material Chandra

    18/170

    $ctiate the tale

    Some o% te standard data,ase ta,les!

    1 001 Y Company co'e tale2 G*$1 Y Customer master tale

    3 )&$1 Y "en'or master taleD M$R$Y Material master tale

    Some o% te %ields in T::;!

    1 B?GR, Y Company co'e2 B?@ Y Company name3 (R01 Y City o the companyD )$*1 Y Country5 ,PR$, Y )anguage

    Some o% te %ields in -"A;!

    1 G?**RY Customer numer2 *$ME1 Y *ame o the customer3 (R01 Y City o the companyD )$*1 Y Country5 ,PR$, Y )anguage

    Some o% te %ields in LA;!

    1 )+&*R Y "en'or numer2 *$ME1 Y *ame o the en'or3 (R01 Y CityD )$*1 Y Country5 ,PR$, Y )anguage

  • 7/26/2019 Sap Abap Material Chandra

    19/170

    "OTE!

    1 00 is the stan'ar' 'ataase tale 4hich contains all the unit omeasurement ;?(Mecute

    I"TER"AL TABLES 0A/0/10

    +nternal tales are collection o recor's

    +nternal tales are temporary tales7 ie7 the 'ata in the internal tale 4ill not

    sae any 4here in the sap

    +nternal tales are 'ynamic memory allocation7 ie7 4e nee' not to proi'esize o the internal tale

    he scope o the internal tale is up to that program

    Placing the 'ata in to the internal tale or rea'ing the 'ata rom the internal

    tale is al4ays recor' y recor' ie7 through 4or! area

    Synta4 o% declaring te internal ta,le!

    $$ L+nternal tale nameN li!e tale o LWor! area nameN

    Synta4 o% accessing %ields %rom .or5 area!

    LWo! area nameN=Liel' nameN

    "OTE!

    $PPE* is the !ey4or' to transer the 'ata rom 4or! area to internaltale

    Program! Emp Ei' Ename Ea''

    C 10 C 25 C 35$$8 Begin o Emp7

    Ei' ;10< ype C7

    Ename ;25< ype C7 Ea'' ;35< ype C7

    E ' E

  • 7/26/2019 Sap Abap Material Chandra

    20/170

    $$ Emp1 li!e tale o Emp

    Emp=Ei' I 1SEmp=Ename I ,PR$(SEmp=Ea'' I ,$*$- *$$RS$ppen' Emp to Emp1

    Emp=Ei' I 2SEmp=Ename I R$#SEmp=Ea'' I GP-BS$ppen' Emp to Emp1

    Emp=Ei' I 3SEmp=Ename I ,$*EEPSEmp=Ea'' I BE?MPES

    $ppen' Emp to Emp1

    )oop at Emp1 to Emp

    Write8 / Emp=Ei'7 Emp=Ename7 Emp=Ea''

    En' )oop

    Synta4! B?GR, ;D< ype C (r

    B?GR, ype B?GR, (r

    B?GR, li!e 001=B?GR,

    ype is use' to reer the 'ata types or 'ata elements

    )i!e is use' to reer the ariales or iel's

    O,=ect!

    o 'isplay the company co'es7 company names . cities

    W$ B?GR, B?@ (R01

    $$8 Begin o W$7 B?GR, li!e 001=B?GR,7 B?@ li!e 001=B?@7 (R01 li!e 001=(R017 En' o W$

    $$ + li!e tale o W$

  • 7/26/2019 Sap Abap Material Chandra

    21/170

    ,elect B?GR, B?@ (R01 rom 001 into tale +

    )oop at + into W$Write8 / W$=B?GR,7 W$=B?@7 W$=(R01En')oop

    "OTE!

    he or'er o the iel's in the 4or! area as 4ell as the or'er o the iel's inselect uery must e same

    O,=ect!

    o 'isplay the "en'or numers7 "en'or names7 . Countries

    W$ )+&*R *$ME1 )$*1$$8 Begin o W$7

    )+&*R li!e )&$1=)+&*R7 *$ME1 li!e )&$1=*$ME17 )$*1 li!e )&$1=)$*17 En' o W$

    $$ + li!e tale o W$

    ,elect )+&*R *$ME1 )$*1 rom )&$1 into tale +

    )oop at + into W$ Write8 / W$=)+&*R7 W$=*$ME17 W$=)$*1

    En')oop

    Di%%erences ,et.een Data,ase ta,les + Internal ta,les!

    ataase tale +nternal tale

    ataase tales are gloal7 +nternal tales are local7 ie7 4e can ie7

    4e can access the 'ata= access the internal tale 4ith in the

    ase tales rom any4here program only inthe sap

    ataase tales are permanent +nternal tales are temporary storage

    storage location )ocation

    We must proi'e the size o +nternal tales is 'ynamic memory the

    'ataase tale allocation

    O,=ect!

    o 'isplay the customer numers7 customer names7 cities . countries

    W$ G?**R *$ME1 (R01 )$*1

  • 7/26/2019 Sap Abap Material Chandra

    22/170

    $$8 Begin o W$7 /J4or! area starte'J/ G?**R li!e G*$1=G?**R7 *$ME1 li!e G*$1=*$ME17 (R01 li!e G*$1=(R017

    )$*1 li!e G*$1=)$*17 En' o W$ /J4or! area en'e'J/

    $$ + li!e tale o W$ /J+nternal tale create'J/

    ,elect G?**R *$ME1 (R01 )$*1 rom G*$1 into +

    )oop at + into W$Write8 / W$=G?**R7 W$=*$ME17 W$=(R017 W$=)$*1En')oop

    Types o% Internal Ta,les!

    4o ypes

    +n'e>e' -ashe'

    ,tan'ar' ,orte'

    Standard Internal Ta,le! 0:/0/10

    +t accepts 'uplicate recor's

    -ere all iel's are non=uniue iel's

    Pushing 'ata rom 4or! area to internal tale is al4ays through $PPE*!ey4or'

    ,earching o a recor' is through )+*E$R search

    Synta4!

    $$ L+nternal ale nameN li!e stan'ar' tale o L4or! area nameNEg8 $$ + li!e stan'ar' tale o W$

    Sorted Internal Ta,le!

    +t 4onSt accept 'uplicate recor's

  • 7/26/2019 Sap Abap Material Chandra

    23/170

    -ere 4e must speciy at least one iel' as uniue or non=uniue iel's

    Pushing 'ata rom 4or! area to internal tale is al4ays through +*,ER

    !ey4or'

    ,earching o a recor' is through B+*$R search

    Synta4! $$ L+nternal ale nameN li!e sorte' tale o L4or! area nameN 4ith

    uniue/non uniue !ey Liel'1N Liel'2NEg8 $$ + li!e sorte' tale o EMP 4ith uniue !ey E+

    7ased Internal Ta,le!

    +t 4onSt accept 'uplicate recor's -ere 4e must speciy at least one iel' as uniue iel'

    Pushing 'ata rom 4or! area to internal tale is al4ays through C())EC

    !ey4or'

    ,earching o a recor' is through -$,-E $)(R+-M ie7 Mi'point

    algorithm

    Synta4!

    $$ L+nternal ale nameN li!e hashe' tale o L4or! area nameN 4ith

    uniue/non uniue !ey Liel'1N Liel'2NEg8 $$ + li!e hashe' tale o EMP 4ith uniue !ey E+

    "OTE!

    +n the real time 4e al4ays 4or! 4ith stan'ar' internal tales ecause7 4eare 4or!ing 4ith the 'ata in the 'ataase +n the 'ataase there 4ill e no'uplicates

    Types o% Declaring te Internal Ta,les!

    + you 4ant to 'eclare some o the iel's rom any one o the 'ataase

    Synta4!

    $$8 Begin o LW$ nameN7 )ist o iel's7 En' o LW$ nameN

    $$ L+ nameN li!e tale o LW$ nameNEg8

    W$V001 B?GR, B?@ (R01

    $$ B i W$ 001

  • 7/26/2019 Sap Abap Material Chandra

    24/170

    B?GR, li!e 001=B?GR,7B?@ li!e 001=B?@7(R01 li!e 001=(R017

    En' o W$V001$$ +V001 li!e tale o W$V001

    +V001

    + you 4ant to 'eclare all the iel's rom any one o the

    'ataase tale

    Synta4!

    $$8 Begin o LW$ nameN+nclu'e ,tructure L tale nameN$$ En' o LW$ nameN

    $$ L+ nameN li!e tale o LW$ nameNEg8 W$V001 B?GR, B?@ (R01

    $$8 Begin o W$V001+nclu'e ,tructure 001$$ En' o W$V001$$ +V001 li!e tale o W$V001

    +V001 B?GR, B?@ (R01

    eclaring the internal tales y reerring 'ataase tales

    Synta4!

    $$ LW$ nameN li!e L tale nameN$$ L+ nameN li!e tale o LW$/ nameN

    Eg8

    W$V001 B?GR, B?@ (R01

    $$ W$V001 li!e 001$$ +V001 li!e tale o 001

    (r$$ +V001 li!e tale o 001$$ W$V001 li!e line o +V001/001

    +V001 B?GR, B?@ (R01

  • 7/26/2019 Sap Abap Material Chandra

    25/170

    eclaring the 4or! area y using $B)E, !ey4or'

    Synta4!

    ales L tale name NEg8 ales 001

    W$V001 B?GR, B?@ (R01

    By 'eault $B)E, !ey4or' creates one W$ 4ith the name o 'ataase tale

    name . also contains all the iel's in 'ataase tale

    eclaring the internal tale y using PE, !ey4or'

    Synta4!

    ypes8 Begin o L type name N7 )ist o iel's7 En' o L type nameN

    $$ LW$ nameN ype Ltype nameN$$ L+ nameN li!e tale o LW$ nameN

    Eg8 yV001 B?GR, B?@ (R01

    ypes8 Begin o yV0017 B?GR, li!e 001VB?GR,7 B?@ li!e 001=B?@7 (R01 li!e 001=(R017 En' o yV001

    $$ W$V001 ype yV001$$ +V001 li!e tale o W$V001

    +V001 B?GR, B?@ (R01

    O,=ect!

    o 'isplay the all the iel's rom )&$1 tale

    P J i W$ )&$1

  • 7/26/2019 Sap Abap Material Chandra

    26/170

    J +nclu'e structure )&$1J ata en' o W$V)&$1J ata +V)&$1 li!e tale o W$V)&$1

    J ata W$V)&$1 li!e )&$1

    J ata +Vla1 li!e tale o W$V)&$1

    J ata +V)&$1 li!e tale o )&$1J ata W$V)&$1 li!e line o +V)&$1

    ypes egin o yV)&$1 +nclu'e structure )&$1 ypes en' o yV)&$1

    ata W$V)&$1 ype yV)&$1

    ata +V)&$1 li!e tale o W$V)&$1

    ,elect J rom )&$1 into tale +V)&$1

    )oop at +V)&$1 into W$V)&$1 Write8 / W$=)&$1 En'loop

    eclaring the internal taleSs 4ith -ea'er line

    By 'eault hea'er line creates one 4or! area 4ith the name o internal taleie7 the name o the 4or! area as 4ell as the name o the internal tale issame

    eclaring the internal tale 4ith hea'er line y using (CC?R, !ey4or'

    Synta4!

    $$8 Begin o L+ nameN occurs 07 )ist o iel's/ internal structure7

    En' o L+ nameN

    Eg8$$8 Begin o +V001 occurs 07

    B?GR, li!e 001=B?GR,7 B?@ li!e 001=B?@7 (R01 )+GE 001=(R017 En' o +=001

    -ere +V001 acts as an internal tale 4ith hea'er line7 ie7 it creates one

    ! i h h i l l i

  • 7/26/2019 Sap Abap Material Chandra

    27/170

    "OTE!

    1 -ere (CC?R, 0 allocates :GB o memory or internal tale2 + the 'ata in the internal tale e>cee's :GB then it rings one more

    :GB o memory up to 2B

    3 (CC?R, * allocates * recor's o memory or the internal taleF ithe 'ata in internal tale e>cee's * recor's o memory then it ringsone more * recor's o memory up to 2B

    eclaring the internal tale 4ith hea'er line y using ypes !ey4or'

    Synta4!

    ypes8 Begin o Lype nameN7 )ist o iel's7

    En' o Lype nameNata L+ name N ype tale o Lype nameN 4ith hea'er lineEg8

    +V001 B?GR, B?@ (R01

    ypes8 Begin o yV0017 B?GR, li!e 001=B?GR,7 B?@ li!e 001=B?@7 (R01 li!e 001=(R017 En' o yV001

    ata +V001 ype tale o yV001 4ith hea'er line +V001 B?GR, B?@ (R01

    Initiali9ing Tecni6ues o% Internal Ta,le! 0/0/10

    1 Clear

    2 Reresh3 &ree

    $lear!

    Clear al4ays use' to clear the contents o the 4or! area onlySynta4!

    Clear L 4or! area name NEg8 Clear W$V001

    W$V001 B?GR, B?@ (R01 1000 C, -

    $ Cl

  • 7/26/2019 Sap Abap Material Chandra

    28/170

    W$V001 B?GR, B?@ (R01

    Clear also clears the contents o the internal tale

    Synta4!

    Clear L +nternal tale nameNEg8 Clear +V001

    +V001 B?GR, B?@ (R01

    "OTE!

    1 +n the real time7 4e neer use clear to clear the contents o internaltale

    2 + 4e are 4or!ing 4ith internal tale 4ith hea'er line then the name ohe 4or! area as 4ell as the name o the internal tale are same7 in thissituation also clear clears the contents o the 4or! area

    3 + you 4ant to clear the contents o the internal tale then 4e use ZXSto the internal tale

    Eg8 Clear +V001

    +V001 B?GR, B?@ (R01

    Clear +V001 ZX

    +V001 B?GR, B?@ (R01

    Re%res!

    Reresh al4ays clears the contents o the internal tale only

    Synta4!

    Reresh L +nternal tale nameN

    Eg8 Reresh +V001

    W$ 001 B?GR, B?@ (R01

  • 7/26/2019 Sap Abap Material Chandra

    29/170

    1000 C, -

    2000 +BM C-E

    3000 -C) B$*

    $ter Reresh

    W$V001 B?GR, B?@ (R01

    "OTE!

    + 4e are 4or!ing 4ith internal tale 4ith hea'er line then the name o4or! area as 4ell as the name o the internal tale are same7 in this situation alsoreresh clears the contents o the internal tale only

    ree!

    &ree acts li!e Reresh

    Reresh clears the contents o the internal tale only not the memory 4hich

    is allocate' or that internal tale7 4here as ree clears the contents o theinternal tale as 4ell as the memory 4hich is allocate' or that internal tale

    Synta4! &ree L +nternal tale nameN

    Attri,utes o% Internal Ta,le!

    4o types

    ype o the internal tale *um o recor'saailale in the

    internal tale

    G+* )+*E,

    , -

    ;,tan'ar'< ;,orte'< ;-ashe' LnumNEg8 Rea' tale +V001 into W$V001 in'e> 3

    +V001 B?GR, B?@ (R01

    1000 C, -

    2000 +BM C-E

    3000 -P M?M

    D000 -C) B$*

    5000 C$P$M+*+

    P?*

    W$V001 B?GR, B?@ (R01

    3000 -P M?M

    Reading a single record %rom te internal ta,le ,ased on condition!

    Synta4!

    Rea' tale L+ nameN into LW$ nameN 4ith !ey Lcon'itionNEg8 Rea' tale +V001 into W$V001 4ith !ey B?GR,ISD000S

    Reading multiple records %rom te internal ta,le ,y using loop at 5ey.ord!

    Synta4!

    )oop at L+ nameN into LW$ nameN 4here Lcon'itionN Write

    En'loopEg8 )oop at +V001 into W$V001 4here (R01IS-S

    W it / W$ 001 B?GR, W$ 001 B?@ W$ 001 (R01

  • 7/26/2019 Sap Abap Material Chandra

    33/170

    En'loop

    #odi%y te internal ta,le ,y using #ODI> 5ey.ord!

    his is the t4o step proce'ure

    1 &ill the latest 'ata into 4or! area2 Mo'iy the internal tale

    Synta4!

    Mo'iy L+ nameN rom LW$ nameN transporting Liel'1NLiel'2N Where Lcon'itionN

    Eg8 W$V001=B?@ I +BMS W$V001=(R01 I B$*S

    Mo'iy +V001 rom W$V001 transporting (R01 4here

    B?GR, I 2000S

    Delete te data %rom internal ta,le ,ased on Inde4!

    Synta4!

    elete L+ nameN 4here Lcon'itionNEg8 elete +V001 4here B?GR, IS5000S

    + you are not mentioning any con'ition then it 'eletes the 'ata entirely in the

    internal tale

    Sort te data in te internal ta,le!

    Synta4!

    ,ort L+ nameN y Liel' name1NEg8 ,ort +V001 y B?GR,

    By 'eault sorting 4ill e ascen'ing

    + you 4ant to 'isplay the 'ata in 'escen'ing

    Synta4!

    ,ort L+ nameN y Liel' nameN 'escen'ingEg8 ,ort +V001 y B?GR, 'escen'ing

    + 4e hae t4o similar internal tales7 i you 4ant to moe the 'ata rom one

    internal tale to anotherSynta4!

    L+2N I L+1N

    + you 4ant to appen' the 'ata rom irst internal tale to secon'

    Synta4!

  • 7/26/2019 Sap Abap Material Chandra

    34/170

    $ppen' LW$N to L+ nameN

    $ppen' lines o L1st+N to L2n'+N

    Eg8 $ppen' lines o +V001 to +V0011

    +nsert LW$N into tale L+NEg8 +nsert lines o L+1N into tale L+2N

    $ec5ing te internal ta,le!

    + Linternal taleN is initial

    Empty

    + not Linternal taleN is initial

    -aing some inormation

    $ontrol structures!

    Control structures are use' to control the e>ecution seuenceo a programhere are t4o types o control structures

    Branching )ooping

    + Case Con'itional looping ?ncon'itional looping

    While o

    I%!

    Synta4!

    + Lcon'itionN

    Bloc! o statementsElse/elsei Lcon'itionNBloc! o statements

  • 7/26/2019 Sap Abap Material Chandra

    35/170

    En'i

    Eg8 parameter 'ay type ++ 'ayI 1SWrite sunS

    Elsei 'ayI 2SWrite monSElsei 'ayI 3SWrite tueS

    Elsei 'ayISASWrite satSElseWrite inali' 'aySEn'i

    $ase!

    Synta4!

    Case L statement NWhen L result 1NBloc! o statements

    When L result 2NBloc! o statements

    When othersBloc! o statementsEn'case

    Eg8 parameter 'ay type +Case 'ay

    When 1SWrite sunSWhen 2SWrite monS

    When othersWrite inali' 'aySEn'case

    "ote!

  • 7/26/2019 Sap Abap Material Chandra

    36/170

    +n the real time 4e al4ays use case instea' o neste'i7 ecause case isaster as 4ell as clear than i

  • 7/26/2019 Sap Abap Material Chandra

    37/170

    "ote!

    ,=,?BRC is the system ariale 4hich contains 0S i the aoe statemente>ecute' successully (ther4ise it contains non=zeroS ;mot o times it contains D

  • 7/26/2019 Sap Abap Material Chandra

    38/170

    Synta4!

    +nsert LB tale nameN rom tale L+ nameN accepting 'uplicate!eys

    he aoe statement aoi's the termination o the program as 4ell as inserts the

    non='uplicate recor's . ignores the 'uplicate recor's

    "ote!

    ,=BC* is the system ariale 4hich returns numer o recor'ssuccessully inserte' in to the 'ataase tale

    Update (single record ? o*er .rite)!

    ?p'ate up'ates the 'ata in to the 'ataaseFi there is a match oun' in the 'ataase ase' on the !ey iel' other4ise it ignores

    the recor'

    Synta4!

    ?p'ate LB tale nameN rom LW$ name N

    "ote!

    +n this case7 4e must pass change' inormation along 4ith ol' inormationin the 4or! area

    Eg8ata W$V001 li!e 001W$V001=B?GR, IS0A:SW$V001=B?@ I ,PR$( EC-SW$V001=(R01 I M?MS?p'ate 001 rom W$V001

    Update multiple records!

    +t is similar as up'ate single recor'

    Synta4!?p'ate LB tale nameN rom tale L+ nameN

    Update particular column!

    Synta4!?p'ate LB tale nameN set Liel'1N I LalueN Liel'2N I LalueN

    h 'i i

  • 7/26/2019 Sap Abap Material Chandra

    39/170

    Eg8?p'ate 001 set (R01 ISC-ES 4here B?GR,I 0A:S

    #odi%y!

    Mo'iy acts li!e up'ate i there is a match oun' in the 'ataase ase' on the

    !ey iel' other4ise it acts li!e insert Mo'iy neer ails

    Synta4!

    1 Mo'iy LB tale nameN rom LW$ nameN2 Mo'iy LB tale nameN rom tale L+ nameN

    Eg8ata8 W$V001 li!e 0017

    +V001 li!e tale o 001W$V001=B?GR, I 1000SW$V001=B?@ I C,SW$V001=(R01 I C-ES$ppen' W$V001 to +V001W$V001=B?GR, I 0SW$V001=B?@ I "E*G+SW$V001=(R01 I -S$ppen' W$V001 to +V001Mo'iy 001 rom tale +V001

    Delete!

    elete 'eletes the 'ata rom the 'ataase ase' on con'ition

    Synta4!

    elete rom LB tale nameN 4here Lcon'itionNEg8 elete rom 001 4here B?GR, I 0A:S

    $ommit .or5! 12/0/10his comman' is use' to commit the 'ataase ater change'

    happen in the 'ataase

    Synta4!

    Commit 4or!

    Roll,ac5 .or5!his comman' is use' to un'o the 'ataase operations

  • 7/26/2019 Sap Abap Material Chandra

    40/170

    Synta4!

    Rollac! 4or!

    Select!options!

    ,elect=options is a !ey4or' 4hich accepts single alue7

    multiple single alues7 single range7 multiple single ranges

    Synta4!

    ,elect=options Lname o the select=optionsN or Lariale nameNEg8

    ata "1 li!e 001=B?GR, ,elect=options ,VB?GR, ro "1

    ,VB?GR, to

    "ote!

    he name o the select=options acts as an internal tale 4ith hea'er line ie7the name o the 4or! area as 4ell as the name p the internal tale is the similarname o the select=options

    $omponents? %ields o% te select!options!

    1 )o4 % the lo4 alue o the select=options2 -igh % the high alue o the select=options

    3 ,ign % inclu'e ;+< or e>clu'e ;E

  • 7/26/2019 Sap Abap Material Chandra

    41/170

    O,=ect!

    Base' on the gien company co'es to 'isplay the company co'es7company names7 an' cities

    Program!

    ata "1 li!e 001VB?GR, ,elect=options ,VB?GR, or "1

    ata8 Begin o W$V0017 B?GR, li!e 001VB?GR,7 B?@ li!e 001VB?@7 (R01 li!e 001V(R017 En' o W$V001

    ata +V001 li!e tale o W$V001,elect B?GR, B?@ (R01 rom 001 into tale+V001 4here B?GR, in ,VB?GR,

    )oop at +V001 into W$V001Write8 / W$V001=B?GR,7 W$V001=B?@7 W$V001=(R01En'loop

    "ote!

    +n the real time 4hen eer 4e are 4or!ing 4ith plants7 storagelocations then 4e remoe the interals

    Synta4!

    ,elect=options Lname o the select=optionsN or Lariale nameN nointerals

    Eg8,elect=options ,VB?GR, or 1 no interals

    +n the real time 4hen eer 4e are 4or!ing 4ith 'ates then 4e remoe the

    e>tension

    Synta4!

    ,elect=options Lname o the select=optionsN or Lariale nameN *o=e>tension

    + you 4ant remoe the oth e>tensions an' interals

    Synta4!

    ,elect=options Lname o the select optionN or LarialeN no=e>tension no interal

  • 7/26/2019 Sap Abap Material Chandra

    42/170

    "ote!

    +n the real time 4hen eer 4e are 4or!ing 4ith company co'e7 i it is onlyone company then 4e remoe the e>tension an' the interal

    Some o% te standard data,ase ta,les!

    #ARA! #aterial master ta,le

    1 M$*R % Material numer2 M$R % Material type ;Material type means ra4 material7 semi material7inishe' materialt=001,elect=options ,VB?GR, or "1Parameter8 PVis as chec! o>7

    PV*on is as chec! o>,election=screen en' o loc! B

    Output! ,election=criteria

    "ote!

    + you 4ant to proi'e the meaningul t>t to the input ariale7 then yougo toF menu ar % go to % te>t elements % selection te>ts

    ,elect the chec! o>7 i the iel' is coming rom 'ata 'ictionary7

    other4ise 4e pass the input manually

    ,ae the te>t

    $ctiate the te>t

    Bac!

    "ote!

    + 4e are 4or!ing 4ith QBegin o line . En' o lineT then the name o theparameters 4ill 'isappear7 at that time 4e must proi'e comment eore or aterthe chec! o> or ra'io utton

    Synta4 o% pro*iding a comment!

    ,election=screen comment @;< te>t=LnoN

    ,tarting num o

    Position characters

    "

    ,VB?GR, to

    isplay

    *on isplay

  • 7/26/2019 Sap Abap Material Chandra

    50/170

    ,!ip is the !ey4or' to proi'e the space in et4een any t4o inputariales

    Synta4!

    ,election=screen s!ip LnoN

    By 'eault s!ip is one line7 4e can s!ip ma>imum lines at a time

    Program!

    ata "1 li!e 001VB?GR,,election=screen egin o loc! $ 4ith rame,elect=options ,VB?GR, or "1,election=screen s!ip 1,election=screen egin o line

    Parameter PVis as chec! o>,election=screen comment 2;A< te>t=001Parameter PV*on is as chec! o>,election=screen comment 11;11< te>t=002,election=screen en' o line,election=screen en' o loc! $

    Output!

    "ote!

    he alue o the actie chec! o> or actie ra'io utton is @S

    Types o% Reports!

    here are t4o types o reports hey are81 Classical reports2 +nteractie reports

    $lassical reports!

    $ classical report is nothing ut to 'isplay the entireinormation in to a single listEg8

    ,VB?GR, to

    isplay *on isplay

    ,PR$(

    R$#

  • 7/26/2019 Sap Abap Material Chandra

    51/170

    Interacti*e reports!

    $n +nteractie report is nothing ut to 'isplay the summarize'inormation in the asic list . ne>t leel inormation in the secon'ary listsEg8 0

    1 1

    "ote!

    We can hae only one asic list . up to 20 secon'ary lists

    ,=),+* is the system ariale 4hich contains the current list in'e>

    numer

    E*ents in $lassical reports! 1/0/10

    Eents in classical reports are1 +nitialization2 $t selection=screen3 $t selection=screen onD ,tart=o=selection5 op=o=page En'=o=pageA En'=o=selection

    Initiali9ation!

    +nitialization is an eent 4hich is triggere' eore 'isplaying theselection=screen

    Ad*antage!

    his is use' to assign the 'eault alues to the selection=screen

    At selection!screen!

    $t selection=screen is an eent 4hich is triggere' at aterproi'ing the input to the selection=screen . eore leaing the selection=screen

    Ad*antage!

    his is use' to ali'ate the gien input

    At selection!screen on!

    $t selection=screen on is an eent 4hich is triggere' atthe selection=screen ase' on the gien iel'

    Ad*antage!

    his is use' to ali'ate the gien input

    St t % l ti

    ,PR$(R$#

    ,PR$( E?

    R$# E?

  • 7/26/2019 Sap Abap Material Chandra

    52/170

    ,tart=o=selection is an eent 4hich is triggere' ater leaingthe selection=screen . eore 'isplaying the output

    Ad*antage!

    his is use' to retrieing the 'ata rom the 'ataase . place' in to

    internal tales

    "ote!

    ,tart=o=selection is a 'eault eent in the classical reports

    Top!o%!page!

    op=o=page is an eent 4hich is triggere' at the op o each page

    Ad*antage!

    his is use' to 'isplay the hea'er inormation

    End!o%!page!

    En'=o=page is an eent 4hich is triggere' at the En' o each page

    Ad*antage!

    his is use' to 'isplay the ooter inormation

    End!o%!selection!

    En'=o=selection is an eent 4hich is triggere' ater

    manipulating the 'ata

    Ad*antage!

    his is use' to 'isplay the output

    Order o% te E*ents!

    $t selection=screen on 2

    +nitialization 31 start=o=

    2 ,election$t selection=screen

    Initiali9ation!

    +nitialization

    , B?GR,=lo4 I 1000S

    op=o=page

    5En'=o=selection

    D A

    En'=o=page

    ,election=screen

  • 7/26/2019 Sap Abap Material Chandra

    53/170

    ,VB?GR,=high I 2000S,VB?GR,=sign I +S,VB?GR,=option I BS$ppen' ,VB?GR,

    ,VB?GR,=lo4 I 3000S,VB?GR,=high I S,VB?GR,=sign I +S,VB?GR,=option I EOS$ppen' ,VB?GR,

    #essage!

    We hae ie 'ierent types o messages hey are81 $BE* ;$

  • 7/26/2019 Sap Abap Material Chandra

    54/170

    Clic! on sae % local o9ect

    Clic! on messages=ta

    Proi'e the 'escriptions against numers

    Clic! on sae

    Eg8Parameter PV*( type +

    + PV*( L 10Message $000;U,M,

  • 7/26/2019 Sap Abap Material Chandra

    55/170

    Di%%erences ,et.een single select +select up to ; ro.s!

    ,elect single ,elect up to 1 ro4s

    1 +t al4ays retriees only one recor'at a time

    2 -ere 4e must pass entire primary!ey comination in the 4herecon'ition3 his is use' to retriee particularrecor',ynta>8=

    1 +t al4ays retriees only onerecor'

    2 Enough to pass a part o !eycomination in the 4here con'ition+t al4ays pic!s the irst recor'among the matche' recor's3 his is use' or ali'ation

    Eg8$$8 BE+* (& W$VG*B17

    G?**R )+GE G*B1=G?**R7 B?GR, )+GE G*B1=B?GR,7

    E* (& W$VG*B1

    ,E)EC ,+*)E G?**R B?GR, &R(M G*B1 +*( W$VG*B1 W-EREG?**R I 00000011S $* G?**R I \3000\

    WR+E8 / W$VG*B1=G?**R7 W$VG*B1=B?GR,?)+*E

    ,E)EC G?**R B?GR, &R(M G*B1 +*( W$VG*B1 ?P ( 1 R(W,W-ERE G?**R I \00000011\E*,E)ECWR+E8 / W$VG*B1=G?**R7 W$VG*B1=B?GR,

    Some o% te data,ase ta,les! 1A/0/10

    &BA-! sales document eader ta,le3

    1 "BE)* % ,ales 'ocument numer2 "BP % ,ales 'ocument entry3 "G(R % ,ales organizationD G?**R % Customer numer5 B?GR, % Company co'e $?$R % ,ales 'ocument type

    &BAP! Sales document item ta,le3

    1 "BE)* % ,ales 'ocument numer72 P(,*R % item numer3 M$*R Material numer

  • 7/26/2019 Sap Abap Material Chandra

    56/170

    D UME* % uantity5 ME+*, % ?(M *EWR % *et alue

    At selection!screen!

    &alidation!

    Eg81 $$ "1 )+GE M$R$=M$*R$ ,E)EC+(*=,CREE*,E)EC M$*R &(RM M$R$ +*( "1 ?P ( 1 R(W,W-ERE M$*R +* ,VM$*RE*,E)EC+& ,=,?BRC LN 0ME,,$E E000;,M,< W+- +*"$)+ M$ER+$)SE*+&

    2 $$8 "1 )+GE M$R$=M$*R7 "2 )+GE 001W=WERG,

    $ ,E)EC+(*=,CREE*,E)EC M$*R &(RM M$R$ +*( "1 ?P ( 1 R(W,W-ERE M$*R I PVM$*R

    E*,E)EC+& ,=,?BRC LN 0ME,,$E E000;,M,< W+- +*"$)+ M$ER+$)SE*+&,E)EC WERG, &R(M 001W +*( "2 ?P ( 1 R(W,W-ERE WERG, I PVWERG,+& ,=,?BRC LN 0ME,,$E E000;,M,< W+- +*"$)+ P)$*SE*+&

    ,E)EC M$*R WERG, &R(M M$RC +*( ;"17"2< ?P ( 1R(W, W-ERE M$*R I PVM$*R $* WERG, I PVWERG,E*,E)EC+& ,=,?BRC LN 0ME,,$E E000;,M< W+- M$ER+$) +, *( ?*ERP)$*SE*+&

    At selection!screen on!

    $$ "1 )+GE 001W=WERG,$ ,E)EC+(* ,CREE* (* P WERG,

  • 7/26/2019 Sap Abap Material Chandra

    57/170

    ,E)EC WERG, &(RM 001W +*( "1 ?P ( 1 R(W,W-ERE WERG, I PVWERG,E*,E)EC+& ,=,?BRC LN 0ME,,$E E000;,M,< W+- +*"$)+ P)$*S

    E*+&

    Start!o%!selection!

    ,$R=(&=,E)EC+(*,E)EC B?GR, B?@ (R01 &R(M 001 +*( $B)E+V001 W-ERE B?GR, +* ,VB?GR,

    Top!o%!page!

    (P=(&=P$EWR+E ,PR$( EC-*()(+E,S

    End!o%!page!

    E*=(&=P$EWR+E -$*G (?S

    End!o%!selection!

    E*=(&=,E)EC+(*)((P $ +V001 +*( W$V001WR+E8 / W$V001=B?GR,7 W$V001=B?@7 W$V001=(R01E*)((P

    "ote!

    1 +n the reports one eent en's 4ith another eent

    2 When eer 4e are 4or!ing 4ith E*=(&=P$E eent then 4e mustproi'e line=countS in the name o the report,ynta>8=

    )ine=count @;

  • 7/26/2019 Sap Abap Material Chandra

    58/170

    Clic! on sae

    Proi'e the ariant name . 'escription

    ,ae

    "ote!

    + you 4ant to aoi' the title in the 'isplaye' output then 4e must *(,$*$R P$E -E$+*S in the name o the reportO,=ect!

    Base' on the gien company co'es to 'isplay the company co'es7company names7 names . cities y using eents7 in the top al4ays 'isplaythe 4elcome to sprao technologiesS in the ottom to 'isplay than! youS

    Program!

    $$ "1 )+GE 001=B?GR,

    ,E)EC+(*=,CREE* BE+* (& B)(CG $ W+- &R$ME+)E E@=001,E)EC=(P+(*, ,VB?GR, &(R "1,E)EC+(*=,CREE* E* (& B)(CG $

    $$8 BE+* (& W$V0017 B?GR, )+GE 001=B?GR,7 B?@ )+GE 001=B?@7 (R01 )+GE 001=(R017

    E* (& W$V001

    $$ +V001 )+GE $B)E (& W$V001

    $ ,E)EC+(*=,CREE*

    ,E)EC B?GR, &R(M 001 +*( "1 ?P ( 1 R(W, W-EREB?GR, +* ,VB?GR,E*,E)EC

    +& ,=,?BRC LN 0ME,,$E E000;,M,< W+- \+*"$)+ C(MP$*\E*+&

    ,$R=(&=,E)EC+(*

    ,E)EC B?GR, B?@ (R01 &R(M 001 +*( $B)E+V001 W-ERE B?GR, +* ,VB?GR,

    (P=(&=P$EWR+E \WE)C(ME ( ,$P\

  • 7/26/2019 Sap Abap Material Chandra

    59/170

    E*=(&=P$EWR+E \-$*G (?\

    E*=(&=,E)EC+(*

    )((P $ +V001 +*( W$V001WR+E 8/ W$V001=B?GR,7 W$V001=B?@7 W$V001=(R01E*)((P

    E*ents in interacti*e reports!

    1 $t line=selection2 $t user=comman'3 op=o=page 'uring line=selectionD $t P&L*N

    5 ,E P&=,$?,

    At line!selection!

    $t line=selection is an eent 4hich is triggere' at the time ouser clic!s on any recor' o any list

    At user!command!

    +t is an eent 4hich is triggere' at the time o user clic!s onany menu item

    Top!o%!page during line!selection!

    +t is an eent 4hich is triggere' at the top oeach secon'ary list

    At P"!

    +t is an eent 4hich is triggere' at the time o user clic!s on anyunction !eys ;&1 to &12

  • 7/26/2019 Sap Abap Material Chandra

    60/170

    5 ,=),+*

    S>!LISEL!

    +t is the system ariale 4hich contains the contents o the selecte'recor'

    S>!LILLI!

    +t is the system ariale 4hich contains the e>act line numer o theselecte' recor' y the user

    S>!U$O##!

    +t is the system ariale 4hich contains the unction co'e o theselecte' menu item

    S>!LI""O!

    +t is the system ariale 4hich contains the line numer o the lastrecor' 'isplaye'S>!LSI"D!

    +t is the system ariale 4hich contains the current list in'e> numer

    +nteractie reports supports the user interaction is al4ays through 'oule

    clic! or &2

    When eer the user 'oule clic!s on any recor' o any list at line=selection

    eent 4ill e triggere' . list in'e> 4ill e incremente' y one

    + you 4ant to retriee the 'ata or this list 4e shoul' !no4 the recor' 4hich

    is clic!e' y the user in the preious list

    7ide!-i'e is the !ey4or' 4hich maintains the copy o the preious list 4ith

    output line numers . their contents When eer the user 'oule clic!s on anyrecor' o any list at that time at line=selection eent 4ill e triggere' . list in'e> isincremente' y one . that particular recor' 4ill e moing rom hi'e area to 4or!area

    Base' on the 4or! area 4e retriee the 'ata or thene>t list

    "ote!-i'e al4ays maintain ater the 4rite statement

  • 7/26/2019 Sap Abap Material Chandra

    61/170

    O,=ect!

    o 'isplay the company co'es7 company names . cities in the asiclist7 4hen eer the user clic!s on any recor' then 4e 'isplay the customerun'er that company in the irst secon'ary list When eer the user clic!s onany recor' in the irst secon'ary list then 4e 'isplay the customer list in the

    secon' secon'ary list

    Program!

    $$8 BE+* (& W$V0017 B?GR, )+GE 001=B?GR,7 B?@ )+GE 001=B?@7 (R01 )+GE 001=(R017 E* (& W$V001

    $$ +V001 )+GE $B)E (& W$V001

    $$8 BE+* (& W$VG*B17 B?GR, )+GE G*B1=B?GR,7 G?**R )+GE G*B1=G?**R7 $G(* )+GE G*B1=$G(*7 E* (& W$VG*B1

    $$ +VG*$1 )+GE $B)E (& W$VG*$1

    $$8 BE+* (& W$VG*$17 G?**R )+GE G*$1=G?**R7 *$ME1 )+GE G*$1=*$ME17 (R01 )+GE G*$1=(R017 E* (& W$VG*$1

    $$ +VG*$1 )+GE $B)E (& W$VG*$1

    ,E)EC B?GR, B?@ (R01 &R(M 001 +*( $B)E

    +V001

    )((P $ +V001 +*( W$V001WR+E8 / W$V001=B?GR,7 W$V001=B?@7 W$V001=(R01-+E8 W$V001=B?GR,7 W$V001=B?@7 W$V001=(R01E*)((P

    $ )+*E=,E)EC+(*

    +& ,=),+* I \1\

  • 7/26/2019 Sap Abap Material Chandra

    62/170

    ,E)EC B?GR, G?**R $G(* &R(M G*B1 +*( $B)E+VG*B1 W-ERE B?GR, IW$V001=B?GR,

    )((P $ +VG*B1 +*( W$VG*B1

    WR+E8 / W$VG*B1=B?GR,7 W$VG*B1=G?**R7 W$VG*B1=$G(*-+E8 W$VG*B1=B?GR,7 W$VG*B1=G?**R7 W$VG*B1=$G(*E*)((P

    E),E+& ,=),+* I \2\,E)EC G?**R *$ME1 (R01 &R(M G*$1 +*( $B)E+VG*$1 W-ERE G?**R I W$VG*B1=G?**R

    )((P $ +VG*$1 +*( W$VG*$1WR+E8 / W$VG*$1=G?**R7 W$VG*$1=*$ME17 W$VG*$1=(R01E*)((PE*+&

    Assignment!

    o 'isplay the purchasing 'ocument numers7 'ocument types7en'or numers in the asic list7 4hen eer the user clic!s on any recor' then 4e'isplay the item 'etails ;EBE)*7 EBE)P7 ME*E7 ME+*, . *EPR< in the irstsecon'ary list

    Program!

    $$8 BE+* (& W$VEGG(7 EBE)* )+GE EGG(=EBE)*7 B,$R )+GE EGG(=B,$R7

    )+&*R )+GE EGG(=)+&*R7E* (& W$VEGG(

    $$ +VEGG( )+GE $B)E (& W$VEGG(

    $$8 BE+* (& W$VEGP(7 EBE)* )+GE EGP(=EBE)*7 EBE)P )+GE EGP(=EBE)P7 ME*E )+GE EGP(=ME*E7 ME+*, )+GE EGP(=ME+*,7 *EPR )+GE EGP(=*EPR7

    E* (& W$ EGP(

  • 7/26/2019 Sap Abap Material Chandra

    63/170

    $$ +VEGP( )+GE $B)E (& W$VEGP(

    ,E)EC EBE)* B,$R )+&*R &R(M EGG( +*( $B)E+VEGG(

    )((P $ +VEGG( +*( W$VEGG(WR+E8 / W$VEGG(=EBE)*7 W$VEGG(=B,$R7 W$VEGG(=)+&*R-+E8 / W$VEGG(=EBE)*7 W$VEGG(=B,$R7 W$VEGG(=)+&*RE*)((P

    $ )+*E=,E)EC+(*

    +& ,=),+* I 1,E)EC EBE)* EBE)P ME*E ME+*, *EPR +*( $B)E+VEGP( W-ERE EBE)* +* W$VEGG(=EBE)*

    )((P $ +VEGP( +*( W$VEGP(WR+E8 / W$VEGP(=EBE)*7 W$VEGP(=EBE)P7 W$VEGP(=ME*E7 W$VEGP(=ME+*,7 W$VEGP(=*EPRE*)((PE*+&

    "ote! 1:/0/10C(*"ER,+(*VE@+V$)P-$V+*P?S is the unctional mo'ule 4hich

    is use' to appen' zeros to the input ariale ase' on the length o the inputarialeEg8

    $$ $ ;5< PE C$I231

    C(*"ER,+(*VE@+V$)P-$V+*P?

    +*P? I $(?P? I $$ 00231

    Steps to call te %unction module!

    (pen the program

    Place the cursor 4here 4e 4ant to call the unction mo'ule

    Clic! on pattern

    Proi'e your unction mo'ule name

    C(*"ER,+(*VE@+V$)P-$V+*P?

    Enter

  • 7/26/2019 Sap Abap Material Chandra

    64/170

    ie input . output

    O,=ect!

    Base' on the gien company co'es to 'isplay the company co'es7 companynames . cities in the asic list7 4hen eer the user clic!s on any recor' then

    4e 'isplay the en'ors un'er that company in the irst secon'ary list Wheneer the user clic!s on any recor' in the irst secon'ary list then 4e 'isplaythe en'or 'etails in the secon' secon'ary list y using ,=)+,E)S

    Program!

    $$ "1 )+GE 001=B?GR,,E)EC=(P+(*, ,VB?GR, &(R "1

    $$8 BE+* (& W$V0017 B?GR, )+GE 001=B?GR,7

    B?@ )+GE 001=B?@7 (R01 )+GE 001=(R017 E* (& W$V001

    $$ +V001 )+GE $B)E (& W$V001

    $$8 BE+* (& W$V)&B17 )+&*R )+GE )&B1=)+&*R7 B?GR, )+GE )&B1=B?GR,7 $G(* )+GE )&B1=$G(*7 E* (& W$V)&B1

    $$ +V)&B1 )+GE $B)E (& W$V)&B1

    $$8 BE+* (& W$V)&$17 )+&*R )+GE )&$1=)+&*R7

    *$ME1 )+GE )&$1=*$ME17 (R01 )+GE )&$1=(R017 E* (& W$V)&$1

    $$ +V)&$1 )+GE $B)E (& W$V)&$1

    ,E)EC B?GR, B?@ (R01 &R(M 001 +*( $B)E+V001 W-ERE B?GR, +* ,VB?GR,

    )((P $ +V001 +*( W$V001WR+E8 / W$V001=B?GR,7 W$V001=B?@7 W$V001=(R01

  • 7/26/2019 Sap Abap Material Chandra

    65/170

    E*)((P

    $ )+*E=,E)EC+(*

    +& ,=),+* I \1\,E)EC )+&*R B?GR, $G(* &R(M )&B1 +*( $B)E+V)&B1 W-ERE B?GR, I,=)+,E)H0;D

  • 7/26/2019 Sap Abap Material Chandra

    66/170

    Assignment!

    Base' on the gien company co'es to 'isplay the company co'es7company names7 cities in the asic list7 i the user clic!s on company co'e then 4e'isplay the purchasing 'ocument hea'er 'etails in the irst secon'ary list + the

    user clic!s on any recor' then 4e 'isplay the item 'etails ;EBE)*7 EBE)P7ME*E7 ME+*, . *EPR< in the irst secon'ary list y using get cursortechniue

    Program!

    $$ "1 )+GE 001=B?GR,,E)EC=(P+(*, ,VB?GR, &(R "1

    $$8 "2 ;15

  • 7/26/2019 Sap Abap Material Chandra

    67/170

    )((P $ +V001 +*( W$V001WR+E8 / W$V001=B?GR,7 W$V001=B?@7 W$V001=(R01E*)((P

    $ )+*E=,E)EC+(*

    +& ,=),+* I \1\

    E C?R,(R &+E) "2 "$)?E "3+& "2 I \W$V001=B?GR,\C$)) &?*C+(* \C(*"ER,+(*VE@+V$)P-$V+*P?\E@P(R+*+*P? I "3+MP(R+*(?P? I "3

    ,E)EC EBE)* B,$R B?GR, &R(M EGG( +*( $B)E+VEGG( W-ERE B?GR, I "3)((P $ +VEGG( +*( W$VEGG(WR+E8 / W$VEGG(=EBE)*7 W$VEGG(=B,$R7 W$VEGG(=B?GR,E*)((P

    E),E+& ,=),+* I 2

    E C?R,(R &+E) "2 "$)?E "3E),E+& "2 I \W$VEGG(=EBE)*\C$)) &?*C+(* \C(*"ER,+(*VE@+V$)P-$V+*P?\E@P(R+*+*P? I "3+MP(R+*(?P? I "3

    ,E)EC EBE)* EBE)P ME*E ME+*, *EPR &R(M EGP(+*( $B)E +VEGP( W-ERE EBE)* I "3)((P $ +VEGP( +*( W$VEGP(WR+E8 / W$VEGP(=EBE)*7 W$VEGP(=EBE)P7 W$VEGP(=ME*E7 W$VEGP(=ME+*,7W$VEGP(=*EPRE*)((PE*+&

    E*+&

  • 7/26/2019 Sap Abap Material Chandra

    68/170

    Menu painter is a tool 'esign the user interace to the program

    he transaction co'e or menu painter is ,ED1

    ?+

    ?+ title ?+ status

    itle ar Menu ar , tool ar

    &unction !eys $pplication tool ar

    Steps to design our o.n 'UI to te program!

    E>ecute ,ED1

    Proi'e your program name or 4hich 4e 4ant to 'esign the our o4n ?+

    Proi'e status name eg ,$

    Clic! on create

    Proi'e short 'escription % unction te>t % enter

    ,elect the short cut !ey % enter

    ,ae

    Chec! $ctiate

    "ote!

    1 We can 'esign up to menu items in the menu ar2 ,ystem . help are the 'eault menu items in the menu ar

    3 We can 'esign up to 35 push uttons in the application tool arD ,et P&=status is the eent 4hich is use' to attach the o4n ?+ to the

    program,ynta>8=

    ,et P&=,tatus is the eent 4hich is use' to attach the o4n ?+to the program

    o4nloa'S is the unction mo'ule 4hich is use' to 'o4nloa' the 'ata rom

    internal tale to presentation serer ;C 'rie7 'rie

  • 7/26/2019 Sap Abap Material Chandra

    69/170

    ,E)EC=(P+(*, ,VB?GR, &(R "1

    $$8 BE+* (& W$V0017 B?GR, )+GE 001=B?GR,7 B?@ )+GE 001=B?@7

    (R01 )+GE 001=(R017 E* (& W$V001

    $$ +V001 )+GE $B)E (& W$V001

    ,E)EC B?GR, B?@ (R01 &R(M 001 +*( $B)E+V001 W-ERE B?GR, +* ,VB?GR,

    )((P $ +V001 +*( W$V001WR+E8 / W$V001=B?GR,7 W$V001=B?@7 W$V001=(R01E*)((P

    ,E P&=,$?, \,$\

    $ ?,ER=C(MM$*

    +& ,=?C(MM I \(W*\C$)) &?*C+(* \(W*)($\

    E@P(R+*&+)EPE I \$\

    $B)E, $$=$B I +V001E*+&

    or All Entries! 21/0/10+nner 9oin pic! the 'ata ase' on the (*S con'ition irst7 ne>t it

    ase' on W-ERES con'ition

    +n the real time the ma>imum program e>ecution tome in ore=groun' is00secS

    More than t4o tales 9oin7 some times lea's to timeout7 so 4e go or &(R

    $)) E*R+E,S

    &or all entries pic! the 'ata ase' on W-ERES con'ition irst7 ne>t it ase'

    on (*S con'ition

    O,=ect!

    Base' on the gien company co'es to 'isplay the company co'es7

    company names7 customer numers

  • 7/26/2019 Sap Abap Material Chandra

    70/170

    $$ "1 )+GE 001=B?GR,,E)EC=(P+(*, ,VB?GR, &(R "1

    $$8 BE+* (& W$V0017 B?GR, )+GE 001=B?GR,7

    B?@ )+GE 001=B?@7 E* (& W$V001

    $$ +V001 )+GE $B)E (& W$V001

    $$8 BE+* (& W$VG*B17 B?GR, )+GE G*B1=B?GR,7 G?**R )+GE G*B1=G?**R7 E* (& W$VG*B1

    $$ +VG*B1 )+GE $B)E (& W$VG*B1

    $$8 BE+* (& W$V&+*$)7 B?GR, )+GE 001=B?GR,7

    G?**R )+GE G*B1=G?**R7 B?@ )+GE 001=B?@7 E* (& W$V&+*$)

    $$ +V&+*$) )+GE $B)E (& W$V&+*$)

    ,E)EC B?GR, B?@ &R(M 001 +*( $B)E +V001W-ERE B?GR, +* ,VB?GR,

    +& *( +V001 +, +*++$)

    ,E)EC B?GR, G?**R &R(M G*B1 +*( $B)E +VG*B1

    &(R $)) E*R+E, +*+V001 W-ERE B?GR, I +V001=B?GR,E*+&

    )((P $ +VG*B1 +*( W$VG*B1

    W$V&+*$)=B?GR, I W$VG*B1=B?GR,W$V&+*$)=G?**R I W$VG*B1=G?**R

    RE$ $B)E +V001 +*( W$V001 W+- GE B?GR, IW$VG*B1=B?GR,

  • 7/26/2019 Sap Abap Material Chandra

    71/170

    W$V&+*$)=B?@ I W$V001=B?@

    $PPE* W$V&+*$) ( +V&+*$)C)E$R8 W$V&+*$)7 W$V0017 W$VG*B1E*)((P

    WR+E8 1;5

  • 7/26/2019 Sap Abap Material Chandra

    72/170

    $$8 BE+* (& W$V&+*$)7 EBE)* )+GE EGG(=EBE)*7 B,$R )+GE EGG(=B,$R7 )+&*R )+GE )&$1=)+&*R7 *$ME1 )+GE )&$1=*$ME17

    EBE)P )+GE EGP(=EBE)P7 *EPR )+GE EGP(=*EPR7 E* (& W$V&+*$)

    $$ +V&+*$) )+GE $B)E (& W$V&+*$)

    ,E)EC EBE)* B,$R )+&*R &R(M EGG( +*( $B)E+VEGG( W-ERE EBE)* +* ,VEBE)*

    +& *( +VEGG( +, +*++$)

    ,E)EC )+&*R *$ME1 &R(M )&$1 +*( $B)E +V)&$1 &(R$)) E*R+E, +*+VEGG( W-ERE )+&*R I +VEGG(=)+&*R

    ,E)EC EBE)* EBE)P *EPR &R(M EGP( +*( $B)E+VEGP( &(R $)) E*R+E, +*+VEGG( W-ERE EBE)* I +VEGG(=EBE)*E*+&

    )((P $ +VEGP( +*( W$VEGP(

    W$V&+*$)=EBE)* I W$VEGP(=EBE)*W$V&+*$)=EBE)P I W$VEGP(=EBE)PW$V&+*$)=*EPR I W$VEGP(=*EPR

    RE$ $B)E +VEGG( +*( W$VEGG( W+- GE EBE)* IW$VEGP(=EBE)*

    W$V&+*$)=B,$R I W$VEGG(=B,$RW$V&+*$)=)+&*R I W$VEGG(=)+&*R

    RE$ $B)E +V)&$1 +*( W$V)&$1 W+- GE )+&*R IW$VEGG(=)+&*R

    W$V&+*$)=)+&*R I W$V)&$1=)+&*RW$V&+*$)=*$ME1 I W$V)&$1=*$ME1

    $PPE* W$V&+*$) ( +V&+*$)C)E$R8 W$ &+*$) W$ EGG( W$ EGP( W$ )&$1

  • 7/26/2019 Sap Abap Material Chandra

    73/170

    E*)((P

    )((P $ +V&+*$) +*( W$V&+*$)WR+E8 / W$V&+*$)=EBE)*7 W$V&+*$)=B,$R7 W$V&+*$)=)+&*R7 W$V&+*$)=*$ME17

    W$V&+*$)=EBE)P7 W$V&+*$)=*EPRE*)((P

    O,=ect! 22/0/10Base' on the gien sales 'ocument numer to 'isplay the sales

    'ocument numer7 'ocument type7 customer numer7 customer name7 item numer7material numer7 material 'escription . net alue

    Program!

    +*C)?E ,$+V+*C)?E1

    $$8 BE+* (& W$V"B$G7 "BE)* )+GE "B$G="BE)*7 $?$R )+GE "B$G=$?$R7 G?**R )+GE "B$G=G?**R7 E* (& W$V"B$G

    $$ +V"B$G )+GE $B)E (& W$V"B$G

    $$8 BE+* (& W$VG*$17 G?**R )+GE G*$1=G?**R7 *$ME1 )+GE G*$1=*$ME17 E* (& W$VG*$1

    $$ +VG*$1 )+GE $B)E (& W$VG*$1

    $$8 BE+* (& W$V"B$P7 "BE)* )+GE "B$P="BE)*7

    P(,*R )+GE "B$P=P(,*R7 *EWR )+GE "B$P=*EWR7 M$*R )+GE "B$P=M$*R7

    E* (& W$V"B$P

    $$ +V"B$P )+GE $B)E (& W$V"B$P

    $$8 BE+* (& W$VM$G7 M$*R )+GE M$G=M$*R7

    M$G@ )+GE M$G=M$G@7 E* (& W$VM$G

  • 7/26/2019 Sap Abap Material Chandra

    74/170

    $$ +VM$G )+GE $B)E (& W$VM$G

    $$8 BE+* (& W$V&+*$)7 "BE)* )+GE "B$G="BE)*7 $?$R )+GE "B$G=$?$R7

    G?**R )+GE G*$1=G?**R7 *$ME1 )+GE G*$1=*$ME17 P(,*R )+GE "B$P=P(,*R7 *EWR )+GE "B$P=*EWR7 M$*R )+GE M$G=M$*R7 M$G@ )+GE M$G=M$G@7 E* (& W$V&+*$)

    $$ +V&+*$) )+GE $B)E (& W$V&+*$)

    $$ "1 )+GE "B$G="BE)*,E)EC=(P+(*, ,V"BE)* &(R "1

    +*C)?E ,$+V+*C)?E1

    ,E)EC "BE)* $?$R G?**R &R(M "B$G +*( $B)E+V"B$G W-ERE "BE)* +* ,V"BE)*

    +& *( +V"B$G +, +*++$)

    ,E)EC G?**R *$ME1 &R(M G*$1 +*( $B)E +VG*$1&(R $)) E*R+E, +*+V"B$G W-ERE G?**R I +V"B$G=G?**R

    ,E)EC "BE)* P(,*R *EWR M$*R &R(M "B$P +*($B)E +V"B$P&(R $)) E*R+E, +* +V"B$G W-ERE "BE)* I +V"B$G=

    "BE)*

    E*+&

    +& *( +V"B$P +, +*++$)

    ,E)EC M$*R M$G@ &R(M M$G +*( $B)E +VM$G&(R $)) E*R+E, +*+V"B$P W-ERE M$*R I +V"B$P=M$*R

    E*+&

  • 7/26/2019 Sap Abap Material Chandra

    75/170

    )((P $ +V"B$P +*( W$V"B$PW$V&+*$)="BE)* I W$V"B$P="BE)*W$V&+*$)=P(,*R I W$V"B$P=P(,*RW$V&+*$)=*EWR I W$V"B$P=*EWRW$V&+*$)=M$*R I W$V"B$P=M$*R

    RE$ $B)E +V"B$G +*( W$V"B$G W+- GE "BE)* IW$V"B$G="BE)*W$V&+*$)="BE)* I W$V"B$G="BE)*W$V&+*$)=$?$R I W$V"B$G=$?$RW$V&+*$)=G?**R I W$V"B$G=G?**R

    RE$ $B)E +VG*$1 +*( W$VG*$1 W+- GE G?**R IW$V"B$G=G?**RW$V&+*$)=G?**R I W$VG*$1=G?**RW$V&+*$)=*$ME1 I W$VG*$1=*$ME1

    RE$ $B)E +VM$G +*( W$VM$G W+- GE M$*R IW$V"B$P=M$*RW$V&+*$)=M$*R I W$VM$G=M$*RW$V&+*$)=M$G@ I W$VM$G=M$G@

    $PPE* W$V&+*$) ( +V&+*$)C)E$R8 W$V"B$G7 W$V"B$P7 W$VG*$17 W$VM$G7

    W$V&+*$)E*)((P

    )((P $ +V&+*$) +*( W$V&+*$)WR+E8 / W$V&+*$)="BE)*7 W$V&+*$)=$?$R7 W$V&+*$)=G?**R7 W$V&+*$)=*$ME17 W$V&+*$)=P(,*R7 W$V&+*$)=

    *EWR7 W$V&+*$)=M$*R7 W$V&+*$)=M$G@E*)((P

    O,=ect!

    Base' on the gien materials to 'isplay the material numer7 materialtype7 plant numer7 plant name . material 'escription y using &(R $))E*R+E,

    Program!

    $$8 BE+* (& W$VM$R$7 M$*R )+GE M$R$=M$*R7 M$R )+GE M$R$=M$R7 E* (& W$VM$R$

    $$ +VM$R$ )+GE $B)E (& W$VM$R$

  • 7/26/2019 Sap Abap Material Chandra

    76/170

    $$8 BE+* (& W$VM$RC7 M$*R )+GE M$RC=M$*R7 WERG, )+GE M$RC=WERG,7 E* (& W$VM$RC

    $$ +VM$RC )+GE $B)E (& W$VM$RC

    $$8 BE+* (& W$V001W7 WERG, )+GE 001W=WERG,7 *$ME1 )+GE 001W=*$ME17 E* (& W$V001W

    $$ +V001W )+GE $B)E (& W$V001W

    $$8 BE+* (& W$VM$G7 M$*R )+GE M$G=M$*R7 M$G@ )+GE M$G=M$G@7 E* (& W$VM$G

    $$ +VM$G )+GE $B)E (& W$VM$G

    $$8 BE+* (& W$V&+*$)7 M$*R )+GE M$R$=M$*R7 M$R )+GE M$R$=M$R7

    WERG, )+GE M$RC=WERG,7 *$ME1 )+GE 001W=*$ME17 M$G@ )+GE M$G=M$G@7 E* (& W$V&+*$)

    $$ +V&+*$) )+GE $B)E (& W$V&+*$)

    $$ "1 )+GE M$R$=M$*R

    ,E)EC=(P+(*, ,VM$*R &(R "1

    +*C)?E ,$+V+*C)?E2V1

    ,E)EC M$*R M$R &R(M M$R$ +*( $B)E +VM$R$W-ERE M$*R +* ,VM$*R

    +& *( +VM$R$ +, +*++$)

    ,E)EC M$*R WERG, &R(M M$RC +*( $B)E +VM$RC&(R $)) E*R+E, +*+ M$R$ W-ERE M$*R I + M$R$ M$*R

  • 7/26/2019 Sap Abap Material Chandra

    77/170

    ,E)EC WERG, *$ME1 &R(M 001W +*( $B)E +V001W&(R $)) E*R+E, +*+VM$RC W-ERE WERG, I +VM$RC=WERG,

    ,E)EC M$*R M$G@ &R(M M$G +*( $B)E +VM$G&(R $)) E*R+E, +*+VM$RC W-ERE M$*R I +VM$RC=M$*R

    E*+&

    )((P $ +VM$RC +*( W$VM$RC

    W$V&+*$)=M$*R I W$VM$RC=M$*RW$V&+*$)=WERG, I W$VM$RC=WERG,

    RE$ $B)E +VM$R$ +*( W$VM$R$ W+- GE M$*R IW$VM$RC=M$*RW$V&+*$)=M$R I W$VM$R$=M$R

    RE$ $B)E +V001W +*( W$V001W W+- GE WERG,I W$V001W=WERG,W$V&+*$)=*$ME1 I W$V001W=*$ME1

    RE$ $B)E +VM$G +*( W$VM$G W+- GE M$*R IW$VM$RC=M$*RW$V&+*$)=M$G@ I W$VM$G=M$G@

    $PPE* W$V&+*$) ( +V&+*$)E*)((P

    )((P $ +V&+*$) +*( W$V&+*$)WR+E8 / W$V&+*$)=M$*R7 S7 W$V&+*$)=M$R7 S7

    W$V&+*$)=WERG,7 S7 W$V&+*$)=*$ME17 S7 W$V&+*$)=M$G@E*)((P

    #odulari9ation tecni6ues!

    Mo'ularization techniues are use' to 'ii'e theusiness processing logic in to reusale loc! o statements

    Mo'ularization techniues are t4o step proce'ure

    1 eining the reusale loc!2 Calling the reusale loc!

  • 7/26/2019 Sap Abap Material Chandra

    78/170

    here are t4o types o mo'ularizing techniues hey are8Mo'ularization techniues

    ,ource co'e &unctionality

    +nclu'e Macros ,uroutines &unction mo'ule

    Include!

    We cannot e>ecute an inclu'e program in'epen'ently7 4here as the sameinclu'e program can e inclu'e' in any numer o e>ecutale program

    Ad*antage!

    his is use' to improe the rea'aility o the program

    "ote!

    +n the real time 4e use inclu'e programs or 'eclarations

    Steps to create?de%ine te include program!

    E>ecute ,E3:

    Proi'e your inclu'e program name

    Clic! on create

    Proi'e title

    Proi'e type as % inclu'e

    ,ae % local o9ect

    Eg8$$8 BE+* (& W$V0017 B?GR, )+GE 001=B?GR,7 B?@ )+GE 001=B?@7 E* (& W$V001

    $$ +V001 )+GE $B)E (& W$V001 ,ae

    Chec!

    $ctiate

    Synta4 o% calling te include program in any e4ecuta,le program!

    +nclu'e Linclu'e nameNEg8

    +nclu'e ,$+V+*C)?E

  • 7/26/2019 Sap Abap Material Chandra

    79/170

    ,E)EC B?GR, B?@ (R01 &R(M 001 +*( $B)E+V001

    )((P $ +V001 +*( W$V001WR+E8 / W$V001=B?GR,7 W$V001=B?@7 W$V001=

    (R01E*)((P

    #acros! 23/0/10 + you 4ant to access the loc! o statements more than once in a

    program7 then 4e place those statements in the 'einition o the macro

    Macros are use' to perorm the arithmetical operations

    Macros can ta!e up to place hol'ers ;.17 .2 .

  • 7/26/2019 Sap Abap Material Chandra

    80/170

    E*=(&=E&+*++(*UC$) 15 J 10WR+E RE,?)UC$) 15 H 10WR+E RE,?)

    #ultiple records using macros!

    $$8 BE+* (& EMP7 E+ ;10< PE C7 E*$ME ;25< PE C7 E$ ;35< PE C7 E* (& EMP

    $$ EMP1 )+GE $B)E (& EMP

    E&+*E &+))EMP=E+ I .1EMP=E*$ME I .2EMP=E$ I .3$PPE* EMP ( EMP1E*=(&=E&+*++(*

    &+)) 1S ,PR$(S ,$*$- *$$RS

    &+)) 2S R$#S BE?MPES&+)) 1S ,$*EEPS BE?MPES

    )((P $ EMP1 +*( EMPWR+E8 / EMP=E+7 EMP=E*$ME7 EMP=E$E*)((P

    "ote!

    We cannot nest the 'einition o the macro ;4ith in a macro 4e canSt 4rite

    another macro

  • 7/26/2019 Sap Abap Material Chandra

    81/170

    Synta4 o% de%ining te Su,routine!

    &orm Lname o the suroutineN using L+"1N type LN L+"2N typeLN Changing L("1N type LN L("2N type LN======

    ====== Business logic======En' orm

    +"= input ariale7 (B= output ariale7 = 'ata type

    Synta4 o% calling te Su,routine!

    Perorm Lname o the suroutineN using Linput1NLinput2N ChangingLoutput1NLoutput2N

    "ote!

    1 +n the suroutine calling shoul' e the irst . 'einition shoul' e the ne>t2 We cannot place any e>ecutale statement ater the 'einition o the

    suroutine

    $$ RE,?) PE +P$R$MER8 PV+*P?1 PE +7

    PV+*P?2 PE +PER&(RM $ ?,+* PV+*P?1 PV+*P?2 C-$*+*

    RE,?)WR+E RE,?)&(RM $ ?,+* $ PE + B PE + C-$*+* C PE +C I $ H BE*&(RM

    Eg8$$8 BE+* (& W$V0017 B?GR, )+GE 001=B?GR,7 B?@ )+GE 001=B?@7

    E* (& W$V001

    $$ +V001 )+GE $B)E (& W$V001

    ,E)EC B?GR, B?@ (R01 &R(M 001 +*( $B)E+V001

    PER&(RM RE$=$$ ?,+* +V001 D C-$*+*W$V001

    WR+E8 / W$V001=B?GR,7 W$V001=B?@7 W$V001=(R01

  • 7/26/2019 Sap Abap Material Chandra

    82/170

    &(RM RE$=$$ ?,+* $ )+GE +V001 B PE +C-$*+* C )+GE W$V001RE$ $B)E $ +*( C +*E@ BE*&(RM

    "ote!here are t4o types o ,uroutines hey are81 +nternal suroutines2 E>ternal suroutines

    +nternal suroutine is nothing ut the 'einition o suroutine as 4ell as the

    calling o suroutine in the same program

    E>ternal suroutine is nothing ut the 'einition o suroutine in one program .

    the calling o suroutine in another program

    Synta4 o% calling te e4ternal su,routines!

    Perorm Lname o the suroutineN in program Lprogram nameN usingLinput ariale 1NLinput ariale 2N Changing Loutput ariale 1NLoutputariale 2NEg8

    $$ RE,?) PE +PER&(RM $ +* PR(R$M ,$+ ?,+* 10 15 C-$*+*RE,?)WR+E RE,?)&(RM $ ?,+* $ PE + B PE + C-$*+* C PE +C I $H BE*&(RM

    Termination o% te su,routine! 2D/0/10

    ,uroutine normally en's 4ith E*&(RMS i4e 4ant to terminate the suroutine earlier then 4e use E@+ or C-ECGcomman's

    E@+ is use' to terminate the suroutine uncon'itionally

    C-ECG is use' to terminate the suroutine con'itionally

    Eg8$$ R PE +PER&(RM U+" ?,+* PV+*P?1 PV+*P?2 C-$*+* R

    WR+E R&(RM U+" ?,+* $ PE + B PE + C(M+* C PE +

  • 7/26/2019 Sap Abap Material Chandra

    83/170

    C I $ H BE*&(RM

    Di%%erences ,et.een #acros + Su,routines!

    #acros Su,routines1 +n macro 'einition shoul' e theirst . the calling shoul' e the ne>t2 he 'einition o the macro as4ell as the calling o the macro inthe same program3 Macros can ta!e up to placehol'ers

    D We can place any e>ecutalestatements ater the 'einition o themacro5 Macros are use' in -R $B$P

    1 +n suroutine calling shoul' e theirst . 'einition shoul' e the ne>t2 he 'einition o the suroutine as4ell as the calling o the suroutinemay or may not e in the same

    program3 ,uroutines can ta!e any numero place hol'ersD We canSt place any e>ecutalestatements ater the 'einition o themacro5 ,uroutines are use' in oth$B$P . -R $B$P

    'lo,al data!

    ,uroutines can access the gloal 'eclarations in 4hich they are'eine'When eer the changes occurre' in the suroutine those changes 4ill e relecte'

    to gloal 'eclarations"ote!

    )(C$)is the !ey4or' to aoi' the changes in suroutines

    Eg8$B)E, 001001=B?GR, I 1000S001=B?@ I C,S001=(R01 I -S

    PER&(RM U)(B$)WR+E8 / 001=B?GR,7 001=B?@7 001=(R01&(RM U)(B$))(C$) 001001=B?GR, I 2000S001=B?@ I +BMS001=(R01 I M?MSWR+E8 / 001=B?GR,7 001=B?@7 001=(R01E*&(RM

    unction module!

  • 7/26/2019 Sap Abap Material Chandra

    84/170

    &unction mo'ules are reusale components that are 'eine' inunctional lirary

    Each &unction mo'ule must e attache' 4ith one &unction group 4hich

    contains t4o inclu'e programs y 'eault7 one is or common suroutines7 an'another one is or gloal 'eclarations

    $ll the unction mo'ules un'er that unction group can access the oth theinclu'e programs

    When eer 4e are calling the any unction mo'ule then all the unction mo'ules

    un'er that group 4ill e loa'e' n to the memory o the calling program7 so thatitSs etter to group the relate' unction mo'ules in to one unction group

    &

    "ote!

    We can test the unction mo'ule in'epen'ently 4ithout calling the unctionmo'ule

    Steps to create unction group!

    E>ecute ,E3A

    +n the menu ar % goto % unction groups % create group

    Proi'e your unction group name

    Proi'e short 'escription

    ,ae % local o9ect

    Steps to acti*ate te %unction group!

    E>ecute ,E3A

    +n the menu ar % enironment % inactie o9ects

    E>pan' your unction group

    ,elect your unction group

    Clic! on actiate ;in ECC 0 % select unction group % right clic! % actiateportD Changing5 ales

    &M1

    &M2 &M3

    ,uroutinesloal 'eclarations

  • 7/26/2019 Sap Abap Material Chandra

    85/170

    E>ceptionA ,ource co'e

    ;3Attri,utes!

    $ttriutes speciy the type o the unction mo'ule7 normal or remote

    We can access the normal unction mo'ule 4ith in the serer only7 4here as 4e canaccess remote unction mo'ules 4ith in the serer as 4ell as outsi'e the sereralso

    2 +mport acts li!e using in the suroutine

    3 E>port acts li!e changing the suroutine

    D Changing acts li!e oth import . e>port

    5 ales acts li!e oth import . e>port only or internal tales

    E>ception use to han'le the errors

    A ,ource co'e % the logic relate' to unction mo'ule

    Di%%erences ,et.een %unction module + su,routine!

    unction module Su,routine

    1 &unction mo'ules are gloal7 ie74e can access the unction mo'ule4ith in the serer as 4ell as outsi'ethe serer also2 We can test the unction mo'ulein'epen'ently

    3 We can han'le the errors inunction mo'ule

    D &unction mo'ules are 'eine' yusing ,E3A transaction co'e

    1 ,uroutines are local7 ie7 4e canaccess the suroutine 4ith in theserer only

    2 We canSt test the suroutinein'epen'ently 4ithout calling thesuroutine3 We canSt han'le the errors insuroutine

    D ,uroutines are 'eine' y using,E3: transaction co'e

    Steps to create %unction module!

    E>ecute ,E3A

    Proi'e your unction mo'ule name

    Create

    Proi'e unction group name . short 'escription

    ,ae

  • 7/26/2019 Sap Abap Material Chandra

    86/170

    "ote!

    &unction mo'ules return single alues7 multiple single alues so that 4e nonee' to 4rite any 'isplay statement

    O,=ect!

    eelop a unction mo'ule to calculate the a''ition o t4o numers

    Program!

    +MP(R$ PE +B PE +

    E@P(RC PE +

    ,(?RCE C(EC I $H B

    O,=ect!

    o 'eelop the unction mo'ule7 to 'isplay the customers un'er gien

    company co'e

    Program!

    +MP(RPVB?GR, )+GE 001=B?GR,

    $B)E,+ )+GE G*B1

    ,(?RCE C(E,E)EC J &R(M G*B1 +*( $B)E + W-ER B?GR, IPVB?GR,

    O,=ect! 25/0/10 o 'eelop the unction mo'ule7 to 'isplay the material 'etails7 ase' on

    the gien material numer

    Program!

    +MP(RPVM$*R )+GE M$R$=M$*R

  • 7/26/2019 Sap Abap Material Chandra

    87/170

    E@P(RW$ )+GE M$R$E@CEP+(*,

    *(V$$

    ,(?RCE C(E,E)EC ,+*)E J &R(M M$R$ +*( $B)E W$ W-ERM$*R I PV M$*R+& ,=,?BRC LN 0R$+,E *(V$$E*+&

    Steps to call a %unction module!

    (pen the program

    Place the cursor 4here you 4ant to call the unction mo'ule . clic! on the

    pattern

    Proi'e your &M name

    Eg8$$ @ PE +P$R$MEER8 PV+*P?1 PE +7

    PV+*P?2 PE +

    C$)) &?*C+(* \,$+V&M\E@P(R+* $ I PV+*P?1 B I PV+*P?2+MP(R+* C I @ WR+E @

  • 7/26/2019 Sap Abap Material Chandra

    88/170

    AL& (ABAP LIST &IE

  • 7/26/2019 Sap Abap Material Chandra

    89/170

    Wheneer 4e 4or!ing 4ith all the iel's orm any one o the 'ataase tale at that time4e no nee' to prepare iel' catalogue 4e simply pass +V,R?C?RE V*$ME as ataasetale name

    +n this scenario unction mo'ule pic!s the column hea'ings rom the 'ata element o eachiel' an' 'isplay iel's in the similar or'er o the iel's in the tale

    PREPARE T7E IELD $ATALO'UE

    #etode;Wheneer 4or!ing 4ith all the iel's rom any one o the 'ataase tales then 4e nonee' prepare iel' catalogue 4e simply passI_STRUCTURE_NAMEas 'ataase tale name#etodeFManually illing iel' catalogue#etodeGBy usingREUSE_ALV_FIELDCATALOG_MERGEunction mo'ule

    REUSEAL&IELD$ATALO'#ER'E

    +t is the unction mo'ule 4hich is use' to prepare the iel' catalogue the input or theaoe unction mo'ule is 'ata 4or! area + 4e are 4or!ing 4ith internal tale 4ith hea'er line

    then 4e pass internal tale namehe output or the aoe unction mo'ule is iel' catalogue internal tale

    Some o% te %ields in ield $atalogue Internal Ta,le

    &+E) *$ME %==== *ame o the iel'C()VP(, %======== Column Position,E)E@V, , === small,E)E@VM Column -ea'ing M === me'ium,E)E@V) ) === long-(,P( =========-an'le ,ymol

    E+================Change Mo'eEMP-$,+UE====== Colour

    *(V(? ========== -i'e the iel'*(VUER( ======== Remoe the lea'ing zeros*(V,+* ======== +nternal tale name$B*$ME ======= Remoe the lea'ing sign(?P?)E* ==== )ength o the iel'

    "OTE

    +n SLIS4e hae one type that is SLISTIELD$ATAL&4hich contains the entireiel's relate' to iel' catalogue ,o 4e simply 'eclare iel' catalogue internal tale y reerringSLISTIELD$ATAL&3

    "OTE

    SLIS is thetype group 4hich contains all the types relate' to $)"

    STEPS TO $REATE T>PE 'ROUP

    E>ecute ,E:0 ;+n ECC 0 ,E 11

  • 7/26/2019 Sap Abap Material Chandra

    90/170

    ,$"E

    PRO'RA#

    TYPEPOOL YSPRAO.

    TYPES: BEGIN OF YSPRAOT001!BUKRS LIKE T001BUKRS!

    BUTXT LIKE T001BUTXT!

    ORT01 LIKE T001ORT01!

    END OF YSPRAOT001.

    ,$"E7 C-ECG7 $C+"$E

    "OTEWheneer 4e are reerring any type un'er any type group then 4e must inclu'e typegroup name in the report ;not in the report name,PR$( ;$ny *ameecute or &:

    +n Bottom Win'o4

    E>pan' Standard3Doc3Type

    oule Clic! on S$REE"

  • 7/26/2019 Sap Abap Material Chandra

    93/170

    Proi'e your )ogo path

    Enter

    "OTE

    Wheneer 4e are 4or!ing 4ith Eents then 4e must passI$ALLBA$-PRO'RA#as current program name in the ri' isplayPRO'RA#

    *&-----------------------------------------------------------**& P()+ ( / TOP_OF_PAGE /0 END_OF_LIST E12/3 **------------------------------------------------------------*REPORT YRAKESH_ALV_EVENTS .

    TYPE-POOLS SLIS.*** DECLARING ITDATA :BEGIN OF WA_FINAL, BUKRS LIKE T$$-BUKRS, BUT!T LIKE T$$-BUT!T, KUNNR LIKE KNB-KUNNR, AKONT LIKE KNB-AKONT, END OF WA_FINAL.DATA IT_FINAL LIKE TABLE OF WA_FINAL.

    ***FILLING ITSELECT T$$4BUKRS T$$4BUT!T KNB4KUNNR KNB4AKONT INTO TABLEIT_FINALFROM T$$ INNER 5OIN KNB ON T$$4BUKRS = KNB4BUKRS.

    *** DECALRING FILE CAT IT

    DATA IT_FCAT TYPE SLIS_T_FIELDCAT_ALV.

    ***FILLING FIELD CATLOGCALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'E!PORTING I_PROGRAM_NAME = SY-CPROG I_INTERNAL_TABNAME = 'WA_FINAL' I_INCLNAME = SY-CPROG CHANGING

    CT_FIELDCAT = IT_FCAT.***DECLARE EVENT ITDATA : IT_EVENT TYPE SLIS_T_EVENT, WA_EVENT LIKE LINE OF IT_EVENT.***FILLING THE EVENT ITWA_EVENT-NAME = 'TOP_OF_PAGE'.WA_EVENT-FORM = '#TOP'.APPEND WA_EVENT TO IT_EVENT.WA_EVENT-NAME = 'END_OF_LIST'.WA_EVENT-FORM = '#EOL'.APPEND WA_EVENT TO IT_EVENT.

    ***DISPLAY THE DATACALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'E!PORTING

  • 7/26/2019 Sap Abap Material Chandra

    94/170

    IT_FIELDCAT = IT_FCAT IT_EVENTS = IT_EVENT TABLES T_OUTTAB = IT_FINAL.**** DEFINING SUB ROUTINEFORM #TOP.

    DATA : IT_LIST TYPE SLIS_T_LISTHEADER, WA_LIST LIKE LINE OF IT_LIST. WA_LIST-INFO = 'T6232 C73(+2 7/02 C(+/8'. WA_LIST-TYP = 'S'. 9 H-6202, S-32;2

  • 7/26/2019 Sap Abap Material Chandra

    95/170

    DATA : BEGIN OF WA_KNB, KUNNR LIKE KNB-KUNNR, BUKRS LIKE KNB-BUKRS, AKONT LIKE KNB-AKONT, PERNR LIKE KNB-PERNR, END OF WA_KNB.

    DATA IT_KNB LIKE TABLE OF WA_KNB.***FILLING IT_T$$.SELECT BUKRS BUT!T ORT$ FROM T$$ INTO TABLE IT_T$$ WHERE BUKRSINS_BUKRS.

    ***DECLARE IT_FCAT.DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV, WA_FCAT LIKE LINE OF IT_FCAT.

    ***FILLING FIELD CATALOG.

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'E!PORTING I_PROGRAM_NAME = SY-CPROG I_INTERNAL_TABNAME = 'WA_T$$' I_INCLNAME = SY-CPROG CHANGING CT_FIELDCAT = IT_FCAT.*********************************************DECLARE IT_FCAT FOR SECOND LIST.DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV, WA_FCAT LIKE LINE OF IT_FCAT.

    ***FILLING FIELD CATALOG FOR SECONDLIST.CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'E!PORTING I_PROGRAM_NAME = SY-CPROG I_INTERNAL_TABNAME = 'WA_KNB' I_INCLNAME = SY-CPROG CHANGING CT_FIELDCAT = IT_FCAT.

    ***DECLARING IT_EVENT.

    DATA : IT_EVENT TYPE SLIS_T_EVENT, WA_EVENT LIKE LINE OF IT_EVENT.***FILLING IT_EVENT. WA_EVENT-NAME = 'TOP_OF_PAGE'. WA_EVENT-FORM = '#TOP'. APPEND WA_EVENT TO IT_EVENT.

    WA_EVENT-NAME = 'END_OF_LIST'. WA_EVENT-FORM = '#EOL'. APPEND WA_EVENT TO IT_EVENT.

    WA_EVENT-NAME = 'USER_COMMAND'. WA_EVENT-FORM = '#UC'.

    APPEND WA EVENT TO IT EVENT

  • 7/26/2019 Sap Abap Material Chandra

    96/170

    *** DISPLAY DATACALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'E!PORTING I_CALLBACK_PROGRAM = SY-CPROG IT_FIELDCAT = IT_FCAT

    IT_EVENTS = IT_EVENT

    TABLES T_OUTTAB = IT_T$$. REFRESH IT_FCAT.*** CALLING FORMS.***DEF OF FORM #TOP.

    FORM #TOP.DATA : IT_LIST TYPE SLIS_T_LISTHEADER, WA_LIST LIKE LINE OF IT_LIST.

    WA_LIST-INFO = 'COMPANY DETAILS'. WA_LIST-TYP = 'S'.

    APPEND WA_LIST TO IT_LIST.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' E!PORTING IT_LIST_COMMENTARY = IT_LIST I_LOGO = 'YRAKESH'.ENDFORM.

    ***DEF OF FORM #EOL.FORM #EOL.

    DATA : IT_LIST TYPE SLIS_T_LISTHEADER, WA_LIST LIKE LINE OF IT_LIST.

    WA_LIST-INFO = 'THAN '. WA_LIST-TYP = 'S'.

    APPEND WA_LIST TO IT_LIST. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    E!PORTING IT_LIST_COMMENTARY = IT_LIST I_END_OF_LIST_GRID = '!' .ENDFORM.

    *** DEF OF FORM #UC.FORM #UC USING A LIKE SY-UCOMM B TYPE SLIS_SELFIELD.

    IF B-FIELDNAME = 'BUKRS'.

    SELECT KUNNR BUKRS AKONT PERNR FROM KNB INTO TABLE IT_KNB WHERE

    BUKRS = B-VALUE.

    CALL FUNCTION 'REUSE ALV GRID DISPLAY'

  • 7/26/2019 Sap Abap Material Chandra

    97/170

    E!PORTING IT_FIELDCAT = IT_FCAT TABLES T_OUTTAB = IT_KNB.

    ENDIF.

    ENDFORM.Date F3:J3F:;:3

    SO#E O T7E I#PORTA"T TRA"SA$TIO" $ODES3

    @03 ======isplay Customer@G03 ====== isplay "en'orMM03 ====isplay MaterialME23* === isplay Purchase (r'er"$03 ===== isplay ,ales (r'erMB03 ==== isplay Material ocument&B03 ===== isplay $ccounting ocument

    S>"TAK O $ALLI"' TRA"SA$TIO"

    C$)) R$*,$C+(* L=C(ENSEg Call ransaction @G03S

    S>"TAK O SET T7E &ALUE TO T7E TRA"SA$TIO"

    ,E P$R$MEER + L+ *ameNS &+E) L"alueNEg ,E Parameter + )+&S &iel' P502S

    STEPS TO IDE"TI> T7E PARA#ETER ID

    E>ecute the ransaction

    Place Cursor on the iel'

    Clic! on &1 an' Clic!Tecnical In%ormation (7ammer Sym,ol)

    +'entiy the Parameter +

    OB@E$T

    Base' on the gien Purchasing 'ocument numer to 'isplay Purchasing ocumentnumer7 ocument type7 "en'or *umer7 +tem *umer an' Ouantity y using $)" + userclic!s on any Purchasing ocument *umer ;P(< then 4e 'isplay the Purchase (r'er 'etails yusing ME23* transaction + the user clic!s on any "en'or then 4e 'isplay the en'or 'etails yusing @G03 transaction

    -+*8 EBE)*7 B,$R7 )+&*R7 EBE)P7 ME*EE--O E-PO

    EBE)* EBE)*B,$R EBE)P)+&*R ME*E

    REPORT YRAKESH_ALV_TRANS .

  • 7/26/2019 Sap Abap Material Chandra

    98/170

    TYPE-POOLS SLIS.DATA V LIKE EKKO-EBELN.SELECT-OPTIONS S_EBELN FOR V .

    ***DECLARE IT3DATA : BEGIN OF WA_EKKO,

    EBELN LIKE EKKO-EBELN, BSART LIKE EKKO-BSART, LIFNR LIKE EKKO-LIFNR, END OF WA_EKKO.DATA IT_EKKO LIKE TABLE OF WA_EKKO.

    DATA: BEGIN OF WA_EKPO, EBELN LIKE EKPO-EBELN, EBELP LIKE EKPO-EBELP, MENGE LIKE EKPO-MENGE, MEINS LIKE EKPO-MEINS,

    NETPR LIKE EKPO-NETPR, COL>?@ TYPE C, END OF WA_EKPO.DATA IT_EKPO LIKE TABLE OF WA_EKPO.

    DATA : BEGIN OF WA_FINAL, EBELN LIKE EKKO-EBELN, BSART LIKE EKKO-BSART, LIFNR LIKE EKKO-LIFNR, EBELP LIKE EKPO-EBELP, MENGE LIKE EKPO-MENGE,

    END OF WA_FINAL.DATA IT_FINAL LIKE TABLE OF WA_FINAL.

    ***FILLING DATA INTO ITS USING FOR ALL ENTRIES.

    SELECT EBELN BSART LIFNR FROM EKKO INTO TABLE IT_EKKO WHERE EBELNINS_EBELN.

    IF NOT IT_EKKO IS INITIAL.SELECT EBELN EBELP MENGE FROM EKPO INTO TABLE IT_EKPO FOR ALL

    ENTRIES INIT_EKKO WHERE EBELN = IT_EKKO-EBELN.ENDIF.

    LOOP AT IT_EKPO INTO WA_EKPO.WA_FINAL-EBELN = WA_EKPO-EBELN.WA_FINAL-EBELP = WA_EKPO-EBELP.WA_FINAL-MENGE = WA_EKPO-MENGE.READ TABLE IT_EKKO INTO WA_EKKO WITH KEY EBELN = WA_EKPO-EBELN.WA_FINAL-BSART = WA_EKKO-BSART.WA_FINAL-LIFNR = WA_EKKO-LIFNR.

    APPEND WA_FINAL TO IT_FINAL.ENDLOOP.***DECLARE CATALOG

  • 7/26/2019 Sap Abap Material Chandra

    99/170

    DATA IT_FCAT TYPE SLIS_T_FIELDCAT_ALV.DATA WA_FCAT LIKE LINE OF IT_FCAT.***FILLING CATALOGCALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'E!PORTING I_PROGRAM_NAME = SY-CPROG

    I_INTERNAL_TABNAME = 'WA_FINAL' I_INCLNAME = SY-CPROG CHANGING CT_FIELDCAT = IT_FCAT.

    ***DECLARE IT EVENTS TAB.DATA : IT_EVENT TYPE SLIS_T_EVENT, WA_EVENT LIKE LINE OF IT_EVENT.

    *** FILLING IT EVENTWA_EVENT-NAME = 'USER_COMMAND'.

    WA_EVENT-FORM = '#UC'.APPEND WA_EVENT TO IT_EVENT.*** DISPLAY OUTPUT.CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'E!PORTING I_CALLBACK_PROGRAM = SY-CPROG IT_FIELDCAT = IT_FCAT IT_EVENTS = IT_EVENT TABLES T_OUTTAB = IT_FINAL.

    *** DEF OF #UC.

    FORM #UC USING A LIKE SY-UCOMM B TYPE SLIS_SELFIELD.

    IF B-FIELDNAME = 'LIFNR'.

    SET PARAMETER ID 'LIF' FIELD B-VALUE.

    CALL TRANSACTION '!K$%' AND SKIP FIRST SCREEN.

    ELSEIF B-FIELDNAME = 'EBELN'.

    SET PARAMETER ID 'BES' FIELD B-VALUE.

    CALL TRANSACTION 'ME"%N'.

    ENDIF.ENDFORM.

    OB@E$T

    o 'isplay the Material *umers7 Material types an' Material roup y using $)" an'also proi'e the -(,P( to the Material an' Re' Colour to Material roup

    REPORT YRAKESH_ALV_MATARIAL .

    TYPE POOLS SLIS

  • 7/26/2019 Sap Abap Material Chandra

    100/170

    ***DECLARING ITDATA: BEGIN OF WA_MARA, MATNR LIKE MARA-MATNR, MTART LIKE MARA-MTART, MATKL LIKE MARA-MATKL, END OF WA_MARA.

    DATA IT_MARA LIKE TABLE OF WA_MARA.

    ***FILLING IT_MARA

    SELECT MATNR MTART MATKL FROM MARA INTO TABLE IT_MARA .

    ***DECLARING IT_FCAT.DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV, WA_FCAT LIKE LINE OF IT_FCAT.

    ***FILLING IT_FCAT.

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'E!PORTING I_PROGRAM_NAME = SY-CPROG I_INTERNAL_TABNAME = 'WA_MARA' I_INCLNAME = SY-CPROG CHANGING CT_FIELDCAT = IT_FCAT.

    ***CUSTOMI#ING WA_FCAT-HOTSPOT = '!'. MODIFY IT_FCAT FROM WA_FCAT TRANSPORTING HOTSPOT

    WHERE FIELDNAME = 'MATNR'. WA_FCAT-EMPHASI#E = 'C$'. MODIFY IT_FCAT FROM WA_FCAT TRANSPORTING EMPHASI#E WHERE FIELDNAME = 'MATKL'.

    ****DISPLAY OUT PUTCALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'E!PORTING IT_FIELDCAT = IT_FCAT TABLES T_OUTTAB = IT_MARA.

    Date F3:J3F:;:

    BLOCKED ALV:

    Bloc!e' $)" is use' to 'isplay the output in Bloc! 4iseSTEPS TO

  • 7/26/2019 Sap Abap Material Chandra

    101/170

    2 &ile' Catalogue +nternal ale3 Eent +nternal aleD )ayout Wor! $rea

    ( Repeat the same ,EP 2 or all the internal tales

    3 isplay the loc!e' $)" y ?sing REUSEAL&BLO$-LISTDISPLA>1 unctionmo'ule

    OB@E$TBase' on gien Purchasing ocument numers to 'isplay the ocument -ea'er etails

    ;EBE)*7B,$R7)+&*R7B?GR,< an' +tem etails;EBE)*7EBE)P7ME*E7ME+*,7*ERPR< By using Bloc!e' $)"

    REPORT YRAKESH_BALV_PODETAILS .

    TYPE-POOLS SLIS.DATA V LIKE EKKO-EBELN.SELECT-OPTIONS S_EBELN FOR V.

    ***DECLARE IT TABLES.

    DATA : BEGIN OF WA_EKKO, EBELN LIKE EKKO-EBELN, BSART LIKE EKKO-BSART, LIFNR LIKE EKKO-LIFNR, BUKRS LIKE EKKO-BUKRS, END OF WA_EKKO.DATA IT_EKKO LIKE TABLE OF WA_EKKO.

    DATA: BEGIN OF WA_EKPO, EBELN LIKE EKPO-EBELN,

    EBELP LIKE EKPO-EBELP, MENGE LIKE EKPO-MENGE, MEINS LIKE EKPO-MEINS, NETPR LIKE EKPO-NETPR, END OF WA_EKPO.DATA IT_EKPO LIKE TABLE OF WA_EKPO.

    ***FILL THE IT TABLES. SELECT EBELN BSART LIFNR BUKRS FROM EKKO INTO TABLE IT_EKKOWHERE EBELN IN S_EBELN.

    IF NOT IT_EKKO IS INITIAL. SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLEIT_EKPO FORALL ENTRIES IN IT_EKKO WHERE EBELN = IT_EKKO-EBELN.ENDIF.

    ***DECLARE IT_FCAT.DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV, IT_FCAT" TYPE SLIS_T_FIELDCAT_ALV.

    ***FILL IT_FCAT.CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

  • 7/26/2019 Sap Abap Material Chandra

    102/170

    I_PROGRAM_NAME = SY-CPROG I_INTERNAL_TABNAME = 'WA_EKKO' I_INCLNAME = SY-CPROG CHANGING CT_FIELDCAT = IT_FCAT.

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'E!PORTING I_PROGRAM_NAME = SY-CPROG I_INTERNAL_TABNAME = 'WA_EKPO' I_INCLNAME = SY-CPROG CHANGING CT_FIELDCAT = IT_FCAT".***DECLARE IT_EVENT.DATA: IT_EVENT TYPE SLIS_T_EVENT, IT_EVENT" TYPE SLIS_T_EVENT.*** DECLARE WA_LAYOUT.

    DATA: WA_LAYOUT TYPE SLIS_LAYOUT_ALV, WA_LAYOUT" TYPE SLIS_LAYOUT_ALV.

    ***INTIALI#E BLOCKED ALV.CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT' E!PORTING I_CALLBACK_PROGRAM = SY-CPROG.

    ***APPENDING BLOCK LIST.CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND' E!PORTING

    IS_LAYOUT = WA_LAYOUT IT_FIELDCAT = IT_FCAT I_TABNAME = 'IT_EKKO' IT_EVENTS = IT_EVENT TABLES T_OUTTAB = IT_EKKO.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND' E!PORTING IS_LAYOUT = WA_LAYOUT" IT_FIELDCAT = IT_FCAT"

    I_TABNAME = 'IT_EKPO' IT_EVENTS = IT_EVENT" TABLES T_OUTTAB = IT_EKPO.***DISPLAY OUTPUT.CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

    OB@E$T (ASSI'"#E"T)

    Base' on gien Company co'es to 'isplay the company 'etails;B?GR,7B?@7(R01< . Customers 'etails un'er Company ;B?GR,7G?**R7$G(*?@ TYPE C, END OF WA_EKPO.

    DATA IT_EKPO LIKE TABLE OF WA_EKPO.

    ***F;/) D IT3.

    SELECT EBELN BSART LIFNR BUKRS FROM EKKO INTO TABLE IT_EKKO WHEREEBELNIN S_EBELN.

    SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPOWHEREEBELN IN S_EBELN.

    WA_EKPO-COL = 'C$'.MODIFY IT_EKPO FROM WA_EKPO TRANSPORTING COL WHERE NETPR $$$.

    ***D2

  • 7/26/2019 Sap Abap Material Chandra

    107/170

    WA_FCAT-FIELDNAME = 'EBELN'.WA_FCAT-COL_POS = ''.WA_FCAT-SELTE!T_M = 'PUR.DOC'.WA_FCAT-TABNAME = 'IT_EKPO'.

    APPEND WA_FCAT TO IT_FCAT.CLEAR WA_FCAT.

    WA_FCAT-FIELDNAME = 'EBELP'.WA_FCAT-COL_POS = '"'.WA_FCAT-SELTE!T_M = 'DOC.TYP'.WA_FCAT-TABNAME = 'IT_EKPO'.

    APPEND WA_FCAT TO IT_FCAT.CLEAR WA_FCAT.

    WA_FCAT-FIELDNAME = 'MENGE'.WA_FCAT-COL_POS = '%'.WA_FCAT-SELTE!T_M = 'TY'.WA_FCAT-TABNAME = 'IT_EKPO'.

    APPEND WA_FCAT TO IT_FCAT.CLEAR WA_FCAT.

    WA_FCAT-FIELDNAME = 'MEINS'.WA_FCAT-COL_POS = '?'.

    WA_FCAT-SELTE!T_M = 'UOM'.WA_FCAT-TABNAME = 'IT_EKPO'.

    APPEND WA_FCAT TO IT_FCAT.CLEAR WA_FCAT.

    WA_FCAT-FIELDNAME = 'NETPR'.WA_FCAT-COL_POS = ''.WA_FCAT-SELTE!T_M = 'PRICE'.WA_FCAT-TABNAME = 'IT_EKPO'.

    APPEND WA_FCAT TO IT_FCAT.CLEAR WA_FCAT.

    *** D2

  • 7/26/2019 Sap Abap Material Chandra

    108/170

    I_TABNAME_HEADER = 'IT_EKKO' I_TABNAME_ITEM = 'IT_EKPO' IS_KEYINFO = WA_KEY TABLES T_OUTTAB_HEADER = IT_EKKO T_OUTTAB_ITEM = IT_EKPO.

    BKPF (Accounting Document Header Table)\

    BELNR A$$%&'()' D%$&+,'( N&+-,

    G/AR F)$23 Y,2

    BUKRS C%+42'5 C%6,

    BLART D%$&+,'( T54,

    BUDAT P%()' D2(,

    BLDAT D%$&+,'( D2(,

    BSEG (Accounting Document Item Table)

    BELNR A$$%&'()' D%$&+,'( N&+-,

    G/AR F)$23 Y,2

    BUKRS C%+42'5 C%6,

    BU7EI I(,+

    DMBTR A+%&'( )' L%$23 C&,'$5

    "RBTR A+%&'( )' D%$&+,'( C&,'$5

    OB@E$T ASSI'"#E"TTo display the Accounting Document Header and Item details by Using

    Hierarchical ALV based given fnancial year.REPORT YRAKESH_HIRARCHICAL_ALV .

    TYPE-POOLS SLIS.

    DATA V LIKE BKPF-G5AHR.SELECT-OPTIONS S_G5AHR FOR V.

    DATA V" LIKE BKPF-BUKRS.SELECT-OPTIONS S_BUKRS FOR V".

    ***DECLARING IT TABLES.

    DATA : BEGIN OF WA_BKPF, BELNR LIKE BKPF-BELNR, G5AHR LIKE BKPF-G5AHR, BUKRS LIKE BKPF-BUKRS, BLART LIKE BKPF-BLART, BUDAT LIKE BKPF-BUDAT, BLDAT LIKE BKPF-BLDAT, END OF WA_BKPF.DATA IT_BKPF LIKE TABLE OF WA_BKPF.

    DATA : BEGIN OF WA_BSEG,

  • 7/26/2019 Sap Abap Material Chandra

    109/170

    G5AHR LIKE BSEG-G5AHR, BUKRS LIKE BSEG-BUKRS, BU#EI LIKE BSEG-BU#EI, DMBTR LIKE BSEG-DMBTR, WRBTR LIKE BSEG-WRBTR, END OF WA_BSEG.

    DATA IT_BSEG LIKE TABLE OF WA_BSEG.INCLUDE YRAKESH_IT_BKPF.INCLUDE YRAKESH_IT_BSEG.

    ***FILLING IT

    SELECT BELNR G5AHR BUKRS BLART BUDAT BLDAT FROM BKPF INTO TABLEIT_BKPFWHERE G5AHR IN S_G5AHR AND BUKRS IN S_BUKRS.

    SELECT BELNR G5AHR BUKRS BU#EI DMBTR WRBTR FROM BSEG INTO TABLEIT_BSEG

    WHERE G5AHR IN S_G5AHR AND BUKRS IN S_BUKRS.

    ***DECLARE IT_FCAT.

    DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV, WA_FCAT LIKE LINE OF IT_FCAT.

    ***FILLING FIELD CATALOG

    *** FILLING FOR BKPF>ACCOUNT DOCUMENT HEADER@

    WA_FCAT-FIELDNAME = 'BELNR'.WA_FCAT-COL_POS = ''.WA_FCAT-SELTE!T_S = 'ACC.DOC.NO'.WA_FCAT-TABNAME = 'IT_BKPF'.

    APPEND WA_FCAT TO IT_FCAT.

    WA_FCAT-FIELDNAME = 'G5AHR'.WA_FCAT-COL_POS = '"'.WA_FCAT-SELTE!T_S = 'FISCAL YR'.WA_FCAT-TABNAME = 'IT_BKPF'.

    APPEND WA_FCAT TO IT_FCAT.

    WA_FCAT-FIELDNAME = 'BUKRS'.WA_FCAT-COL_POS = '%'.WA_FCAT-SELTE!T_S = 'COMPANY CODE'.WA_FCAT-TABNAME = 'IT_BKPF'.

    APPEND WA_FCAT TO IT_FCAT.

    WA_FCAT-FIELDNAME = 'BLART'.

    WA_FCAT-COL_POS = '?'.WA_FCAT-SELTE!T_S = 'AC_DOC_TY'.WA FCAT-OUTPUTLEN = ''

  • 7/26/2019 Sap Abap Material Chandra

    110/170

    WA_FCAT-TABNAME = 'IT_BKPF'.

    APPEND WA_FCAT TO IT_FCAT.

    WA_FCAT-FIELDNAME = 'BUDAT'.WA_FCAT-COL_POS = ''.

    WA_FCAT-SELTE!T_S = 'POST_DATE'.WA_FCAT-TABNAME = 'IT_BKPF'.

    APPEND WA_FCAT TO IT_FCAT.

    WA_FCAT-FIELDNAME = 'BLDAT'.WA_FCAT-COL_POS = ''.WA_FCAT-SELTE!T_S = 'DOC_DATE'.WA_FCAT-TABNAME = 'IT_BKPF'.

    APPEND WA_FCAT TO IT_FCAT.

    ***FILLING FOR BSEG>ACCOUNTING ITEM TABLE@

    WA_FCAT-FIELDNAME = 'BELNR'.WA_FCAT-COL_POS = ''.WA_FCAT-SELTE!T_S = 'ACC.DOC.NO'.WA_FCAT-TABNAME = 'IT_BSEG'.

    APPEND WA_FCAT TO IT_FCAT.

    WA_FCAT-FIELDNAME = 'G5AHR'.

    WA_FCAT-COL_POS = '"'.WA_FCAT-SELTE!T_S = 'FISCAL YR'.WA_FCAT-TABNAME = 'IT_BSEG'.

    APPEND WA_FCAT TO IT_FCAT.

    WA_FCAT-FIELDNAME = 'BUKRS'.WA_FCAT-COL_POS = '%'.WA_FCAT-SELTE!T_S = 'COMPANY CODE'.WA_FCAT-TABNAME = 'IT_BSEG'.

    APPEND WA_FCAT TO IT_FCAT.

    WA_FCAT-FIELDNAME = 'BU#EI'.WA_FCAT-COL_POS = '?'.WA_FCAT-SELTE!T_S = 'ITEM'.WA_FCAT-TABNAME = 'IT_BSEG'.

    APPEND WA_FCAT TO IT_FCAT.

    WA_FCAT-FIELDNAME = 'DMBTR'.WA_FCAT-COL_POS = ''.

    WA_FCAT-SELTE!T_S = 'LOCAL_CURR.'.WA_FCAT-TABNAME = 'IT_BSEG'.

  • 7/26/2019 Sap Abap Material Chandra

    111/170

    APPEND WA_FCAT TO IT_FCAT.

    WA_FCAT-FIELDNAME = 'WRBTR'.WA_FCAT-COL_POS = ''.WA_FCAT-SELTE!T_S = 'DOC_CURR.'.WA_FCAT-TABNAME = 'IT_BSEG'.

    APPEND WA_FCAT TO IT_FCAT.

    DATA WA_KEY TYPE SLIS_KEYINFO_ALV.*DATA WA_KEY LIKE LINE OF IT_KEY.

    ***FILING THE KEY INFO .WA_KEY-HEADER$ = 'BELNR'.WA_KEY-ITEM$ = 'BELNR'.WA_KEY-HEADER$" = 'G5AHR'.

    WA_KEY-ITEM$" = 'G5AHR'.WA_KEY-HEADER$% = 'BUKRS'.WA_KEY-ITEM$% = 'BUKRS'.

    CALL FUNCTION 'REUSE_ALV_HIERSE_LIST_DISPLAY' E!PORTING IT_FIELDCAT = IT_FCAT I_TABNAME_HEADER = 'IT_BKPF' I_TABNAME_ITEM = 'IT_BSEG' IS_KEYINFO = WA_KEY TABLES

    T_OUTTAB_HEADER = IT_BKPF T_OUTTAB_ITEM = IT_BSEG.

  • 7/26/2019 Sap Abap Material Chandra

    112/170

    STEPS TO COP" THE E$ISTING GUI: 3"ecute $3 4, %lic0 onSTATUSin Application tool bar. +rovide 5678

    PROGRA!: SAPLKKBLSTATUS: Sta%&a'&( F)**S+'ee%.

    ToPROGRA!:9$+6A7:#UI ;9our program nameSTATUS:$TAT ;9our program $tatus.

    %lic0 on COP"

    OB,ECT:

    *&---------------------------------------------------------------------**T( 03;8 P7

  • 7/26/2019 Sap Abap Material Chandra

    113/170

    WA_FCAT-FIELDNAME = 'EBELN'.WA_FCAT-COL_POS = ''.WA_FCAT-SELTE!T_M = 'PUR_DOC_NO'.APPEND WA_FCAT TO IT_FCAT.CLEAR WA_FCAT.

    WA_FCAT-FIELDNAME = 'EBELP'.WA_FCAT-COL_POS = '"'.WA_FCAT-SELTE!T_M = 'ITEM NO'.APPEND WA_FCAT TO IT_FCAT.CLEAR WA_FCAT.

    WA_FCAT-FIELDNAME = 'MENGE'.WA_FCAT-COL_POS = '%'.WA_FCAT-SELTE!T_M = '7/8'.APPEND WA_FCAT TO IT_FCAT.

    CLEAR WA_FCAT.

    WA_FCAT-FIELDNAME = 'MEINS'.WA_FCAT-COL_POS = '?'.WA_FCAT-SELTE!T_M = 'UOM'.APPEND WA_FCAT TO IT_FCAT.CLEAR WA_FCAT.

    WA_FCAT-FIELDNAME = 'NETPR'.WA_FCAT-COL_POS = ''.WA_FCAT-SELTE!T_M = 'PRICE'.

    APPEND WA_FCAT TO IT_FCAT.CLEAR WA_FCAT.

    ***DECLARE WORK AREA FOR LAY OUT.

    DATA WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

    ***FILLING LAYOUT WA.

    WA_LAYOUT-INFO_FIELDNAME = 'COL'.WA_LAYOUT-COLWIDTH_OPTIMI#E = '!'.

    WA_LAYOUT-#EBRA = '!'.

    ***DECLARE IT EVENT.

    DATA : IT_EVENT TYPE SLIS_T_EVENT, WA_EVENT LIKE LINE OF IT_EVENT.

    ***FILL THE IT EVENT.

    WA_EVENT-NAME = 'PF_STATUS_SET'.WA_EVENT-FORM = '#PSS'.

    APPEND WA_EVENT TO IT_EVENT.CLEAR WA_EVENT.

  • 7/26/2019 Sap Abap Material Chandra

    114/170

    WA_EVENT-NAME = 'USER_COMMAND'.WA_EVENT-FORM = '#UC'.APPEND WA_EVENT TO IT_EVENT.CLEAR WA_EVENT.

    ***DISPLAY OP.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'E!PORTING I_CALLBACK_PROGRAM = SY-CPROG IS_LAYOUT = WA_LAYOUT IT_FIELDCAT = IT_FCAT IT_EVENTS = IT_EVENT TABLES T_OUTTAB = IT_EKPO.

    ***FILLING THE FORMS

    FORM #PSS USING A TYPE SLIS_T_E!TAB.

    SET PF-STATUS 'STAT'.

    ENDFORM.

    FORM #UC USING B LIKE SY-UCOMM C TYPE SLIS_SELFIELD.

    IF B = 'DOWN'.

    CALL FUNCTION 'DOWNLOAD'E!PORTING FILETYPE = 'DAT' TABLES DATA_TAB = IT_EKPO.

    ENDIF.ENDFORM.

    To display the +urchasing Document * items

  • 7/26/2019 Sap Abap Material Chandra

    115/170

    2/A/10 #ODULE POOL PRO'RA##I"'

    ransaction /ialog pool programming /Mo'ule pool programming

    $ transaction is the collection o seuential screen 4hich accept the input an' 'isplay theoutput

    ,E3: ,E11,creen painter % ,E51

    ,creen painter % ,ED1=his is also calle' 'ialog pool programming since 4e hae an interaction /n screen=+t is also calle' mo'ule programming ecause the lo4 logic o each screen acts as mo'ule

    =$ transaction contains either e>ecutale program or mo'ule pool programierence et4een e>ecutale program an' mo'ule pool program

    E>ecutale Mo'ule pool

    =4e can e>ecute an e>ecutale programin'epen'ently 4ithout 'epen's on an other

    program

    We canSt e>ecute a mo'ule pool programin'epen'ently through transaction co'e only4e can e>ecute the mo'ule pool program

    he type o the e>ecutale program is 1 ype o the mo'ule pool program is M

    $ll the stan'ar' reports are e>ecutale

    programs

    $ll the stan'ar' transactions are mo'ule pool

    program;>'017 >!01ecute ,E:0=clic! on e'it o9ect=select the program ta=proi'e your program

    = clic! on create=remoe top inclu'e 4ith top incl

    =enter=select on type is mo'ule pool ype=sae=local o9ect

    =in the let panel select the program=Proi'e your program=saeWor!ing 4ith screen painter

    =,creen painter is a tool 4hich contain oth graphical as 4ell as alpha numerical mo'e Components o ,creen painter

    1 $ttriute 2 )ayout 3 Element list D &lo4logic e'itor1 $ttriute8 $ttriute speciy the type o the screen either normal or su screen or 'ialog screen2 )ayout8 )ayout is the collection o screen element that input/output screen7 push utton7 ra'io

    utton7 chec! o>7 tale control3 Element list8 Elements list contains the entire screen element 4hich 'esign in the currentscreen an' this 'ata types an' lengthD &lo4 logic e'itor8 &lo4 logic e'itor contains logic relate' to the screen = he lin!ing or communication /n lo4 logic e'itor to aap e'itor is al4ays throughscreen element that is each element in the screen that shoul' e an eualent 'eclaration isaailale in aap e'itor

    Eent in lo4 logic e'itor

    1 PB( ;Process eore (utput< 2 P$+ ;Process ater +nput< 3 P(" ;Process on "alue Reuest< D P(- ;Process on -elp reuest8

    R$*E, L*$ME(& -E R$*EN &(R L"$R+$B)E *$MEN E@8 $$ "1 )+GE 001=B?GR, R$*E, R=B?GR, &(R "1 =he name o range acts as internal tale 4ith hea'er line =hat mean the name o the 4or! area an' name o the internal tale is same as theranges

    &or multiple inputs

    Ranges selection!option

    Reuire'

  • 7/26/2019 Sap Abap Material Chandra

    121/170

    )o47 high7

    ,ign7 option

    +t 4onSt proi'e any screen it proi'e a screen to enter theo enter the input +nput alues

    here is no 'eault alues y 'eault sign I +S

    (ption I BS Both are use' in 4here con'ition

    A/A/10 ,CREE* 1000

    CC(E (

    $ttriute )ine sel multiple an' selcol

    Co'e

    W(RG+* W+- ,?B,CREE* $RE,

    B$CG+,P)

    Bac!o4nloa'

    ,E)

    CC(E C?