Dynamic Programming : Bind table

Hello to all,
I intend to bind a table dynamically for which i am following these steps:
1. Created the context node dynamically in WDINIT.
2. Filled the context node (made a select query and then using bind_table)
3. In WDDOModify, used the following code
   CALL METHOD VIEW->GET_ROOT_ELEMENT
     RECEIVING
       ROOT_VIEW_ELEMENT = LR_ROOT_ELEMENT .
   "DOWNCAST IT
    LR_CONTAINER ?= LR_ROOT_ELEMENT.
4. Created an UI elemnt and bound the data source
CALL METHOD CL_WD_TABLE=>NEW_TABLE
  EXPORTING
    BIND_DATA_SOURCE              = 'SFLIGHTS_CONTEXT'
   ID                            = 'TABLE_SFLIGHT'
  RECEIVING
    CONTROL                       = LR_TABLE
5. CALL METHOD LR_CONTAINER->ADD_CHILD
  EXPORTING
    THE_CHILD = LR_TABLE
6 CALL METHOD CL_WD_FLOW_DATA=>NEW_FLOW_DATA
  EXPORTING
    ELEMENT     = LR_TABLE
  RECEIVING
    CONTROL     = LR_FLOW_DATA
With this all i am getting in the browser is an empty table. Well i have used the <b>bind_data_source</b> parameter = the context, and this context is very much filled in the WDDOINIT method but can't understand this behavior of getting an empty table.
Please help me with this

Hi Abhishek,
I am putting the Exaple code which will help you to solve the problem. Here the logic in my example are the User enters TABLENAME into the Input field and he want to display the information about that Table with data.
DATA: lr_root_info TYPE REF TO if_wd_context_node_info,
lr_node_info TYPE REF TO if_wd_context_node_info,
lr_context_node TYPE REF TO if_wd_context_node,
lr_context_elem TYPE REF TO if_wd_context_element,
lv_tabname TYPE string,
lr_db_tab TYPE REF TO data.
FIELD-SYMBOLS: <lfs_db_tab> TYPE ANY TABLE.
read db table name from context
lr_context_node = wd_context->get_child_node( name = 'TABLE_NAME' ).
lr_context_elem = lr_context_node->get_element( ).
lr_context_elem->get_attribute(
EXPORTING name = 'TABLENAME'
IMPORTING value = lv_tabname ).
TRANSLATE lv_tabname TO UPPER CASE.
get meta data info of root context node
lr_root_info = wd_context->get_node_info( ).
create context structure
CALL METHOD lr_root_info->add_new_child_node
EXPORTING
STATIC_ELEMENT_TYPE = lv_tabname
name = 'DB_TABLE'
receiving
child_node_info = lr_node_info.
create data object of correct type and assign field symbol
CREATE DATA lr_db_tab TYPE TABLE OF (lv_tabname).
ASSIGN lr_db_tab->* TO <lfs_db_tab>.
read DB content
SELECT * FROM (lv_tabname)
INTO CORRESPONDING FIELDS OF TABLE <lfs_db_tab>
UP TO 100 ROWS.
bind table to context
lr_context_node = wd_context->get_child_node( name = 'DB_TABLE' ).
CALL METHOD lr_context_node->bind_table
EXPORTING
new_items = <lfs_db_tab>.
Best Regards,
Vijay

Similar Messages

  • Download a special kind of internal table (dynamic programming)

    Hi guys,
    with dynamic programming, i've created a complex internal table of this type :
    KNA1                          |
    KNB1                          |                         
    GS_CUSTOMERADDRESS            |               
    GS_CUSTOMERGENERALDETAIL      |
    The declaration of the internal table is :
    TYPES: BEGIN OF gty_record,
            table TYPE tabname,
            dataref  TYPE REF TO data,
           END OF gty_record.
    This means that each line, has a different line-type. In the first field of the table, i have the name of the structure. In the second, the data-part (in debug double click on leads to structure contents - field by field).
    The structure KNA1 contains C and packed (P) fields also so when i pass the internal table to FM GUI_DOWNLOAD, i have this short-dump : UC_OBJECTS_NOT_CONVERTIBLE.
    Is there a way to solve this problem quickly?
    The goals is download all data of a customer into a local file. Data is distribuited on different structures, readed by standard bapi 'BAPI_CUSTOMER_GETDETAIL2'. This file will be read in another program, of another system.
    Any hints/suggestion will be appreciated.
    Thanks a lot.
    Andrea

    Hi Sandra,
    thx for you suggestions.
    About your answer :
    " Or use a DO. ASSIGN COMPONENT sy-index OF STRUCTURE ... to loop at each field, and do whatever you want with them (using WRITE ... TO ... for example, to convert numbers into text)."
    I cannot use this approach to the problem, because i should keep in mind the dimension of single fields and the blanks should be concatenated also, but RESPECTING BLANK switch of concatenate instruction doesen't exists in 4.7 abap.
    Sure, i can use a workaround, but i'll have a lot of programming.
    "you could use XML for instance. It's rather standard! By using CALL TRANSFORMATION ID SOURCE dataObject RESULT XML string."
    This could be the solution. I've already read some posts about it before write mine. I should test it: i don't know if in 4.7 release works. So i could transform the internal table to xml and save to text file.
    But then, how i can read xml string and mapping again in this special kind of table ?
    Is CALL TRANSFORMATION ID SOURCE XML String RESULT Dataobject instruction sufficient to perform this task?
    Thanks a lot
    Andrea
    BR
    Sandra

  • How can i dynamically update a table in my program?

    Hi there!
    I would like to know if anyone can assist me with advice on how to dynamically update
    a table within my program, with new values from the database?
    Thanking You all.

    Add rows to its model.
    Kind regards,
    Levi

  • Help needed regarding Dynamic Programming

    Hi,
    While doing dynamic programming , we bind the context variable with two types of
    values .
    1 . ddic
    2 . extern
    My doubt is in which case we should use ddic and where to use extern .
    Can anybody help me out regarding this.
    Thanks a lot.

    Hi Ki,
    Predefined, Web Dynpro UI-specific, and user-defined Dictionary types all have the
    prefix ddic:.
    wdContext.getNodeInfo()
    .addAttribute(
    "Visibility",
    "ddic:com.sap.ide.webdynpro.uielementdefinitions.Visbility")
    •&#61472;Logical Dictionary types from Adaptive RFC models have the prefix extern:.
    Check this links
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9214b1e5-0601-0010-fdb0-ec32d43b06e0
    /people/dipankar.saha3/blog/2007/05/31/how-to-create-dynamic-approval-process-using-conditional-loop-block-in-guided-procedure
    Regards,
    Mithu

  • How to change the images dynamically in a table.

    Hai,
                     How to change the images dynamically in a table based on the condition in webdynpro abap.
    Edited by: Ravi.Seela on Oct 13, 2011 2:17 PM

    This has been much discussed earlier. Do search posts.
    For your scenario i would do the following.
    inside your node which is binded to the table, i create a new node image with cardinality 1 ..1 and a attribute called path of type string.
    create a  supply function for the node image .
    Supply method now has a Element (Parent element ) and node.
    Based on your record in element, set the right image source to path attribute and bind the node.
    This will make sure that the framework calls the image supply function for every row in a table.

  • How to display the rows dynamically in the table display in web dynpro abap

    Hi experts,
                   There is a visible row count tab where you can give the no of rows to be displayed in the output table, but i want it to be done dynamically as the row count of my table may change dynamically at runtime.
    And i want to know how to reduce the width of a column as my table display is taking the length as per the binded table specifications.Can anyone please help me out in this issue.
    Thanks in advance,
    Anita.

    Hi Anita
    You can bind the visiblerowcount property to the a context attribute. and at runtime you can set the context attribute to the no of rows you want in your table,
    Regards
    Naresh

  • 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> ).

  • Submitting a dynamic program with layout name

    Hi,
    I searched many blogs and the SDN forum but couldn't find a solution.
    I need to know the layout fields of an ALV report for a later usage. Let me explain it with code:
    I used below code to extract data of a dynamic program.
    cl_salv_bs_runtime_info=>set(
      EXPORTING display  = abap_false
        metadata = abap_true
        data     = abap_true ).
      Submit (program)  USING SELECTION-SET variant EXPORTING LIST TO MEMORY
                AND RETURN.
      TRY.
          cl_salv_bs_runtime_info=>get_data_ref(
      IMPORTING r_data = lf_ref ).
          ASSIGN lf_ref->* TO <lt_data>.
        CATCH cx_salv_bs_sc_runtime_info.
          MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
      ENDTRY.
      cl_salv_bs_runtime_info=>clear_all( ).
      CREATE DATA lf_ref1 LIKE LINE OF <lt_data>.
      ASSIGN lf_ref1->* TO <lt_line>.
    What I need is to submit program with a (known) layout. If it is not possible, how can i modify the ALV report to fit a layout's display properties. (If I can manage to get -dynamic program- layout's visible fields, it will work too.)
    Thank you.

    Hi ,
    Check this LINK  you can take help from this
    create dynamic varient and pass  to Submit program .
    [how to create a variant dynamically and get it?;
    OR  :
    you can use function module to get layout names and  reprot 
    ranges: lr_report for ltdx-report,
              lr_handle for ltdx-handle,
              lr_log_group for ltdx-log_group,
              lr_username  for ltdx-username,
              lr_variant   for ltdx-variant,
              lr_type      for ltdx-type.
    call function 'LT_VARIANTS_READ_FROM_LTDX'
        exporting
          i_tool          = r_tool
          i_text          = r_text
        tables
          et_variants     = rt_variants
          it_ra_report    = lr_report
          it_ra_handle    = lr_handle
          it_ra_log_group = lr_log_group
          it_ra_username  = lr_username
          it_ra_variant   = lr_variant
          it_ra_type      = lr_type
        exceptions
          not_found       = 1
          others          = 2.
    regards
    Deepak.
    Edited by: Deepak Dhamat on Jan 23, 2012 8:18 AM

  • Populating values in dynamically generated internal table

    Hi,
    We can generate internal tables dynamically and also populate them with values from database.But is there any way to populate the dynamically generated internal table(has 2-3 selected fields) with values from another internal table(has all fields required by the program) being populated within the same program?
    Thanks & Regards,
    Savitha

    Hi
    Dynamic internal table is internal table that we create on the fly with flexible column numbers.
    For sample code, please look at this code tutorial. Hopefully it can help you
    Check this link:
    http://www.****************/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm
    Reward points if useful
    Regards
    Anji

  • Appending column to an dynamically created internal table

    Hi folks,
    i have an dynamically created internal table <dyn_tab> which is based on a parameter p_table (  containing the table name ). now i want to add one more column to this <dyn_tab> table where i can store further information in. how can i do that ?
    i appreciate your help!

    Hi,
    Please check this sample program.
    type-pools : abap.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: dy_table type ref to data,
          dy_line  type ref to data,
          xfc type lvc_s_fcat,
          ifc type lvc_t_fcat.
    selection-screen begin of block b1 with frame.
    parameters: p_table(30) type c default 'T001'.
    selection-screen end of block b1.
    start-of-selection.
      perform get_structure.
      perform create_dynamic_itab.     
    form get_structure.
      data : idetails type abap_compdescr_tab,
           xdetails type abap_compdescr.
      data : ref_table_des type ref to cl_abap_structdescr.
      * Get the structure of the table.
      ref_table_des ?= 
          cl_abap_typedescr=>describe_by_name( p_table ).
      idetails[] = ref_table_des->components[].
        loop at idetails into xdetails.
        clear xfc.
        xfc-fieldname = xdetails-name .
        xfc-datatype = xdetails-type_kind.
        xfc-inttype = xdetails-type_kind.
        xfc-intlen = xdetails-length.
        xfc-decimals = xdetails-decimals.
        append xfc to ifc.
      endloop.
    *Add your new field(s) into table ifc here.
    endform.
    form create_dynamic_itab.
    * Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = ifc
                   importing
                      ep_table        = dy_table.
        assign dy_table->* to <dyn_table>.
      * Create dynamic work area and assign to FS
      create data dy_line like line of <dyn_table>.
      assign dy_line->* to <dyn_wa>.
    endform.
    Regards,
    Ferry Lianto

  • Dynamic Programming - Attribute Mapping

    Hi
    Im working on Web Dynpro for ABAP Application where Im using dynamic programming.
    I've created node and attributes dynamically (using ADD_NEW_CHILD_NODE & ADD_ATTRIBUTE methods resp.) & bound the dynamically created Textedit UI elements to those attributes. The application is running fine upto this.
    Now I want to get the text entered in textedit field from the context. For this I'm using GET_ATTRIBUTE method. Here Im getting dump with error message 'Could not find attribute V_TEST.1.CN_INPUT.1.ATTR11 '. When I debug the GET_ATTRIBUTE method, I found out that the internal table DYNAMIC_ATTRIBUTES is initial. The internal table ATTRIBUTES->* is getting populated in the metod ADD_ATTRIBUTE.
    Pls suggest the solution or any alternative method for this.

    Hi ,
    this is happening because the attributes are added dynamically . to get the attribute value at runtime u have to follow the below procedure .
    DATA : LR_ROOT_INFO TYPE REF TO IF_WD_CONTEXT_NODE_INFO ,
              LR_NODE_INFO TYPE REF TO IF_WD_CONTEXT_NODE_INFO,
               LR_STRUCTDESCR TYPE REF TO CL_ABAP_STRUCTDESCR ,
               LS_COMPONENT TYPE CL_ABAP_STRUCTDESCR=>COMPONENT,
               LT_COMPONENTS TYPE CL_ABAP_STRUCTDESCR=>COMPONENT_TABLE,
               LR_TYPE TYPE  REF TO CL_ABAP_DATADESCR .
    LR_TYPE ?= cl_abap_TYPEdescr=>describe_by_name( p_name  = 'MATNR' ).
        LS_COMPONENT-NAME = 'MATNR'.
        LS_COMPONENT-TYPE = LR_TYPE .
       APPEND LS_COMPONENT TO LT_COMPONENTS.
    LR_TYPE ?= cl_abap_TYPEdescr=>describe_by_name( p_name  = 'MAKTX' ).
        LS_COMPONENT-NAME = 'MAKTX'.
        LS_COMPONENT-TYPE = LR_TYPE .
       APPEND LS_COMPONENT TO LT_COMPONENTS.
    CALL METHOD cl_abap_structdescr=>create
          EXPORTING
            p_components = LT_COMPONENTS
               receiving
           p_result     = LR_STRUCTDESCR
    CATCH cx_sy_struct_creation .
        *ENDTRY.
      LR_ROOT_INFO = WD_CONTEXT->GET_NODE_INFO( ).
            CALL METHOD lr_root_info->add_new_child_node
      498    EXPORTING
      499  *    supply_method                =
      500  *    supply_object                =
      501  *    dispose_method               =
      502  *    dispose_object               =
      503  *    static_element_type          =
      504      name                         = 'DATA'                                  " NODE NAME
      505  *    is_mandatory                 = ABAP_FALSE
      506  *    is_mandatory_selection       = ABAP_FALSE
      507  *    is_multiple                  = ABAP_TRUE
      508  *    is_multiple_selection        = ABAP_TRUE
      509  *    is_singleton                 = ABAP_FALSE
      510      is_initialize_lead_selection = ABAP_false
      511      static_element_rtti          = LR_STRUCTDESCR   
      512  *    is_static                    = ABAP_TRUE                       " ADD ATTRIBUTE AS STATIC
      513  *    attributes                   =
      514    receiving
      515      child_node_info              = LR_NODE_INFO .
    Regards
    Yash

  • Dynamic Programming - RTTC - Appending lines

    I give up! Maybe someone else can help me with this Dynamic Programming problem.
    I am using RTTC to create an itab. Now I want to append lines and for some reason can't seem to crack the syntax I need.
    My latest attempt looks like this...
                FIELD-SYMBOLS: <table> TYPE ANY TABLE,
                               <row> TYPE ANY.
                lo_sdescr      = cl_abap_structdescr=>create( lt_components ).
                lo_tdescr      = cl_abap_tabledescr=>create( lo_sdescr ).
                CREATE DATA lr_alloc->alloc_table TYPE HANDLE lo_tdescr.
                CREATE DATA lr_struct TYPE HANDLE lo_rdescr.
                ASSIGN lr_alloc->alloc_table->* TO <table>.
                APPEND INITIAL LINE TO <table> ASSIGNING <row>.
    The syntax check I get on the APPEND statement is "You cannot use explicit or implicit index operations on tables with type "ANY TABLE".
    All the doco and examples I can find use a simple "SELECT * ... INTO CORRESPONDING FIELDS OF TABLE <table>" syntax which it not what I need to do.
    Any help it appreciated.
    Thanks
    Graham Robbo

    Hello Graham
    The solution is quite simple (at least to overcome your syntax error):
    FIELD-SYMBOLS:
      <gt_itab>     TYPE STANDARD TABLE,  " use STANDARD instead of ANY
      <gs_struc>    TYPE ANY.
    *& Report  Z_RTTI_CREATE_COMPLEX_ITAB
    *& NOTE: revised version of ZUS_SDN_RTTI_CREATE_STRUCTURES
    *& Thread: Dynamic Programming - RTTC - Appending lines
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="980407"></a>
    REPORT  z_rtti_create_complex_itab.
    TYPE-POOLS: abap.
    DATA:
      celltab          TYPE lvc_t_styl.  " becomes field of complex itab
    DATA:
      gd_tabnam        TYPE string,
      gd_tabfield      TYPE string,
      go_table         TYPE REF TO cl_salv_table,
      go_sdescr        TYPE REF TO cl_abap_structdescr,
      go_sdescr_new    TYPE REF TO cl_abap_structdescr,
      go_tdescr        TYPE REF TO cl_abap_tabledescr,
      gdo_data         TYPE REF TO data,
      gdo_handle       TYPE REF TO data,
      gs_component     TYPE abap_compdescr,
      gs_comp          TYPE abap_componentdescr,
      gt_components    TYPE abap_component_tab.
    FIELD-SYMBOLS:
      <gt_itab>     TYPE STANDARD TABLE,
      <gs_struc>    TYPE ANY.
    PARAMETER:
      p_tabnam      TYPE tabname  DEFAULT 'KNB1'.
    START-OF-SELECTION.
      " Describe structure
      go_sdescr ?= cl_abap_structdescr=>describe_by_name( p_tabnam ).
      gd_tabnam     = go_sdescr->get_relative_name( ).
      " Simulate dynamic addition of columns
      LOOP AT go_sdescr->components INTO gs_component.
        "   Build fieldname
        CONCATENATE gd_tabnam gs_component-name INTO gd_tabfield
                                                SEPARATED BY '-'.
        CLEAR: gs_comp.
        gs_comp-type ?= cl_abap_datadescr=>describe_by_name( gd_tabfield ).
        gs_comp-name  = gs_component-name.
        APPEND gs_comp TO gt_components.
      ENDLOOP.
      "   Create instances of dynamic structure and dynamic internal table
      go_sdescr_new  = cl_abap_structdescr=>create( gt_components ).
      go_tdescr      = cl_abap_tabledescr=>create( go_sdescr_new ).
      "   Create data refence followed by table creation
      CREATE DATA gdo_handle TYPE HANDLE go_sdescr_new.
      ASSIGN gdo_handle->* TO <gs_struc>.
      CREATE DATA gdo_handle TYPE HANDLE go_tdescr.  " !!!
      ASSIGN gdo_handle->* TO <gt_itab>.
      APPEND INITIAL LINE TO <gt_itab> ASSIGNING <gs_struc>.
      TRY.
          CALL METHOD cl_salv_table=>factory
            IMPORTING
              r_salv_table = go_table
            CHANGING
              t_table      = <gt_itab>.
          go_table->display( ).
        CATCH cx_salv_msg .
      ENDTRY.
    END-OF-SELECTION.
    Regards
      Uwe

  • Dynamic Programming - subsequence counting

    I have two string arrays (X and Y) and I want to count the number of times that a sequence X appears as a subsequence of a sequence Y by using dynamic programing. Could you guys give me some ideas about how to create the DP table?
    thanks

    black_makeba wrote:
    yes, this is a java programming. And the task is to figure out the algorithm. If I knew the algorithm, Coding would be trivial. So I am asking for any ideas about the algorithm.I have a weak spot for problems like this so here's a solution but I'm not sure it qualifies as "dynamic programming" in your assignment.
    You start out with an X string like "abcd". We call this string X(0) because it's in its initial state. Now if the first letter "a" has been found the string is called X(1) which is "bcd" (the first letter has been found and is no longer of interest). When the X(0) string "abcd" has advanced to X(4) all letters have been found.
    Example:
    X(0): "abcd" - initial string
    X(1): "bcd" - first letter found
    X(2): "cd" - second
    X(3): "d" - third
    X(4): "" - whole string found
    In the general case you have strings from X(0) to X(N) where N is the number of letters in the original X string.
    Now you consider each letter in the Y sequence from left to right and for each letter you create an X(0) string. You may also have accumulated a number of X strings in other states like maybe five X(1) and four X(2) etcetera. You have a look at the current letter in the Y sequence and check if the X(0) string can be advanced to X(1). If not you discard it. Once a string is in X(1) it's never discarded. Then you also check all other X strings and see if you can advance them. You never advance a string beyond the X(N) state. This proceeds to the end of the Y sequence when the number of X(N) strings tells you how many hits there were.
    Now here comes what I would call a "dynamic programming" strategy. In the above algoritm you keep all X strings of all states but you don't have to. You only need to know how many X strings you have in each state because they all advance too the next state in unison. So you get a table with one entry for each X state. The entry holds the number of X strings in that state.
    What you need to figure out is how to update the X state table as you consider each letter in the Y sequence. The entry for X(N) is the number of hits.

  • Dynamic Programming Using Java

    hiiii...anyone knows how to use a dynamic programming to compare a mouse movement using java??? i hope some one can help me......

    This was just an idea. I do not know of any program
    implementing this. I will not help you store coordinates
    into a database, but I can explain my suggestion in
    more detail.
    Since the characters might be more dependent on the page
    then the user, you must make a sub character for each page.
    Your table row must then contain following fields:
    user, time, page, x-cord, and y-cord.
    Now assume following
    - we will use the characters 'average speed' and
    'centre of gravity of movement'.
    - we have two sessions of data, that is two sets of table
    rows as described above. Every set belongs to different
    users.
    - the sessions are spread on a set of pages.
    Now we will compute the distance between these users. There
    are a lot of distance metrics but let us choose the most
    common one. Let P be a set of points in R^n and p.n
    be the n coordinate of the point p in P. Then for any p1
    and p2 in P, define the distance metric to be
    D(p1,p2) = summa_{over n} (p1.n-p2.n)^2
    Define the average speed for a certain user and page to be
    Speed(user, page) (in) R. Further more let
    Gravity(user, page) (in) R^2 be the centre of gravity of
    movement for a user and page.
    Then the total distance is
    D(user_1, user_2) = summa_{over all pages} k1*D(Gravity(user_1, page), Gravity(user_2, page)) + k2*D(Speed(user_1, page), Speed(user_2, page))
    where k1 and k2 are constants determines the importance
    you want to assign the two characters.

  • Dynamic Programming with 2-D Arrays Possible in Oracle 10g or not?

    Hi all,
    Is there are 2-D arrays in Oracle? and when not, how can I implement any Dynamic Programming Algorithm (An [Knapsack Problem|http://en.wikipedia.org/wiki/Knapsack_problem] ) on data that I have
    Thanks in advance
    Edited by: ZiKaS on Dec 28, 2008 7:10 AM

    Hello,
    By combining single dimension collections you can build 2,3 or x dimension matrix:
    Declare
      type  typ_int is table of integer index by binary_integer ;
      type  typ_tab_int is table of typ_int index by binary_integer ;
      my_table typ_tab_int ;
    Begin
      for i in 1..10 loop
        for j in 1..5 loop
          my_table(i,j) := i * j ;
        end loop;
      end loop;
    End;Francois

Maybe you are looking for