Relating to save variant in alv objects

Hi,
   i had a requirement to select or deselect few fields and these fields ahould be able to save, in our case they are using abapobject to display alv using container, can any one please let me know what is the solution.
regards.
venkat.

HI Venkat
just go to this PDF which described about ALV Objects
<b>https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907</b>
and here search for Variant then you can find the necessary Information regarding Variants
Regards Rk

Similar Messages

  • What is the button to change the variant in alv?

    Hi guys,
              can u tell me  is there any button to change the variant in alv?. what is tanscation varient in report , hw it will used.

    Hi
    The ALV Grid Control is a tool with which you can output non-hierarchical lists in a
    standardized format. The list data is displayed as a table on the screen.
    The ALV Grid Control offers a range of interactive standard list functions that users need
    frequently (find, sort, filter, calculate totals and subtotals, print, print preview, send list,
    export list (in different formats), and so on. These functions are implemented in the
    proxy object class. You as the programmer have the possibility to turn off functions not
    needed. In most cases the implementations of the standard functions provided by the
    control are sufficient. However, if required, you can adjust these implementations to
    meet application-specific needs.
    You can add self-defined functions to the toolbar, if necessary.
    The ALV Grid Control allows users to adjust the layout of lists to meet their individual
    requirements (for example, they can swap columns, hide columns, set filters for the
    data to be displayed, calculate totals, and so on). The settings (list customizing) made
    by a specific user are called a display variant. Display variants can be saved on a userspecific
    or on a global basis. If such display variants exist for a list, they can be offered
    to the user for selection. If a display variant is set as the default variant, the associated
    list is always displayed based on the settings of this variant.
    <b>2. REUSE_ALV_LIST_DISPLAY
    REUSE_ALV_GRID_DISPLAY
    REUSE_ALV_FIELDCATALOG_MERGE
    REUSE_ALV_COMMENTARY_WRITE</b>
    3. Use of Field Catalog is to determines the technical properties & add formating information of the column.
    6. all the definition of internal table, structure, constants are declared in a type-pool called SLIS.
    7.fieldcat-fieldname
    fieldcat-ref_fieldname
    fieldcat-tabname
    fieldcat-seltext_m
    5. Form user_command using r_ucomm like sy-ucomm rs_selfield type slis_selfield.
    Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.
    In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output.
    The report output can contain up to 90 columns in the display with the wide array of display options.
    The commonly used ALV functions used for this purpose are;
    <b>1. REUSE_ALV_VARIANT_DEFAULT_GET
    2. REUSE_ALV_VARIANT_F4
    3. REUSE_ALV_VARIANT_EXISTENCE
    4. REUSE_ALV_EVENTS_GET
    5. REUSE_ALV_COMMENTARY_WRITE
    6. REUSE_ALV_FIELDCATALOG_MERGE
    7. REUSE_ALV_LIST_DISPLAY
    8. REUSE_ALV_GRID_DISPLAY
    9. REUSE_ALV_POPUP_TO_SELECT</b>
    Purpose of the above Functions are differ not all the functions are required in all the ALV Report.
    But either no.7 or No.8 is there in the Program.
    How you call this function in your report?
    After completion of all the data fetching from the database and append this data into an Internal Table. say I_ITAB.
    Then use follwing function module.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = 'Prog.name'
    I_STRUCTURE_NAME = 'I_ITAB'
    I_DEFAULT = 'X'
    I_SAVE = 'A'
    TABLES
    T_OUTTAB = I_ITAB.
    IF SY-SUBRC <> 0.
    WRITE: 'SY-SUBRC: ', SY-SUBRC .
    ENDIF.
    ENDFORM. " GET_FINAL_DATA
    The object F_IT_ALV has a field, the activity ACTVT, which can
    contain four permitted values: 01, 02, 03 and 70. Each of the
    activities 01, 02 and 70 controls the availability of particular
    functions (in the menu and the toolbar) of the ALV line item list:
    a) 01: "Settings -> Display variant -> Save..."
    b) 02: "Settings -> Display variant -> Current..." and
    "Settings -> Display variant -> Current header rows "
    c) 70: "Settings -> Display variant -> Administration..."
    Activity 03 corresponds to the minimum authorization, which is the
    most restricted one: The user can only select layouts which have
    been configured already. In particular, all of the other functions
    named above are inactive with activity 03.
    Now if you want to permit a user to change the column selection and
    the headers as well as to save the layout thus created, for example,
    but if you do not want to permit the user to administrate the
    layouts, you grant him or her the authorization for activities 01
    and 02.
    Check this link it will be mosty usefull for u
    http://www.sap-img.com/fu017.htm
    Reward all helpfull answers
    Regards
    Pavan

  • DB Table for Layout Variant in ALV report

    Please help me by providing the table name which will get an entry when we save Layout Variant in ALV(OO ALV grid) output.

    Hi,
    I have seen the table LTDX which is giving me the Variant names for a particular program. Hope this will help you.
    Database table is LTDX
    Database view is V_LTDX.
    Regards,
    Venaktesh

  • Save Layout in ALV Grid

    Hi,
    I have to save layout in ALV grid which should persist every time when i start the transaction.I am able to get save, change and manage option in the grid and also able to set the default layout but this default layout doesnot work.
    please see the code :
      l_repvar  = sy-repid.
      ls_variant = l_repvar.
      l_varient = 'A'.
      ls_variant-variant = l_varient.
      draft_layout-sel_mode = 'D'.
      draft_layout-stylefname = 'CELLPROP'.
      draft_layout-no_f4 = 'X'.
    DISPLAY THE DATA ON THE GRID
      CALL METHOD draft_grid->set_table_for_first_display
        EXPORTING
          i_structure_name     = 'PSHLP_DRAFT_ST'
          is_layout            = draft_layout
          it_toolbar_excluding = g_it_exclude
          is_variant           = ls_variant
          i_save               = 'A'
          i_default            = 'X'
        CHANGING
          it_fieldcatalog      = draft_fieldcat
          it_outtab            = l_draft[].
    i have tried by chaging i_save to 'X' and 'U' but no difference.
    Useful answers will be rewarded.
    Thanks and Regards,
    Harsh

    hi,
    try with this code,
    DATA: wa_disvariant LIKE disvariant.
        wa_disvariant-report = g_repid.
        wa_disvariant-username = sy-uname.
    and pass these values in your function module,
             i_save                      = 'X'
             is_variant                  = wa_disvariant
    thanks and regards,
    muralidhar.

  • Variants for alv

    please let me know about variants in alv??
    with details.
    why we use variants at alvs??
    please let me know

    We can change the display of the list by using the display variants.  Basically the display variants decide the appearance of the list. We can save display variants of the list by going Settings &#61614; Display variant &#61614; Save of the ALV display.
    We can ask the ALV to use a particular display variant for display.  We have to pass the variant name to the display FM through the parameter IS_VARIANT (explained earlier).  We can also provide a selection to the user in the selection screen to select a particular display variant.  The FM used to obtain the F4 help for the selection of the layout or the variant is explained next.
    F4 HELP FOR DISPLAY VARIANTS (REUSE_ALV_VARIANT_F4)
    The function module REUSE_ALV_VARIANT_F4 gives a popup to the user to select the display variant from a list of variants, which have been already saved.
    Some of the important parameters of the above function modules are:
    1.      IS_VARIANT (Like DISVARIANT) (Export Parameter)
    Pass the program name in the field REPORT of this structure.
    2.      I_SAVE (Export Parameter)
    Set this parameter as ‘A’ if you want to give the user an option to save an output layout user specifically or as a standard variant.
    Set this parameter as ‘U’ if you want to give the user an option to save an output layout only user specifically
    Set this parameter as ‘X’ for standard save only
    Leave it blank to provide no save option.
    3.      ES_VARIANT (Like DISVARIANT) (Import Parameter)
    Pass the same variable as was passed for the first parameter.  When we select a particular layout to be used, The FM  returns the name of the variant in the field VARIANT of this structure.
    Regards,
    Vidya

  • Saving variants in ALV

    Hi I created a ALV report which is supposed to save variants.
    But in my program the save button is missing.
    all we can do is display/ hide some selected fileds.
    How can i enable the save button?

    Just apply this in your Code....first execute the report and save it in a name...next time u can choose the same layout in the selection screen itself.
    data:
      wk_variant          like disvariant,
      wx_variant          like disvariant,
      wk_variant_save(1)  type c,
      wk_exit(1)          type c,
      wk_repid            like sy-repid.
    selection-screen skip 1.
    *SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-016.
    parameters: p_vari like disvariant-variant .    "Variant
    initialization.
      perform f_init_variant.
      perform f_variant_default using p_vari.
    at selection-screen on value-request for p_vari.
      perform f_variant_f4 using p_vari.
    start-of-selection.
    when calling alv pass the parameters as below.
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program = sy-repid
          is_layout          = wk_layout
          it_fieldcat        = alvfld[]
          i_default          = 'X'        <------
          i_save             = 'A'        <-----
          is_variant         = wk_variant <-------
          it_events          = v_events[]
        tables
          t_outtab           = it_stpo.
    *&      Form  f_init_variant
          text
    -->  p1        text
    <--  p2        text
    form f_init_variant .
      clear: wk_variant.
      wk_repid              = sy-repid.
      wk_variant-report     = wk_repid.
      wk_variant-username   = sy-uname.
      wk_variant_save       = text-032. "All types
    endform.                    " f_init_variant
    *&      Form  f_variant_default
          text
         -->P_P_VARI  text
    form f_variant_default  using    p_variant.
      wx_variant = wk_variant.
      if not p_variant is initial.
        wx_variant-variant = p_variant.
      endif.
      call function 'LVC_VARIANT_DEFAULT_GET'
        exporting
          i_save        = wk_variant_save
        changing
          cs_variant    = wx_variant
        exceptions
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          others        = 4.
      case sy-subrc.
        when 0.
          p_variant = wx_variant-variant.
        when 2.
          clear: p_variant.
      endcase.
    endform.                    " f_variant_default

  • REUSE_ALV_GRID_DISPLAY_LVC can't save variant

    Hi I'm using that FM but the SAVE variant button isn't activated.
    I tried with all I_SAVE possible values ('X', 'A', 'U'). With and without IS_VARIANT parameter. But it isn't working yet.
    The call looks like that:
    Maybe the problem is because I'm using a field symbol for internal table? But the data is displayed so I don't think...
    Note: Don't tell me to use the new ALV way because my SAP version doesn't have the necessary classes.
      DATA: gs_variant TYPE disvariant.
      gs_variant = sy-cprog.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          it_fieldcat_lvc                   = gt_fcat
          i_save                            = 'A'
          is_variant                        = gs_variant
        TABLES
          t_outtab                          = <gt_bom_alv>
        EXCEPTIONS
          OTHERS                            = 1.
    Thank you.

    I think you need to change this:
    DATA:
    gs_variant TYPE disvariant,
    v_repid TYPE sy-repid.
    v_repid = sy-repid.
    gs_variant-repid = sy-repid. "Change this
      gs_variant = sy-cprog.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          i_callback_program         = v_repid "Add this
          it_fieldcat_lvc                  = gt_fcat
          i_save                             = 'A'
          is_variant                        = gs_variant
        TABLES
          t_outtab                          = <gt_bom_alv>
        EXCEPTIONS
          OTHERS                            = 1.
    BR,
    Suhas
    Edited by: Suhas Saha on Feb 18, 2010 5:53 PM

  • Editable field in ALV Object Model

    Hi Guys,
    I'm using method cl_salv_table=>factory to display an ALV (Object Model) in my report.
    I want to "open up" one field for user entries, in other words make one column of my table editable.
    I assumed to find the respective methods in class cl_salv_table, cl_salv_columns_table or cl_salv_display_settings, so far without getting anywhere.
    I know about the field-catalogue and the method set_ready_for_input in class CL_GUI_ALV_GRID - it's not working once you're in the object model.
    Any ideas how to do that?
    Thank you!
    With best regards,
    Andreas

    Hi Guys,
    I'm using method cl_salv_table=>factory to display an ALV (Object Model) in my report.
    I want to "open up" one field for user entries, in other words make one column of my table editable.
    I assumed to find the respective methods in class cl_salv_table, cl_salv_columns_table or cl_salv_display_settings, so far without getting anywhere.
    I know about the field-catalogue and the method set_ready_for_input in class CL_GUI_ALV_GRID - it's not working once you're in the object model.
    Any ideas how to do that?
    Thank you!
    With best regards,
    Andreas

  • How to add search help for field in ALV object

    Hello,
    In a program, we use ALV object ( container) to create a liste like : field1, field2 .. but when display we do not have search help for this . Could you please help me how to add match code in this case for field 1 and field2, We use set_table_for_first_display
    Thanks,

    Hi,
    when you define your field catalogue you can create data elements with search help in se11 and use them for field 1 and field 2.
    But maybe it is enough to use data elements belonging to a domain with a value help and to set field F$AVAILABL in the field catalogue or to fill the name of the field CHECKTABLE.
    Regards,
    Klaus

  • END_OF_PAGE in ALV Object model

    Dear all,
    I am using ALV Object model, but the END_OF_PAGE is not triggering. I have pasted the sample code below. Let me know how to get  END_OF_PAGE  in ALV OM.
    REPORT  ztest_rr.
    DATA : it_sflight TYPE TABLE OF sflight.
    DATA : gr_sflight TYPE REF TO cl_salv_table,
           gr_content TYPE REF TO cl_salv_form_element,
           gr_sorts   TYPE REF TO cl_salv_sorts,
           gr_events  TYPE REF TO cl_salv_events,
           gr_print   TYPE REF TO cl_salv_print.
          CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_top_of_page FOR EVENT
              top_of_page OF cl_salv_events
              IMPORTING
              page
              table_index
              r_top_of_page,
          handle_end_of_page FOR EVENT
              end_of_page OF cl_salv_events
              IMPORTING
              page
              r_end_of_page.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    DATA : gr_handler TYPE REF TO lcl_eventhandler.
          CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_top_of_page.
        PERFORM create_alv_form_content_top
          USING    page
                   table_index
          CHANGING gr_content.
        r_top_of_page->set_content( gr_content ).
      ENDMETHOD.                    "handle_top_of_page
      METHOD handle_end_of_page.
        PERFORM create_alv_form_content_eop
        USING    page
        CHANGING gr_content.
        r_end_of_page->set_content( gr_content ).
      ENDMETHOD.                    "handle_end_of_page
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT *
      FROM sflight
      INTO TABLE it_sflight.
      TRY.
          CALL METHOD cl_salv_table=>factory
            EXPORTING
              list_display   = if_salv_c_bool_sap=>true
       r_container    =
       container_name =
            IMPORTING
              r_salv_table   = gr_sflight
            CHANGING
              t_table        = it_sflight
        CATCH cx_salv_msg .
      ENDTRY.
      CALL METHOD gr_sflight->get_sorts
        RECEIVING
          value = gr_sorts.
      CALL METHOD gr_sorts->set_group_active
        EXPORTING
          value = if_salv_c_bool_sap=>true.
      TRY.
          CALL METHOD gr_sorts->add_sort
            EXPORTING
              columnname = 'CARRID'
       position   =
       sequence   = IF_SALV_C_SORT=>SORT_UP
       subtotal   = IF_SALV_C_BOOL_SAP=>FALSE
               group      = if_salv_c_sort=>group_with_newpage
       obligatory = IF_SALV_C_BOOL_SAP=>FALSE
    receiving
       value      =
        CATCH cx_salv_not_found .
        CATCH cx_salv_existing .
        CATCH cx_salv_data_error .
      ENDTRY.
      CALL METHOD gr_sflight->get_event
        RECEIVING
          value = gr_events.
      CALL METHOD gr_sflight->get_print
        RECEIVING
          value = gr_print.
      CALL METHOD gr_print->set_reserve_lines
        EXPORTING
          value = 5.
      CREATE OBJECT gr_handler.
      SET HANDLER gr_handler->handle_top_of_page FOR gr_events.
      SET HANDLER gr_handler->handle_end_of_page FOR gr_events.
      CALL METHOD gr_sflight->display
    *&      Form  CREATE_ALV_FORM_CONTENT_TOP
          text
         -->P_PAGE  text
         -->P_TABLE_INDEX  text
         <--P_GR_CONTENT  text
    FORM create_alv_form_content_top  USING    l_page
                                               l_table_index
                                      CHANGING lr_content.
      WRITE 'HAI'.
    ENDFORM.                    " CREATE_ALV_FORM_CONTENT_TOP
    *&      Form  CREATE_ALV_FORM_CONTENT_EOP
          text
         -->P_PAGE  text
         <--P_GR_CONTENT  text
    FORM create_alv_form_content_eop  USING    l_page
                                      CHANGING lr_content.
      WRITE 'BYE'.
    ENDFORM.                    " CREATE_ALV_FORM_CONTENT_EOP

    Dear all,
    I am using ALV Object model, but the END_OF_PAGE is not triggering. I have pasted the sample code below. Let me know how to get  END_OF_PAGE  in ALV OM.
    REPORT  ztest_rr.
    DATA : it_sflight TYPE TABLE OF sflight.
    DATA : gr_sflight TYPE REF TO cl_salv_table,
           gr_content TYPE REF TO cl_salv_form_element,
           gr_sorts   TYPE REF TO cl_salv_sorts,
           gr_events  TYPE REF TO cl_salv_events,
           gr_print   TYPE REF TO cl_salv_print.
          CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_top_of_page FOR EVENT
              top_of_page OF cl_salv_events
              IMPORTING
              page
              table_index
              r_top_of_page,
          handle_end_of_page FOR EVENT
              end_of_page OF cl_salv_events
              IMPORTING
              page
              r_end_of_page.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    DATA : gr_handler TYPE REF TO lcl_eventhandler.
          CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_top_of_page.
        PERFORM create_alv_form_content_top
          USING    page
                   table_index
          CHANGING gr_content.
        r_top_of_page->set_content( gr_content ).
      ENDMETHOD.                    "handle_top_of_page
      METHOD handle_end_of_page.
        PERFORM create_alv_form_content_eop
        USING    page
        CHANGING gr_content.
        r_end_of_page->set_content( gr_content ).
      ENDMETHOD.                    "handle_end_of_page
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT *
      FROM sflight
      INTO TABLE it_sflight.
      TRY.
          CALL METHOD cl_salv_table=>factory
            EXPORTING
              list_display   = if_salv_c_bool_sap=>true
       r_container    =
       container_name =
            IMPORTING
              r_salv_table   = gr_sflight
            CHANGING
              t_table        = it_sflight
        CATCH cx_salv_msg .
      ENDTRY.
      CALL METHOD gr_sflight->get_sorts
        RECEIVING
          value = gr_sorts.
      CALL METHOD gr_sorts->set_group_active
        EXPORTING
          value = if_salv_c_bool_sap=>true.
      TRY.
          CALL METHOD gr_sorts->add_sort
            EXPORTING
              columnname = 'CARRID'
       position   =
       sequence   = IF_SALV_C_SORT=>SORT_UP
       subtotal   = IF_SALV_C_BOOL_SAP=>FALSE
               group      = if_salv_c_sort=>group_with_newpage
       obligatory = IF_SALV_C_BOOL_SAP=>FALSE
    receiving
       value      =
        CATCH cx_salv_not_found .
        CATCH cx_salv_existing .
        CATCH cx_salv_data_error .
      ENDTRY.
      CALL METHOD gr_sflight->get_event
        RECEIVING
          value = gr_events.
      CALL METHOD gr_sflight->get_print
        RECEIVING
          value = gr_print.
      CALL METHOD gr_print->set_reserve_lines
        EXPORTING
          value = 5.
      CREATE OBJECT gr_handler.
      SET HANDLER gr_handler->handle_top_of_page FOR gr_events.
      SET HANDLER gr_handler->handle_end_of_page FOR gr_events.
      CALL METHOD gr_sflight->display
    *&      Form  CREATE_ALV_FORM_CONTENT_TOP
          text
         -->P_PAGE  text
         -->P_TABLE_INDEX  text
         <--P_GR_CONTENT  text
    FORM create_alv_form_content_top  USING    l_page
                                               l_table_index
                                      CHANGING lr_content.
      WRITE 'HAI'.
    ENDFORM.                    " CREATE_ALV_FORM_CONTENT_TOP
    *&      Form  CREATE_ALV_FORM_CONTENT_EOP
          text
         -->P_PAGE  text
         <--P_GR_CONTENT  text
    FORM create_alv_form_content_eop  USING    l_page
                                      CHANGING lr_content.
      WRITE 'BYE'.
    ENDFORM.                    " CREATE_ALV_FORM_CONTENT_EOP

  • ALV object model - List download

    H Experts,
    I have used ALV object model to list display.
    Also i have used class CL_ALV_COLUMNS_TABLE and its method set_long_text to set the column heading.
    Now if i execute this report, long text is displayed properly in column heading.
    But when i download this report output in spreadsheet, short text is displayed in column heading which is taken from the data element in DDIC.
    Example:
    I have declaed a column of type ABWTG.
    I have set leng text as 'TEST'.
    When i execute the report, column heading is displayed "TEST', which is as expected.
    But when i download this report in spreadsheet, column heading is displayed as 'NUMBER' in spread sheet. While downloading column heading is taken from the data element for field ABWTG. But i want the long text 'TEST' to be displayed when the report output is downloaded.
    Please suggest how to do it.
    Regards

    Hi,
    As per my understanding , it is displaying in excel based on ur ddic_output_length field.
    only becoz of that field it will show the same header.
    IF u will change the value at run time for this field then u will not get that issue,
    I m also searching on the same issue.
    Thanks
    Rahul

  • ALV object in Web dynpro ABAP

    Hi All,
    I want to include ALV object in web dynpro ABAP, instead of a table in a window. I have SAP Version 4.6 as backend.
    Pl help.

    Hi Nirmal,
    the information on ALV and WDA is here: http://help.sap.com/saphelp_nw2004s/helpdata/en/74/fd4142646ab46be10000000a155106/frameset.htm
    As you know, Web Dynpro ABAP is availiable with NW2004s, not before.
    Regards, Heidi

  • How do I create a context menu in the new ALV object model (cl_salv_table)?

    Hi,
    Does anyone know how to create a context menu (right click on line or field) in the new ALV object model (class CL_SALV_TABLE)?
    Thanks in advance
    Keld Gregersen
    PS: In the past we could use event CONTEXT_MENU_REQUEST in class CL_GUI_ALV_GRID, so it must be possible

    I don't think there's "any such animal" in the new class. I'm not 100% certain however but the new class is only useful for fairly simple display only type grids.
    There's no edit capability either.
    I'd stick with cl_gui_alv_grid until there's some decent extra functionality in the cl_salv_table class.
    It's fine for quick "bog standard" displays as it doesn't need a field catalog or any screens to be created by the user or developer  - but you pay a price for that in limited fnctionality.
    Cheers
    jimbo

  • Dynamically built query on execution How to save the data in Object Type

    Hi,
    In pl/sql I am building and executing a query dynamically. How can I stored the output of the query in object type. I have defined the following object type and need to store the
    output of the query in it. Here is the Object Type I have
    CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPE AS OBJECT(
    pkid NUMBER,
    pkname VARCHAR2(100);
    pkcity VARCHAR2(100);
    pkcounty VARCHAR2(100)
    CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPETAB AS TABLE OF FIRST_RECORDTYPE;Here is the query generated at runtime and is inside a LOOP
    --I initialize my Object Type*
    data := new FIRST_RECORDTYPETAB();
    FOR some_cursor IN c_get_ids (username)
    LOOP
    x_context_count := x_context_count + 1;
    -- here I build the query dynamically and the same query generated is
    sql_query := 'SELECT pkid as pid ,pkname as pname,pkcity as pcity, pkcounty as pcounty FROM cities WHERE passed = <this value changes on every iteration of the cursor>'
    -- and now I need to execute the above query but need to store the output
    EXECUTE IMMEDIATE sql_query
    INTO *<I need to save the out put in the Type I defined>*
    END LOOP;
    How can I save the output of the dynamically built query in the Object Type. As I am looping so the type can have several records.
    Any help is appreciated.
    Thanks

    hai ,
    solution for Dynamically built query on execution How to save the data in Object Type.
    Step 1:(Object creation)
    SQL> ED
    Wrote file afiedt.buf
    1 Create Or Replace Type contract_details As Object(
    2 contract_number Varchar2(15),
    3 contrcat_branch Varchar2(15)
    4* );
    SQL> /
    Type created.
    Step 2:(table creation with object)
    SQL> Create Table contract_dtls(Id Number,contract contract_details)
    2 /
    Table created.
    Step 3:(execution Of procedure to insert the dynamic ouput into object types):
    Declare
    LV_V_SQL_QUERY Varchar2(4000);
    LV_N_CURSOR Integer;
    LV_N_EXECUTE_CURSOR Integer;
    LV_V_CONTRACT_BR Varchar2(15) := 'TNW'; -- change the branch name by making this as input parameter for a procedure or function
    OV_V_CONTRACT_NUMBER Varchar2(15);
    LV_V_CONTRACT_BRANCH Varchar2(15);
    Begin
    LV_V_SQL_QUERY := 'SELECT CONTRACT_NUMBER,CONTRACT_BRANCH FROM CC_CONTRACT_MASTER WHERE CONTRACT_BRANCH = '''||LV_V_CONTRACT_BR||'''';
    LV_N_CURSOR := Dbms_Sql.open_Cursor;
    Dbms_Sql.parse(LV_N_CURSOR,LV_V_SQL_QUERY,2);
    Dbms_Sql.define_Column(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER,15);
    Dbms_Sql.define_Column(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH,15);
    LV_N_EXECUTE_CURSOR := Dbms_Sql.Execute(LV_N_CURSOR);
    Loop
    Exit When Dbms_Sql.fetch_Rows (LV_N_CURSOR)= 0;
    Dbms_Sql.column_Value(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER);
    Dbms_Sql.column_Value(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH);
    Dbms_Output.put_Line('CONTRACT_BRANCH--'||LV_V_CONTRACT_BRANCH);
    Dbms_Output.put_Line('CONTRACT_NUMBER--'||OV_V_CONTRACT_NUMBER);
    INSERT INTO contract_dtls VALUES(1,CONTRACT_DETAILS(OV_V_CONTRACT_NUMBER,LV_V_CONTRACT_BRANCH));
    End Loop;
    Dbms_Sql.close_Cursor (LV_N_CURSOR);
    COMMIT;
    Exception
    When Others Then
    Dbms_Output.put_Line('SQLERRM--'||Sqlerrm);
    Dbms_Output.put_Line('SQLERRM--'||Sqlcode);
    End;
    step 4:check the values are inseted in the object included table
    SELECT * FROM contract_dtls;
    Regards
    C.karukkuvel

  • Variant in ALV selection screen

    Hi friends,
         How to protect a variant in ALV selection screen from changing or deleting by other users.
    Thanks,
    Rajesh

    Rajesh,
    You still need someone to be able to change the variant, right? That is what exactly PROTECT VARIANT does.
    If you select the field Protect variant, the variant can only be changed by the person who created it or last changed it.                         
    Regards,
    Ravi
    Note :Please mark the helpful answers  and close the thread if the quesiton is answered

Maybe you are looking for

  • 3512 all in one printer will not copy

    Installed new ink, both color and black. Cleaned print heads and still get broken copy results with light print and white lines  going horizontally through the words. 

  • PR type

    Hello friend We use SRM server 5.5 with classic scenario. We will use the BADI BBP_SC_TRANSFER_BE to determine the PR type and number range. But I’m not sure the following logic is correct. Could you check this? We have two PR type in R/3. 1) KGPR (G

  • HR replication with twin backends

    Hi,    We have a system which is already went live, HR replication happens to the SRM system. There is a proposal that SRM system will be connected to another backend. Will have two backends connected to SRM system. They wanted to go for HR replicati

  • Font Size Selector on Ruler

    According to the new features listed with the new Pages app, there is supposed to be a new font size selector on the ruler in addition to the Style, Bold, Italic, Underline, and Tab stuff. I do not see it. Does anyone else see it?

  • Fixing the lenght of content to be displayed on JSP page

    hi, i want a CSS property which can display specific no. of character of string. My means that I want to display the email of currently logged in user, the place that is available to display email is only 30 character, if length of email is greater t