Sunteți pe pagina 1din 53

REPORTS

Intelligroup Asia Private Limited

ABAP REPORTS

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 1 of 53

REPORTS
Intelligroup Asia Private Limited

TABLE OF CONTENTS
TABLE OF CONTENTS.............................................................................................................2 ........................................................................2 DEBUGGING....................................................................................................................4 Starting the ABAP/ de!"gger.................................................................................................... Co#ponent$ of ABAP/ de!"gger.............................................................................................. Brea%point$...................................................................................................................................& Na'igating thro"gh the !rea%point............................................................................................( Setting )ATC*PO+NTS............................................................................................................., INTERNAL TABLES........................................................................................................8 -e.laration of +nternal Ta!le....................................................................................................../ Sorting of +nternal Ta!le$..........................................................................................................02 Control Brea% State#ent$.........................................................................................................01 S2BRO2T+NES.........................................................................................................................0& -efining S"!ro"tine$..................................................................................................................0& Calling S"!ro"tine$....................................................................................................................0& Pa$$ing Ta!le to a S"!ro"tine...................................................................................................0/ FUNCTIONS...................................................................................................................20 The F"n.tion Li!rary3 ..............................................................................................................20 E4.eption$...................................................................................................................................22 Te$ting of f"n.tion #od"le........................................................................................................21
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 2 of 53

REPORTS
Intelligroup Asia Private Limited

REPORTS......................................................................................................................25 A!o"t report$..............................................................................................................................2& Sele.tion .riteria.........................................................................................................................2( CLASSICAL REPORTS.................................................................................................31 E'ent$ in Cla$$i.al report..........................................................................................................10 Conditional triggering of EOP..................................................................................................11 Co##on error$ that "$er .o##it$...........................................................................................1& 2$ing 5ariant$ 6ith $ele.tion .riteria.......................................................................................1& INTERACTIVE REPORTS.............................................................................................37 A!o"t intera.ti'e report............................................................................................................1, AT L+NE7SELECT+ON e'ent...................................................................................................1/ *+-E te.hni8"e..........................................................................................................................1/ 2$er interfa.e.............................................................................................................................. 2 F"n.tion .ode.............................................................................................................................. 1 9en" painter............................................................................................................................... 1 AT 2SER7CO99AN-............................................................................................................. ( +#portant $y$te# field$ for report$.......................................................................................... , EXERCISES...................................................................................................................48 +NTERNAL TABLES and REPORTS..................................................................................... / S2BRO2T+NES.........................................................................................................................&1

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 3 of 53

REPORTS
Intelligroup Asia Private Limited

DEBUGGING Many times an error free program doesnt give desired output. Behavior of program is different in different situations, with different values of variable. Such program needs additional testing, by which you can test the program by stopping at each point where you feel program is behaving abnormally. The ABAP ! debugger is the development wor"bench tool, which allows you to stop a program during its e#ecution when a particular condition is met. $hen the program is stopped, you can use the debugger to display the contents of the table and variable being used by the program. %t allows you to e#ecute the program step by step, reviewing e#actly the real flow of the program e#ecution. There are many occasions during normal system operation during which the ABAP ! debugger can be started. $hen e#ecuting program, the ABAP ! debugger is automatically started when the system encounters a brea"point. Start !" t#$ ABAP%4 &$'(""$r There are many ways to start debugger By clic"ing the &#ecute button and selecting the debugging mode. 'rom the ABAP ! editor, by e#ecuting a program choosing Program &#ecute (ebugging from the menu. Setting brea"point in the program C)*+)!$!t, )- ABAP%4 &$'(""$r
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 4 of 53

REPORTS
Intelligroup Asia Private Limited

The debugger shows the program information using si# different views. F $.&,/ (isplays the field contents. Ta'.$/ Allows modifying the contents of internal table. Br$a0+) !t,/ (isplays list of Brea"point in the Program. 1at2#+) !t,/ Allows dealing with $atchpoints. Ca..,/ System call status li"e &vent, 'orm etc., O3$r3 $4/ Presents the program structure, events, subroutines, and modules. S$tt !",/ (isplays the calling se)uence within a particular event, up to the current brea"point. All these options are shown in the following screen.

Arrow indicates the brea"point of the program i.e., where user has stopped the program. Br$a0+) !t, A brea"point is the signal, which is specified in the program, tells the system to stop the program e#ecution and to start the debugger. 'ollowing types of brea"point are available with ABAP !* Static are set up with the B+&A,P-%.T "eyword inside the program, which you can directly display with the ABAP ! source code editor. To set the brea"point in the program enters the "eyboard B+&A,P-%.T.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 5 of 53

REPORTS
Intelligroup Asia Private Limited

(ynamic this brea"point is not visible in the code. Position the cursor over the source code line to have the brea"point and then select utilities / brea"point / set. 0ou can delete them or display them from brea"point list. -r you can e#ecute the program in the ABAP ! debugger i.e., in debugging mode. $atchpoints are field specific. The program is stopped when the field reaches the value specified in the watchpoint. &#ecute the program in debugging mode. Position the cursor over the needed field. Press the ' button to get the view of field. Select the chec"bo# for the needed watchpoint. 1lic" on the continue button. ,eywords events The program stops 2ust before e#ecuting a specific event or "eyword. To set brea"point at particular event, from initial screen of debugger, select Brea"point Brea"point at at event at "eyword. &nter the name of the "eyword or event. 1lic" on -,.

Na3 "at !" t#r)("# t#$ 'r$a0+) !t 'ollowing buttons are used to navigate through the program and debugger. S !".$ ,t$+/ &#ecutes a single program command. E5$2(t$/ Similar to the single step, but when a program calls a subroutine, it e#ecutes the whole subroutine unli"e single step. C)!t !($/ &#ecutes the program until it is finished or until it finds ne#t brea"point. R$t(r!/ Allows for e#ecuting the program instruction up to the end of a routine and stops in the line of code where the subroutine gives bac" control to the main program. Ta'.$,/ Switches the debugger to the table view. D ,+.a6 !" a!& *)& -6 !" 3a.($,

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page of 53

REPORTS
Intelligroup Asia Private Limited

&very time the program is stopped within a debugger, you can display and modify the contents of table field and fields. To display the fields, clic" on 3 and you can view the contents of system field, program field, ABAP ! dictionary fields, and e#ternal program fields. D ,+.a6 !" a!& *)& -6 !" !t$r!a. ta'.$, $hen you clic" on the Table button from the initial ABAP ! debugger screen, the system will display the table debugger view. 4ere you need to enter the name of the internal table to be displayed. 0ou can modify or delete or add i.e., insert the internal table 1ontents. These changes are applicable only for the debugging and do not affect the structure of internal table in the program. S$tt !" 1ATC7POINTS &#ecute a program in debugging mode. Position the cursor over the needed field. Press the ' button to get a view of the fields. Select the chec"bo# for the needed watchpoint. 1lic" on the 1-.T%.5& button. To display the active watchpoint select 6oto / Brea"point

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page ! of 53

REPORTS
Intelligroup Asia Private Limited

INTERNAL TABLES 1onsider the following cases* 0ou want to reorgani7e the contents of table. 0ou want to modify few details of table and then display the contents of table to user. 0ou want to perform table calculations on subset of database table. %n above cases you need to recogni7e or change the database table contents. %n ABAP ! you wor" mainly with tables. 8ong life data is stored in database tables. 0ou cannot afford to lose data from database table. %n such cases where you can not wor" directly with database table 9where you are modifying contents of table or reorgani7ing the contents of table or any other case where you are altering contents of table and then displaying output to the user: hence need of intermediate table where you put in all the data from database table and wor" with this data thus avoiding accidental loss of data. These intermediate tables are called INTERNAL TABLES in ABAP ! and are created only during runtime i.e., !) *$*)r6 , r$,$r3$& -)r !t$r!a. ta'.$,. $hen you use %nternal Table in a program, three steps are associated with it. ;. (eclaration of %nternal Table <. Populating %nternal Table =. Processing %nternal Table D$2.arat )! )- I!t$r!a. Ta'.$ (epending on how you create, internal tables are of two types. %nternal tables with header line. $hen you create internal tables with header line, and then default wor"area or header is created. And you can wor" with this header. %nternal Table without header line. %n this case you need to create output e#plicit wor"area to wor" with table. -nly advantage of internal tables without header line is that you
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page " of 53

REPORTS
Intelligroup Asia Private Limited

can nest them i.e., you can have table within table, which is not possible on internal tables with header line.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page # of 53

REPORTS
Intelligroup Asia Private Limited

%nternal table can be declared in the following way* (ata * %tab li"e sflight occurs > with header line 4ere you are declaring internal table, which is similar to sflight i.e., itab li"e sflight i.e., you are referring to e#isting table 9li"e:. 9By default internal table created with this declaration is without header line:. Begin of itab occurs >. %nclude structure sflight &nd of itab 9%nternal Table created with this type of declaration is similar to declaration done in ?a type the only difference is by default internal table created by this type is with header line: Begin of itab occurs > carrid li"e sflight/carrid, connid li"e sflight/connid, fldate li"e sflight/f;date &nd of itab. By default internal table created by this type of declaration is with header line. %n this type of declaration, you are using only those fields from database table, which you re)uire for processing. Begin of itab occurs > carrid li"e sflight/carrid, connid li"e sflight/connid, boo"id li"e sboo"/boo"id id li"e scustom/id, &nd of itab. 4ere you are combining fields from three different tables in one internal table. Begin of itab occurs > 1arrid; li"e sflight/carrid, &nd of itab. 4ere you are specifying different field names.

(ata (ata

* *

(ata

(ata

(ata

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 10 of 53

REPORTS
Intelligroup Asia Private Limited

P)+(.at !" I!t$r!a. Ta'.$ %tab/name @ ?AB1(. Append %tab. 9%n this case itab is filled with one name i.e., ?AB1(.: (o A times. %tab/number @ sy/inde#. Append itab. &nddo. 9%n this case itab is filled with sy/inde# for A times: Select B from sflight into itab. Append itab. &ndselect. Select B from sflight into table itab. N)t$/ Addition of Table in %.T- clause, you omit append itab and &ndselect Select B from sflight Move/corresponding sflight to itab. Append itab. &ndselect. N)t$/ $hile using Move-corresponding, field names of (B table C %nt table should be same. Select B from sflight. Move sflight to itab. Append itab. &ndselect. N)t$/ %n this case structure of sflight and itab should be similar Select carrid; connid; from sflight into 9itab/carr;, itab/connid;: Append itab. 1lear itab. &ndselect.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 11 of 53

REPORTS
Intelligroup Asia Private Limited

Pr)2$,, !" I!t$r!a. Ta'.$ Processing of internal table includes* $riting* write * itab carrid. 9will write only one field: 8oop at itab. 9$ill write whole internal table: $rite itab &ndloop. +eading* 0ou can read internal table by* +ead table itab with "ey carrid @ ?84 94ere you are reading table with "ey: -r +ead table itab with inde# =. 94ere you read table with inde# =: 9.ote* +eading of internal table can be done inside the loop or outside the loop: Modifying* 0ou can modify contents of internal table by specifying "ey or inde#. %tab/carrid @ ?8M Modify table itab inde# =. (elete* delete table itab inde# =. 9$ill delete record with inde# =: 1ommands associated with clearing of internal tables are as follows* 1lear itab 1lear itab D E +efresh itab 'ee itab * * * * $ill clear header of internal table $ill clear body of table. $ill remove contents of internal table. $ill de/allocate memory associated with

internal table. S)rt !" )- I!t$r!a. Ta'.$, To sort contents of internal table you can use S-+T %TAB This command will sort internal table on all !)!8!(*$r 2 +r *ar6 0$6, in ascending order. To specify internal table for given "ey the synta# is,
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 12 of 53

REPORTS
Intelligroup Asia Private Limited

S-+T %TAB B0 1A++%( AS1&.(%.6. %n this case the table itab is sorted with carrid "ey in ascending order. 0ou can sort table in either AS1&.(%.6 or (&S1&.(%.6 order. The default order is AS1&.(%.6. 0ou can sort table with multiple "eys also. The number of S-+T "ey fields is restricted to <A>. %f you specify more than one field then the system sorts the record first by f; then by f< and so on 94ere f;, f< are fields:. C)!tr). Br$a0 Stat$*$!t, 1ontrol brea" statements are used to create statement bloc"s which process only specific table lines the 8--P F &.(8--P bloc". 0ou open such a statement bloc" with the control level statement AT and close it with the control level statement &.(AT. The synta# is as follows* Ta'.$ ,#)(.& '$ ,)rt$& 4#$! 6)( (,$ 2)!tr).8'r$a0 ,tat$*$!t, 9)( 2a! 'r$a0 t#$ ,$:($!t a. a22$,, )- !t$r!a. ta'.$, '6 (, !" t#$,$ ,tat$*$!t,. S6!ta5/ At first. GStatement bloc"H &ndat. T# , , t#$ - r,t ,tat$*$!t t) "$t $5$2(t$& !, &$ t#$ .))+ ;r$*$*'$r 2)!tr). 'r$a0 ,tat$*$!t, ar$ a++. 2a'.$ )!.6 !, &$ t#$ .))+< So in this bloc" you can write or process those statements which you want to get e#ecuted when the loop starts. At .ew carrid. $rite* carrid. &ndat. %n this case whenever the new carrid is reached, carrid will be written. At &nd of carrid. 5line. &ndat. %n this case whenever the end of carrid is reached, a line will be drawn.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 13 of 53

REPORTS
Intelligroup Asia Private Limited

At 8ast. $rite* ?8ast +ecord is reached. &ndat. Processing of statements within this bloc" is done when entire processing of entire internal table is over. 5sually used to display grand totals. 0ou can use either all or one of the above control brea" statements with in the loop for processing internal table. At end of carrid. Sum. &ndat. I! a')3$ 2a,$ t#$ ,tat$*$!t SU= ;a++. 2a'.$ )!.6 4 t# ! AT8ENDAT< 4 .. ,(* (+ a.. t#$ !(*$r 2 - $.&, ! !t$r!a. ta'.$ a!& r$,(.t , ,t)r$& ! ,a*$ !t$r!a. ta'.$ 3ar a'.$.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 14 of 53

REPORTS
Intelligroup Asia Private Limited

SUBROUTINES The process of brea"ing down a large program into smaller modules is supported by ABAP ! through subroutine, also called forms. Subroutines are programs modules, which can be called from ABAP ! programs. 're)uently used parts of program can be put into subroutines and these subroutines can be called e#plicitly from the program. 9)( (,$ ,('r)(t !$, *a !.6 t) *)&(.ar >$ a!& ,tr(2t(r$ 6)(r +r)"ra*. D$- ! !" S('r)(t !$, A subroutine is bloc" of code introduced by '-+M and concluded by &.('-+M. 'ollowing synta# is used to define a form or subroutine* '-+M GnameH GparametersH . . ?.. ? &.('-+M. 4ere parameters is optional. 0ou can have plain subroutine without the parameters for e#ample. '-+M S5B;. ?. . ?. &.('-+M. Ca.. !" S('r)(t !$, 0ou can call subroutines from program by following statement* P&+'-+M GsubrH DGparaHE. Parameters are optional. i.e., you can call subroutine without passing any parameter Perform S5B;. Pa,, !" Data t) S('r)(t !$,

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 15 of 53

REPORTS
Intelligroup Asia Private Limited

$hen you wor" with global data in subroutines, you can put a copy of the global data on a local data stac" and use it to avoid accidental loss of data 9%n this way you protect global data.: 0ou can pass data between calling program and subroutines by using parameters. Parameters, which are defined during definition of a subroutine with '-+M statement are called ?formal parameter. Parameters which are specified during the call of a subroutine with the P&+'-+M statement are called ?actual parameter. Parameters are passed to the '-+M either* By value By +eference By value and return. B6 Va.($ (ata * a type % value <>. Perform sub; using a. $rite a. '-+M sub; using value 9pIa: P F a @ ;A &.(-+M. %n this case during subroutine call, the formal parameter are created as copies of actual parameter. The formal parameters have the memory of their own. 1hanges made to formal parameter have no effect on the actual parameter. 8i"e in this case, though value of pIa is changed to ;A, it has no effect on ?a which remains as <>. B6 R$-$r$!2$ (ata* a type % value <>. Perform sub; using a. $rite a. '-+M sub; using value 9pIa: P F a @ ;A. &.(-+M.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 1 of 53

REPORTS
Intelligroup Asia Private Limited

By default system calls all the forms by reference. %n this case, only the address of the actual parameter is transferred to the formal parameters. The formal parameter has no memory of its own. %f you change the formal parameter, change is visible in actual parameter also. B6 Va.($ a!& R$t(r! (ata * a type % value <>. Perform sub; changing a. '-+M sub; changing value 9pIa: P F a @ ;A. &.(-+M. %n this case if you change formal parameter, then the value of actual parameter is changed when the control is transferred bac" to the main program. Assuming A is declared by (ATA statement and has value <> and subroutine S5B; is called by passing A. 1A88%.6 '-+M 3A85& -' A %. P+-6+AM B&'-+& 1A88%.6 '-+M A @ <> B0 3A85& 95S%.6: 3A85& -' A %. '-+M 9pIa @ ;A: A @ <> PIA @ ;>> 9changing value of pIa: A @ <>. A @ <> PIA @ ;>> 9changing value of pIa: A @ ;>> A @ <>

A'T&+ +&T5+.%.6 '+-M '-+M A @ <> B&'-+& 1A88%.6 '-+M A @ <>

B0 +&'&+&.1& 95S%.6: B& 3A85& A.( +&T5+.

A'T&+ +&T5+.%.6 '+-M '-+M A @ <> B&'-+& 1A88%.6 '-+M

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 1! of 53

REPORTS
Intelligroup Asia Private Limited

A @ <> 914A.6%.6: A'T&+ +&T5+.%.6 '+-M '-+M A @ ;>>

PIA @ ;>> 9changing value of pIa: A @ ;>>.

Pa,, !" Ta'.$ t) a S('r)(t !$ 0ou can pass internal tables as parameters 5S%.6 or 14A.6%.6 in the '-+M and P&+'-+M statements. %f you want to access the components of the internal table, you must specify the type of the corresponding formal parameter. 0ou also must distinguish between internal tables with or without header lines. 'or internal tables with header lies, you must specify the table body by using s)uare brac"ets D E, after the table name to distinguish it from the header line. $ith internal subroutines, you can use T0P& or 8%,& to refer to the internal table you want to pass directly. 0ou can pass all internal tables as parameters in the list after TAB8&S in the '-+M and P&+'-+M statements. %nternal tables passed with TAB8&S are always called by reference. %f you pass all internal table with a header line, the table body and the table wor" area are passed to the subroutine. %f you pass an internal table without a header line, a header line is created automatically as a local data ob2ect in the subroutine. P+-6+AM J(&M(ATA* Begin of itab occurs >, .umber type %, end of itab P&+'-+M S5B; TAB8&S %TAB. 8--P AT %TAB. $+%T&* itab/number. &.(8--P. '-+M S5B; TAB8&S 'I%TAB 8%,& %TAB D E. (- = T%M&S.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 1" of 53

REPORTS
Intelligroup Asia Private Limited

'Iitab/number @ S0/%.(&K. APP&.( 'I%TAB. &.((-. &.('-+M. After starting J(&M- the output appears as follows* ; < = %n this e#ample, an internal table %TAB is declared with a header line. %TAB is passed to the subroutine S5B;, where it is filled using the table wor" area 'I%TAB. And itab is written in main program.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 1# of 53

REPORTS
Intelligroup Asia Private Limited

FUNCTIONS 'unction modules are special e#ternal subroutines stored in a central library. The + = system provides numerous predefined function modules that you can call from your ABAP ! programs, and plus you can create your own function modules. The main difference between a function module and a normal ABAP ! subroutine is as follows* 'unction is stored in central library and has global presence while subroutines are confined to a particular program. Subroutine cannot return values while functions can return values. 5nli"e functions, subroutine cannot handle e#ceptions. And last but not least, the difference in the way the parameters are passed to functions. D$2.ar !" &ata a, 2)**)! +art, , !)t +),, '.$ -)r -(!2t )! *)&(.$,. The calling program and the called function module have separate wor" in ABAP ! (ictionary tables. 0ou use the ABAP ! $or"bench to call, create, and maintain function modules. 0ou can 2)*' !$ ,$3$ra. -(!2t )! *)&(.$, t) -)r* a -(!2t )! "r)(+ ! t#$ -(!2t )! . 'rar6. Since you can define global data that can be accessed from all function modules of one function group, it is reasonable to include function modules that operate with the same data, for e#ample internal table for sales module can be grouped, in one function group. 3ia the ABAP ! (evelopment $or"bench screen, choose (evelopment 'unction 8ibrary or select 'unction 8ibrary in the application toolbar or use se=L transaction code.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 20 of 53

REPORTS
Intelligroup Asia Private Limited

T#$ F(!2t )! L 'rar6/

The function library maintains 'unction Modules, the screen displays following components* All function names should start with JI or 0I followed by any name. Source code (ocumentation Administrative info %mport/e#port parameters Table parameters and e#ception interface 6lobal data Main program 9.ot necessarily in the same order:

D)2(*$!tat )! The documentation describes the purpose of the function module, lists the parameters for passing data to and from the module, and the e#ceptions. The parameters of the parameter type % are import parameters, which are used to pass data to the function module. Parameters of the parameter type & are e#port parameters, which are used to pass data from, the
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 21 of 53

REPORTS
Intelligroup Asia Private Limited

function module to the calling program. &#ceptions describe error scenarios, which can occur in function modules. I*+)rt8$5+)rt +ara*$t$r, %mport parameters correspond to the formal input parameter of subroutines. They pass data from the 2a.. !" +r)"ra* t) t#$ -(!2t )! *)&(.$. &#port parameters correspond to the formal output parameters of subroutines. They pass data from the function module bac" to the calling program 9which his not possible in subroutines: Ta'.$ +ara*$t$r, Table parameters are internal tables. %nternal tables are treated li"e changing parameters and are always passed by reference. E52$+t )!, &#ceptions are used to handle error scenarios, which can occur in function modules. The function module chec"s for any type of error and raise e#ception and returns S0/S5B+1 to the calling program. Main program chec"s this S0/S5B+1 for any errors that have occurred and then ta"es action accordingly. S)(r2$ C)&$ The ABAP ! &dit screen displays the ABAP ! source code of the function module. 0ou can wor" with the source code in the same way as you would wor" with normal ABAP ! programs. %mport parameters, changing parameters, and table parameters can be -ptional. This means that you can omit the corresponding actual parameter when you call the function in the calling program. %f the parameter is optional and the actual parameter is not specified, you can specify a default value for use in the function module. &#port parameters are always optional. As with subroutines, you can specify the data types of the formal parameters in the field +eference type. %n the field +ef. structure, you can specify ABAP ! (ictionary reference structures or fields. Then, the system chec"s the current parameter against the structure or field at runtime.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 22 of 53

REPORTS
Intelligroup Asia Private Limited

T$,t !" )- -(!2t )! *)&(.$ 0ou can test a function module without calling it from an ABAP ! program via the 'unction 8ibrary* Maintain 'unction Modules screen by choosing Single test. 0ou can assign values to the import parameters on the Test 'unction Modules screen.

Ca.. !" F(!2t )! =)&(.$, T) 2a.. a -(!2t )! *)&(.$ -r)* a! ABAP%4 +r)"ra*@ use the 1A88 statement as follows* S6!ta5/ 1A88 '5.1T%-. GmoduleH D&KP-+T%.6 f; @ s; f< @ s< fn @ sn 9parameters which you pass from program to function are s;, s<, sn:E D%MP-+T%.6 f; @ r; f< @ r< fn @ rn 9parameters which program receives you pass from function in r;, r<, rn:E DTAB8&S f; @ a; M fn @ anE &K1&PT%-.S notvalid @ ; not correct @ < -T4&+S @ AE. 0ou can specify the name of the function module GmoduleH as a literal or as a variable. Parameters are passed to and from the function module by e#actly assigning the actual parameters to the formal parameters in the lists after the &KP-+T%.6, %MP-+T%.6, TAB8&S.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 23 of 53

REPORTS
Intelligroup Asia Private Limited

%f in your function if you have raised e#ception not valid then this e#ception can be handled in main program. 'unctions return different sy/subrc for different e#ceptions.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 24 of 53

REPORTS
Intelligroup Asia Private Limited

REPORTS A')(t r$+)rt, +eports, in the + = system are online programs whose function is to retrieve data from database and display it or print it for the user. An end user often needs some information to loo" up, depending upon which various management decisions are ta"en, or to 2ust see business results or simply to continue wor". As + = is collection of all business applications, it has provided a very powerful feature to satisfy this crucial business need i.e., reports are involved at each and every step of business. This type of e#tracting, collecting and formatting data that is stored in database is done by +&P-+T program. The program that is written to retrieve and display data is +&P-+T program and the data that is displayed on the screen when you e#ecute the program is called as 8%ST 9output of the report:. SAP has provided thousands of preprogrammed reports. 5ser 2ust selects a menu option or 2ust one clic" here and there, displays the report. -ften user is unaware that by clic"ing one button he is e#ecuting a complicated report program, which is actually accessing database and then displaying the result. An end user might not feel the necessity of writing a +&P-+T program but a developer has to develop a report manually using the functions and facilities provided by the + = system. 4ow to develop a report using these facilities, is the purpose of this section. $hen you display data, you need to display the data, user needs. 'or e#ample, user wants to see the all the employee, who has 2oined after ;< th (ecember ;NNL. %n this case user has to pass this information, to the system, that he needs only those employee records where 2oining data is greater than ;<th (ecember ;NNL. 'or user, it is passing information to the system but for the system it is input from the user. System ta"es input from the user before it retrieves the data from the database. This is very common re)uirement of any report as the need of any business is to display data, which is re)uired by user.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 25 of 53

REPORTS
Intelligroup Asia Private Limited

S$.$2t )! 2r t$r a System accepts inputs from user through SELECTION CRITERIA. Selection criteria are nothing but input fields which allows the user to restrict information given to program for processing further data. %f you dont specify any criteria for selection, your report program produces a long list of data, which might not be needed by the user. Basically, selection criteria are the fields where user enters some value for which he needs information. Through ,$.$2t )! 2r t$r a (,$r 2a! $!t$r & ,2r$t$ 3a.($ )r ra!"$,. 'or e#ample, user wants to see all the records of the employees, who have 2oined between ;<th (ecember ;NNL and ;<th May ;NNO. This range can be entered in selection criteria. As the user becomes more specific for mentioning the criteria, the list will be smaller and more specific. S6!ta5/ S&8&1T/-PT%-.S GfieldH for Gtable fieldH. 'ield is the variable, which you declare for accepting input from the user. Table field is reference field. S&8&1T/-PT%-.S* fld; for sflight/fldate, carrid; for sflight/carrid. Ma#imum length of the name Select/-ptions variable is O. $hen system e#ecutes this statement, the selection screen is displayed and is li"e this.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 2 of 53

REPORTS
Intelligroup Asia Private Limited

$hen you enter the desired information and clic" on e#ecute button, rest of the program is e#ecuted, that is retrieval of data from database, which matches this information and the list is displayed. Behavior of SELECT8OPTIONS $hen the Select/-ptions statement is e#ecuted the system creates the internal table with the same variable name 9in this case it will be carrid;:. This table is also called as ,$.$2t )! ta'.$. The main purpose of selection table is to store selection criteria. The table has four standard fields, which are as follows* S%6. is a variable, which denotes the system whether the result should be included with those particular criteria. %t can contain either % or &. % denotes %nclusion. The criteria are included. & denotes &#clusion. The criteria are e#cluded from the result. 8-$ the data type of 8-$ is the same as the field type of the database table, for which you are using selection criteria. This acts as lower limit of the selection. 4%64 the data type of 4%64 is the same field type of the database table, for which you are using the selection criteria. This acts as higher
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 2! of 53

REPORTS
Intelligroup Asia Private Limited

limit. %f you dont enter 4%64 value then the 8-$ value defines a single value selection. -PT%-. is two/character field, which contains operators li"e &P, 6T, 8T, 6&, and 8&. $hen the user enters both the values i.e., high and low then this field acts as BT 9between:. %f you dont enter high value then all other operators can be Applicable. 'or each Select/-ptions statement system creates internal table. Default values for select-options %f you want to display default values for the selection criteria before your screen is displayed, give default values for the selection table fields i.e., low or high. S&8&1T/-PT%-.S* 1A++%(; '-+ S'8%64T/1A++%( 1A++%(;/8-$ @ ?84 A.( 1A++%(;/4%64 @ ?SP. (&'A58T

%n this case selection screen is displayed with default values ?84 for lower range and ?SP for higher range. 5ser can use same values or overwrite these values with new values, whichever he needs.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 2" of 53

REPORTS
Intelligroup Asia Private Limited

Sta!&ar& r$+)rt The normal format of any report is as follows* 4&A(%.6 '-+ T4& 8%ST i.e., header area

8%ST 4&A(&+S

(etailed data

At the end of page you can have sub total of page number i.e., footer area

5sually any report has some page headings at the top of page and then data is displayed with column headings, followed by data and at the end of page may be some grand total or page number. Any such report can be displayed by using report program. Such report is called as Classical Report. 5sually a standard report produced by system is one continuous page of QA" lines. The standard report can be declared as followsR +&P-+T J(&MBy default the report produced by system is standard report. But when you need to have your report divided into pages of say <> lines and you want to reserve some area for footer than you need to use following format of report statement*

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 2# of 53

REPORTS
Intelligroup Asia Private Limited

+&P-+T J(&M- line/count <>9=: 8ine/si7e LA. %n this case the line count for one page is <> lines, in which = lines are reserved for footer. 0ou can display your data only in ;L lines. The width of page will be LA characters. As all of us "now ABAP ! is event driven language, the ABAP ! processor controls the e#ecution of events. 'or e#ample in above report at the end of the page, you want to write the page number, reaching end of page is an event. -r whenever at the top of a page you want to write list headers, then in this event you can write the code for displaying the list headers. +eport program is nothing but a set of events either controlled e#ternally or internally. All above events are e#ternal events as the top portion of your page is reached on your screen or on your printer and is no way connected to your program. I!t$r!a. $3$!t, are those events, which are controlled inside the program i.e., either '6 - A $!& - statement or any other decision/ma"ing statement. A sample report program without any events is as follows* +eport 7demo;. Tables* sflight. Select/options carrid; for sflight/carrid. B 'or accepting input from user. $rite* ?This is my first report program. $rite* ;> ?carrier id, <> ?connection id => ?flight date. B These two write statements are for writing heading and column headings. Select B from sflight where carrid in carrid;. $rite* ;> sflight/carrid, <> sflight/connid, => sflight/fldate. &ndselect. $rite* ?page number*?, sy/pagno. %n this case we are writing list headings for report. But these list headings are applicable only for the first page. %f your list is spilling over multiple pages, then these list headings are not applicable to other pages. Again in this program, we write page number after all the data is displayed. This is fine as long as you have one page, but the moment your list spills over multiple pages, the page number will be displayed only after all the records are displayed. So in order to have some data li"e company name or list headings or page number or total of some number field on each page, you need to ma"e use of events.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 30 of 53

REPORTS
Intelligroup Asia Private Limited

CLASSICAL REPORTS E3$!t, ! C.a,, 2a. r$+)rt &vents associated with classical report are as follows and each one will be discussed in detail. %.%T%A8%JAT%-. AT S&8&1T%-./S1+&&. AT S&8&1T%-./S1+&&. -. GfieldH STA+T/-'/S&8&1T%-. T-P/-'/PA6& &.(/-'/PA6& &.(/-'/S&8&1T%-.

%n this case first three events are associated with selection screen. +est of the events are associated with your list. INITIALIBATION $e have already seen how to fill default values for the selection criteria. But in many cases you need to calculate the value and then put it in selection criteria. 'or e#ample, say, you are accepting date from user and you need to fill in the default value for lower range as sy/datum F => days and sy/datum for higher range. %n this case you are calculating lower range and then filling the criteria. This can be done in %.%T%A8%JAT%-. event. Piece of code to do the above tas" would loo" li"e the following* Tables* Sflight. Select/options* fldate; for sflight/fldate. %.%T%A8%JAT%-.. (ata* date; li"e S0/(AT5M. (ate; @ sy/datum F =>. 'ldate;/low @ date;. 'ldate;/high @ sy/datum. Append fldate;. B 4ere appending is re)uired because fldate; is int table This event is triggered when you e#ecute your program for the first time i.e., before selection screen is displayed. AT SELECTION8SCREEN

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 31 of 53

REPORTS
Intelligroup Asia Private Limited

$hen user enters the values in the fields of selection screen and clic"s on e#ecute button, this event gets triggered. This event is basically for chec"ing the values entered by the user for the fields of the selection screen i.e., data validity chec"ing. This event is for entire selection screen. 'or e#ample* 0ou are accepting carrid, connid, fldate from user and you dont want to proceed if user enters no value for carrid and fldate. 5sing AT S&8&1T%-./S1+&&. can do this. Select/options* carrid; for sflight/carrid, 1onnid; for sflight/connid, ';date; for sflight/f;date. AT S&8&1T%-./S1+&&.. %f carrid;/low ne ? and fldate;/low @ ? . &rror message. &ndif. %n this case, if both the fields are entered blan", then the user gets error message. Basically, this event is for many fields on selection screen. 5sually, it is for the fields which are logically related. AT SELECTION8SCREEN ON C- $.&D $hen you want to chec" for specific value of a field. 'or e#ample, carrid should be in the range of ?84 and ?SP. This can be done in this event. Basically, this event is for chec"ing individual fields. 0ou can have many AT selection/screen events in your program 9i.e., for each field specified in the Select/-ptions:. Select/-ptions carrid; for sflight/carrid. AT S&8&1T%-./S1+&&.. %f carrid;/low ne ?84 and carrid;/high ne ?SP. &rror message. &ndif. 4ere the system will not proceed on entering wrong values. START8OF8SELECTION

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 32 of 53

REPORTS
Intelligroup Asia Private Limited

This is the first event for your list. -nce all the events are triggered for selection screen, the data is retrieved from database. (ata declaration, select statements are done in this event. 1onsider the following e#ample* STA+T/-'/S&8&1T%-.. (ata* mtype i. Tables* sflight. Select B from sflight where carrid @ ?84. $rite* sflight/carrid,sflight/connid. &ndselect. TOP8OF8PAGE This event is triggered with first $+%T& statement or whenever new page is triggered. Advantage of using this event is that, whatever you write under this event, is applicable to all the pages. %f you dont have any write statement before T-P/-'/PA6& or in STA+T/-'/S&8&1T%-., this event is not triggered at all. 'or e#ample, if you want the name of company and column headers for all the pages, it can be written in this event. T-P/-'/PA6& $rite* ?%.T&88%6+-5P AS%A P3T. 8T(. $rite * ;> ?carrid, <> ?connid, => ?fldate. END8OF8PAGE This event is triggered at the end of page. &nd/of/page. $rite * ?page number, sy/pagno. %n this case page number will be written on every page. C)!& t )!a. tr ""$r !" )- EOP 1onsider the following case. +&P-+T J(&M-; line/count ;A9=:. Top/of/page. $rite* ?this line is written by top/of/page event. Start/of/selection. $rite* ?this line is written by start/of/selection event.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 33 of 53

REPORTS
Intelligroup Asia Private Limited

&nd/of/page. $rite * ?this line is written by end/of/page event. %n this case &-P will never be triggered, as end of page is never reached. The total 8ine/count defined for page @ ;A in which = lines are for footer area. The output of the above code will be This line is written by top of page event. This line is written by start of selection event. %n output screen, only two lines are written and cursor remains still on = rd line, the end/of/page event is not triggered. To trigger end of page event, cursor should reach at the last position, in this case on ;; th line. Such cases are )uite common, and could be overcome by conditional triggering of end of page. Sy/linct is the system variable, which gives total line count of a list. Sy/linno is the system variable, which gives the current line number where the cursor is placed on the list. 1onsider the following case* +eport 7demo; line count <>9;:. Start/of/selection. (ata* m type i. $rite* ?this is first line. (o A times. $rite* ?the number is, sy/inde#. &nddo. M @ sy/linct, sy/linno F ;. S"ip #. &nd/of/page. $rite* ?page end. The output of above e#ample is as follows * This is first line. The number is ; The number is < The number is = The number is ! The number is A
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 34 of 53

REPORTS
Intelligroup Asia Private Limited

After s"ipping ;> lines Page end %n this case, with all write statement, you dont reach to the end of page. After all write statement, m is calculated in this case* M @ <> F O F ;, So m is ;<. And ;; lines are s"ipped after write statement and end of page is reached. 9%n this case you have Q write statement so Q lines S ; line for page number and ; hori7ontal line which is displayed for any list. So cursor is on Oth line and is subtracted from total line count i.e, <>.: C)**)! $rr)r, t#at (,$r 2)** t, Stating of another event denotes the end of any event. %f you forget to mention the ne#t event then everything is included in the same event. 1onsider the following case* AT S&8&1T%-./S1+&&.. %f carrid;/low ne ? ?. &rr. or message. &ndif. $rite* ?%.T&88%6+-5P AS%A P. 8T(. $+%T&* ;> ?1A++%(, <> ?1-..%(, => ?'8(AT&. STA+T/-'/S&8&1T%-.. ?. ?. ?. %n this case all the write statement are included in the Tat selection screen as top/of/page is not specified. The end of Tat selection/screen is denoted by the starting of start/of/selection. Though the se)uence of events in program is immaterial, it is a good programming practice to write all the events in the order specified above. U, !" Var a!t, 4 t# ,$.$2t )! 2r t$r a %n many cases you need report to e#ecute report at regular interval for certain fi#ed values of selection criteria. That means each times you e#ecute the report you need to enter its values again and again. ABAP ! provides the facility by which you can define the values for selection
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 35 of 53

REPORTS
Intelligroup Asia Private Limited

screen and store it. 5sing 3A+%A.TS can do this. %t can be defined as group of values used for selection criteria while e#ecuting report. 'or a particular report, you create a variant which means variant created for particular report cannot be used for another report. The group of values for the selection criteria is saved and assigned a variant name. So every time you call a report, you need not specify the values for selection criteria but instead call the variant thus avoiding e#tra typing. 5ser can have many variants for a single report. &ach of them can be used as different type of information. 'or e#ample, if a manager wants to see how an employee in personnel department or admin department has performed. 4e need not enter the department, one has to 2ust e#ecute the report with variant. %n case he doesnt "now about the variant, which is available, he can display list of variants attached to the report and values assigned to each variant. Cr$at !" 3ar a!t &#ecute the report program. The selection screen is displayed. &nter the values for selection screen and clic" on saves. / System displays the variant screen &nter the variant name and description for it. Save it. 5sually the variants are useful when you need to e#ecute the report in bac"ground, which will be discussed in bac"ground processing. .

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 3 of 53

REPORTS
Intelligroup Asia Private Limited

INTERACTIVE REPORTS A')(t !t$ra2t 3$ r$+)rt A classical report consists of one program that creates a single list. This means that when the list is displayed, it has to contain all the re)uested data, regardless of the number of details the user want to see. This procedure may result in e#tensive and cluttered lists from which the user has to pic" the relevant data. The desired selections must be made before hand and the report must provide detailed information. This is not possible using the classical report and for this ABAP ! has provided reporting feature called INTERACTIVE REPORT. The list produced by classical report doesnt allow user to interact with the system but the list produced by interactive report allows the user to interact with the system i.e., user can tell the system, that he needs further information. (epending upon what the user tells the system, the action is ta"en. %nteractive reporting thus reduces information retrieval to the data actually re)uired. Interactive reporting allows the user to participate in retrieving and presenting data at each level during the session. %nstead of presenting one e#tensive and detailed list with cluttered information, with interactive reporting you can create a condensed basic list from which the user can call detailed information by positioning the cursor and entering commands. (etailed information is presented in secondary lists. A secondary list may either overlay the basic list completely or appear in an additional dialog window on the same screen. The secondary list can itself be interactive again. The basic list is not deleted when secondary list is created. 5ser can interact with the system by* (ouble clic"ing or pressing '< Selecting menu option 8i"e classical report, the interactive report is also event driven. Both the action mentioned above trigger events and code is written to handle these events. The events triggered by this action are as follows* At line/selection At user/command Top/of/Page (uring 8ine/Selection for Secondary Page 4eader info
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 3! of 53

REPORTS
Intelligroup Asia Private Limited

%nteractive report consists of one BAS%1 list and <> secondary list. Basic list is produced by STA+T/-'/S&8&1T%-. event. $hen the user double clic"s on the basic list or chooses the menu option, the secondary list is produced. All the events associated with classical report e#cept end/of/ page are applicable only to basic list. AT LINE8SELECTION $3$!t (ouble clic"ing is the way most users navigate through programs. (ouble clic"ing on basic list or any secondary list triggers the event AT 8%.&/ S&8&1T%-.. S0/8S%.( denotes the inde# of the list currently created. 'or BAS%1 list it is always >. 'ollowing piece of code shows how to handle the event. Start/of/selection. $rite* ?this is basic list. At line/selection. $rite * ?this is first secondary list. %n this case the output will be displayed on basic list i.e. This is basic list. $hen user double clic"s on this line, the event at line/selection gets triggered and secondary list is produced, i.e. This is first secondary list. 0ou can go bac" to basic list by clic"ing on '= or bac" icon on the standard tool bar. 'or this list, the value of sy/lsind will be ;. 7IDE t$2#! :($ %n this case thins are much simpler. 1onsider the case, wherein you display fields from table sflight in basic list. $hen user double clic"s on any sflight/carrid, you are displaying the detailed information related to that particular carrid on secondary list. 4ence there is a need to store the clic"ed carrid in some variable. So that you can access this carrid for ne#t list. ABAP ! has facilityR a statement called 7IDE, which provides the above functionality. 4%(& command temporarily stores the content of clic"ed field in system area.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 3" of 53

REPORTS
Intelligroup Asia Private Limited

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 3# of 53

REPORTS
Intelligroup Asia Private Limited

S6!ta5/ 4%(& G'%&8(SH. This statement stores the contents of variable GfH in relation to the current output line 9system field S0/8%..-: internally in the so/called 4%(& area. The variable GfH must not necessarily appear on the current line. 0ou have to place the 4%(& statement always directly after the output statement i.e., $+%T& for the variable GfH. As when you hide the variable, control is passed to ne#t record. $hile writing, 1RITE ,tat$*$!t ta0$, t#at r$2)r& -r)* #$a&$r a!& 4r t$, t )! t) t#$ . ,t@ '(t 4#$! 4r t !" )!t) 6)(r !t$ra2t 3$ . ,t 6)( 4 .. * ,, )(t 1,t r$2)r&. To hide several variables, use chain 4%(& statement. As soon as the user selects a line for which you stored 4%(& fields, the system fills the variables in the program with the values stored. A line can be selected. By an interactive event. 'or each interactive event, the 4%(& fields of the line on which the cursor is positioned during the event are filled with the stored values. The 4%(& area is a table, in which the system stores the names and values of all 4%(& fields for each list and line number. As soon as they are needed, the system reads the values from the table. 9Please try to find the name of this table.: Sy/lsind indicates the inde# of the list and can be used to handle all the secondary lists. $hen the user double clic"s on the line or presses '<, sy/ lsind is increased by one and this new sy/lsind can be handled. 'or e#ample* $rite* ?this is basic list. $ill create a basic list. %f sy/lsind @ ;. $rite* ?this is first secondary list. &lseif sy/lsind @ <. $rite* ?This is second secondary list. &ndif.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 40 of 53

REPORTS
Intelligroup Asia Private Limited

$hen this code is e#ecuted,

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 41 of 53

REPORTS
Intelligroup Asia Private Limited

Basic list is produced. $hen the user clic"s on the basic list, sy/lsind becomes one. AT 8%.&/S&8&1T%-. event is triggered. $hatever is written under %' Sy/lsind @ ;, gets e#ecuted. Secondary list is produced. Again if user clic"s on this list, sy/lsind becomes two. AT 8%.&/S&8&1T%-. gets triggered. 1ode written under %' Sy/lsind @ <, gets e#ecuted.

A sample program for AT 8%.&/S&8&1T%-.. U,$r !t$r-a2$ An interactive report starts with basic list where condensed information is stored on basic list and detailed information is stored on secondary list. To implement this "ind of reporting, you need to provide the user with things li"e menu, icons, function "eys. 0ou also need to write code, which must react, to the users action. 'or this, you need to create the interface, which interacts with the user. The user interface is independent of the program or list or screen. 4owever both interface and list can be associated by means of 65% status. A 65% status groups together the interface components. Menu bar Application tool bar 'unction "eys Title bar

The last element of the user interface is independent of the 65% status i.e., titlebar. To assign status to your list the statement S&T P+/STAT5S. Some facts about 65% status are* A program can have multiple 65% status and titles for different lists. Multiple lists can be assigned to same 65% status. .ormally both 65% status and title go together.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 42 of 53

REPORTS
Intelligroup Asia Private Limited

F(!2t )! 2)&$ An important concept, when wor"ing with user interface. 'unction is a four character alphanumeric code, which the system stores in the system variable called S0/51-MM for each function "ey, push button, or menu option. $henever any push button is clic"ed or menu option is selected, the code attached to that, is stored in S0/51-MM and can be handled in your program. =$!( +a !t$r Menu painter is the ABAP ! wor"bench tool for creating and maintaining user interface. Start !" =$!( Pa !t$r ABAP ! development wor"bench menu painter -r Transaction S&!; in the command field. -r Through program S&T P'/STAT5S GvarH %f you double clic" on the variable, the system ta"es you to the menu painter screen. Cr$at !" =$!( 'ar Steps involved are as follows* &nter the name in the first field. %t is 2ust a name given to the menu and is not displayed anywhere in the output. &nter the name of each menu item. 0ou can create up to si# menus 9total eight menu items are available, out of which system and help are mandatory:. &nter name of the menu items and function code. 0ou can have fifteen menu items under one menu.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 43 of 53

REPORTS
Intelligroup Asia Private Limited

%f you leave function blan", the system assumes that this particular menu item will have submenu. 0ou can create the sub menu items under this menu item. 5ser can go up to three levels.

Cr$at !" A++. 2at )! T)). Bar

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 44 of 53

REPORTS
Intelligroup Asia Private Limited

A,, "! F(!2t )! E$6,

%n Application tool bar you can include icon assigned for function "eys. Procedure* Select function "ey. 'rom the menu, more utilities / change te#t type. The system displays a dialog bo#, clic" on icon and presses &.T&+. Select icon from list of icons displayed Cr$at !" GUI t t.$ 'rom your program, you can set title for your list and S&T T%T8&BA+ is used. S6!ta5/ S&T T%T8&BA+ GvarH. 4ere var can be any three/character name. $hen developer double clic"s on the var, system displays the dialog bo# in which you enter the title number, the description, and the actual te#t for title.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 45 of 53

REPORTS
Intelligroup Asia Private Limited

Similar to dictionary ob2ects, the 65% status must be generated to be accessible by program. AT USER8CO==AND $hen the user selects the menu item or presses any function "ey, the event that is triggered is AT 5S&+/1-MMA.(, and can be handled in the program by writing code for the same. The system variable S0/51-MM stores the function code for the clic"ed menu item or for the function "ey and the same can be chec"ed in the program. Sample code would loo" li"e AT 5S&+/1-MMA.(. 1ase sy/ucomm. $hen ?(%SP. Select B from sflight. $rite sflight/carrid, sflight/connid. &ndselect. $hen ?&K%T. 8&A3&. %f 65% status, suppose you have set menu bar for two items and the function code is ?(%SP and ?&K%T respectively. %f the user clic"s the menu item ?(%SP8A0, then function code ?(%SP is stored in the sy/ucomm and whatever is written under the when ?(%SP, gets e#ecuted. This is applicable for &K%T as well. Sy/lsind for the screen increases when the user clic"s the menu item. 5sually you have combination of all the three navigations in your user interface, i.e., you have to create menu bar, assign function code for the function "eys and write code to handle all this in addition to handling double clic"ing. Things to remember while using all the combinations* Sy/lsind increases even if you select menu/item. $hen the user double clic"s on particular line, value of sy/ucomm is ?P%1,.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 4 of 53

REPORTS
Intelligroup Asia Private Limited

%f you set sy/lsind @ < for your ! th secondary list, when control is transferred to the <nd secondary list, all the other lists after < nd are lost or memory allocated to them is lost. Sy/lisel also gives you the value of clic"ed line but in this case you cannot differentiate between field. To retrieve the e#act field, you have to "now the field length of each field. %f you use statement S0/8S%.( @ ;. The system reacts to a manipulation of S0/8S%.( only at the end of an event, directly before displaying the secondary list. So, if within the processing bloc", you use statements whose %.(&K options access the list with the inde# S0/8S%.(, ma"e sure that you manipulate the S0/ 8S%.( field only after processing these statements. The best way is to have it always at the Tas the last statement of the processing bloc". I*+)rta!t ,6,t$* - $.&, -)r r$+)rt, Sy/linct / Sy/linno / Sy/lsind / Sy/listi / previous list Sy/lilli / Sy/lisel / Sy/ucomm / 6ives total line numbers for a page. 6ives current line number on the list %nde# of the lists created in interactive report %nde# of the list from where event was triggered, usually 8ine number of a list from where event was triggered 1ontents of a line from where event was triggered 4olds the function code of clic"ed menu item or function "ey

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 4! of 53

REPORTS
Intelligroup Asia Private Limited

EXERCISES INTERNAL TABLES a!& REPORTS ; 1reate an internal table ta"ing all the fields from B,P' and display fields 1ompany code, (ocument number, (ocument type and date of document. 1reate an internal table ta"ing fields 1ompany code, (ocument number, Account type and Ta# code from table BS&6 and display the same with column headings. 1reate an internal table with following fields* Sales (ocument and Material from table 3BAP. (ate, .ame of the user and sales document type from table 3BA, and Price group and customer group from table 3B,(. Sort the table according to Material number and display the contents. 1reate an internal table called TIBS%S having a similar structure as table BS%S. &#plore all possible methods to create the internal table with header line without header line. 9use data types, data M begin of M.end of, data M. data M. %nclude structure M etc.: Also create a field string 'IBS%S. Populate the internal code and display contents of BS%S. Sort the table according to company code and display contents. (etermine for each material type 9MTA+T: the A table entries with the highest gross weight 9as a ran"ed list:. To do this, read the table MA+A and store the material type 9MTA+T:, material number 9MAT.+:, unit of measure 9M&%.S: and gross weight 9B+6&$: into an internal table. Allow the user to specify the Material type as a parameter on the selection screen. Q 1reate a list of the ma#imum number of available seats for each carrier. To do this, read the table S'8%64T and store the airline carrier id 91A++%(: and ma#imum number of seats 9S&ATSMAK: in an internal table. (etermine the total number of seats for each airline carrier when filing the int table.

<

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 4" of 53

REPORTS
Intelligroup Asia Private Limited

+ead the table S'8%64T into an internal table and then output the internal table with the fields 1A++%(, '8(AT& and P+%1&. (elete all the internal table entries where the airline carrier 91A++%(: is not e)ual to 84. +ead the internal table with entry with the "ey 1A++%( @ 84 and 1-..%( @ >!>>, multiply the price by = and write the modified entry bac" to the internal table. Then -utput the internal table. +ead table TAB.A into internal table and output the fields C)(!tr6@ I&@ Na*$1@ a!& Sa.$,. S)rt t#$ ta'.$ 4 t# C)(!tr6 . (elete all internal table lines with sales lower than A>,>>>. +ead internal table with "ey ?6B and ?>>>>>>>= and multiply the sales by = and change table entry. %nsert any one record of your choice. 'ind out how many lines are there in the internal table. +emove all the contents of the table. (e/allocate the memory associated with table. 5se tables 8'A;, 8'B; and 8'M;. (efine an internal table with the following* 8ifnr li"e 8fa;/lifnr, Bu"rs li"e 8fb;/bu"rs, &"org li"e 8fm;/e"org. Add data from these table into the internal tables. Sort the internal table 8ifnr. +ead the internal table with 8ifnr @ ?AA and change name to trainee. Put bac" the record into the table. (elete first three records of internal table. 1lear header for internal table each time you access a record.

;> 1reate a report, which will give the e#isting stoc" for a material. The report should have subtotal of the stoc" for each storage location and 6rand total of the stoc" at the end of the plant. Plant data should start at new page. %nput* Selection screen which will allow one to select a range of materials. Materials* -utput +eport format as follows*
Updated on - Apr 20, 2004 Created on - Apr 20, 2004 Proprietary & Confidential

Page 4# of 53

REPORTS
Intelligroup Asia Private Limited

Plant

Storage location

Material number

(escription

Stoc" 9unrestricte d: BBBBBB

6rand total

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 50 of 53

REPORTS
Intelligroup Asia Private Limited

Tables and fields* Material .umber MA+A/MAT.+ (escription MA,T/MA,TK Plant MA+1/$&+,S Storage location MA+(/86-+T Stoc" MA+(/8ABST 5se Standard 'ormatting colors. &#ception handling* &rror message U Material not found U F if Material not present. ;; 6enerate a report to list the following details from the tables 8'A; C 8'B; vendor no., vendor name, city, state, telephone no., fa# no., company code and terms of payment. 5ser shall have options to select the vendor number range for which the report is generated. . +eport title* 3endor Master 8isting < 3endor .ame* IIIIIIIIIIIII IIIIIIIIIIIII Address* IIIIIIIIIIIIIIIIII Telephone no. IIIIIIIIIIIIIII IIIIIIIIIIIIII 1ompany code Terms of payments IIIIIIIIIIIII IIIIIIIIIIIIIIIII 3endor no. * 'a# no *

All te#t used in the report shall be generated using te#t elements only. The output list shall have a footer showing page no., date and %ntelligroup9left corner: ;< 6enerate a report for displaying material description, plant C storage data. %nput* Material number 9MA+A/MAT.+: (ata to be displayed for the following three materials only. ;. BPLL>M;A <. 'PAQLN>>=; =. 'P<OQA<>;; -utput format* ;; ;; ;NNO Material .o. 'PNQ!;<;>;
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

+eport to analy7e material stoc"s (escription Meditech Patterned $eld +od


Proprietary & Confidential

Page 51 of 53

REPORTS
Intelligroup Asia Private Limited

Plant ####

-atmeal Q> Storage 8oc. 5nrestricted stoc" ########### ###############

All te#ts are to be generated using Te#t &lements only. 5se tables* MA+A, MA,T, MA+1 and MA+(.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 52 of 53

REPORTS
Intelligroup Asia Private Limited

SUBROUTINES ;. +ead a number between > and ;>> and another digit between > and N. $rite a subroutine that will calculate the sum of all numbers 9below the limit: that end with the digit. The parameters to be passed are limit and digit both by value and sum by reference. &#. %f limit @ QL and digit @ ! then sum should be the sum of !,;!,<!,=!, ..Q!. <. $rite a subroutine 1&.T+&/ST+%.6, which will output a string on the center of a line. The subroutine will accept parameters ST+%.6 pass by value. $rite a program e#tensively using subroutines to print the e)uivalent number in words. 'or e#ample* if the number is QQ, the output should be S%KT0 S%K. 8imit the number range from > F NN. Accept the input number as a parameter. Accept a date from the user. $rite a date as dd/mm/yyyy where mm is month written as VA. '&B MarMetc. Ma"e use of subroutines. A 'or each flight connection, calculate the sales for all flights of an airline carrier. 5se internal table for calculating the sales. 5se a subroutine for the output by passing the internal table as the parameter.

=.

!.

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Proprietary & Confidential

Page 53 of 53

S-ar putea să vă placă și