table popin _ team abap

34
Arun krishnamoorthy Wednesday, May 14, 2014 Popins are Insertion between the rows of the table. There are two kinds of Popins. 1. Row popin 2. Cell Popin Popins are linked to a table for row popin where as popins are linked to a table column for a cell popin. With a cell popin an associated background color of the popin is assigned to the cell so that we can see which cell does this popin belongs to. TABLE POPIN

Upload: ajit-keshari-pradhan

Post on 12-Sep-2015

242 views

Category:

Documents


6 download

DESCRIPTION

sap

TRANSCRIPT

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 1/34

    Arun krishnamoorthy Wednesday, May 14, 2014

    PopinsareInsertionbetweentherowsofthetable.TherearetwokindsofPopins.1.Rowpopin2.CellPopinPopinsarelinkedtoatableforrowpopinwhereaspopinsarelinkedtoatablecolumnforacellpopin.

    Withacellpopinanassociatedbackgroundcolorofthepopinisassignedtothecellsothatwecanseewhichcelldoesthispopinbelongsto.

    TABLE POPIN

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 2/34

    SAPhasprovidedaUIelementTablePopinToggleCelltoprovidetheexpansionandclosingofthetablePopin.ThisTablePopinToggleCellisacellvariantandallwehavetodoistosimplyinsertitinatablecolumnandsettheselectedcellvariantofthetablecolumnandthevariantkeyofthetablepopintogglecellwithacommonvalue,butitshouldnotbenull.

    ApartfromthistheroottableUIelementpropertyselectedpopinmustbebindedtotheattributeoftypestring,sothatwheneveratablepopintogglecellisselectedinaparticularrowthesystemwillprovideavaluetablepopintotheattributebindedtotheselectedpopin.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 3/34

    RefertotheURLformoredetailsonTablePopin.http://help.sap.com/saphelp_erp2005/helpdata/en/23/5e9041d3c72e7be10000000a1550b0/content.htmNowletusseeasimpleapplicationtodemonstratethetablepopin.PartIStep1:GotoSE80andCreateawebdynproComponent.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 4/34

    Assignittoapackageorsaveitinalocalobject.

    Step2:Inthecomponentcontroller,createanodeEKKOandEKPOasshownbelow.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 5/34

    Ifyouwanttoaddattributesfromadictionarystructureortablethenprovidethetablenameorstructureinthedictionarystructureandclickontheaddattributesformthestructure.

    Selecttherequiredfieldsfromthepopupwhichcontainsthefieldsofthedictionarystructureprovidedbyyou.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 6/34

    Theselectedattributeswillbeaddedtoyourcontextnode.

    SimiliarlycreateanothernodeEKPOwithcardinality0..n.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 7/34

    Step3:NowgototheviewlayoutandinsertthetableUIelementasshownbelow.Rightclickontherootcontaineruielementandselectinsertelement.

    ProvidetheIDfortheUIelementandchoosethetypeastable.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 8/34

    Step4:RightclickonthetableUIelementandselecttheinserttablecolumnoption.ThisparticularcolumnwhichweareaddingnowisforthetablepopintogglecellwhichIhadmentionedaboveintheblog.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 9/34

    Rightclickontheinsertedtablecolumnandaddacellvarianttothecolumn.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 10/34

    Selectthecellvariantasatablepopintogglecell.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 11/34

    Step5:RightclickonthetableUIelementandselectcreatebindingtoaddthecolumnstothetablefromthecontextnode.

    Clickonthecontextbuttontochoosethecontextnode.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 12/34

    SelectthecontextnodeEKKOandpressenter.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 13/34

    Keepthecelleditorasthetextviewandpressenter.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 14/34

    Youllnowbeabletoseetheeverycolumnbindedexcepttheonewhichwehavecreatedforthetablepopin.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 15/34

    Step6:GotothemethodDOINITtoinitializesomevaluesforthenodeEKKO.

    UsingcodewizardsetthenodeEKKOasatableoperationandbindsomerecordstothenode.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 16/34

    Codewillbegeneratedbythesystemasbelow.

    SelectsomerecordsformtheEKKOtableandbindit.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 17/34

    Step7:Createawebdynproapplicationtotestthecomponent.

    Youwillseetheoutputinthetablewepopulatedandourtablepopincolumnremainsempty.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 18/34

    PartIIStep8:Sofarwehaveonlyseehowtodisplaytherecordsinthetable.Nowletusseehowtoaddtablepopin.Inthetablepopincellvariantwhichwehavecreatedinthetablepopincolumprovidethevariantkeyaskeyforexample.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 19/34

    Inthetablecolumnofthecellvariantchangethepropertiesasbelow.Changethefixedpositiontotheleftsothatourpopinwillalwaysoccupytheleftposition.Providethevariantkeynameintheselectedcellvariantsothatthiscolumnwillcometoknowithasatablepopinassociatedtoit.

    .Ifyoutesttheapplicationnowatthisstageitwillgoforadump

    Thereasonbehindthisiswheneverwehaveaddedavarianttothetablepopin,thesystemwill

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 20/34

    returnavalueTABLEPOPINtoidentifyinwhichrowthetablepopinhasbeenselected.Tocapturethisvalueforeveryrowitemweneedtocreateaattributeinourcontextnodeforthetable.Gotothecontextnodeandaddanattribute.Note:IfthecontextnodestillhavethestructureEKKOitwillnotallowyoutoaddtheattribute,Inthatcaseremovethedictionarystructurefromthenodeandthenaddtheattribute.

    Createanattributetable_popinoftypestring.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 21/34

    IntherootofthetableUIelement,Bindtheattributetable_popintothepropertyselectedpopin.Sothatwheneverapopinisselectedfromaparticularrowthesystemwillreturnavaluetotheattributetable_popinwithTABLEPOPIN.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 22/34

    Nowinsertatablepopinbyrightclickingonthetableuielementandchoosingtheinserttablepopinoption.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 23/34

    Ifyoutestyourapplicationnow,youwillbeabletoseethetablepopincolumnintheleftsideofthetable.

    Nowwewillbeneedinganeventhandlermethodforhandlingwhatneedstobedoneontheselectionoftablepopin.Gotothetablepopincellvariantandcreateaneventontoggleasshownbelow.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 24/34

    InthistogglemethodwewillwritethelogicforwhathastohappenonselectionoftheTablepopin.BeforewritingalogicweneedtoaddsomeUIelementslikewhatistobedisplayedontheexpansionofthetabelpopin.Rightclickonthetablepopinandselectinsertcontent.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 25/34

    InsertatransparentcontainerUIelementandandtabletodisplaythecontentsoftheEKPOtable.

    Similiarlyinsertthetableuielementinasimilarway.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 26/34

    BindthenodeEKPOtothetablecreatedinsidethecontainer.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 27/34

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 28/34

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 29/34

    AfterBindingwritethefollowingcodeinthetogglemethod.methodonactionontoggle.

    *readthecontextnodeekko.

    datalo_nd_ekkotypereftoif_wd_context_node.

    datalt_ekkotypewd_this>elements_ekko.

    datals_ekkolikelineoflt_ekko.

    *navigatefromtovialeadselection lo_nd_ekko=wd_context>get_child_node(name=wd_thiswdctx_ekko).

    lo_nd_ekko>get_static_attributes_table(importingtable=lt_ekko).

    *toknowwhichrowhasbeenselected,readthetablewithkeytable_popin. *table_popinistheattributeboundedtotheselectedpopinpropertyofthetable *anditreturnsanvaluetablepopintothatfieldwhichyoucanseeindebugger.

    readtablelt_ekkointols_ekkowithkeytable_popin='tablepopin'.

    *nowpopulatetheitemtableforthecorrespondingheadervalueandsetitinthecontextnode.

    datalo_nd_ekpotypereftoif_wd_context_node.

    datalt_ekpotypewd_this>elements_ekpo.

    *navigatefromtovialeadselection lo_nd_ekpo=wd_context>get_child_node(name=wd_this>wdctx_ekpo).

    select*fromekpointocorrespondingfieldsoftablelt_ekpowhereebeln=ls_ekkoebeln.* lo_nd_ekpo>bind_table(new_items=lt_ekposet_initial_elements=abap_true).

    endmethod.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 30/34

    Nowtestyourapplication.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 31/34

    Thetablepopindoesntcloseautomaticallyandthepreviouslyselectedvaluesisdisplayedforallthepopinthereasonbehindthisisthefirstrowwhenitwasselected,thetable_popinattributewillbesetastablepopinandwhenweselectthesecondrowsecondrowtable_popinwillalsosetastablepopinbutwhenwereadthetableusingthevaluetablepopinitwillalwayspickthefirstrowwhichhavethetablepopin.Todifferentiatethepreviouslyselectedpopinandnewlyselectedpopinweneedaflag.CreateaflaginthecontextnodeEKKOasshownbelow.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 32/34

    Nowmodifythecodeasshownbelow.WhatIhavedoneiseverytimewhenatablepopinissetaattributetable_popinIamsettingaflagalongwithit.Nexttimewhentheotherpopinisselected,Iamfirstcheckingforthepreviouslyselectedpopinwiththecombinationoftablepopinandflagx.IfpreviousvalueinthatcombinationisavailableIamclearingitandreadingthecurrentlyselectedpopinwiththevaluetablepopinandsettingtheflagasxtothenewvalue.Whenyouremovethetablepopinvaluefromtheattributethattablepopinwillbeclosed.methodonactionontoggle.

    *readthecontextekko.

    datalo_nd_ekkotypereftoif_wd_context_node.

    datalt_ekkotypewd_this>elements_ekko.datals_ekkolikelineoflt_ekko.

    *navigatefromtovialeadselection lo_nd_ekko=wd_context>get_child_node(name=wd_this>wdctx_ekko).

    *@todohandlenonexistantchild *iflo_nd_ekkoisinitial. *endif.

    lo_nd_ekko>get_static_attributes_table(importingtable=lt_ekko).

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 33/34

    readtablelt_ekkointols_ekkowithkeytable_popin='tablepopin' flag='x'.data:lv_tabixtypesytabix.ifsysubrc=0. lv_tabix=sytabix.clear:ls_ekkotable_popin,ls_ekkoflag.modifylt_ekkofromls_ekkoindexlv_tabix.clearlv_tabix.endif.

    readtablelt_ekkointols_ekkowithkeytable_popin='tablepopin'.

    ifsysubrc=0. lv_tabix=sytabix.ls_ekkoflag='x'.modifylt_ekkofromls_ekkoindexlv_tabix.datalo_nd_ekpotypereftoif_wd_context_node.

    datalt_ekpotypewd_this>elements_ekpo.

    *navigatefromtovialeadselection lo_nd_ekpo=wd_context>get_child_node(name=wd_this>wdctx_ekpo).

    select*fromekpointocorrespondingfieldsoftablelt_ekpowhereebeln=ls_ekkoebeln.* lo_nd_ekpo>bind_table(new_items=lt_ekposet_initial_elements=abap_true).

    endif.

    lo_nd_ekko>bind_table(new_items=lt_ekkoset_initial_elements=abap_true).

    endmethod.

    Nowtesttheapplication.

  • 05/07/2015 TablePopin~TeamABAP

    http://www.teamabap.com/2014/05/tablepopin.html 34/34