5

Click here to load reader

WebDynpro for ABAP Cell Variants

Embed Size (px)

DESCRIPTION

WebDynpro for ABAP Cell Variants

Citation preview

  • Added by Keith Mayerle, last edited by Craig Cmehil on Dec 28, 2009

    Welcome, GuestLoginRegister

    Getting StartedNewslettersStore

    SolutionsServices & SupportAbout SCNDownloadsIndustriesTraining & EducationPartnershipDeveloper CenterLines of BusinessUniversity AlliancesEvents & WebinarsInnovation

    WebDynpro for ABAP Cell Variants

    Cell Variants can be used to put different Cell Editors into different rows of a single column.

    In this Table, two of the Region Column Cells have DropDown by Key editors, while the other two Cells have read-only Input Field editors.

    To build a WebDynpro Component that will display this Table, follow the example below.

    The example program has just one default View: MainIn the Main View Context, create a Node and Attributes as shown. The Variant attribute will not display data in the table; it will be used to control the Cell Editor in the Region Column of each row. TheSupply Function LOADORDERS will fill our table and also determine the Cell Variant for each table row.

    Set these Types for the Attributes:

    Attibute Type

    orders aufnr

    division string

    region string

    variant char10

    Add these elements as shown to the Layout for Main. The Cell Editors for the Order and Division Columns are read-only InputFields. No Cell Editor for the Region column yet - we need to add theCell Variants first.

    SAP Community Network Wiki - Web Dynpro ABAP - WebDynpro f... http://wiki.sdn.sap.com/wiki/display/WDABAP/WebDynpro+for+A...

    1 de 5 20/03/2013 17:57

  • International Orders do not have a Regionselection, so our first Variant will contain aread-only InputField Cell Editor -- right-click theRegion Column and choose Insert Cell Variant

    Give the Cell Variant a name and set its type toTableStandardCell

    Once the Cell Variant is added, set its variantKey to"NOTAPPL". This is the value that when found inthe Context will invoke this "Not Applicable" CellVariant.

    Each Cell Variant has a child Cell Editor - addedthe same way Cell Editors are added directly toTable Columns. Bind the Cell Editor's valueproperty to the Context: MAIN.ORDERS.REGION

    We repeat the process with our second Cell Variant for Domestic Orders - the one that will show a DropDown for Region selection. Its variantKey is "SELECT".

    SAP Community Network Wiki - Web Dynpro ABAP - WebDynpro f... http://wiki.sdn.sap.com/wiki/display/WDABAP/WebDynpro+for+A...

    2 de 5 20/03/2013 17:57

  • Bind the selectedKey property of the DropDown by Key Cell Editor to MAIN.ORDERS.REGION.

    The last Layout step: the selectedCellVariant property of the Region Table Column must be bound to the Context. The Variant attribute will determine which Cell Variant is used for each table row,NOTAPPL or SELECT

    SAP Community Network Wiki - Web Dynpro ABAP - WebDynpro f... http://wiki.sdn.sap.com/wiki/display/WDABAP/WebDynpro+for+A...

    3 de 5 20/03/2013 17:57

  • We also have two Methods to write in View Main.The WDDOINIT method will create our Region drop down values and associate them with the Region Table Collumn.The Supply Function LOADORDERS fills our Table. Note that the Variant attributeis set to NOTAPPL or SELECT to control which Cell Variant is used for that row of data.

    METHOD wddoinit . DATA lo_nd_orders TYPE REF TO if_wd_context_node. DATA lo_node_info TYPE REF TO if_wd_context_node_info. DATA lt_regions TYPE wdy_key_value_table. DATA lwa_region TYPE wdy_key_value.

    lwa_region-key = 'EAST'. lwa_region-value = 'East'. APPEND lwa_region TO lt_regions. lwa_region-key = 'NORTH'. lwa_region-value = 'North'. APPEND lwa_region TO lt_regions. lwa_region-key = 'SOUTH'. lwa_region-value = 'South'. APPEND lwa_region TO lt_regions. lwa_region-key = 'WEST'. lwa_region-value = 'West'. APPEND lwa_region TO lt_regions.

    lo_nd_orders = wd_context->get_child_node( 'ORDERS' ). lo_node_info = lo_nd_orders->get_node_info( ). lo_node_info->set_attribute_value_set( EXPORTING name = 'REGION' value_set = lt_regions ).ENDMETHOD.

    The Supply Function LOADORDERS fills our Table. Note that the Variant attribute is set to NOTAPPL or SELECT to control which Cell Variant is used for that row of data.

    METHOD loadorders .*

    ** data declaration DATA lt_orders TYPE wd_this->elements_orders. DATA ls_order LIKE LINE OF lt_orders. CLEAR ls_order. ls_order-order = '600342'. ls_order-division = 'International'. ls_order-region = 'Not Applicable'.** NOTAPPL invokes the read-only InputField Cell Variant ls_order-variant = 'NOTAPPL'. APPEND ls_order TO lt_orders.

    CLEAR ls_order. ls_order-order = '600349'. ls_order-division = 'Domestic'. ls_order-region = 'NORTH'.** SELECT invokes the DropDown Region selection Cell Variant ls_order-variant = 'SELECT'. APPEND ls_order TO lt_orders.

    CLEAR ls_order. ls_order-order = '600402'. ls_order-division = 'Domestic'.

    SAP Community Network Wiki - Web Dynpro ABAP - WebDynpro f... http://wiki.sdn.sap.com/wiki/display/WDABAP/WebDynpro+for+A...

    4 de 5 20/03/2013 17:57

  • ls_order-region = 'WEST'. ls_order-variant = 'SELECT'. APPEND ls_order TO lt_orders.

    CLEAR ls_order. ls_order-order = '600413'. ls_order-division = 'International'. ls_order-region = 'Not Applicable'. ls_order-variant = 'NOTAPPL'. APPEND ls_order TO lt_orders.

    *

    ** bind all the elements node->bind_table( new_items = lt_orders set_initial_elements = abap_true ).*

    ENDMETHOD.

    Labels

    Comments (1)

    Follow SCN

    Contact UsSAP Help Portal

    PrivacyTerms of UseLegal DisclosureCopyright

    webdynpro abap cell variants

    SAP Community Network Wiki - Web Dynpro ABAP - WebDynpro f... http://wiki.sdn.sap.com/wiki/display/WDABAP/WebDynpro+for+A...

    5 de 5 20/03/2013 17:57