List Programming

download List Programming

of 116

Transcript of List Programming

  • 8/12/2019 List Programming

    1/116

    Lists - Report Programming

    Selection screens are one of the three types of screen in the R/3 System, along with dialogscreens and lists. They are used to displaydata, and also allow user interaction. You create listsusing ABAP statements. They can e output to the screen, ut also to a printer.

    !nli"e screens, which contain defined elements li"e input/output fields and pushuttons, each ofwhich is identified y a name, and where data is e#changed with the ABAP program y means ofidentically$named fields, lists pro%ide a freely$definale area that you fill using the &R'T(, !)'*(+and S'P statements.

    Creating and Displaying Lists

    The ABAP statements that create lists actually create the list on the application ser%er, where it isuffered. The list is then displayed either when the )(A-( T )'ST$PR(SS'*0 statementoccurs in the program, or, for e#ecutale programs, automatically. 'n e#ecutale programs, thelist that you create is displayed 1at the latest2 after the last e%ent loc" in the program.

    &hen the list is displayed, the system calls the list processor, which displays the list on a specialcontainer screen 1numer 452. The container screen temporarily replaces the pre%ious screen ofthe calling program. 't inherits the same position, si6e, and 0!' status. 7owe%er, you can set aspecial 0!' status for list processing efore the list is displayed. 'n an e#ecutale program, thecontainer screen replaces the standard selection screen 1screen 5552, and automatically has thedefault list status.

    User Actions and Detail Lists

    &hen a list is displayed, the list processor has control of the program. 'nteracti%e user actions ona list trigger e%ents in the ABAP program. utput statements in these e%ent loc"s create detail

    lists, which are then automatically displayed at the end of the e%ent loc". You can create up to8 detail lists for a single asic list. 9etail lists temporarily replace the pre%ious list on thecontainer screen. A asic list and its detail lists form a list system of up to twenty le%els. !serscan na%igate etween the different le%els.

    http://locate.click%28%29/
  • 8/12/2019 List Programming

    2/116

    Lists and Screens

    :rom a screen, you can call the list processor and display up to twenty lists in a list system usingthe )(A-( T )'ST$PR(SS'*0 statement. &hen you start processing a screen, the listsystem is always initiali6ed. This means that all list output statements apply to the asic list, andthere are not yet any detail lists. 'f you start a new screen se;uenceduring list processing 1A))SR((* statement2, the list system of the original screen is retained. At the end of the screense;uence, the program returns to the last list le%el to ha%e een displayed.

    reating )ists

    !ser Actions and 9etail )ists

    )ists and Screens

    Printing )ists

    Creating Lists

    The following sections descrie how to create lists in ABAP. )ists are always displayed using theautomatic list display functions in e#ecutale programs.

    reating Simple )ists with the &R'T( Statement

    reating omple# )ists

    http://9fdbab0235c111d1829f0000e829fbfe/content.htmhttp://2f984e8274af11d295870000e8353423/content.htmhttp://9fdba2c435c111d1829f0000e829fbfe/content.htmhttp://9fdb9d2235c111d1829f0000e829fbfe/content.htmhttp://9fdba54635c111d1829f0000e829fbfe/content.htmhttp://9fdb9e1635c111d1829f0000e829fbfe/content.htmhttp://9fdb9f6535c111d1829f0000e829fbfe/content.htmhttp://locate.click%28%29/http://9fdbab0235c111d1829f0000e829fbfe/content.htmhttp://2f984e8274af11d295870000e8353423/content.htmhttp://9fdba2c435c111d1829f0000e829fbfe/content.htmhttp://9fdb9d2235c111d1829f0000e829fbfe/content.htmhttp://9fdba54635c111d1829f0000e829fbfe/content.htmhttp://9fdb9e1635c111d1829f0000e829fbfe/content.htmhttp://9fdb9f6535c111d1829f0000e829fbfe/content.htm
  • 8/12/2019 List Programming

    3/116

    Creating Simple Lists with the WRIT

    Statement

    This section descries how to create simple output lists on the screen. To do this, you use ABAPstatements &R'T(, !)'*( and S'P.

    This section includes the following topics is too short, fewer characters are displayed. *umeric fields aretruncated on the left and prefi#ed with an asteris" 1C2. All other fields are truncated on the right,ut no indication is gi%en that the field is shorter.

    *ATA# +m-er T&PE " A/E 012345678@, tet=0@ T&PE ( A/E 'a-()efh"C'.

    WRITE# =4 +m-er, ;=4 tet.This produces the following output is omitted.

    !S'*0 (9'T @AS =m> Specifies format template =m>.

    !S'*0 * (9'T @AS 9eacti%ates a format template specified in the ABAP 9ictionary.

    *$K(R 'f a field contains only 6eros, these are replaced y lan"s. :or type and * fields, leading 6eros are replaced automatically.

    $ormatting options #or numeric #ields

    "ption $unction

    *$S'0* The leading sign is not displayed on the screen.

    9('@A)S =d> =d> defines the numer of digits after the decimal point.

    (FP*(*T =e> 'n type : fields, the e#ponent is defined in =e>.

    R!*9 =r> Type P fields are multiplied y 5CC1$r2 and then rounded.

    !RR(*Y =c> :ormat according to currency =c> in tale T!RF.

    !*'T =u> The numer of decimal places is fi#ed according to unit =u> specifiedin tale T55E for type P fields.

    $ormatting options #or date #ields

  • 8/12/2019 List Programming

    9/116

  • 8/12/2019 List Programming

    10/116

    ; '@@@012' %OERO. 123

    *ATA float T&PE f A/E '012345678.@'.

    WRITE float EPO%E%T 2.

    123456,7893

    *ATA pa(9 T&PE p A/E '012.345' *E$IMA 2.

    WRITE pa(9 *E$IMA 1.

    WRITE# ; pa(9 RO/%* 1, ; pa(9 RO/%* 0, ; pa(9 RO/%* 0, ; pa(9 RO/%* 1.

    123,46

    12.345,6

    1.234,56

    12,346

    1,235

    WRITE# s)atm, ; s)atm mm)).

    27.6.1995

    95627

    Apart from the formatting options shown in the ao%e tales, you can also use the formattingoptions of the :R@AT statement. These options allow you to specify the intensity and color ofyour output. :or more information, see The :R@AT Statement.

    Displaying Sym&ols and Icons on the List

    You can output symols or R/3 icons on a list y using the following synta# as =length> lines.'f you specify the optional numer =n>, the system reser%es =n> lines of the page length for thepage footer. Those lines of the page footer that are not filled at the (*9$:$PA0( e%ent, appearas lan" lines 1see9efining a Page :ooter2.

    'f you set =length> to 6ero, the system uses the standard page length 1see The Standard )ist2. Toadapt the page length to the current window si6e, see )ists with Se%eral Pages.&hile the list iscreated, the system field SY$)'*T contains the current numer of lines per page 1that is=length>, or 5 for the standard page length2.

    onsider that the length of the page header is part of =length>. Thus, for the listitself you can use only =length> minus page header length minus =n> lines. 'f=length> is less than the page header length, a runtime error occurs.

    'f during list processing the system reaches the end of the area pro%ided for the actual list, itoutputs the page footer, if any, inserts some space, and starts a new page. The space insertedelongs to the list ac"ground and is not a line of the list. The SY$PA0* system field alwayscontains the current page numer.

    &hen determining the page length, "eep in mind the following points cane a %ariale. 'f you set =length> to 6ero, the system uses the standard page length 1Structure ofthe Standard )ist2. The page header is part of the page and thus of the page length.

    You cannot use *(&$PA0( to create or change a page footer. A page footerdefined in the R(PRT statement 1see 9etermining the Page )ength2is "ept assuch, independent of a *(&$PA0( statement.

    :or the actual list output, =length> minus the page header length and the page footer length isa%ailale.

    http://9fdb9f8c35c111d1829f0000e829fbfe/content.htmhttp://9fdb9f8c35c111d1829f0000e829fbfe/content.htmhttp://9fdba04235c111d1829f0000e829fbfe/content.htmhttp://9fdba04235c111d1829f0000e829fbfe/content.htmhttp://locate.click%28%29/http://9fdb9f8c35c111d1829f0000e829fbfe/content.htmhttp://9fdb9f8c35c111d1829f0000e829fbfe/content.htmhttp://9fdba04235c111d1829f0000e829fbfe/content.htm
  • 8/12/2019 List Programming

    35/116

  • 8/12/2019 List Programming

    36/116

    The first *(&$PA0( statement does not start a new page, since no output waswritten to the list efore. The standard page header uses two lines of each pagefor the list header. The page footer uses one line. :or the first 9 loop, two linesper page can e used to &R'T( output. All page rea"s within the 9 loop occurautomaticallyas soon as the list processing reaches the page footer. Thesystem then displays the page footer. The second *(&$PA0( creates a pagerea" from page 3 to . 7ere, the (*9$:$PA0( e%ent is not processed. :or thesecond 9 loop, three lines per page can e used to &R'T( output. Pagerea"s again occur automatically. The page footer appears.

    REPORT )emol"st+eDpael"+e(1 %O TA%*AR* PAGE HEA*I%G I%EIE 3@ I%E$O/%T@=1.

    TOPO?PAGE.

  • 8/12/2019 List Programming

    37/116

    WRITE# 'Top of Pae', spa+o, '&ROW#', ssroDs. /I%E.

    E%*O?PAGE.

    /I%E. WRITE# 'E+) of Pae', spa+o.

    TARTO?EE$TIO%.

    K %EWPAGE I%E$O/%T &ROW.

    *O 0@@ TIME. WRITE ; s"+)e. E%**O.

    This program creates one single endless page, since the *(&$PA0( statementis mar"ed as comment. 'f you specify the '*9(F option, the system scrolls the list of list le%el=id#>. :or more information on list le%els, see 'nteracti%e )ists.

    'f you specify the )'*( option, the system displays the page to which it scrolls starting from line=lin> of the actual list. 't does not count the page header lines.

    Scrolling &y a Speci#ic /um&er o# Pages

    To scroll a list y a specific numer of pages, use the following options of the SR)) statement lies outside the page, the suse;uent output statements are ignored.

    The system writes an output following the PS'T'* statement or a &R'T( statement formattedusing AT to the specified position, regardless of whether there is enough space. That part of theoutput that does not fit onto the line, is truncated. ther &R'T( output then starts on the ne#tline.

    *ertical Positioning

    http://9fdba11235c111d1829f0000e829fbfe/content.htmhttp://9fdba15335c111d1829f0000e829fbfe/content.htmhttp://9fdb9e3035c111d1829f0000e829fbfe/content.htmhttp://locate.click%28%29/http://9fdba11235c111d1829f0000e829fbfe/content.htmhttp://9fdba15335c111d1829f0000e829fbfe/content.htmhttp://9fdb9e3035c111d1829f0000e829fbfe/content.htm
  • 8/12/2019 List Programming

    48/116

    You specify %ertical output positions as followsdoes not lie etween and the page length, the system ignores the statement.

    &hen you use )'*(, the system also counts page header and page footer lines.@a"e sure that you do not unintentionally o%erwrite header or footer lines.

    Positioning "utput %eneath the Page (eader

    To position output on the first line following the entire page header, use the BA statement as numers. Therefore, they should e of data type '.'f the contents of =%ar"> is 6ero, the %ariale has the same effect as the :: option. 'f thecontents of =%ar"> is une;ual to 6ero, the %ariale either has the same effect as the * optionor, together with the )R option, acts li"e the corresponding color numer 1see olors in

    )ists2.

    'f you use the same formatting options for a &R'T( statement that follows the :R@ATstatement, the settings of the &R'T( statement o%erwrite the corresponding settings of the:R@AT statement for the current output.

    :or each new e%ent, the system resets all formatting options to their default%alues. :or a list of e%ents, see(%ents and their (%ent eywords. All formattingoptions ha%e the default %alue ::, e#cept the '*T(*S':'(9 option 1see olorsin )ists2.

    To set all formatting options to :: in one go, use you can set either a color numer or a color specification. 'nstead of colornumer 5, howe%er, you must use ::. 'f you set the color numers at runtime, all%alues of =c> that are less than 6ero or greater than se%en, lead to undefined results.The following tale summari6es the different possiilitiesmust e an entry in dataase tale T55E in column @S(7'. The entry in column 9(A* thendetermines the numer of decimal places of the field =f> to e displayed. 'f the system does notfind the entry =u> in tale T55E, it ignores the option.

    The following restrictions apply for this operation must e a pac"ed numer 1type P2.

    'f =f> has fewer decimal places than the unit =u>, the system ignores the option.

    'f =f> has more decimal places than the unit =u>, the system uses this option only, if the

    operation does not truncate any digits une;ual to 5.

    REPORT )emol"stDr"te+"t I%EIE 3@.*ATA# +m0 T&PE p *E$IMA 0 A/E 0, +m1 T&PE p *E$IMA 3 A/E '1.4'.ET $O/%TR& '/'.

    WRITE# 'FG', +m0 /%IT 'FG', +m1 /%IT 'FG', ; 'P$', +m0 /%IT 'P$', +m1 /%IT 'P$'.This program defines two pac"ed numers, *!@ with one decimal place and

    *!@4 with four decimal places. 'f the unit 0 1"ilograms2 has three decimalplaces in tale T55E and P 1pieces2 has 6ero decimal places in T55E, theoutput appears as follows statement. :or each f ield output using &R'T(M0R'9,the system draws a %ertical grid line to the right of the field and a hori6ontal grid line elow it. Thehori6ontal line dynamically adapts to the length of the field. The lines of all output fields togetherform a grid.

    REPORT )emol"str") I%EIE 5@ %O TA%*AR* PAGE HEA*I%G.

    TABE spfl".*ATA# T&PE ", T&PE ", l T&PE ".

    TOPO?PAGE. WRITE 2 '"st of ?l"hts "+ a *+am"( Gr")' $OOR $OHEA*I%G. /I%E.

    TARTO?EE$TIO%.

    *E?I%E +eDr"). N sl"++o. N 1. s9"p to l"+e . N s(ol+o. pos"t"o+ . Dr"te 'J'. E%*O?*E?I%ITIO%.

    *E?I%E Dr"ter"). N s(ol+o. N sl"++o. pos"t"o+ . Dr"te# 0, 'J'. l N s(ol+o 0. N 1. N 0. s9"p to l"+e . pos"t"o+ . l"+e at =l.

    http://9fdb972835c111d1829f0000e829fbfe/content.htmhttp://9fdb972835c111d1829f0000e829fbfe/content.htmhttp://9fdb972835c111d1829f0000e829fbfe/content.htmhttp://9fdb972835c111d1829f0000e829fbfe/content.htm
  • 8/12/2019 List Programming

    74/116

    N 0. N s(ol+o. s9"p to l"+e . pos"t"o+ . E%*O?*E?I%ITIO%.

    GET spfl".

    +eDr").

    Dr"ter")# spfl"(arr"), spfl"(o++"), spfl"("tfrom, spfl"("tto.

    The functions of the macros *(&M0R'9 and &R'T(M0R'9 defined in the ao%eprogram are demonstrated in the output elow. :or information on macros, see@acros. The e#ecutale program is connected to the logical dataase :S. Afterthe user has entered the corresponding %alues on the selection screen, theoutput may appear as follows 1osolete2

    AT )'*($S()(T'*

    AT !S(R$@@A*9

    'f you ha%e written the corresponding e%ent loc"s in your program, they are e#ecuted. You canaccess the function code in the system field SY$!@@.

    http://locate.click%28%29/
  • 8/12/2019 List Programming

    79/116

    The output from any list statements that you write in these e%ent loc"s is written to detail lists.&ith one ABAP program, you can maintain one asic list and up to 8 detail lists.9etail )ists9ialog Status for )istsonte#t @enus for )ists)ist (%ents in an ABAP Program)ists in 9ialog Bo#esPassing 9ata from )ists to Programs@anipulating 9etail )ists

    Detail Lists

    &hen the system processes e%ent loc"s that are notassigned to interacti%e list e%ents, andwhen processing dialog modules, the ABAP program writes its list output to the asic list.

    TheABAP system fieldSY$)S'*9 contains the inde# of the list currently eing created. &hile the

    asic list is eing created, SY$)S'*9 is 6ero.

    By default, the asic list has a standard list status and a standard page header. The TP$:$PA0( and (*9$:$PA0( e%ents can occur while the asic list is eing created. All output inthese e%ents is placed in the page header or footer of the asic list. 'n e#ecutale programs, theasic list is automatically sent to the list processor and displayed at the end of the (*9$:$S()(T'* e%ent. therwise, it is displayed after the PA' processing loc" on the screen fromwhich the )(A-( T )'ST$PR(SS'*0 statement occurred.

    Creating Detail Lists

    (ach time the user e#ecutes an action on a list, the runtime en%ironment chec"s whether there is

    an e%ent loc" defined that corresponds to the function code. 'f there is, SY$)S'*9 isautomatically increased &y one, and the rele%ant e%ent loc" is e#ecuted. Any list outputarising during this e%ent loc" places its data into a new list 1list le%el2 with the inde# SY$)S'*9.'n order to create a new list le%el, the 0!' status of the asic list must allow user actions, and therele%ant e%ent loc"s must e defined in the program.

    Alllists created during an interacti%e list e%ent are detail lists. (ach interacti%e list e%ent creates anew detail list. &ith one ABAP program, you can maintain one asic list and up to 45 detail lists.'f the user creates a list on the ne#t le%el 1that is, SY$)S'*9 increases2, the system stores thepre%ious list and displays the new one. The user can interact with whiche%er list is currentlydisplayed.

    The system displays this list after processing the entire processing loc" of the e%ent "eyword or

    after lea%ing the processing loc" due to (F'T or 7(. By default, the new list o%erlays thepre%ious list completely. 7owe%er, you can display a list in a dialog o#.'f no other dialog statusis set in the e%ent loc" for the detail list, the system uses the status from the pre%ious list le%el.7owe%er, there is no standard page header for detail lists 1see elow2.

    Conse2uences o# +ent Control

    http://9fdba2eb35c111d1829f0000e829fbfe/content.htmhttp://9fdba34635c111d1829f0000e829fbfe/content.htmhttp://ac523b6d4e6611d3b96c0000e8353423/content.htmhttp://9fdba3ae35c111d1829f0000e829fbfe/content.htmhttp://9fdba3d535c111d1829f0000e829fbfe/content.htmhttp://9fdba3ef35c111d1829f0000e829fbfe/content.htmhttp://9fdba46435c111d1829f0000e829fbfe/content.htmhttp://7bfb96c8882811d295a90000e8353423/content.htmhttp://7bfb96c8882811d295a90000e8353423/content.htmhttp://9fdba3d535c111d1829f0000e829fbfe/content.htmhttp://9fdba3d535c111d1829f0000e829fbfe/content.htmhttp://locate.click%28%29/http://9fdba2eb35c111d1829f0000e829fbfe/content.htmhttp://9fdba34635c111d1829f0000e829fbfe/content.htmhttp://ac523b6d4e6611d3b96c0000e8353423/content.htmhttp://9fdba3ae35c111d1829f0000e829fbfe/content.htmhttp://9fdba3d535c111d1829f0000e829fbfe/content.htmhttp://9fdba3ef35c111d1829f0000e829fbfe/content.htmhttp://9fdba46435c111d1829f0000e829fbfe/content.htmhttp://7bfb96c8882811d295a90000e8353423/content.htmhttp://9fdba3d535c111d1829f0000e829fbfe/content.htm
  • 8/12/2019 List Programming

    80/116

    The fact that you program detail lists in e%ent loc"s has important conse;uences. You cannotnest processing loc"s 1see Structure of an ABAP Program2. Therefore, you cannot processother e%ents within the processing loc"s of interacti%e lists.

    (specially, you cannot

    use separate processing loc"s to process further interacti%e e%ents. A certain useraction always triggers the same processing loc" in your program. You must use controlstatements 1':, AS(2 within the processing loc" to ma"e sure that the systemprocesses the desired statements. There is a range of system field that you can use forthis.

    use the e%ent TP$:$PA0( to influence the list structure of secondary lists. To layout

    the page headers of the secondary lists, you must use the e%ent TP$:$PA0(9!R'*0 )'*($S()(T'* 1see elow2. 7owe%er, the system does process the e%ent(*9$:$PA0( in secondary lists.

    use e%ents such as 0(T and 0(T )AT( to retrie%e data for secondary lists, ut must use

    S()(T statements. You can use the logical dataase assigned to the e#ecutaleprogram 1report2 only for the asic list. 'f you want to use a logical dataase duringinteracti%e e%ents, you must either callanother e#ecutale program using S!@'T, or

    1etter2 call the logical dataaseusing a function module.

    /a+igating in ListsTo return from a high list le%el to the ne#t$lower le%el 1SY$)S'*92, the user can choose Bac+froma detail list. The system releases the last list to ha%e een displayed, and returns to the pre%iouslist le%el. The system deletes the contents of the released list.To determine the list le%el in which the output from an e%ent loc" will e displayed, you canchange the %alue of the system fields SY$)S'*9. This is one of the few e#ceptions to the rule thatstates that you must ne%er o%erwriteABAP system fields. The system accepts only inde# %alueswhich correspond to e#isting list le%els. 't then deletes all e#isting list le%els whose inde# isgreater or e;ual to the inde# you specify. :or e#ample, if you set SY$)S'*9 to 5, the systemdeletes allsecondary lists and o%erwrites the asic list with the current secondary list.&hen you change SY$)S'*9, the change only ta"es effect at the end of the corresponding e%ent.'f you wor" with statements that access the list with inde# SY$)S'*9 1using the '*9(F addition $for e#ample, SR))2, you should set the new %alue of SY$)'S*9 after these statements. Theest place to set it is in the last statement of the e%ent loc".

    System $ields #or Details ListsAfter each user action on a list, the followingABAP system fieldswill e set in the correspondinge%ent loc", the system automaticallyassigns e#tra functions to other function "eys that pro%ideadditional functions.

    AT P:=nn> 1osolete2

    All function "eys of the "eyoard "%%that are not used for predefined system functions,are set to the function codes P:=nn>, where =nn> is a numer etween 5 and 4.9uring list processing, the function codes P:=nn> are lin"ed to the e%ents AT P:=nn>.Choosing P$0nn1 always triggers AT P$0nn1.You should no longer use e%ent loc"sfor P:=nn>.

    AT )'*($S()(T'*

    :or this e%ent, the :4 "ey 1doule$clic"2 is assigned the function code P' and functioncode %hoose. The function also always appears in the application toolar. 9uring listprocessing, the P' function code is assigned to the e%ent AT )'*($S()(T'*. PIC3always triggers AT LI/-SLCTI"/.

    All other function codes are either intercepted y the runtime en%ironment or trigger the e%ent AT!S(R$@@A*9. :unction codes that trigger AT !S(R$@@A*9 must e defined in yourown 0!' status. The easiest way to do this is to use the standard list status and add e#trafunctions of your own to it.

    Dialog Status #or ListsYou can create a dialog status for a list using the @enu Painterin theABAP &or"ench. As soon

    as you create the status, you should choose ExtrasAd,ust templateand select )ist statusfor

    http://540608162d0711d295520000e8353423/content.htmhttp://540608162d0711d295520000e8353423/content.htmhttp://9fdb9d2f35c111d1829f0000e829fbfe/content.htmhttp://9fdb9d2f35c111d1829f0000e829fbfe/content.htmhttp://9fdb9f7235c111d1829f0000e829fbfe/content.htmhttp://link48.click%28%29/http://link49.click%28%29/http://locate.click%28%29/http://540608162d0711d295520000e8353423/content.htmhttp://9fdb9d2f35c111d1829f0000e829fbfe/content.htmhttp://9fdb9f7235c111d1829f0000e829fbfe/content.htmhttp://link48.click%28%29/http://link49.click%28%29/
  • 8/12/2019 List Programming

    85/116

    your template. This status already contains standard function codes for list processing. They aredistriuted as follows on the menus, standard toolar, and application toolar pages

    PPD=n> Scroll forward one list page or =n> pages

    PS=n> Scroll to column =n>

    PS$$ Scroll to first column of the list

    PS$=n> Scroll left y one or =n> columns

    PSD=n> Scroll right y one or =n> columns

    PSDD Scroll to last column of the list

    PK=n> Scroll to line =n>

    P)$=n> Scroll ac" to first line of the page or y =n> lines

    P)D=n> Scroll to last line of the page or y =n> lines

    /.... :or other system commands

    The runtime en%ironment directly ;ueries and processes all function codes of the ao%e tales,e#cept P' and P:=nn>. These function codes do not trigger e%ents, and you cannot use themfor the AT !S(R$@@A*9 e%ent.The function code P' triggers the AT )'*($S()(T'* e%ent, whene%er the cursor is

    positioned on a list line. The function codes P:=nn> always trigger the AT P:=nn> e%ent.Therefore, you cannot use them for the AT !S(R$@@A*9 e%ent either.To trigger AT !S(R$@@A*9, you can define any numer of function codes yourself. 'f theydo not ha%e a function code listed in the ao%e tale, they will trigger AT !S(R$@@A*9. *otethe following special function "ey assignments

    http://ac523b6d4e6611d3b96c0000e8353423/content.htmhttp://ac523b6d4e6611d3b96c0000e8353423/content.htmhttp://ac523b6d4e6611d3b96c0000e8353423/content.htmhttp://ac523b6d4e6611d3b96c0000e8353423/content.htm
  • 8/12/2019 List Programming

    88/116

    must e a component of the current ABAP program, unless you use the : PR0RA@ additionin the S(T T'T)(BAR statement to set a 0!' status of another program =prog>.You can use the &'T7 option of the S(T T'T)(BAR statement to replace these placeholders inthe title at runtime with the contents of the corresponding fields =g0> .... =g8>. The system alsoreplaces N placeholders in succession y the contents of the corresponding =g"> parameters.To display an ampersand character UNG, repeat it in the title UNNG.

    !amples

    (#ample for dialog status in a list.REPORT )emol"stme+pa"+ter.TARTO?EE$TIO%. ET P?TAT/ 'TET'. WRITE# 'Bas"( l"st, &I%* N', sls"+).

    AT I%EEE$TIO%. WRITE# 'I%EEE$TIO%, &I%* N', sls"+).

    AT /ER$OMMA%*. $AE s(omm. WHE% 'TET'.

    WRITE# 'TET, &I%* N', sls"+). E%*$AE.This program uses a status T(ST, defined in the @enu Painter.

    1. :unction "ey "5has the function code !ES!and the te#t !est for demo.

    4. :unction code T(ST is entered in the )ist menu.3. The function codes P' and T(ST are assigned to pushuttons.

    The user can trigger the AT !S(R$@@A*9 e%ent either y pressing "5, ory choosing )ist !est for demo, or y choosing the pushutton !est fordemo.The user can trigger the AT )'*($S()(T'* e%ent y selecting a line.

    (#ample of setting a dialog status for the current list

    REPORT )emol"stsetpfstats0.*ATA# f(o)e T&PE TABE O? s(omm, Daf(o)e T&PE s(omm.TARTO?EE$TIO%. Daf(o)e N '?$0 '. APPE%* Daf(o)e TO f(o)e. Daf(o)e N '?$1 '. APPE%* Daf(o)e TO f(o)e. Daf(o)e N '?$2 '. APPE%* Daf(o)e TO f(o)e. Daf(o)e N '?$3 '. APPE%* Daf(o)e TO f(o)e. Daf(o)e N '?$4 '. APPE%* Daf(o)e TO f(o)e. Daf(o)e N 'PI$F'. APPE%* Daf(o)e TO f(o)e. ET P?TAT/ 'TET'. WRITE# 'P?tats#', spf9e.

    AT I%EEE$TIO%.

    I? sls"+) N 1@. ET P?TAT/ 'TET' E$/*I%G f(o)e. E%*I?. WRITE# '"+eele(t"o+, &I%*#', sls"+), ; ' &P?FE', spf9e.

    AT /ER$OMMA%*. I? sls"+) N 1@. ET P?TAT/ 'TET' E$/*I%G f(o)e. E%*I?.

  • 8/12/2019 List Programming

    89/116

    WRITE# '/ser$omma+), &I%*#', sls"+), ; ' &/$OMM#', s(omm, ; ' &P?FE', spf9e.Suppose that the function codes : to :O are defined in the status T(ST andassigned to pushuttons< The function code P' is assigned to function "ey "2.&hen the program starts, the user can create detail lists y selecting a line orchoosing one of the function codes : to :O. :or all secondary lists up to le%el45, the user interface T(ST is the same as for the asic lista))f+(t"o+ EPORTI%G f(o)e N 'BA$F' tet N tet@@1. E%*I?.E%*?ORM.

    'n the dialog status BAS' for the asic list, TF is assigned to &+i(#"1. 'nthe callac" routine, a conte#t menu is defined. The definition depends on thecursor position and the list currently displayed.

    'f the user right$clic"s the two$line default page header on the asic list, thesystem displays a single$line conte#t menu. The Bac+function is e#ecuted y theruntime en%ironment. 'f you right$clic" a list line, a two$line conte#t menu isdisplayed. The $etailfunction triggers the e%ent AT !S(R$@@A*9.

    List +ents in an A%AP ProgramAfter a user interaction on a list, the ABAP runtime en%ironment chec"s whether it should processthe function code itself 1for e#ample, (F or P2, or whether it should trigger the rele%ante%ent. !nli"e normal screens, in which the PA' e%ent is triggered, the runtime en%ironmenttriggers three special e%ents when list e%ents occur. You can use the corresponding e%ent loc"sin your ABAP program to react to the user action. :rom within the program, you can use the SY$!@@ system field to access the function code. There is no M9( field that is filled.

    +ent %loc's #or $unction Codes P$0nn1 4"&solete5

    &hen the user chooses a function code P:=nn> 1=nn> can e etween 5 and 42, the system

    always triggers the AT P:=nn> e%ent. 'n the standard list status, the function "eys "%%that arenot reser%ed for predefined system functions all ha%e the function code P:=nn> as long as acorresponding e%ent loc" is defined in the program.

    AT P?..

    These e%ent loc"s are e#ecuted when the user chooses the corresponding function "ey. Theposition of the cursor in the list is irrele%ant.

    http://locate.click%28%29/
  • 8/12/2019 List Programming

    92/116

    'f you use these e%ent loc"s at all, it should only &e #or temporary test +ersions. 'n productionprograms, you should only use AT !S(R$@@A*9 with a dialog statusof your own to assignfunction codes to function "eys. &hen you use your own interfaces, the system displays afunction te#t e#plaining what the function does. This does not happen when you use AT P:=nn>e%ent loc"s.

    +ent %loc' #or $unction Code PIC3

    &hen the user triggers the function code P', AT )'*($S()(T'* is always triggered if thecursor is positioned on a list line. The function code P' is, y default, always lin"ed withfunction "ey "2and hence with the mouse doule$clic". onse;uently, if you ha%e a simpleprogram that does not react to any further user actions, you only need to write this e%ent loc".

    AT I%EEE$TIO%. .

    As descried in the section 9ialog Status for )ists,the function code P' is always added to thestandard list status when you ha%e an AT )'*($S()(T'* e%ent in your program.

    'f you assign P' to other function "eys or menu entries, AT )'*($S()(T'* is also triggeredwhen the user chooses then. You should a%oid this for the sa"e of the semantics.

    on%ersely, if you ha%e a more e#tensi%e program that does not react to line selection, youshould not use the function code P'. 'nstead you should assign a different function code to "2,to ensure that as many e%ents as possile trigger the AT !S(R$@@A*9 e%ent.

    +ent %loc' #or User-De#ined $unction Codes

    'f the user chooses a function code during list processing that is neither processed y the system,or P' or P:=nn>, the system triggers the e%ent AT !S(R$@@A*9. :or this e%ent, youmust define your own 0!' status for a list. To react to your own function codes in a program, youmust define the following e%ent loc" e#ists, the system sets SY$S!BR to 5, otherwise to .The options ha%e the following effects '*T =g0> ... =f n> '*T =g n>

    The system interprets the output %alues of the %ariales =f"> in line =lin> as characterstrings and places them either into the same fields =f"> or, when using '*T, into thefields =g">.&hen refilling the fields, the system applies the con%ersion rules.:ields that do not appear in a line do not affect the target field. 'f a field appears se%eraltimes in a line, the system uses only the first one.The system transports the field contents using the output format, that is, including allformatting characters. This may cause prolems, such as con%erting editing characters todecimal characters or other incompatile cases.You use this option mainly to process user entries in list fields that accept input, sinceyou cannot use the 7'9( techni;ue in this case.

    : !RR(*T PA0(

    &ith this option, =lin> is not the numer of the line of the entire list, ut the numer of theline of the currently displayed page of the addressed list. The system field SY$PA0(stores the corresponding page numer.

    : PA0( =p>

    &ith this option, =lin> is not the numer of the line of the entire list, ut the numer of aline on page =p> of the addressed list.

  • 8/12/2019 List Programming

    104/116

    This statement reads a line twice in succession. To do this, you use the R(A9 !RR(*T )'*(statement in your program contains the position of the cursor within the list line. 'f the cursor is on thefirst column, =off> H 5.

    -A)!( =%al>

    The field =%al> contains the character string output representation of the line on whichthe cursor is positioned. The representation includes formatting characters.

    )(*0T7 =len>

    The field =len> contains the output length of the line on which the cursor is positioned.

  • 8/12/2019 List Programming

    106/116

    REPORT APMTT %O TA%*AR* PAGE HEA*I%G I%EIE 3@.*ATA# HOTPOT=0@ A/E '$l"(9 me!', ?=0@, O?? T&PE I, I% T&PE I, A=3@, E% T&PE I.?IE*&MBO

  • 8/12/2019 List Programming

    107/116

  • 8/12/2019 List Programming

    108/116

    TOPI%E top TITEI%E t"t HEA*I%E hea) E%*I%E e+). WRITE# 'Propert"es of Pae', =0 pa, '#', ; 'W")th# ', (ol, ; 'e+th# ', le+, ; '"+es# ', l"+, ; '?"rst "+e# ', l"+0, ; 'Pae Hea)er# ', top, ; 'T"tle "+es# ', t"t, ; 'Hea)er "+es#', hea), ; '?ooter "+es#', e+).This program creates a two$page list of fi%e lines per page. Two lines are usedfor the self$defined page header and one line for the page footer. 'f the userselects a line, a dialog o# appears containing the list attriutes.&hile creating the secondary list, all %ariants of the 9(SR'B( )'ST statementapply to the asic list. The system displays the results in the dialog window. Thelines and pages to e descried are addressed dynamically using SY$)'))'.

    anipulating Detail Lists

    This section descries how you can manipulate the appearance and attriutes of detail lists.

    Scrolling through 9etail )ists

    Set the ursor from within the Program

    @odify )ist )ines

    Scrolling in Detail Lists

    You can scroll in a detail list using the SR)) statement. The Scrolling in )istssection containsa full description of the statement and how to use it for asic lists.

    &hen you use the SR)) statement with detail lists, you must rememer the following to specify line =n> of the list le%el with the inde# =id#>.V !se : !RR(*T PA0( to specify line =n> of the currently displayed page1page numer SY$PA0(2 .

    V !se : PA0( =p> to specify line =n> of page =p>.You can refer to the line most recently read in the list line with the current contentsof the fields =f"> or =g">. 'f necessary, the system con%erts the field type to type .'f a field =f"> occurs more than once in the line, the system modifies only the first. 'f a field =f">

    does not occur in the line at all, the system ignores the option.The system modifies e#isting fields =f"> regardless of the current contents you write from SY$)'S() into the line. 'f you made changes to the line at the output position of a f ield =f"> usingSY$)'S(), the :'()9 -A)!( option o%erwrites them.

    Changing $ield $ormattingTo modify the formatting of fields in the line you want to change, use the option :'()9 :R@ATof the @9':Y statement as follows. You can specify formats from the :R@AT statement in=options">.The option :'()9 :R@AT o%erwrites the specifications of the )'*( :R@AT option for thecorresponding field1s2. 'f a field =f"> occurs more than once in the line, the system modifies onlythe first. 'f a field =f"> does not occur in the line at all, the system ignores the option.

    !amples

    (#ample of line formatting.REPORT )emol"stmo)"fl"+eformat I%EIE 3@ %O TA%*AR* PAGEHEA*I%G.*ATA ( T&PE " A/E 0.

    WRITE 'ele(t l"+e to mo)"f the -a(9ro+)'.AT I%EEE$TIO%. I? ( N 7. ( N @. E%*I?. MO*I?& $/RRE%T I%E I%E ?ORMAT $OOR N (. A** 0 TO (.This program creates an output line whose ac"ground color the user canchange y selecting the line again and again