ABAP: Dynamic creation of transparent container

Hello,
I have this code and it fails (null pointer exception):
transparent_container = cl_wd_transparent_container=>new_transparent_container( ).
  cl_wd_grid_data=>new_grid_data( element = transparent_container ).
  ui_container->add_child( transparent_container ).
What is the problem? Do I need to create transparent container and pass some parameters?
Thank you.

Hello Armin,
yes it is.
I have some code like this:
  "create a transparent container
  transparent_container = cl_wd_transparent_container=>new_transparent_container( ).
  cl_wd_grid_data=>new_grid_data( element = transparent_container ).
  ui_container->add_child( transparent_container ).
  "create a dropDown with figures
  drop_down_figure = cl_wd_dropdown_by_key=>new_dropdown_by_key( bind_selected_key = 'REPOSITORY.FIGURES' on_select = 'GET_OPERATOR' ).
  cl_wd_grid_data=>new_grid_data( element = drop_down_figure ).
  ui_container->add_child( drop_down_figure ).
If I comment out code where I create transparent container it works fine and creates dropDown.
However, as soon as I add transparent container I get NullPointer exception.
Thank you.

Similar Messages

  • Dynamic Programming: Adding Transparent Container to Root Element

    Hi,
    I simply am adding a Transparent Container to the Root Element dynamically and I am getting the error "The ASSERT condition was violated".
    Does anyone have an idea what the problem is.
    Below is my VERY MUCH simplified code:
    method WDDOMODIFYVIEW .
      DATA:
        LR_ROOT TYPE REF TO CL_WD_UIELEMENT_CONTAINER,
        LR_TCONTAINER TYPE REF TO CL_WD_TRANSPARENT_CONTAINER,
        LR_FLOW_DATA TYPE REF TO CL_WD_FLOW_DATA.
      LR_ROOT ?= VIEW->GET_ROOT_ELEMENT( ).
      LR_TCONTAINER = CL_WD_TRANSPARENT_CONTAINER=>NEW_TRANSPARENT_CONTAINER(
        id = 'TCONTAINER_01' ).
      LR_FLOW_DATA = CL_WD_FLOW_DATA=>NEW_FLOW_DATA( LR_TCONTAINER ).
      LR_TCONTAINER->SET_LAYOUT_DATA( LR_FLOW_DATA ).
      LR_ROOT->ADD_CHILD( LR_TCONTAINER ).
    endmethod.

    Found the answer on this link:
    Creating dynamic tranparent container

  • ABAP: dynamic creation of nested elements

    Hello,
    I need to create a dropDown and put it into transparent container dynamically. Here is some things that I have:
    Trasparent container:
      transparent_container = cl_wd_transparent_container=>new_transparent_container( ).
      cl_wd_grid_layout=>new_grid_layout( container = transparent_container ).
      cl_wd_grid_data=>new_grid_data( element = transparent_container ).
      ui_container->add_child( transparent_container ).
    and a dropDown:
    drop_down_figure = cl_wd_dropdown_by_key=>new_dropdown_by_key( bind_selected_key = 'REPOSITORY.FIGURES' on_select = 'GET_OPERATOR' ).
      cl_wd_grid_data=>new_grid_data( element = drop_down_figure ).
      ui_container->add_child( drop_down_figure ).
    I need to put this dropDown inside trasparent container that was just created.
    I can get reference to the container this way:
    tr_cont = ui_container->get_child( index = 1 ).
    return type of the above code is cl_wd_uielement.
    I do not see any methods of this type that allow me to put dropDown inside this element.
    Do I need to cast it to cl_wd_uielement_container type first? If so how is casting done?
    Thank you.

    Hi Georrgy,
    Casting is done using "?=".
    For ex:
    DATA: THE_TABLE_CELL_EDITOR type ref to CL_WD_DROPDOWN_BY_KEY,
    THE_TABLE_CELL_EDITOR ?= wd_table_column->GET_TABLE_CELL_EDITOR( ).
    Here I am getting a table cell editor which can be of any type say dropdown, Link to Action etc and since I need dropdown I am casting it using "?=".
    Regards,
    Srini.

  • Dynamic programming: Add transparent container to root container

    Hi all,
    I'm trying to add a transparent container to the root container,
    but I´m getting this error: 'ASSERT condition was violated'
    METHOD WDDOMODIFYVIEW .
      DATA: LR_ROOT       TYPE REF TO CL_WD_UIELEMENT_CONTAINER,
            LR_TCONTAINER TYPE REF TO CL_WD_TRANSPARENT_CONTAINER.
      LR_ROOT ?= VIEW->GET_ROOT_ELEMENT( ).
      LR_TCONTAINER = CL_WD_TRANSPARENT_CONTAINER=>NEW_TRANSPARENT_CONTAINER( ).
      CL_WD_FLOW_DATA=>NEW_FLOW_DATA( LR_TCONTAINER ).
      LR_ROOT->ADD_CHILD( LR_TCONTAINER ).
    ENDMETHOD.
    Is something wrong with this code?
    Thank you.
    Regards,
    Thomas

    >
    Giscard Rous wrote:
    > I have the same problem.
    > I am getting the error "The ASSERT condition was violated".
    >
    > I have reduced my code to just simply add a transparent container to the rootuielement and I am getting the error.
    >
    > I could not figure out why.  Does anyone have info on this?  Thanks.
    >
    > Giscard
    My problem was the layout, after I added it, the problem was solved.
    METHOD WDDOMODIFYVIEW .
      DATA: LR_ROOT       TYPE REF TO CL_WD_UIELEMENT_CONTAINER,
                 LR_TCONTAINER TYPE REF TO CL_WD_TRANSPARENT_CONTAINER.
      LR_ROOT ?= VIEW->GET_ROOT_ELEMENT( ).
      LR_TCONTAINER = CL_WD_TRANSPARENT_CONTAINER=>NEW_TRANSPARENT_CONTAINER( ).
      CL_WD_FLOW_DATA=>NEW_FLOW_DATA( LR_TCONTAINER ).
      CL_WD_FLOW_LAYOUT=>NEW_FLOW_LAYOUT( LR_TCONTAINER ).
      LR_ROOT->ADD_CHILD( LR_TCONTAINER ).
    ENDMETHOD.
    Hope it helps you.
    Regards,
    Thomas

  • Generate a dynamic Transparent container in WD

    Hi all,
    i' ve created a Transparent conatiner in where i will write my text, i also created a Button (ADD)
    what i want now is, after clicking on the (Add) Button, a new Transparent container will appear, 
    how can' I do this dynamically??  i dont want to create 10 or 20 transparent container in my main view, i want to create  only one, and after clicking on the Add Button, an other one will appears,
    is there a way or any method to do this?
    thank you all for your help

    Hello Thomas,
    You could refer the below thread. [thread|Re: How to dynamically generate a transparent container ?]
    all the code required to do things dynamically has to be inside wddomodifyview method of that particular view.
    Since you want that on a click of a button you would like to add a new transparent container, you could create a varible of type wdy_boolean under attributes tab of the view and onaction associated with the button you change that value and you write the code for transparent container in wddomodifyview, and before that could you could have a if statement if variable value is true you would run the below code.
    Regards
    Anurag Chopra

  • Short dump while creating transparent container dynamically

    Hi experts!
    I want to create a transparent container dynamically, but I get a Short Dump (
    Note
    The following error text was processed in the system NSP : Access via 'NULL' object reference not possible.
    The error occurred on the application server Datatrain_NSP_00 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Method: CREATE_BY_VIEW_ELEMENT of program CL_WDR_VIEW_ELEMENT_ADAPTER===CP)
    while doing so. Below my code...
    Can somebody please advise I don't know what I did wrong....
    Thanks in advance!
    Points will be rewarded
    METHOD wddomodifyview .
    DATA: lr_container TYPE REF TO cl_wd_uielement_container,
            lr_matrix_head TYPE REF TO cl_wd_matrix_data,
            lv_hlp_str TYPE string VALUE 'DYNCONT_1',
            lr_trans_cont TYPE REF TO cl_wd_transparent_container.
        lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
    CALL METHOD cl_wd_transparent_container=>new_transparent_container
      EXPORTING
        enabled                  = ABAP_TRUE
        id                       = lv_hlp_str
        is_layout_container      = ABAP_TRUE
      receiving
        control                  = lr_trans_cont
        lr_matrix_head = cl_wd_matrix_head_data=>new_matrix_head_data(
                            element = lr_trans_cont ).
        lr_trans_cont->set_layout_data( lr_matrix_head ).
        lr_container->add_child( lr_trans_cont ).

    Hi Felix,
    You need to set the layout first and then set the layout data. Use the method cl_wd_matrix_layout=>new_matrix_layout. Do a set_layout on the container and then do set_layout_data. That should solve your problem.
    Regards
    Nithya

  • Add a Transparent Container dynamically in wddomodifyview

    Hi All,
    I have added UI Elements to views before. Now, I am trying to add a Transparent Container to a Group, which does not work. I am using the same procedure as I have used it for other UI Elements before, but I keep receiving the dump:
    The following error text was processed in the system JIL : Access via 'NULL' object reference not possible.
    The error occurred on the application server SV-SAP-2_JIL_01 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Method: CREATE_NW7_BY_VIEW_ELEMENT of program CL_NW7_VIEW_ELEMENT_ADAPTER===CP
    My code is as follows:
    lo_group ?= view->get_element( 'GROUP' ).
        lo_tc = cl_wd_transparent_container=>new_transparent_container( id = 'TC_SECOND_ELEMENT' ).
        cl_wd_matrix_head_data=>new_matrix_head_data( element = lo_tc ).
        lo_group->add_child( the_child = lo_tc ).
    Why does the coding above not work?? How is the proper coding to add a Transparent Container to my group?
    THANKS, Johannes

    Hi,
    Your coding seems to me fine. Though i am not sure if this line causes the error.
    cl_wd_matrix_head_data=>new_matrix_head_data( element = lo_tc ).
    I normally get this error when the UI element property is not binded correctly. How sure are you that this error is coming  because of this TransparentContainer ?.
    You can comment out the whole and check if this is working.
    Then enable one by one and see if you get it worked.

  • Dynamic Transparent Container

    Hi,
    I am new to Web Dynpro. I have the following problem.
    How to set Streched horizontal property in Transparent Container dynamically?
    Thanks,
    Peter,

    hi
    hope it will be very helpful
    IWDTransparentContainer transNew=(IWDTransparentContainer)view.createElement(IWDTransparentContainer.class,"TranName");
    transNew.createLayout(IWDMatrixLayout.class);
    transNew.destroyAllChildren();
    IWDMatrixLayout gl=(IWDMatrixLayout)transNew.createLayout(IWDMatrixLayout.class);
    gl.setStretchedHorizontally(false);
    gl.setStretchedVertcally(false);
    if you give gl.setStretchedVertcally(false);
    it will be very compact structure in your view
    Regards
    Dhinakar J

  • How to hide a transparent container and its fields in webdynpro abap

    Hello Friends,
    I am trying to create a view where i want to show some fields based on some other field.
    What i exactly need is When i enter some data in 1 input field .
    Corresponding to that input field few text fields wud be opened automatically in the same view.
    No Pop-ups allowed.
    What i am doing is !!
    i have created another Transparent container for my  text view fields.
    But i  am unable to hide this fields..
    Kindly help..
    At the runtime..
    After entering the value in the input field..
    This transparent container should become visible with the textview fields...
    Gaur Mayank

    Hi,
    Create A Context Attribute (Say  Visible_Hide )of Type WDUI_VISIBILITY with initial value as 01.
    Goto your Container, Bind the Visible Property with Above Created Attribute(Visible_Hide).
    In the Input Field,Use the OnEnter Event and Set the Value to Visible_Hide as 02.
    Then the Container will be Visible.
    Thaks.
    Uma

  • Transparent Container Cell Background design

    Hi All,
    I have a scenario where in on click of a link, I'm needed to highlight a transparent container. In Webdynpro JAVA i used to achieve this using Transparent Container -> cellBackGroundDesign -> WDCellBackgroundDesign.BORDER
    What is the equivalent of this in WD ABAP. I do not find any such attribute in particular.
    Any pointers on this will be of great help.
    Thanks & Regards,
    Gayathri Shanbhag

    Hi All
    On switching from flow to matrix layout I found the property cellBackGroundDesign, but it is not bindable to an attribute, in my scenario I'm needed to set the border/highlight dynamically. Please suggest if there is an alternative.
    Thanks & Regards,
    Gayathri Shanbhag

  • Transparent Container UI Element

    Hi
    I am new to Web Dynpro for ABAP and have been tasked with the creation of a complex input screen with a tabbed strip of 12 tabs with 7 columns on each tab.  Each column also has multiple input fields on it. 
    My question is in the design of the screen.  I am currently equating the Transparent Container as an (X)HTML DIV tag for my screen formatting.
    Would this be a fair assumption?
    Are there any documents on screen design?
    Regards
    Ian

    Ian,
    For HTML client TransparentContainer is in fact rendered as DIV element. Though, it may be changed.
    Anyway, this is quite safe analogy.
    For your task you may use either:
    1. Matrix/Grid layout of Tab content and no Transparent containers at all. You may get columns effect using layout only.
    2. Matrix layout with 7 columns (one row) and transparent container in every cell. Use this only if [1] is not suitable, i.e. when layout in every column differs too much.
    Valery Silaev
    SaM Solutions
    http://www.sam-solutions.net

  • How to embed views dynamically in a view container ?

    Hi ,
        Can you please guide me how to embed a view dynamically in a view container ?
    Thanks & Regards
    Gaurav Jain

    Hello,
    Please read this [/people/rajagopal.vemuri/blog/2006/09/19/web-dynpro-for-abap-creating-dynamic-ui-elements-and-context-step-by-step].
    Regards.

  • Dynamic creation of TabStrip

    Hi,
    I want to create a tabstrip dynamically.The tabstrip should have 3 tabs, and in each of the tabs i want to put some UI elements like a label, input field, dropdown, tables.........etc.
    Im able to create the tabstrip and add tabs to it dynamically.
    I've even created the UI elements which i wanted to put in the tabs.............But im not able to proceed as i dont know how to add the UI elements to the tabs.......
    Can anyone tell me how to add UI elements to a tab in a tabstrip?
    Regards,
    Padmalatha.K
    Points will be rewarded.

    Hi,
    Following code will help you to understand the dynamic creation and adding them
    //Tabstrip
           IWDTabStrip tabStrip = view.createElement(IWDTabStrip.class);
           //Tab
           IWDTab tab = view.createElement(IWDTab.class);
           //Input Field
           IWDInputField inputField = view.createElement(IWDInputField.class);
           //Adding inputfield to tab
           tab.setContent(inputField);
           //Adding tab to tabstrip
           tabStrip.addTab(tab);
    //Finally add this tabstip to either your root container or some other container.
    Regards
    Ayyapparaj

  • Programatically hide a transparent container

    Hi Experts,
    i am using select options in my application.
    i have made two block for the selec options (transparent container 1 and transparent container 2) by using add_block method of select option.So i cant do the normal context binding as containers are created programatically.
    Now i have a requirement to hide one of the block on click of an event so that the select options inside is also hidden.
    DATA lo_ui_element      type ref to CL_WD_UIELEMENT.
          DATA lo_container       TYPE REF TO cl_wd_uielement_container.
          DATA lo_transc           TYPE REF TO cl_wd_view_element.
    " get root container
         lo_container ?= view->get_root_element( ).
    *" get button reference
         lo_transc ?= lo_container->get_child() // Get the tray which container the view container of select options.
    then inside this i have the transparent container which has the selec options.
    Please help
    Tashi

    Hi Tashi,
    1. Add your Select-Options screen elements(Your blocks) to UI View Container element and bind the context to WDUI_VISIBILITY. Set the visibility depends on your requirement.
    2. You have REMOVE_SELECTION_SCREEN_ITEM method from Interface IF_WD_SELECT_OPTIONS to remove the fields at runtime.
    Please follow the below link
    Creation and Deletion of selection screen elements based on user action
    Hope it helps you
    BR,
    RAM.

  • Move transparent container from tab to new view

    Hi
    I have a scenario where I wish to move the whole layout structure from a tab to a new view.
    Essentially I want to move from a tabstrip to a roadmap type of development.  My issue is that if I copy the transparent container that houses the whole structure, when I paste the structure all my elements have _CP. Is there any way to paste without have this suffix?
    Cheers
    Ian

    >
    Thomas Jung wrote:
    > I can't think of any offical way of doing this. 
    >
    > I have one suggestion - but it is totally not supported by SAP and if anyone asks you didn't get it from me.
    > You could use SAPLink to export the component to XML.  Once in XML on your desktop, use a text editor to do a mass find and replace.  Then reimport the same object back into your system via SAPLink.
    > [http://code.google.com/p/saplink/|http://code.google.com/p/saplink/]
    >
    > Just curious however - why worry about the _CP on the UI elements at all?  It is just that you don't like the prefix?  I agree it makes things look messy, but if you are correcting binding UI to your context instead of directly coding against the UI elements (with the rare exception of really dynamic stuff) the IDs of the element shouldn't break anything in your application.
    PS:  Obviously monkeying around with the component using find and replace on the XML and importing via SAPLink could be dangerous. I just thought after I posted I should stress the warning a little more.  You probably want to copy your entire component before attempting this - just incase it completely screws things up.

Maybe you are looking for

  • Illustrator file missing objects when placed in InDesign

    I created an Illustrator file that has text converted to outlines. Some of it is white and some of it is other colors. When I save the file as eps, pdf or export as jpg and then place the files in InDesign, the white outlined text doesn't show up. Ad

  • Need to reinstall carbon copy in new disk format...

    I want to reinstall Tiger on my eMac and keep all my settings and files. The only thing I need to change is that I formatted the drive in the Unix format because I thought it was the preferred standard. Oops. I have .mac but no other back up software

  • Compatibility with multiple inputs

    i've been thinking about buying a firewire 1814 (made by m-audio), but i'm curious as to whether it will work with LE 7. especially with an intel-based macbook pro. (i've heard bad stories of people buying these devices but they are not intel compati

  • ACS v3.2 Default Username and Password

    Dear All, Do you know what is the default login username and password for ACS v3.2? Besides, If I forget the password, is there any password recovery procedure for ACS? Thanks. C.K.

  • Cache mode for specific query

    Hello BI guys, This is Calvin from Korea. We are implementing BI 7.0 and have some severe performance problem. For some queries they don't use cache mode, even though the global cache are used. When I checked these kind of queries by performance info