Dropdown listboxes in pl/sql

Hi,
This is what I want to do. I have created forms using pl/sql and I have 2 dropdown list boxes. The information in the listboxes comes from a table in the database. The first one is a source system. and the second one is an rma number. I want it so that when the source system is picked that only the rma numbers related to that source system will be displayed in the DDL. Is it possible to do this? if so How? There are approximately 100,000 rma_numbers in the database
THanks,
Jennifer

For the second (rma) ddl, you could create a record group to hold the values, with Type Query and the Query set to:
Select RMA, RMA from TABLE_RMA where SOURCE = :some_variable
Then for the when-button-pressed, etc, triggers call a procedure that uses the built-in "POPULATE_LIST" with say:
POPULATE_LIST(the_lists_id, 'the_record_groups_name');
I think that would work.

Similar Messages

  • Dropdown listbox getting values from domain

    Hi,
    I want to create a Dropdown listbox that gets its values from a dictionary domain. I usually get the values from a table but there's a case where I need to get them from a domain. Is it possible?
    Thanks.

    Hi Carles,
    If you are talking about the Domain which is used inside a Data Element, while defining data types, and as far as my knowledge goes...
    We cannot store values in Domain...they are just for declaring Data types...And it is the Table Field which stores the values...
    Hope this helps...
    <b><i>Do reward each useful answer..!</i></b>
    Thanks,
    Tatvagna.

  • How to get the values in the dropdown listbox  for screen field

    hi friends !
            I have selected dropdown listbox for a field in the screeen. Now, how to pass the possible values into the list. Please give the kind help.
    Regards,
    -Prasad.

    Hi Prasad,
    As Raja had mentioned, this topic has been discussed many times in this forum in the past. Please make sure that you first search the forum for related topics before you post new ones. that would avoid a lot of redundancy. Anyays, here are some of the topics you can refer to:
    Drop down list
    DROP DOWN BOX
    http://help.sap.com/saphelp_46c/helpdata/en/9f/dbabe435c111d1829f0000e829fbfe/content.htm
    Regards,
    Anand Mandalika.
    P.S: Please don't forget to reward points and close the thread once your problem is resolved.

  • How to read selected item of the dropdown listbox in dialog prgmming

    hello to all,
    i need one help.In dialog programming how to read the selected value of the dropdown listbox created in se51. the values are appering in listbox by using FM 'VRM_SET_VALUES' .and function code is also assigned to lisbox .but how to read that one particular value selected by user form the dropdown list.
    thanks.

    hello mate
    Try this following  logic and code  u will getting the answer
    Here this example  :  
                      Let Name of the LIST BOX BE  :  LT
    Code :
    Data Declaration :
      I_NATIO TYPE VRM_VALUES,
      W_NATIO LIKE LINE OF I_NATIO
    data: begin of itab occurs 0,
    LT(10)  type c,    
    end of itab.
    **This query to data retrival
    select  x1 x2 into table itab form tbl .
    loop at itab.
    w_natio-key = itab-LT.
    w_natio-text = itab-LT.
    append w_natio into i_natio.
    clear w_natio.
    endloop.
    **This code  for setting values in the list box
    CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          ID     = 'LT'
          VALUES = I_NATIO.
    **This code getting the valu form the list box
      CALL FUNCTION 'VRM_GET_VALUES'
        EXPORTING
          ID     = 'LT'
        IMPORTING
          VALUES = I_NATIO.
    **simply to print the values selected
    write : i_natio-lt.
    I hope this will help u out.
    Anand

  • Webdb dropdown listboxes

    Hi,
    I am using webdb 2.2.0 to build forms. I have created a dynamic html page which have 2 dropdown listboxes on it. THese are populated by a select statement. This is what I want to do. I want to be able to select an item in the first listbox which is a source system and populate the 2nd DDL with data with the same source system that I have selected with the first DDL. How can I accomplish this?
    Jen

    You should have a record group based on a select that fetches the "rma numbers" (whatever those are)depending on the "source system". Then, on the when-list-changed trigger for the "source system" list-item, use populate_list('rma_num_list', 'rma_record_group');
    I figure that's what you need.
    Regards,
    BD.

  • Dropdwon listboxes in pl/sql

    Hi,
    This is what I want to do. I have created forms using pl/sql and I have 2 dropdown list boxes. The information in the listboxes comes from a table in the database. The first one is a source system. and the second one is an rma number. I want it so that when the source system is picked that only the rma numbers related to that source system will be displayed in the DDL. Is it possible to do this? if so How? There are approximately 100,000 rma_numbers in the database
    Thanks,
    Jennifer

    You should have a record group based on a select that fetches the "rma numbers" (whatever those are)depending on the "source system". Then, on the when-list-changed trigger for the "source system" list-item, use populate_list('rma_num_list', 'rma_record_group');
    I figure that's what you need.
    Regards,
    BD.

  • Setting default text to dropdown listbox

    I have a field on my Webdynpro defined as DropDownByKey.
    The field's list for the dropdown list is coming from a domain with a list of all the values.
    I want to default the field to one of the values in the list from the domain, but I want the description, not the key value to default or showup as the default.
    I don't see the method to use in class CL_WD_DROPDOWN_BY_KEY.  Is there a method or someway to do this?
    Thanks
    John

    Sujay,
    I found out the easiest way around this without adding any code. 
    If you have a field on your iView that points to a structure or table field where the domain for that particular field is a list of values, typically the doman has a fixed value as the key and then the short description.
    In most cases the user does not want to see the key fixed value, just the description.
    When you add this field to your iView, you must choose the properties DropDownByKey.  This will take care of showing the description and not the fixed key value.  And not to worry, the value stored to the database will be the fixed value and not the description.
    Johnny

  • Add initial line to dropdown listbox

    Hi colleagues,
    I want to add a initial line to a drop down list box, which I am filling by my own.
    Its an bsp_wd_dropdown_table.
    I already tried 3 ways to get this done:
    INSERT INITIAL LINE INTO lt_ddlb INDEX 1
    APPEND INITIAL LINE TO lt_ddlb.
    ls_ddlb-key = ''.
    ls_ddlb-value = ''.
    APPEND ls_ddlb TO lt_ddlb.
    But all 3 variants are not working - the framework is deleting the initial line.
    But If I assign a key, and a empty value, it may works, but I need to change my whole coding, where I am checking if this value is initial...
    Any ideas?
    Best Regards,
    Marcus
    Edited by: Marcus Rieck on May 31, 2010 1:07 PM

    Hi Marcus,
    I've done a similar thing before and your 3rd part works well for me.
    data: lt_ddlb type bsp_wd_dropdown_table,
            ls_ddlb type bsp_wd_dropdown_line.
      if gr_ddlb_fieldtype is not bound.
        CREATE OBJECT gr_ddlb_fieldtype
          EXPORTING
            iv_source_type = 'T'.
        ls_ddlb-key = '1'.
        ls_ddlb-value = 'GP-ID'.
        append ls_ddlb to lt_ddlb.
        ls_ddlb-key = '2'.
        ls_ddlb-VALUE = 'Information'.
        append ls_ddlb to lt_ddlb.
        ls_ddlb-key = ''.
        ls_ddlb-value = ''.
        append ls_ddlb to lt_ddlb.
        gr_ddlb_fieldtype->set_selection_table( lt_ddlb ).
      endif.
      rv_valuehelp_descriptor = gr_ddlb_fieldtype.
    Actually I'm not sure if it's important where to enter the empty line.
    In my case i added it at the end.
    Maybe you can post your get_v-method just for checking?
    Regards
    Dennis

  • Sales office is not visible in dropdown listbox on BP Organisation tab

    Hi Experts,
    we use CRM 4.0 with R/3. I have created a new sales office in ppoma_crm transaction in CRM.
    Under the function tab I set everything like in another sales office but if I want to choose my new sales office in BP transaction under Organization tab the new sales office is not displayed.
    Thanks for the help in advance!
    Regards,
    Tom

    Hi Thomas,
    Go to PPOMA_CRM transaction and select the org with sales group details
    Go to Attribute tab in lowermost right hand window. Select scenario, sales.
    Check the option 'Permitted for determination'
    Save the settings.
    Go to SE38.
    Execute report: HRBCI_ATTRIBUTES_BUFFER_UPDATE
    Best Regards,
    Pratik Patel
    <b>Reward with Points!</b>

  • Dropdown menue or selectlist from fetched SQL results

    Hello i try to build a selectlist or a dropdown menue from fetched Sql results i tryed many ways to realise this but nothing works is anybody here knowing how to do this?
    heres my code example but it isnt work:
    <?php
    if ($conn=OCILogon($HTTP_POST_VARS['user'], $HTTP_POST_VARS['pass'], $HTTP_POST_VARS['dienst'])) {
    echo "Successfully connected to Oracle.\n";
    OCILogoff($c);
    } else {
    $err = OCIError();
    echo "Oracle Connect Error " . $err[text];
    //fetch
    $stmt = OCIParse($conn,"select Table_Name from User_Tables");
    OCIExecute($stmt);
         while (OCIFetch($stmt))
         print "<select name="Rang">";     
         print "<option>$id</option>\n";
         print "</select>";
    OCILogoff($conn);
    ?>
    Message was edited by:
    LOD
    Message was edited by:
    LOD

    There's a basic error in your sample code. You query for table_name from user_tables, which basically just lists the tables that exist in your schema. Since you're using 'id' further on, I suspect your query would look something like 'select id from users'.
         while (OCIFetch($stmt))
         print "<select name="Rang">";     
         print "<option>$id</option>\n";
         print "</select>";
    }This won't work for 2 major reasons.
    1. the $id variable is not set to anything. Note that OCIFetch does not extract variables. You can retrieve them using OCIResult($stmt, 'id'). I myself prefer to use OCIFetchInto as it is much easier to use and gives code that is better readable:
    while (ocifetchinto($stmt, $record))
      print $record['ID'];
    }2. You've put the <select></select> code in your loop. I assume that you only want to loop options, so the <select></select> should be moved to outside the loop.

  • Adobe Livecycle and SQL Server Conditional Dropdowns

    Hello All,
    I am trying to figure it out but have a little difficulty.
    I have two dropdowns connected to a SQL database (for this purpose DD1 and DD2). I need to be able to make the dropdowns conditional.
    Example:
    SQL DB
    Fruit | Color
    Apple | Green
    Apple | Red
    Apple | Purple
    Apple | White
    Plum | Purple
    Plum | Light Purple
    Plum | Black
    DD1 will ask what the fruit will be. DD2 will ask the color depending on DD1.

    Hi Dang_Randy,
    Doing the following might help.
    1) On the enter/initialize event of DD1, call a servlet that fetches all the fruits. Split and add the fruit items to DD1.
    2) Once the fruit is selected from DD1, on the exit or change event of DD1, call another servlet (pass fruit selected in DD1) that fetches the colors of the fruit.
    Hope this helps.
    Thanks,
    VJ

  • Dropdown Lisx box in servlets

    HI,
    I have a servlet with dropdown list box and text item. Whenever i choose the value based on that I have to display some data
    below the these Items.( Dropdown and Text item).
    The input in the text item will search in the below diplayed data and re-display again.
    My question is, when i change the value in the dropdown listbox, it is not changing the data and selected value is
    NOT staying in the dropdown listbox. can anybody help me in this problem.
    Here is my code...
    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("</HEAD>");
    String i_country="USA";
    String i_key =" ";
    out.println("<BODY onLoad=\"document.lov.i_key.focus()\">");
    out.println("<DIV align=left>");
    out.println("<FORM ACTION=physician_internal_medical_school_popup name=lov>");
    // out.println("<INPUT TYPE=hidden NAME=pProfessionID VALUE=1>");
    out.println("<FONT FACE=Arial,Helvetica SIZE=-1>Country:<SELECT NAME=i_country onChange=\"document.lov.submit()\">");
    while(Country.next())
    if(Country.getString("country").equals(i_country))
    out.println("<OPTION SELECTED>"+Country.getString("country"));
    else{
    out.println("<OPTION>"+Country.getString("country"));
    } // End of IF stmt
    } // End of While Country
    out.println("</SELECT>");
    out.println("</FONT>");
    out.println("<FONT FACE=Arial,Helvetica SIZE=-1>Search:</FONT><INPUT TYPE=text NAME=i_key SIZE=20 MAXLENGTH=20 onChange=\"document.lov.submit()\" VALUE="+ i_key+">");
    out.println("</FORM>");
    if ( i_country == "** UNKNOWN **")
    School_2 = stmt3.executeQuery(" SELECT name "+
    "     FROM LP_SCHL_PRG "+
    "          WHERE profession_id = "+p_profession_id +
    "          AND country IS NULL "+
    " AND name LIKE '%"+i_key+"%'"+
    "          ORDER BY 1" );
    while(School_2.next())
    out.println("<FONT FACE=Arial,Helvetica SIZE=-2><A HREF=\"javascript:sendValue('Albany Medical College')\">"+School_2.getString("name")+"</A></FONT><BR>");
    } // End of While School_2
    }else
    School_1 = stmt2.executeQuery(" SELECT name "+
    "     FROM LP_SCHL_PRG "+
    "          WHERE profession_id = "+p_profession_id +
    "          AND country = '"+i_country +"'"+
    " AND UPPER(name) LIKE '%"+i_key+"%'"+
    "          ORDER BY 1 ");
    while(School_1.next())
    out.println("<FONT FACE=Arial,Helvetica SIZE=-2><A HREF=\"javascript:sendValue('Medical College')\">"+School_1.getString("name")+"</A></FONT><BR>");
    } // End of While School_2
    } // End of If
    out.println("</FORM>");
    out.println("</DIV>");
    out.println("</BODY>");
    out.println("</HTML>");

    Just a hint:
    I think that
    get reference of status_tab into M_MAT_REF
    creates a reference to the local variable status_tab.
    At the time then the drop-down is rendered, this local variable does not exist anymore.
    I would try is this way
      FIELD-SYMBOL <fs> TYPE TIHTTPNVP.
      CREATE DATA me->m_mat_ref TYPE TIHTTPNVP.
      ASSIGN me->m_mat_ref->* TO <fs>.
      <fs> = status_tab.
    or this way
    1) change the type of m_mat_ref to TYPE TIHTTPNVP (not TYPE REF TO TIHTTPNVP).
    2)
    DATA lr_mat_ref TYPE REF TO TIHTTPNVP.
    m_mat_ref = status_tab.
    GET REFERENCE OF m_mat_ref INTO lr_mat_ref.
    p_replacement_bee = CL_HTMLB_DROPDOWNLISTBOX=>FACTORY(
    id = p_cell_id
    selection = m_row_ref->STATUS
    table = lr_mat_ref
    nameOfKeyColumn = 'NAME'
    nameOfValueColumn = 'VALUE' ).

  • Mail values from dynamic dropdown

    Hi all,
    need your help to solve a problem.
    With LCD, I create a form with a dropdown listbox and a send button.
    If I maintain the values directly in LCD, everything works fine. The mail contains an XML with the chosen value.
    I've also find out, how to read the value dynamically from an XML.
    But when I do both, the XML contains the entire list instead of the selected value.
    Does anybody have a solution?
    Thanks and regards
    Martin

    Hi
    This should provide you the clue.
    Eg;
    *// Call the function module to send mail notification
          CALL FUNCTION 'ZHR_EMAIL_SEND_NOTIFCATION' IN BACKGROUND TASK AS SEPARATE UNIT
            EXPORTING
              im_pernr = ipspar-pernr
              im_massn = ipspar-massn
              im_massg = ipspar-massg
              im_begda = ipspar-begda
              im_endda = ipspar-endda.
    In this example, the preparation and sending the mail is done in the FM which is called in SEPERATE UNIT (different logical unit of work), so that, dynamic actions and mail sending are seperated and work in different space.
    Regards
    Raj

  • IC WebClient: Add Dropdown Box to TableView

    Has anyone successfully added a dropdown box inside of a CRM IC WebClient table that uses a context node?  If so, I would appreciate some advice!  I have read Brian's blog about table view iterators, but as usual the application in CRM is slightly different. 
    I'm working with a custom column in the result list (Customers context) on the BuPaSelectCustomer view.  I want my custom column to be editable via a dropdown box.  Here's what I've done:
    1) Created a custom class that implements the IF_HTMLB_TABLEVIEW_ITERATOR interface
    2) Created an attribute of the Customers context class called ITERATOR that is typed as the new class in #1
    3) Added the iterator attribute to the crmic:tableView
    element in the page which points to the attribute defined in #2: iterator = "<%= customers->iterator %>"
    4) Set edit = "TRUE" attribute in the crmic:tableViewColumn element for my new column named 'ZZSLSTATUS'
    5) In the controller class SET_MODELS method:
    * Create iterator for table
      IF NOT iterator IS BOUND.
        CREATE OBJECT iterator TYPE ZCL_CRM_SELCUST_TV_ITERATOR
          EXPORTING
            ir_context_node = typed_context->customers.
      ENDIF.
    The constructor looks like this:
    method CONSTRUCTOR .
      gr_context_node = ir_context_node.
    endmethod.
    6) GET_COLUMN_DEFINITIONS looks like this:
      data: wrapper type ref to cl_bsp_wd_collection_wrapper.
      gv_current_line = 0.
      gv_tableview_id = p_tableview_id.
    * get the wrapper of the context node
      wrapper = gr_context_node->get_collection_wrapper( ).
    * fill the local iterator
      gr_iterator = wrapper->get_iterator( ).
    7) RENDER_ROW_START looks like this:
    * Position on correct index
      gr_iterator->get_by_index( iv_index = p_row_index ).
    8) RENDER_CELL_START looks like this:
    DATA: LT_RECSTAT      TYPE TABLE OF IHTTPNVP,
          LS_RECSTAT      TYPE IHTTPNVP,
          LR_COL_DROPDOWN TYPE REF TO CL_HTMLB_DROPDOWNLISTBOX.
    FIELD-SYMBOLS: <TABLE> TYPE  TIHTTPNVP.
    * Simple 1 record table for now
      LS_RECSTAT-NAME  = '1'.
      LS_RECSTAT-VALUE = 'Not Called'.
      APPEND LS_RECSTAT TO LT_RECSTAT.
      CASE P_COLUMN_KEY.
        WHEN 'ZZSLSTATUS'.
          IF NOT P_EDIT_MODE IS INITIAL.
    *       Create replacement bee to show a dropdown listbox in the
    *       table cell
            CREATE OBJECT LR_COL_DROPDOWN.
            LR_COL_DROPDOWN->ID                = P_CELL_ID.
            LR_COL_DROPDOWN->NAMEOFKEYCOLUMN   = 'NAME'.
            LR_COL_DROPDOWN->NAMEOFVALUECOLUMN = 'VALUE'.
            TRY.
                CREATE DATA LR_COL_DROPDOWN->TABLE TYPE TIHTTPNVP.
              CATCH CX_SY_CREATE_DATA_ERROR.
                RETURN.
            ENDTRY.
            ASSIGN LR_COL_DROPDOWN->TABLE->* TO <TABLE>.
            IF SY-SUBRC = 0.
              <TABLE> = LT_RECSTAT.
            ENDIF.
            LR_COL_DROPDOWN->SELECTION = GR_CONTEXT_NODE->GET_ZZSLSTATUS(
                                                ATTRIBUTE_PATH = ''
                                                ITERATOR = GR_ITERATOR ).
            P_REPLACEMENT_BEE = LR_COL_DROPDOWN.
          ENDIF.
      ENDCASE.
    Nothing happens to the cells in my column (they still appear as uneditable with their initial values) and my breakpoints aren't hit in the custom iterator class methods when the table is rendered.  Any ideas? 
    Thanks,
    Brad

    Brad or anyone who could help:
    I found this article very useful and tried to follow the samples. I am not very experienced in BSP and I only need to add a column to BuPaSelectCPforCustomer IC webclient tableview.
    Step 1 - done.
    step 2 - I am not sure I did it right. I created a custom class ZCL_CRM_IC_BUPASELCP_CN02 for CONTACTRELATION and added an attribute ITERATOR to the class.
    step 3 I add this to crmic:tableView
       iterator = "<%= CONTACTRELATION->iterator %>"
       but I go compile errors like "Field iterator is unknown".
    Step 4 - skip
    Step 5 - I assume the controller class is the top controller which in my case is ZL_CRM_IC_BUPASELECTCPFOR_IMPL->SET_MODELS. I added this code:
         IF NOT iterator IS BOUND.
         ENDIF.
    I got the same compile errors like "Field iterator is unknown".
    I think I missed something somewhere. I would really appreciate it if you could shed more light on this.
    Thank you so much.

  • Listbox in alv grid output -Possible?

    Can List box or drop down box can be placed in ALV Grid(Using FM) Ouput for a field .
    please clarify

    Check thse two examples.
    BCALV_EDIT_06
    BCALV_EDIT_07
    check the steps..
    Re: Dopdown Listbox in ALV Grid OO Concept
    and also Check this code.
    also check the below threads...
    List Box in ALV Grid
    In ALV  list box
    Dropdown list  in ALV
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    REPORT  ZTEST1234_ALV_TOP    MESSAGE-ID ZZ                           .
    DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: L_VALID TYPE C,
          V_FLAG,
          V_DATA_CHANGE,
          V_ROW TYPE LVC_S_ROW,
          V_COLUMN TYPE LVC_S_COL,
          V_ROW_NUM TYPE LVC_S_ROID.
    DATA: IT_ROW_NO TYPE LVC_T_ROID,
          X_ROW_NO TYPE LVC_S_ROID.
    DATA:BEGIN OF  ITAB OCCURS 0,
         VBELN LIKE LIKP-VBELN,
         POSNR LIKE LIPS-POSNR,
         CELLCOLOR TYPE LVC_T_SCOL, "required for color
         DROP(10),
         END OF ITAB.
    "The Below Definitions Must.....
    DATA:
    * Reference to document
           DG_DYNDOC_ID       TYPE REF TO CL_DD_DOCUMENT,
    * Reference to split container
           DG_SPLITTER          TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
    * Reference to grid container
           DG_PARENT_GRID     TYPE REF TO CL_GUI_CONTAINER,
    * Reference to html container
           DG_HTML_CNTRL        TYPE REF TO CL_GUI_HTML_VIEWER,
    * Reference to html container
           DG_PARENT_HTML     TYPE REF TO CL_GUI_CONTAINER.
    "up to here
    *       CLASS lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
    **Hot spot Handler
        HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                          IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
    **Double Click Handler
        HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                                         IMPORTING E_ROW E_COLUMN ES_ROW_NO,
        TOP_OF_PAGE FOR EVENT TOP_OF_PAGE              "event handler
                             OF CL_GUI_ALV_GRID
                             IMPORTING E_DYNDOC_ID.
    *        END_OF_LIST FOR EVENT end_of_list              "event handler
    *                         OF CL_GUI_ALV_GRID
    *                         IMPORTING E_DYNDOC_ID.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    *       CLASS lcl_event_handler IMPLEMENTATION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Handle Hotspot Click
      METHOD HANDLE_HOTSPOT_CLICK .
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW_ID.
        V_COLUMN = E_COLUMN_ID.
        V_ROW_NUM = ES_ROW_NO.
    *    MESSAGE I000 WITH V_ROW 'clicked'.
        CLEAR IT_ROW_NO[].
        X_ROW_NO-ROW_ID = V_ROW.
        APPEND X_ROW_NO TO IT_ROW_NO .
        CALL METHOD G_GRID->SET_SELECTED_ROWS
          EXPORTING
            IT_ROW_NO = IT_ROW_NO.
      ENDMETHOD.                    "lcl_event_handler
    *Handle Double Click
      METHOD  HANDLE_DOUBLE_CLICK.
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW.
        V_COLUMN = E_COLUMN.
        V_ROW_NUM = ES_ROW_NO.
        IF E_COLUMN = 'VBELN'.
          SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
          CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
        ENDIF.
        IF E_COLUMN = 'POSNR'.
          SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
          CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN."
        ENDIF.
      ENDMETHOD.                    "handle_double_click
    *  METHOD END_OF_LIST.                   "implementation
    ** Top-of-page event
    *    PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
    *  ENDMETHOD.                            "top_of_page
        METHOD TOP_OF_PAGE.                   "implementation
    * Top-of-page event
        PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
      ENDMETHOD.                            "top_of_page
    ENDCLASS.                    "LCL_EVENT_HANDLER IMPLEMENTATION
    *&             Global Definitions
    DATA:      G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
                G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
    DATA: OK_CODE LIKE SY-UCOMM,
          SAVE_OK LIKE SY-UCOMM,
          G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
          GS_LAYOUT TYPE LVC_S_LAYO.
    data: v_lines type i.
    data: v_line(3) type c.
    *- Fieldcatalog for First and second Report
    DATA: IT_FIELDCAT  TYPE  LVC_T_FCAT,
          X_FIELDCAT TYPE LVC_S_FCAT,
          LS_VARI  TYPE DISVARIANT.
    *                START-OF_SELECTION
    START-OF-SELECTION.
      SELECT VBELN
             POSNR
             FROM LIPS
             UP TO 20 ROWS
             INTO CORRESPONDING FIELDS OF TABLE ITAB.
    describe table itab lines v_lines.
    END-OF-SELECTION.
      IF NOT ITAB[] IS INITIAL.
        CALL SCREEN 100.
      ELSE.
        MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
      ENDIF.
    *&      Form  CREATE_AND_INIT_ALV
    *       text
    FORM CREATE_AND_INIT_ALV .
      DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
      "attention.....from here
      "split your container here...into two parts
      "create the container
      CREATE OBJECT G_CUSTOM_CONTAINER
               EXPORTING CONTAINER_NAME = G_CONTAINER1.
      "this is for top of page
    * Create TOP-Document
      CREATE OBJECT DG_DYNDOC_ID
                       EXPORTING STYLE = 'ALV_GRID'.
    * Create Splitter for custom_container
      CREATE OBJECT DG_SPLITTER
                 EXPORTING PARENT  = G_CUSTOM_CONTAINER
                           ROWS    = 2
                           COLUMNS = 1.
    * Split the custom_container to two containers and move the reference
    * to receiving containers g_parent_html and g_parent_grid
      "i am allocating the space for grid and top of page
      CALL METHOD DG_SPLITTER->GET_CONTAINER
        EXPORTING
          ROW       = 1
          COLUMN    = 1
        RECEIVING
          CONTAINER = DG_PARENT_HTML.
      CALL METHOD DG_SPLITTER->GET_CONTAINER
        EXPORTING
          ROW       = 2
          COLUMN    = 1
        RECEIVING
          CONTAINER = DG_PARENT_GRID.
    *  CALL METHOD DG_SPLITTER->GET_CONTAINER
    *    EXPORTING
    *      ROW       = 2
    *      COLUMN    = 1
    *    RECEIVING
    *      CONTAINER = DG_PARENT_HTML.
    *  CALL METHOD DG_SPLITTER->GET_CONTAINER
    *    EXPORTING
    *      ROW       = 1
    *      COLUMN    = 1
    *    RECEIVING
    *      CONTAINER = DG_PARENT_GRID.
      "you can set the height of it
    * Set height for g_parent_html
      CALL METHOD DG_SPLITTER->SET_ROW_HEIGHT
        EXPORTING
          ID     = 1
          HEIGHT = 5.
      "from here as usual..you need to specify parent as splitter part
      "which we alloted for grid
      CREATE OBJECT G_GRID
             EXPORTING I_PARENT = DG_PARENT_GRID.
    * Set a titlebar for the grid control
      CLEAR GS_LAYOUT.
      GS_LAYOUT-GRID_TITLE = TEXT-003.
      GS_LAYOUT-ZEBRA = SPACE.
      GS_LAYOUT-CWIDTH_OPT = 'X'.
      GS_LAYOUT-NO_ROWMARK = 'X'.
      GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
      CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
      CREATE OBJECT G_HANDLER.
      SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
      SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
    *  SET HANDLER G_HANDLER->END_OF_LIST FOR G_GRID.
      SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.
      DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
      DATA: L_INDEX TYPE SY-TABIX.
      "Here i am changing the color of line 1,5,10...
      "so you can change the color of font conditionally
      LOOP AT ITAB.
        L_INDEX = SY-TABIX.
        IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
          LS_CELLCOLOR-FNAME = 'VBELN'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
          LS_CELLCOLOR-FNAME = 'POSNR'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
        ENDIF.
      ENDLOOP.
    * setting focus for created grid control
      CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
        EXPORTING
          CONTROL = G_GRID.
    * Build fieldcat and set editable for date and reason code
    * edit enabled. Assign a handle for the dropdown listbox.
      PERFORM BUILD_FIELDCAT.
      PERFORM  SET_DRDN_TABLE.
    * Optionally restrict generic functions to 'change only'.
    *   (The user shall not be able to add new lines).
      PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
    **Vaiant to save the layout
      LS_VARI-REPORT      = SY-REPID.
      LS_VARI-HANDLE      = SPACE.
      LS_VARI-LOG_GROUP   = SPACE.
      LS_VARI-USERNAME    = SPACE.
      LS_VARI-VARIANT     = SPACE.
      LS_VARI-TEXT        = SPACE.
      LS_VARI-DEPENDVARS  = SPACE.
    **Calling the Method for ALV output
      CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
          IS_VARIANT           = LS_VARI
          IS_LAYOUT            = GS_LAYOUT
          I_SAVE               = 'A'
        CHANGING
          IT_FIELDCATALOG      = IT_FIELDCAT
          IT_OUTTAB            = ITAB[].
      "do these..{
    * Initializing document
      CALL METHOD DG_DYNDOC_ID->INITIALIZE_DOCUMENT.
    * Processing events
      CALL METHOD G_GRID->LIST_PROCESSING_EVENTS
        EXPORTING
          I_EVENT_NAME = 'TOP_OF_PAGE'
          I_DYNDOC_ID  = DG_DYNDOC_ID.
      "end }
    * Set editable cells to ready for input initially
      CALL METHOD G_GRID->SET_READY_FOR_INPUT
        EXPORTING
          I_READY_FOR_INPUT = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
    *       text
    *      -->PT_EXCLUDE text
    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
    * Only allow to change data not to create new entries (exclude
    * generic functions).
      DATA LS_EXCLUDE TYPE UI_FUNC.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_fieldcat
    *       Fieldcatalog
    FORM BUILD_FIELDCAT .
      DATA: L_POS TYPE I.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
      X_FIELDCAT-FIELDNAME = 'VBELN'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-NO_ZERO    = 'X'.
      X_FIELDCAT-OUTPUTLEN = '10'.
      X_FIELDCAT-HOTSPOT = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Item'(025).
      X_FIELDCAT-FIELDNAME = 'POSNR'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
      X_FIELDCAT-FIELDNAME = 'DROP'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      X_FIELDCAT-EDIT = 'X'.
      X_FIELDCAT-DRDN_HNDL = '1'.
      X_FIELDCAT-DRDN_ALIAS = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
    ENDFORM.                    " build_fieldcat
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF G_CUSTOM_CONTAINER IS INITIAL.
    **Initializing the grid and calling the fm to Display the O/P
        PERFORM CREATE_AND_INIT_ALV.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  SET_DRDN_TABLE
    *       text
    FORM SET_DRDN_TABLE.
      DATA:LT_DRAL TYPE LVC_T_DRAL,
            LS_DRAL TYPE LVC_S_DRAL.
      LOOP AT ITAB .
    * First listbox (handle '1').
        IF SY-INDEX = 1.
          LS_DRAL-HANDLE = '1'.
          LS_DRAL-VALUE =  ' '.
          LS_DRAL-INT_VALUE =  ' '.
        ELSE.
          LS_DRAL-HANDLE = '1'.
          LS_DRAL-VALUE =  ITAB-POSNR.
          LS_DRAL-INT_VALUE =  ITAB-POSNR.
        ENDIF.
        APPEND LS_DRAL TO LT_DRAL.
      ENDLOOP.
    **Setting the Drop down table for Reason Code
      CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
        EXPORTING
          IT_DROP_DOWN_ALIAS = LT_DRAL.
    ENDFORM.                               " set_drdn_table
    *&      Form  EVENT_TOP_OF_PAGE
    *       text
    *      -->DG_DYNDOC_ID  text
    FORM EVENT_TOP_OF_PAGE USING   DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT.
      "this is more clear.....check it
      "first add text, then pass it to comentry write fm
      DATA : DL_TEXT(255) TYPE C.  "Text
    * Populating header to top-of-page
      CALL METHOD DG_DYNDOC_ID->ADD_TEXT
        EXPORTING
          TEXT      = 'Test Report'
          SAP_STYLE = CL_DD_AREA=>HEADING.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move program ID
      CONCATENATE 'Program Name :' SY-REPID
             INTO DL_TEXT SEPARATED BY SPACE.
    * Add Program Name to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move User ID
      CONCATENATE 'User ID :' SY-UNAME INTO DL_TEXT SEPARATED BY SPACE
    * Add User ID to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move count (no of records).
      move v_lines to v_line.
      CONCATENATE 'No of records :' v_line INTO DL_TEXT SEPARATED BY SPACE.
    * Add Client to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move date
      WRITE SY-DATUM TO DL_TEXT.
      CONCATENATE 'Date :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.
    * Add Date to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move time
      WRITE SY-UZEIT TO DL_TEXT.
      CONCATENATE 'Time :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.
    * Add Time to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    * Populating data to html control
      PERFORM HTML.
    ENDFORM.                    " EVENT_TOP_OF_PAGE
    *&      Form  ADD_TEXT
    *       To add Text
    FORM ADD_TEXT USING P_TEXT TYPE SDYDO_TEXT_ELEMENT.
    * Adding text
      CALL METHOD DG_DYNDOC_ID->ADD_TEXT
        EXPORTING
          TEXT         = P_TEXT
          SAP_EMPHASIS = CL_DD_AREA=>HEADING.
    ENDFORM.                    " ADD_TEXT
    *&      Form  HTML
    *       text
    FORM HTML.
      DATA : DL_LENGTH  TYPE I,                           " Length
             DL_BACKGROUND_ID TYPE SDYDO_KEY VALUE SPACE. " Background_id
    * Creating html control
      IF DG_HTML_CNTRL IS INITIAL.
        CREATE OBJECT DG_HTML_CNTRL
             EXPORTING
                  PARENT    = DG_PARENT_HTML.
      ENDIF.
    * Reuse_alv_grid_commentary_set
      CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
        EXPORTING
          DOCUMENT = DG_DYNDOC_ID
          BOTTOM   = SPACE
        IMPORTING
          LENGTH   = DL_LENGTH.
    * Get TOP->HTML_TABLE ready
      CALL METHOD DG_DYNDOC_ID->MERGE_DOCUMENT.
    * Set wallpaper
      CALL METHOD DG_DYNDOC_ID->SET_DOCUMENT_BACKGROUND
        EXPORTING
          PICTURE_ID = DL_BACKGROUND_ID.
    * Connect TOP document to HTML-Control
      DG_DYNDOC_ID->HTML_CONTROL = DG_HTML_CNTRL.
    * Display TOP document
      CALL METHOD DG_DYNDOC_ID->DISPLAY_DOCUMENT
        EXPORTING
          REUSE_CONTROL      = 'X'
          PARENT             = DG_PARENT_HTML
        EXCEPTIONS
          HTML_DISPLAY_ERROR = 1.
      IF SY-SUBRC NE 0.
        MESSAGE I999 WITH 'Error in displaying top-of-page'(036).
      ENDIF.
    ENDFORM.                    " HTML

Maybe you are looking for