Dynamic context binding in web dynpro alv

I use dynamic context binding (see code below to show and edit the ALV table.
'DB_TABLE' is a tranparent table. It works fine.
But now this table should be expanded with additional fields which are only known at runtime and could be different from case to case.
How can I get these fields in the context dynamically?
  DATA:
        rootnode_info TYPE REF TO if_wd_context_node_info,
        dyn_node      TYPE REF TO if_wd_context_node,
        tablename   TYPE string.
  rootnode_info = wd_context->get_node_info( ).
  tablename = 'DB_TABLE'.
  cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
    parent_info = rootnode_info
    node_name = tablename
    structure_name = tablename
    is_multiple = abap_true ).
  DATA:
        stru_tab TYPE REF TO data.
  FIELD-SYMBOLS: <tab> TYPE table.
  CREATE DATA stru_tab TYPE TABLE OF (tablename).
  ASSIGN stru_tab->* TO <tab>.
  SELECT * FROM (tablename) INTO CORRESPONDING FIELDS OF TABLE <tab>.
  dyn_node = wd_context->get_child_node( name = tablename ).
  dyn_node->bind_table( <tab> ).

You should create a structure dynamically and use this as the context structure. See the coding below, where a structure is created, which contains CARRID and CONNID.
DATA: node_info type ref to if_wd_context_node_info,
      struct_type TYPE REF TO cl_abap_structdescr,
      table_type  type ref to cl_abap_tabledescr,
      comp_tab    TYPE cl_abap_structdescr=>component_table,
      comp        LIKE LINE OF comp_tab,
      my_table    type ref to data,
      my_row      type ref to data.
  field-symbols: <table> type table,
                 <row> type data,
                 <flight> type sflight.
* build a structure description from the list of single fields
  comp-name = 'CARRID'.
  comp-type ?= cl_abap_datadescr=>describe_by_name( 'S_CARR_ID' ).
  APPEND comp TO comp_tab.
  comp-name = 'CONNID'.
  comp-type ?= cl_abap_datadescr=>describe_by_name( 'S_CONN_ID' ).
  APPEND comp TO comp_tab.
* note this structure contains the fields "CONNID" and "CARRID"
  struct_type = cl_abap_structdescr=>create( comp_tab ).
* now the nodeinfo is created
  node_info = wd_context->get_node_info( ).
  node_info = node_info->add_new_child_node(
    name                         = 'MY_NODE'
    IS_MANDATORY                 = ABAP_true
    IS_MULTIPLE                  = ABAP_true
    STATIC_ELEMENT_RTTI          = struct_type
    IS_STATIC                    = ABAP_false
* fill new node;
  data: l_node type ref to if_wd_context_node,
        l_flight type STANDARD TABLE OF sflight.
  l_node = wd_context->get_child_node( 'MY_NODE' ).
  l_flight = wd_assist->get_flights( ).
*  if you could create a local data type, would be fine, but if you have to do it dynamically ...
  struct_type = node_info->GET_STATIC_ATTRIBUTES_TYPE( ).
* create tabledescriptor from structdescription (standard table, no keys)
  table_type = cl_abap_tabledescr=>create( p_line_type = struct_type ).
  create data my_table type handle table_type.
  assign my_table->* to <table>.
  loop at l_flight assigning <flight>.
    create data my_row type handle struct_type.
    assign my_row->* to <row>.
    move-corresponding <flight> to <row>.
    append <row> to <table>.
  endloop.
  l_node->bind_table( <table> ).

Similar Messages

  • Dynamic Context Mapping in Web Dynpro ABAP

    Hi Experts,
    How can I create two dynamic Context nodes, one in ViewController and the other in Component Controller and finally create a context mapping between them?
    Regards,
    Johan Kriek.

    Hi Johan,
    I found a method IF_WD_CONTEXT_NODE_INFO~ADD_NEW_MAPPED_CHILD_NODE that seems to be the one that I am looking for.
    I do have same idea but i have been trying to give solution by using above method,unfortunately here my server is down.check the below code. i didnt check this code due to server down.
    DATA: lo_nd_purchase_header TYPE REF TO if_wd_context_node,
          lo_el_purchase_header TYPE REF TO if_wd_context_element,
    ls_purchase_header TYPE wd_this->element_purchase_header,
          lo_node_info type ref to if_wd_context_node_info,
          lo_child_node_info type ref to if_wd_context_node_info,
          MAPPING_INFO type WDR_CONTEXT_MAPPING_INFO.
    * navigate from <CONTEXT> to <PURCHASE_HEADER> via lead selection
      lo_nd_purchase_header = wd_context->get_child_node( name = wd_this->wdctx_purchase_header ).
                  CALL METHOD LO_ND_PURCHSE_HEADER->GET_NODE_INFO
                    RECEIVING
                      NODE_INFO = lo_node_info.
           MAPPING_INFO-controller = 'ZWDC_ALV'. "conponent name
           MAPPING_INFO-path = 'PURCHASE_HEADER'. "Controller context node name
          CALL METHOD LO_NODE_INFO->ADD_NEW_MAPPED_CHILD_NODE
            EXPORTING
              CHILD_NAME      = 'PURCHASE_HEADER'
              MAPPING_INFO    =  MAPPING_INFO
    *          IS_STATIC       = ABAP_TRUE
            RECEIVING
              CHILD_NODE_INFO = lo_child_node_info

  • Web Dynpro ALV grid format

    Hi,
    I have a web dynpro alv table that has many columns (about 20) I would like it to be displayed so that the user does not have to scroll right to see all the data.
    at the moment columns:
    col1 col2 col3 ......col19 col20
    i would like the second half of the table under the 1sta half:
    col1 col2 col3...col9 col10
    col11 col12...col19 col20
    Is there any way that i can get the table to be split into two or some other nice way to display without scrolling?

    You won't be able to do this with a single ALV.  I suppose you could have two ALVs and bind them both to the same context.  You wouldn't be able to sync the veritcal scrolling between the the two ALVs however.  I'm also not sure how usage this design is from a UI design pattern.  I would think the acceptible approach would be to use horizontal scrolling within the ALV.  You don't have to make the ALV display all columns at once as this can make your entire page very wide and require using the browser scrolling.  Instead consider using the set_scrollable_col_count method.

  • Detail Button in Web Dynpro ALV

    Hi at all,
    when I create an ALV in Standard ABAP there is a small "Detail" button on the left side of the button row without any additional complex programming.
    How can I get this button in Web Dynpro ALV?
    Dirk

    The standard ALV Component in Web Dynpro doesn't have this features.  It wouldn't be too difficult to add manually.  You could simply bind a custom view to the lead selection of the same context you are using in the ALV and use the form wizard to generate the UI elements.  It isn't quite as nice becuase it woudl require a few manual steps for each usage of the ALV where you want this functionality.

  • How can I set the data binding between Web Dynpro & Database table

    Dear friend,
    I am a beginner of Web Dynpro. I want to develop my simple project like these:
    1. Create my own database table via Dictionary Project such as TAB_USER and have 3 fields: USER_ID, USER_NAME, USER_POSITION and I have already deployed & archived it.
    2. Create my own Web Dynpro Project, and create the input fields as User ID, User name, User position and icon 'Save' on the selection screen and I have deployed it already.
    For the process, I want to input data at the screen and save the data in the table, please give me the guide line like these:
    1. How can I set the data binding between Web Dynpro and Database table ?
    2.  Are there any nescessary steps that I will concern for this case?
    Sorry if my question is simple, I had try  to find solution myself, but it not found
    Thanks in advances,
    SeMs

    Hi,
    You can write your own connection class for establishing the connection with DB.
    Ex:
    public class  ConnectionClass {
    static Connection con = null;
    public static Connection getConnection() {
    try{
    Context ctx = new InitialContext();
    DataSource ds = (DataSource) ctx.lookup("jdbc/TSPAGE");
    con = ds.getConnection();
    return con;
    }catch(Exception e){
    return null;
    You can place the above class file in src folder and you can use this class in webdynpro.
    You can have another UserInfo class for reading and writing the data into the DB .
    Regards, Anilkumar
    PS : Refer
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/java/simple java bean generator for database.pdf
    Message was edited by: Anilkumar Vippagunta

  • Web Dynpro ALV grid column colour

    Hi,
    I have tried to set the colour of a column for my web dynpro alv with the below code but it the colour for this column has not changed - it seems to remain the standard colour.  Is there something else i need to do?
      DATA: lt_columns TYPE salv_wd_t_column_ref
          , ls_columns  TYPE salv_wd_s_column_ref
          , lr_column TYPE REF TO cl_salv_wd_column
      lt_columns = lo_value->if_salv_wd_column_settings~get_columns( ).
      LOOP AT lt_columns INTO ls_columns.
        IF ls_columns-id CS 'TOTAL_'.
          lr_column = ls_columns-r_column.
          lr_column->set_cell_design( cl_wd_abstr_master_table_col=>e_cell_design-positive ). "CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-GROUP_LEVEL1
        ENDIF.
      ENDLOOP.

    Hi Samir,
    You will have to create an attribut WDUI_TABLE_CELL_DESIGN and bind this attribute with the cell design property of the column. Check this wiki link [https://wiki.sdn.sap.com/wiki/display/Snippets/ABAP%20Web%20Dynpro%20ALV%20-%20Change%20Cell%20Colour%20based%20on%20Content], it will solve your issue.
    Regards,
    Radhika.

  • Dynamic radio button in web dynpro abao

    Hi expert,
    I want to dynamic radio button by  web dynpro abap .
    Kindly give me a soulation ASAP.
    Thanks and regard's
    Vikash

    hi,
    method wddomodifyview .
    if first_time eq abap_true.
    data: LR_CONTAINER         type ref to CL_WD_UIELEMENT_CONTAINER,
          LR_RADIOBUTTON1            type ref to CL_WD_RADIOBUTTON,
          LR_RADIOBUTTON2            type ref to CL_WD_RADIOBUTTON,     
          LR_FLOW_DATA         type ref to CL_WD_FLOW_DATA.
    " bind text property will give TEXT that appears next to Radio Button
    CALL METHOD cl_wd_radiobutton=>new_radiobutton
      EXPORTING
       bind_selected_key   =  '01' 
       BIND_TEXT           =  'saurav'
      receiving
        control             = LR_RADIOBUTTON1.
    " bind text property will give TEXT that appears next to Radio Button
    CALL METHOD cl_wd_radiobutton=>new_radiobutton
      EXPORTING
        bind_selected_key   = '02'
       BIND_TEXT           = 'mago'
      receiving
        control             = LR_RADIOBUTTON2.
    LR_FLOW_DATA        =  CL_WD_FLOW_DATA=>NEW_FLOW_DATA( element = LR_RADIOBUTTON1  ).
    LR_FLOW_DATA        =  CL_WD_FLOW_DATA=>NEW_FLOW_DATA( element = LR_RADIOBUTTON2  ).
    LR_CONTAINER ?= view->GET_ELEMENT( 'ROOTUIELEMENTCONTAINER' ).
    LR_CONTAINER->ADD_CHILD( LR_RADIOBUTTON1  ).
    LR_CONTAINER->ADD_CHILD( LR_RADIOBUTTON2  ).
    endif.
    endmethod.
    Thanx.

  • Cannot see Ecatt option in context menu in web dynpro abap in SE80 ECC 6.0

    Hi ,
    I saw a presentation by Thomas in which there is option of recording ecatt script on context menu in web dynpro abap application.we are on ECC 6.0 we are trying to record WDA applications and test them by using Ecatt but I am unable to see the option of recording the ecatt script in SE80 editor.
    Why could this be happening

    Thanks ,
    I saw that disappointing note ...any other way to automate web dynpro abap testing ? please advise.

  • How to Email POWL Reports / Apply Web Dynpro ALV Table Layout Settings

    Hi all,
    we want to be able to automatically extract POWL reports and email them to users in a batch job.
    We can refresh a POWL report using FM POWL_QUERY_REFRESH, and access the raw report data using method CL_POWL_QUERY_ACCESSOR=>GET_CACHED_RESULTS.
    However this merely gives us a table of raw data.  No view layout (ie. Web Dynpro ALV table layout) settings have been applied, so there is no hiding or arranging of columns, row sorting, calculations or filters.
    Ideally we would like to be able to specify a query and view layout.  The batch job would then refresh and extract the data, and format the data according to the view layout before sending it on as an attachment in an email.
    Does anyone know how to determine and apply Web Dynpro ALV table layout settings to format table data outside of the Web Dynpro environment ?
    Thanks & regards,
    Grogan

    Hi Grogan,
    Did you find out how this works..i also have the same issue.
    Thanks
    Jdsouza

  • Web dynpro Alv ENHANCEMENT

    hI,
    i HAVE a requirement to add extra 2 columns in web dynpro alv of standard web dynpro component
    what are the steps to be taken.

    Hi Madhav,
    Please cehck Thomus answer in this thread..
    is possible to enhance standard ALV?
    Enhancement Implementation - Removing columns in standard ALV table
    Cheers,
    Kris.

  • Web Dynpro ALV grid filter on date

    Hi,
    I want to set a "view" on my web dynpro alv grid that uses the current date.  Is there a way to specify the current date in the filter values?  Thanks,
    Samir

    Thanks Thomas.  I will certainly look into using POWL in the future.
    A related question - Its possible to use a filter by entering something like " .01. " but it doesnt seem to allow me to save that value as its not a date.  Is there any way around this?  Thanks

  • Web Dynpro ALV grid sub totals

    Hi,
    I have managed to get totals working with web dynpro ALV using code like this :
      DATA: lr_field TYPE REF TO cl_salv_wd_field.
    For total calculations...
      lo_value->if_salv_wd_std_functions~set_aggregation_allowed( abap_true ).
      lr_field = lo_value->if_salv_wd_field_settings~get_field( 'N_OF_DLRS' ).
      lr_field->if_salv_wd_aggr~create_aggr_rule( aggregation_type = if_salv_wd_c_aggregation=>aggrtype_total ).
    Please can someone advise how i can do subtotals also.  Thanks
    Edited by: Samir Vora on Jul 15, 2009 12:40 PM

    Hi,
    For creating subtotals, you can have a look at following article:
    [Tutorial for Creation Subtotals using ALV|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-technology/wd%20abap/tutorial%20for%20creating%20totals%20and%20subtotals%20using%20alv.pdf].
    Hope this helps.
    Regards
    Manas Dua

  • Web Dynpro ALV grid totals

    Hi,
    I have created an application that uses a web dynpro alv grid.  I want to display totals - is there a setting that can do this automatically - if so, can you please tell me how to do this?    Thanks,

    Hi
    You can take help of following code snippet to create totals for a particular column
    Data: lr_function_settings TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
      DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
            lr_column          TYPE REF TO cl_salv_wd_column,
            lt_column type salv_wd_t_column_ref,
            ls_column type salv_wd_s_column_ref.
    Data:  lr_field_amnt type REF TO CL_SALV_WD_FIELD.
    * get reference of ALV component
      lr_salv_wd_table = wd_this->wd_cpifc_OVERVIEW_EARNED_ALV( ).
      wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
    *  get function settings
      lr_function_settings ?= wd_this->alv_config_table.
    * display columns in correct order
      lr_column_settings ?= wd_this->alv_config_table.
      lt_column = lr_column_settings->get_columns( ).
      loop at lt_column into ls_column.
    CASE ls_column-id.
    when 'AMOUNT'
    * aggregate field
            CALL METHOD LR_FUNCTION_SETTINGS->IF_SALV_WD_FIELD_SETTINGS~GET_FIELD
              EXPORTING
                FIELDNAME = 'AMOUNT'
              RECEIVING
                VALUE     = lr_field_amnt.
    * create aggregate rule as total
            CALL METHOD LR_FIELD_AMNT->IF_SALV_WD_AGGR~CREATE_AGGR_RULE
              EXPORTING
                AGGREGATION_TYPE = IF_SALV_WD_C_AGGREGATION=>AGGRTYPE_TOTAL
              RECEIVING
                VALUE            = lv_aggr_rule.
    endcase.
    Regards
    Manas DUa

  • Web Dynpro ALV grid equivalent of onLeadSelect

    Hi,
    I am new to web dynpro alv and would like to know how to implement the equivelent of the action onLeadSelect that you can do with a table UIElement, but I want to do this for the ALV table that I have.  Many thanks,
    Samir

    Hi,
    Go to the View's property tab and include you ALV in that.
    whenever you instantiate the ALV then in the view, METHODS tab, you can find the Event handler for the lead selection for that ALV. Implement that.
    Method name           Method type         Event        
    ONLEADSELECT     Eventhandler        ON_LEAD_SELECT
    Check out the links -
    Re: click event on ALV
    http://www.flickr.com/photos/31042772@N08/3408386623/
    Regards,
    Lekha

  • Web Dynpro ALV grid column width

    Hi,
    I have a web dynpro alv grid that has columns titles that are long.  What is the best way of displaying the data without taking up too much space with the titles? 
    For example is it possible to wrap the title into 2 or 3 rows
    Thanks,
    Samir

    Hi,
    DATA: lr_column type ref to cl_salv_wd_column,
    lr_colheader type ref to cl_salv_wd_column_header.
              CALL METHOD lrcolumn->get_header
                RECEIVING
                  value = lr_COLHEADER.
    lr_COLHEADER->set_ddic_binding_field( if_salv_wd_c_ddic_binding=>ddic_bind_short ).
    Refer this if_salv_wd_c_ddic_binding in se24 for more.
    Regards,
    Lekha.

Maybe you are looking for

  • 3D pdf - Poor image resolution (see attached jpg)

    I create 3D pdf's from MicroStation on a regular basis to deliver to clients,and I have never had a problem with it until using the latest version of Reader.  When I open a 3D pdf on my workstation (using Adobe Reader 9.1), it looks fine; when my cli

  • Iphone 3GS won't hold a charge, won't leave the recovery screen and the screen itself is very dim. Is there an easy way to fix this?

    I left my phone out in the rain and it got wet, the water got inside the phone and you could visibly see water in the screen. Inside the phone the hardware was a little wet but not soaking. None of the water dectors have been tripped. I have to leave

  • I have fixed -48

    Very simple but requires a windows PC with itunes installed. I had experienced the -48 error with 2 back iPod 30gb called up india several times but the same thing happened again and again. I then took a tip from a mate and reformated my ipod to Wind

  • How to know whether my oracle 10g instalation in unicode supported or not

    Hi i am new to oracle. I have installed Oracle 10g client and server. I want to know whether the database created can store unicode data/arabic data. Please guide me how can i find whether unicode support is on for my db or not. The outputs of some o

  • Help on Multiselect list

    I created a Multiselect list for item :P5_REGIONS(USING DYNAMIC ) DYNAMIC QUERY IS SELECT DISTINCT DEPTNO FROM DEPT; Mutiselect list 10 20 30 40 50 I have another item name :P5_SELECTED_REGIONS So what I want to do is When user select multi values fr