Working with Object Oriented ALV

Hi All..
could anyone please send me the sample code for working with OO ALV.
Like.. I have two tables VBAK and VBAP... what I'll do if working with FM approach, is that, I'll join both the tables on certain condition, put the joined data in a Final Internal Table, and then display it in ALV grid using REUSE_ALV_GRID_DISPLAY.
Now I want to do the same thing using OO ALV.
Quick Help will be appreciated very much..
Thanks..

TABLES: zsflight.
G L O B A L   I N T E R N  A L   T A B L E S
   DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
G L O B A L   D A T A
   DATA:
         g_wa_sflight LIKE sflight.
Declare reference variables to the ALV grid and the container
   DATA:
     go_grid             TYPE REF TO cl_gui_alv_grid,
     go_custom_container TYPE REF TO cl_gui_custom_container.
S T A R T - O F - S E L E C T I O N.
   START-OF-SELECTION.
    CALL SCREEN 100.
*&      Module  USER_COMMAND_0100  INPUT
      text
module USER_COMMAND_0100 input.
     CASE SY-UCOMM.
       WHEN 'EXIT'.
         LEAVE PROGRAM.
     ENDCASE.
endmodule.                 " USER_COMMAND_0100  INPUT
*&      Module  STATUS_0100  OUTPUT
      text
module STATUS_0100 output.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
Create objects
     IF go_custom_container IS INITIAL.
     create object go_custom_container
       exporting
        PARENT                      =
         container_name              = 'ALV_CONTAINER'  “UR CUSTOM CONTROL NAME
        STYLE                       =
        LIFETIME                    = lifetime_default
        REPID                       =
        DYNNR                       =
        NO_AUTODEF_PROGID_DYNNR     =
      EXCEPTIONS
        CNTL_ERROR                  = 1
        CNTL_SYSTEM_ERROR           = 2
        CREATE_ERROR                = 3
        LIFETIME_ERROR              = 4
        LIFETIME_DYNPRO_DYNPRO_LINK = 5
        others                      = 6
     IF sy-subrc <> 0.
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
     ENDIF.
     create object go_grid
       exporting
        I_SHELLSTYLE      = 0
        I_LIFETIME        =
         i_parent          = go_custom_container
        I_APPL_EVENTS     = space
        I_PARENTDBG       =
        I_APPLOGPARENT    =
        I_GRAPHICSPARENT  =
        I_USE_VARIANT_CLASS = SPACE
        I_NAME            =
      EXCEPTIONS
        ERROR_CNTL_CREATE = 1
        ERROR_CNTL_INIT   = 2
        ERROR_CNTL_LINK   = 3
        ERROR_DP_CREATE   = 4
        others            = 5
     IF sy-subrc <> 0.
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
     ENDIF.
PERFORM load_data_into_grid.
     ENDIF.
endmodule.                 " STATUS_0100  OUTPUT
*&      Form  load_data_into_grid
      text
-->  p1        text
<--  p2        text
form load_data_into_grid.
SELECT *
       FROM sflight
       INTO TABLE gi_sflight.
Load data into the grid and display them
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
   I_BYPASSING_BUFFER            =
   I_BUFFER_ACTIVE               =
   I_CONSISTENCY_CHECK           =
    I_STRUCTURE_NAME              = 'SFLIGHT'
   IS_VARIANT                    =
   I_SAVE                        =
   I_DEFAULT                     = 'X'
   IS_LAYOUT                     =
   IS_PRINT                      =
   IT_SPECIAL_GROUPS             =
   IT_TOOLBAR_EXCLUDING          =
   IT_HYPERLINK                  =
   IT_ALV_GRAPHICS               =
   IT_EXCEPT_QINFO               =
  CHANGING
    it_outtab                     = gi_sflight
   IT_FIELDCATALOG               =
   IT_SORT                       =
   IT_FILTER                     =
EXCEPTIONS
   INVALID_PARAMETER_COMBINATION = 1
   PROGRAM_ERROR                 = 2
   TOO_MANY_LINES                = 3
   others                        = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform.                    " load_data_into_grid
Name of the structure would be a structure of your alv display and gi_sflight would be the internal containing the data.
Thanks,
Jayant

Similar Messages

  • Save layout Button in Object Oriented ALV

    Hi  gurus,
    I am working on Object Oriented ALV. I am facing one problem when the outpput get shown on the screen the save layout and select layout buttons are not appearing on the application toolbar of alv.
    TRY .
          cl_salv_table=>factory( IMPORTING r_salv_table = g_alv_out
                                   CHANGING t_table      = i_alv ).
        Set status GUI
          g_alv_out->set_screen_status(
              pfstatus      = 'STANDARD'
              report        = sy-repid
              set_functions = g_alv_out->C_FUNCTIONS_ALL ).
           g_columns = g_alv_out->get_columns( ).
        Set new description texts for columns
          PERFORM f_set_column_name USING:
                'LTEXT' text-001 text-001 text-001 space,
                'NAME1' text-002 text-002 text-002 space,
                'TXZ01' text-003 text-007 text-007 space,
                'KWERT' text-004 text-004 text-004 space,
                'WEMNG' text-005 text-010 text-011 space,
                'BALNC' text-012 text-013 text-014 space,
                'AFNAM' text-006 text-008 text-009 space.
          PERFORM f_set_column_name USING 'WEMNG'
                  space space space 'WAERS'.
          PERFORM f_set_column_name USING 'KWERT'
                  space space space 'WAERS'.
        Set column as hotspot
          g_column ?= g_columns->get_column( 'EBELN' ).
          g_column->set_cell_type( g_column->hotspot ).
          g_events = g_alv_out->get_event( ).
          CREATE OBJECT gr_events .
          SET HANDLER gr_events->on_double_click FOR g_events.
        Display report
          g_alv_out->display( ).
        CATCH cx_salv_msg.
      ENDTRY.
    where in the Status  STANDARD I have entered all the buttons includeing these two buttons
    Can you please Help me in solving this issue.
    thanks,
    Vinod.
    Edited by: vinod parhad on Jul 2, 2010 1:35 PM

    data: gr_layout  type ref to cl_salv_layout,
    gr_alv     type ref to cl_salv_table,
    gs_key     type salv_s_layout_key,
    * in your SALV routine.... after FACTORY call
    gs_key-report = sy-repid.
    * User can save layout.
      gr_layout  = gr_alv->get_layout( ). "layouts
      gr_layout->set_key( gs_key ).  "Pass Program Name
      gr_layout->set_save_restriction( cl_salv_layout=>restrict_none ). "User can save
    See also Rich Heilman's excellent tutorials on SALV by searching for SALV Tutorial,
    See also programs named: SALV* for demonstrations of SALV outputs and how to code.
    Edited by: BreakPoint on Jul 2, 2010 1:46 PM add references for tutorials

  • How to display horizontal line in top-of-page by using object oriented ALV?

    How to display horizontal line in top-of-page by using object oriented ALV.
    I am created top-of-page in object oriented alv.
    But not be successes in showing horizontal line in it.
    Can any one pls give solution for this..
    Thanks and regards..

    Hi
    Try like this
    data: gt_list_top_of_page type slis_t_listheader. " Top of page text. 
    Initialization. 
    perform comment_build using gt_list_top_of_page[]. 
    form top_of_page. 
    * Note to self: the gif must be loaded into transaction OAOR with 
    * classname 'PICTURES' AND TYPE 'OT' to work with ALV GRID Functions. 
    * I Loaded NOVALOGO2 into system. 
    call function 'REUSE_ALV_COMMENTARY_WRITE' 
         exporting 
    * I_LOGO = 'NOVALOGO2' 
    * i_logo = 'ENJOYSAP_LOGO' 
             it_list_commentary = gt_list_top_of_page. 
    endform. " TOP_OF_PAGE 
    form comment_build using e04_lt_top_of_page type slis_t_listheader. 
    data: ls_line type slis_listheader. 
          clear ls_line. 
          ls_line-typ = 'A'. 
          ls_line-info = 'Special'(001). 
          fgrant = xgrant. 
          concatenate ls_line-info fgrant 
          'Stock Option Report to the board'(002) 
                 into ls_line-info separated by space. 
                        condense ls_line-info. 
          append ls_line to e04_lt_top_of_page. 
    endform. " COMMENT_BUILD
    Use following syntex for footer print in alv:
    * For End of Page
    form END_OF_PAGE.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      write: sy-uline(50).
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    *  For End of Report
    form END_OF_LIST.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    check this link
    http://abapprogramming.blogspot.com/
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5dc3e690-0201-0010-1ebf-b85b3bed962d
    Changing width of a custom container dynamically
    Display Page numbers in ALV
    Insert picture in selection screen.
    Logo in OO ALV Grid
    Reward all helpfull answers
    Regards
    Pavan

  • How to capture index/row no of row in table using object oriented alv.

    i have a table with many fields. i have an alv grid table displayed using object oriented alv. when i double click on a record, i call another screen. there i want to display the record number. eg, if i doubleclick on the third row, i will go to next screen and display 3 there.
    please let me know how it is done as it is urgent.
    thanks in advance.

    Hi,
    Use the following code to get rowno.
    CLASS lcl_grid_events DEFINITION DEFERRED.
    DATA:
      grid1_events      TYPE REF TO lcl_grid_events.
    CLASS lcl_grid_events DEFINITION.
      PUBLIC SECTION.
        METHODS:
          dbclk
           FOR EVENT double_click  OF cl_gui_alv_grid
           IMPORTING e_row
                     e_column
                     es_row_no.
    ENDCLASS.                    "lcl_grid_events DEFINITION
    CLASS lcl_grid_events IMPLEMENTATION.
      METHOD dbclk.
    *access e_row variable, which contains the record no.
      ENDMETHOD.                    "dbclk
    ENDCLASS.                    "lcl_grid
    write the following code after method call of set_table_for_first_display
        CREATE OBJECT grid1_events.
        SET HANDLER grid1_events->dbclk
                    FOR grid1.
    reward point if useful.

  • Interactive object oriented alv

    hi friends,
         i want interactive object oriented alv report. i want some example program for that.

    try like this
    *& Report  ZALV_OOP
    REPORT  zalv_oop.
          CLASS lcl_event_handler DEFINITION
    CLASS lcl_event_handler DEFINITION .
      PUBLIC SECTION .
        METHODS:
    *--Double-click control
        handle_double_click
        FOR EVENT double_click OF cl_gui_alv_grid
        IMPORTING e_row e_column es_row_no.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_handler DEFINITION
          CLASS lcl_event_handler IMPLEMENTATION
    CLASS lcl_event_handler IMPLEMENTATION .
    *--Handle Double Click
      METHOD handle_double_click .
        PERFORM handle_double_click USING e_row e_column es_row_no .
      ENDMETHOD .                    "handle_double_click
    ENDCLASS .                    "lcl_event_handler IMPLEMENTATION
    TABLES : mseg.
    DATA : BEGIN OF itab OCCURS 0,
            mblnr LIKE mseg-mblnr,
            matnr LIKE mseg-matnr,
            menge LIKE mseg-menge,
           END OF itab.
    DATA : gr_alvgrid TYPE REF TO cl_gui_alv_grid,
           gr_ccontainer TYPE REF TO cl_gui_custom_container,
           gt_fcat TYPE lvc_t_fcat,
           gs_layo TYPE lvc_s_layo.
    DATA gr_event_handler TYPE REF TO lcl_event_handler .
    DATA : ok_code LIKE sy-ucomm.
    DATA : t_mat LIKE mara-matnr.
    DATA: variant TYPE disvariant.
    SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_mblnr FOR mseg-mblnr.
    SELECTION-SCREEN : END OF BLOCK blk1.
    START-OF-SELECTION.
      SET SCREEN 100.
      CREATE OBJECT gr_event_handler .
      PERFORM get_data.
      PERFORM dis_data.
    *&      Form  get_data
          text
    FORM get_data.
      SELECT mblnr matnr menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab
       WHERE mblnr IN s_mblnr.
      variant-report = sy-repid.
      variant-username = sy-uname.
    ENDFORM.                    "get_data
    *&      Form  dis_data
          text
    FORM dis_data.
      IF gr_alvgrid IS INITIAL.
        CREATE OBJECT gr_ccontainer
          EXPORTING
            container_name              = 'CC_ALV'
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc  0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        CREATE OBJECT gr_alvgrid
          EXPORTING
            i_parent          = gr_ccontainer
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc  0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        PERFORM create_fcat CHANGING gt_fcat.
        PERFORM create_layout CHANGING gs_layo.
        CALL METHOD gr_alvgrid->set_table_for_first_display
          EXPORTING
            is_variant                    = variant
            i_save                        = 'A'
            is_layout                     = gs_layo
          CHANGING
            it_outtab                     = itab[]
            it_fieldcatalog               = gt_fcat
        IF sy-subrc  0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .
      ENDIF.
    ENDFORM.                    "dis_data
    *&      Form  create_fcat
          text
         <--P_GT_FCAT  text
    FORM create_fcat  CHANGING pt_fcat TYPE lvc_t_fcat.
      DATA : ls_fcat TYPE lvc_s_fcat.
      ls_fcat-fieldname = 'MBLNR'.
      ls_fcat-coltext = 'Material Doc.'.
      APPEND ls_fcat TO pt_fcat.
      ls_fcat-fieldname = 'MATNR'.
      ls_fcat-coltext = 'Material'.
      APPEND ls_fcat TO pt_fcat.
      ls_fcat-fieldname = 'MENGE'.
      ls_fcat-coltext = 'Quantity'.
      APPEND ls_fcat TO pt_fcat.
    ENDFORM.                    " create_fcat
    *&      Form  create_layout
          text
         <--P_GS_LAYO  text
    FORM create_layout  CHANGING ps_layo TYPE lvc_s_layo.
      ps_layo-zebra = 'X'.
    ENDFORM.                    " create_layout
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'ZALV_OOP'.
    SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      ok_code = sy-ucomm.
      CASE ok_code.
        WHEN 'BACK' OR 'UP' OR 'CANC'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  handle_double_click
          text
         -->I_ROW      text
         -->I_COLUMN   text
         -->IS_ROW_NO  text
    FORM handle_double_click USING i_row TYPE lvc_s_row
                                   i_column TYPE lvc_s_col
                                   is_row_no TYPE lvc_s_roid.
      READ TABLE itab INDEX is_row_no-row_id .
      IF sy-subrc = 0 .
        IF i_column = 'MATNR'.
          t_mat = itab-matnr.
          SET PARAMETER ID 'MAT' FIELD t_mat.
          CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
          SET PARAMETER ID 'MAT' FIELD space.
        ELSEIF i_column = 'MBLNR'.
          CALL TRANSACTION 'MIGO'.
        ENDIF .
      ENDIF.
    ENDFORM .                    "handle_double_click
    here in screen 100 i have taken one custom control with name cc_alv

  • Field symbols in Object Oriented ALV

    Hi Friends....Can somebody explain me what is the significance of field symbols in OO ALV. Why it is assigned to Field catalog. Also explain me the basic steps to do Object Oriented ALV. Thanks in advance...

    Hi Satyesh,
    Field symbols are symbolic names to which a memory area can be assigned during program runtime. A field symbol can be used instead of data objects at operand positions of statements.
    Please go through this following code.  This uses field symbols for OO ALV.
      LCL_TABLE_DISPLAY DEFINITION
    CLASS lcl_table_display DEFINITION.
      PUBLIC SECTION.
        TYPE-POOLS: abap, slis.
        CLASS-METHODS: display_list IMPORTING in_data TYPE STANDARD TABLE,
                       display_grid IMPORTING in_data TYPE STANDARD TABLE.
        METHODS: constructor IMPORTING in_data TYPE STANDARD TABLE
                             EXCEPTIONS casting_error
                                        empty_fieldcat.
        METHODS: output_list,
                 output_grid.
        METHODS: set_table_name   IMPORTING in_tabname  TYPE any,
                 set_alv_title    IMPORTING in_title    TYPE any,
                 set_alv_settings IMPORTING in_settings TYPE any,
                 set_alv_layout   IMPORTING in_layout   TYPE any,
                 set_alv_event    IMPORTING in_name     TYPE any
                                            in_form     TYPE any.
      PRIVATE SECTION.
        CLASS-DATA: g_table_object TYPE REF TO lcl_table_display.
        TYPES: BEGIN OF ty_defin,
                 fieldname     TYPE fieldname,
                 ref_tabname   TYPE tabname,
                 ref_fieldname TYPE fieldname,
               END OF ty_defin.
        DATA: g_repid  TYPE repid,
              g_struc  TYPE tabname,
              g_table  TYPE tabname.
        DATA: gt_data  TYPE REF TO data.
        DATA: g_title  TYPE lvc_title,
              gt_fcat  TYPE slis_t_fieldcat_alv,
              gs_sett  TYPE lvc_s_glay,
              gs_layo  TYPE slis_layout_alv,
              gt_evnt  TYPE slis_t_event.
        DATA: gt_defin TYPE TABLE OF ty_defin,
              g_level  TYPE tabname.
        METHODS: output_table IMPORTING data TYPE REF TO data
                                        mode TYPE c,
                 fill_fieldcat IMPORTING repid TYPE repid
                                         struc TYPE tabname
                                CHANGING fcat  TYPE slis_t_fieldcat_alv
                              EXCEPTIONS no_definition,
                 get_definition IMPORTING repid TYPE repid
                                          struc TYPE tabname
                                 CHANGING abap  TYPE rsfb_source,
                 recursive_definition IMPORTING repid TYPE repid
                                       CHANGING abap  TYPE rsfb_source,
                 map_structure IMPORTING source TYPE any
                                CHANGING destin TYPE any.
    ENDCLASS.
      LCL_TABLE_DISPLAY IMPLEMENTATION
    CLASS lcl_table_display IMPLEMENTATION.
      Display table in ALV list
      METHOD display_list.
        IF NOT g_table_object IS INITIAL.
          FREE: g_table_object.
        ENDIF.
        CREATE OBJECT g_table_object EXPORTING in_data = in_data.
        CALL METHOD g_table_object->output_list.
      ENDMETHOD.
      Display table in ALV grid
      METHOD display_grid.
        IF NOT g_table_object IS INITIAL.
          FREE: g_table_object.
        ENDIF.
        CREATE OBJECT g_table_object EXPORTING in_data = in_data.
        CALL METHOD g_table_object->output_grid.
      ENDMETHOD.
      Create table display
      METHOD constructor.
        DATA: ls_data TYPE REF TO data.
        DATA: ob_desc TYPE REF TO cl_abap_structdescr.
        DATA: l_absol TYPE char200,
              l_repid TYPE repid,
              l_struc TYPE tabname.
        FIELD-SYMBOLS: <table> TYPE STANDARD TABLE,
                       <struc> TYPE ANY.
      Get data and store it into attribute
        CREATE DATA me->gt_data LIKE in_data.
        ASSIGN me->gt_data->* TO <table>.
        <table> = in_data.
      Get global data definition
        CREATE DATA ls_data LIKE LINE OF <table>.
        ASSIGN ls_data->* TO <struc>.
        CATCH SYSTEM-EXCEPTIONS assign_casting_illegal_cast = 1.
          ob_desc ?= cl_abap_typedescr=>describe_by_data( <struc> ).
        ENDCATCH.
        IF sy-subrc = 1.
          RAISE casting_error.
        ENDIF.
      Get program name and main type used to define table
        l_absol = ob_desc->absolute_name.
        SPLIT l_absol AT '\TYPE=' INTO l_repid l_struc.
        SHIFT l_repid UP TO '='.
        SHIFT l_repid.
        CHECK l_struc NP '%_*'.
        IF me->g_repid NE l_repid
        OR me->g_struc NE l_struc.
        Set attributes
          me->g_repid = l_repid.
          me->g_struc = l_struc.
          me->g_table = l_struc.
          REPLACE 'TY' WITH 'WT' INTO me->g_table.
        Field catalog
          CALL METHOD fill_fieldcat EXPORTING repid = l_repid
                                              struc = l_struc
                                     CHANGING fcat  = me->gt_fcat.
          IF me->gt_fcat IS INITIAL.
            RAISE empty_fieldcat.
          ENDIF.
        ENDIF.
      ENDMETHOD.
      Output list
      METHOD output_list.
        CALL METHOD output_table EXPORTING data = me->gt_data
                                           mode = 'L'.
      ENDMETHOD.
      Output grid
      METHOD output_grid.
        CALL METHOD output_table EXPORTING data = me->gt_data
                                           mode = 'G'.
      ENDMETHOD.
      Output table
      METHOD output_table.
        DATA: ls_vari TYPE disvariant.
        FIELD-SYMBOLS: <table> TYPE STANDARD TABLE.
        ASSIGN me->gt_data->* TO <table>.
      Get default user variant
        ls_vari-report = me->g_repid.
        ls_vari-username = sy-uname.
        CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
             EXPORTING
                  i_save     = 'U'
             CHANGING
                  cs_variant = ls_vari
             EXCEPTIONS
                  OTHERS     = 0.
      Display table contents
        IF mode = 'G'.
          CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
               EXPORTING
                    i_callback_program = me->g_repid
                    i_grid_title       = me->g_title
                    i_grid_settings    = me->gs_sett
                    is_layout          = me->gs_layo
                    it_fieldcat        = me->gt_fcat
                    i_save             = 'U'
                    is_variant         = ls_vari
                    it_events          = me->gt_evnt
               TABLES
                    t_outtab           = <table>
               EXCEPTIONS
                    OTHERS             = 0.
        ELSE.
          CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
               EXPORTING
                    i_callback_program = me->g_repid
                    is_layout          = me->gs_layo
                    it_fieldcat        = me->gt_fcat
                    i_save             = 'U'
                    is_variant         = ls_vari
                    it_events          = me->gt_evnt
               TABLES
                    t_outtab           = <table>
               EXCEPTIONS
                    OTHERS             = 0.
        ENDIF.
      ENDMETHOD.
      Fill field catalog
      METHOD fill_fieldcat.
        DATA: lt_abap   TYPE TABLE OF rssource.
        DATA: ls_defin  TYPE ty_defin.
        DATA: lt_dfies  TYPE TABLE OF dfies,
              ls_dfies  TYPE dfies,
              ls_dd04v  TYPE dd04v,
              ls_dd01v  TYPE dd01v,
              l_flong   TYPE dfies-lfieldname,
              l_dname   TYPE dfies-domname.
        DATA: ls_fcat   TYPE slis_fieldcat_alv,
              ls_fcat2  TYPE slis_fieldcat_alv.
        DATA: l_index   TYPE i,
              l_nbfld   TYPE i.
        FREE: me->gt_defin.
      Process data definition
        CALL METHOD get_definition EXPORTING repid = repid
                                             struc = struc
                                    CHANGING abap  = lt_abap.
      Process sub levels if required
        CALL METHOD recursive_definition EXPORTING repid = repid
                                          CHANGING abap  = lt_abap.
        IF me->gt_defin IS INITIAL.
          RAISE no_definition.
        ENDIF.
        LOOP AT me->gt_defin INTO ls_defin.
          CLEAR: ls_fcat.
          MOVE-CORRESPONDING ls_defin TO ls_fcat.
        Retrieve info about this field
          FREE: ls_dfies, ls_dd04v, ls_dd01v, l_dname.
          l_flong = ls_fcat-ref_fieldname.
          SET LOCALE LANGUAGE 'E'.
          TRANSLATE: ls_fcat-ref_tabname   TO UPPER CASE,
                     ls_fcat-ref_fieldname TO UPPER CASE,
                     l_flong               TO UPPER CASE.
          IF NOT ls_fcat-ref_tabname IS INITIAL.
          Try to get info about field in table
            CALL FUNCTION 'DDIF_FIELDINFO_GET'
                 EXPORTING
                      tabname        = ls_fcat-ref_tabname
                      fieldname      = ls_fcat-ref_fieldname
                      lfieldname     = l_flong
                 IMPORTING
                      dfies_wa       = ls_dfies
                 EXCEPTIONS
                      not_found      = 1
                      internal_error = 2
                      OTHERS         = 3.
            IF sy-subrc = 0.
              MOVE-CORRESPONDING ls_dfies TO ls_fcat.
              ls_fcat-fieldname = ls_defin-fieldname.
              MOVE: ls_dfies-keyflag   TO ls_fcat-key,
                    ls_dfies-scrtext_m TO ls_fcat-seltext_l,
                    ls_dfies-domname   TO l_dname.
            ENDIF.
          ELSE.
          Try to get info about structure
            ls_defin-ref_tabname = ls_defin-ref_fieldname.
            CALL FUNCTION 'DDIF_FIELDINFO_GET'
                 EXPORTING
                      tabname   = ls_defin-ref_tabname
                 TABLES
                      dfies_tab = lt_dfies
                 EXCEPTIONS
                      OTHERS    = 0.
            IF NOT lt_dfies IS INITIAL.
            Process fields of this structure
              LOOP AT lt_dfies INTO ls_dfies.
                CLEAR: ls_fcat.
                MOVE-CORRESPONDING ls_dfies TO ls_fcat.
                CONCATENATE ls_defin-fieldname ls_fcat-fieldname
                       INTO ls_fcat-fieldname
                  SEPARATED BY '-'.
                MOVE ls_dfies-keyflag TO ls_fcat-key.
                MOVE ls_dfies-scrtext_m TO ls_fcat-seltext_l.
                ls_fcat-tabname = me->g_table.
                CLEAR: ls_fcat-col_pos,
                       ls_fcat-offset.
                IF ls_fcat-ref_tabname IS INITIAL.
                  ls_fcat-ddictxt = 'L'.
                ENDIF.
              Display Yes/No fields as checkboxes
                IF ls_dfies-domname = 'XFELD'.
                  ls_fcat-checkbox = 'X'.
                ENDIF.
              Add field to field catalog
                APPEND ls_fcat TO fcat.
              ENDLOOP.
            ELSE.
            Try to get info about data element
              CALL FUNCTION 'DDIF_DTEL_GET'
                   EXPORTING
                        name          = ls_fcat-ref_fieldname
                        langu         = sy-langu
                   IMPORTING
                        dd04v_wa      = ls_dd04v
                   EXCEPTIONS
                        illegal_input = 1
                        OTHERS        = 2.
              IF sy-subrc = 0.
                MOVE-CORRESPONDING ls_dd04v TO ls_fcat.
                MOVE: ls_dd04v-scrtext_m TO ls_fcat-seltext_l,
                      ls_dd04v-domname   TO l_dname.
              ELSE.
              Finally try to get info about domain
                CALL FUNCTION 'DDIF_DOMA_GET'
                     EXPORTING
                          name          = ls_fcat-ref_fieldname
                          langu         = sy-langu
                     IMPORTING
                          dd01v_wa      = ls_dd01v
                     EXCEPTIONS
                          illegal_input = 1
                          OTHERS        = 2.
                IF sy-subrc = 0.
                  MOVE-CORRESPONDING ls_dd01v TO ls_fcat.
                  MOVE: ls_dd01v-ddtext  TO ls_fcat-seltext_l,
                        ls_dd01v-domname TO l_dname.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDIF.
        Table name must be internal table containing data
          ls_fcat-tabname = g_table.
        No offset
          CLEAR: ls_fcat-offset.
        Default text is stored in long text
          IF ls_fcat-ref_tabname IS INITIAL.
            ls_fcat-ddictxt = 'L'.
          ENDIF.
        Display Yes/No fields as checkboxes
          IF l_dname = 'XFELD'.
            ls_fcat-checkbox = 'X'.
          ENDIF.
        Add field to field catalog
          APPEND ls_fcat TO fcat.
        ENDLOOP.
      Link between fields
        DESCRIBE TABLE fcat LINES l_nbfld.
        LOOP AT fcat INTO ls_fcat.
          IF sy-tabix NE l_nbfld.
            l_index = sy-tabix + 1.
            READ TABLE fcat INTO ls_fcat2 INDEX l_index.
            IF sy-subrc = 0.
              IF ls_fcat-datatype = 'CURR'.
              Currency unit
                IF ls_fcat2-datatype = 'CUKY'.
                  ls_fcat-cfieldname = ls_fcat2-fieldname.
                  ls_fcat-ctabname   = ls_fcat2-tabname.
                  MODIFY fcat FROM ls_fcat.
                ELSE.
                  LOOP AT fcat INTO ls_fcat2
                               FROM l_index
                              WHERE datatype = 'CUKY'.
                  First currency unit after field
                    ls_fcat-cfieldname = ls_fcat2-fieldname.
                    ls_fcat-ctabname   = ls_fcat2-tabname.
                    MODIFY fcat FROM ls_fcat.
                    EXIT.
                  ENDLOOP.
                  IF sy-subrc NE 0.
                  No currency unit after field, try before
                    READ TABLE fcat INTO ls_fcat2
                                WITH KEY datatype = 'CUKY'.
                    IF sy-subrc = 0.
                      ls_fcat-cfieldname = ls_fcat2-fieldname.
                      ls_fcat-ctabname   = ls_fcat2-tabname.
                      MODIFY fcat FROM ls_fcat.
                    ENDIF.
                  ENDIF.
                ENDIF.
              ENDIF.
              IF ls_fcat-datatype = 'QUAN'.
              Quantity unit
                IF ls_fcat2-datatype = 'UNIT'.
                  ls_fcat-cfieldname = ls_fcat2-fieldname.
                  ls_fcat-ctabname   = ls_fcat2-tabname.
                  MODIFY fcat FROM ls_fcat.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDMETHOD.
      Get definition of type from code source
      METHOD get_definition.
        DATA: l_strng TYPE rssource,
              ls_abap TYPE rssource,
              l_fdpos TYPE i,
              l_first TYPE i,
              l_lastr TYPE i.
        DATA: lt_incl TYPE TABLE OF repid,
              ls_incl TYPE repid.
      Get program code
        READ REPORT repid INTO abap.
        CHECK sy-subrc EQ 0.
      Get first line of definition
        CONCATENATE 'BEGIN OF' struc INTO l_strng
                                SEPARATED BY space.
        LOOP AT abap INTO ls_abap.
          IF ls_abap CS l_strng.
            l_fdpos = strlen( l_strng ) + sy-fdpos.
            IF ls_abap+l_fdpos(1) CA ', "'.
              l_first = sy-tabix.
              EXIT.
            ENDIF.
          ENDIF.
        ENDLOOP.
        IF l_first IS INITIAL.
        Table is defined in an include
          CALL FUNCTION 'RS_GET_ALL_INCLUDES'
               EXPORTING
                    program    = repid
               TABLES
                    includetab = lt_incl
               EXCEPTIONS
                    OTHERS     = 1.
          IF sy-subrc = 0.
            LOOP AT lt_incl INTO ls_incl.
            Try to find definition in this include
              READ REPORT ls_incl INTO abap.
              LOOP AT abap INTO ls_abap.
                IF ls_abap CS l_strng.
                  l_fdpos = strlen( l_strng ) + sy-fdpos.
                  IF ls_abap+l_fdpos(1) CA ',. "'.
                    l_first = sy-tabix.
                    EXIT.
                  ENDIF.
                ENDIF.
              ENDLOOP.
              IF NOT l_first IS INITIAL.
                EXIT.
              ENDIF.
            ENDLOOP.
          ENDIF.
        ENDIF.
      Get last line of definition
        CONCATENATE 'END OF' struc INTO l_strng
                              SEPARATED BY space.
        LOOP AT abap INTO ls_abap.
          IF ls_abap CS l_strng.
            l_fdpos = strlen( l_strng ) + sy-fdpos.
            IF ls_abap+l_fdpos(1) CA ',. "'.
              l_lastr = sy-tabix - l_first.
              EXIT.
            ENDIF.
          ENDIF.
        ENDLOOP.
      Keep only relevant code lines
        IF l_first LE 0
        OR l_lastr LE 0.
          REFRESH abap.
        ELSE.
          DELETE abap TO l_first.
          DELETE abap FROM l_lastr.
        ENDIF.
      ENDMETHOD.
      Get definition of type recursively
      METHOD recursive_definition.
        DATA: lt_token TYPE TABLE OF stokex,
              ls_token TYPE stokex,
              lt_state TYPE TABLE OF sstmnt,
              ls_state TYPE sstmnt.
        DATA: ls_defin TYPE ty_defin,
              l_reffld TYPE fieldname.
        DATA: lt_recu  TYPE TABLE OF rssource.
      Retrieve tokens
        SCAN ABAP-SOURCE abap
                  TOKENS INTO lt_token
              STATEMENTS INTO lt_state.
        LOOP AT lt_state INTO ls_state.
          CLEAR: ls_defin.
        Field name
          READ TABLE lt_token INTO ls_token
                             INDEX ls_state-from.
          ls_defin-fieldname = ls_token-str.
        Reference type
          READ TABLE lt_token INTO ls_token
                             INDEX ls_state-to.
          l_reffld = ls_token-str.
        Check if this type is defined in program
          FREE: lt_recu.
          CALL METHOD get_definition EXPORTING repid = repid
                                               struc = l_reffld
                                      CHANGING abap  = lt_recu.
          IF lt_recu IS INITIAL.
            IF NOT g_level IS INITIAL.
             CONCATENATE g_level ls_defin-fieldname INTO ls_defin-fieldname
                                                           SEPARATED BY '-'.
              CONDENSE ls_defin-fieldname.
            ENDIF.
            IF l_reffld CS '-'.
              SPLIT l_reffld AT '-'
                           INTO ls_defin-ref_tabname
                                ls_defin-ref_fieldname.
              IF ls_defin-ref_tabname = 'SY'.
                ls_defin-ref_tabname = 'SYST'.
              ENDIF.
            ELSE.
              ls_defin-ref_fieldname = ls_token-str.
            ENDIF.
            APPEND ls_defin TO me->gt_defin.
          ELSE.
          Process sub levels
            IF me->g_level IS INITIAL.
              me->g_level = ls_defin-fieldname.
            ELSE.
              CONCATENATE me->g_level ls_defin-fieldname INTO me->g_level
                                                 SEPARATED BY '-'.
            ENDIF.
            CALL METHOD recursive_definition EXPORTING repid = repid
                                              CHANGING abap  = lt_recu.
            IF me->g_level CS '-'.
              SHIFT me->g_level RIGHT UP TO '-'.
              SHIFT me->g_level RIGHT.
              SHIFT me->g_level LEFT DELETING LEADING space.
            ELSE.
              CLEAR: me->g_level.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDMETHOD.
      Set table name
      METHOD set_table_name.
        me->g_table = in_tabname.
      ENDMETHOD.
      Set title
      METHOD set_alv_title.
        me->g_title = in_title.
      ENDMETHOD.
      Set settings
      METHOD set_alv_settings.
        CALL METHOD map_structure EXPORTING source = in_settings
                                   CHANGING destin = me->gs_sett.
      ENDMETHOD.
      Set layout
      METHOD set_alv_layout.
        CALL METHOD map_structure EXPORTING source = in_layout
                                   CHANGING destin = me->gs_layo.
      ENDMETHOD.
      Add event
      METHOD set_alv_event.
        DATA: ls_evnt TYPE slis_alv_event.
        ls_evnt-name = in_name.
        ls_evnt-form = in_form.
        COLLECT ls_evnt INTO gt_evnt.
      ENDMETHOD.
      Map fields from incoming structure into attribute
      METHOD map_structure.
        DATA: ob_desc  TYPE REF TO cl_abap_structdescr,
              ls_compo TYPE abap_compdescr.
        FIELD-SYMBOLS: <field> TYPE ANY,
                       <struc> TYPE ANY.
        ob_desc ?= cl_abap_typedescr=>describe_by_data( destin ).
        LOOP AT ob_desc->components INTO ls_compo.
          ASSIGN COMPONENT ls_compo-name OF STRUCTURE source TO <field>.
          IF <field> IS ASSIGNED.
            ASSIGN COMPONENT ls_compo-name OF STRUCTURE destin TO <struc>.
            CATCH SYSTEM-EXCEPTIONS conversion_errors = 1.
              MOVE <field> TO <struc>.
            ENDCATCH.
            UNASSIGN <field>.
          ENDIF.
        ENDLOOP.
      ENDMETHOD.
    ENDCLASS.
    PLZ REWARD POINTS

  • Why do we use cl_gui_cfw= flush method in Object Oriented ALV programming

    Dear Friends,
    Please solve my query regarding control framework. Why do we use cl_gui_cfw=>flush method in Object Oriented ALV programming. I studied and found that this method transfers automation queue to Front end.  But I could not find any further update on this.
    Thanks & Regards
    Amit Sharma

    Generally this is to restrict the traffic b/w frontend and backend. This means that every operation in Control Framework should be first buffered in the backend and synchronized with the frontend at certain points (one of this point is calling synchronization method cl_gui_cfw=>flush ). This explicit order of synchronization is due to RFC call needed for every communication b/w front/back end. So to avoid to many RFC calls we do it only at certain time.
    Please refer [Automation Queue|http://help.sap.com/saphelp_wp/helpdata/en/9b/d080ba9fc111d2bd68080009b4534c/frameset.htm]. I think it explains the concept quite well.
    Regards
    Marcin

  • COPA Report Layout with Object List (ALV)

    Hi,
    I have question about the COPA report layout with object list (ALV). Everytime I executed the report with ALV format, the amount for quantity column always shows with 3 decimal number, menwhile for amount column always follow by 2 decimal number.
    Can anyone help me regarding this matter? I do not know how to turn off the decimal number to be 0 in this type of layout, although in the form itself I already put 0 decimal number.
    Thanks.

    Hi,
    Better to raise this issue in CO Forum. You can expect some solution.
    regards

  • HOw to make an Object oriented alv respond to double click

    Hi all,
    HOw to make an Object oriented alv respond to double click.SAmple code will be helpful.
    Thanks in advance,
    Alex.

    Hi,
    1. Create a Control (for Custom and Split Containers only)
    2. Instantiate a Container Object (in case of Custom and Split Containers, specify the control which is created by us in Screen painter) CREATE OBJECT
    3. Instantiate an Object of the kind of report that has to be displayed (List, Grid or Tree). CREATE OBJECT . Here we need to specify the Parent Container as the so that it sits in that container.
    4. Call appropriate methods to display the report on the screen. CALL METHOD ->
    DATA : g_dock TYPE REF TO cl_gui_docking_container,
    g_split TYPE REF TO cl_gui_easy_splitter_container,
    g_cont1 TYPE REF TO cl_gui_container,
    g_cont2 TYPE REF TO cl_gui_container,
    g_grid1 TYPE REF TO cl_gui_alv_grid,
    g_grid2 TYPE REF TO cl_gui_alv_grid.
    i_mara is an internal table of structure MARA
    SELECT * FROM mara INTO TABLE i_mara.
    i_kna1 is an internal table of structure KNA1
    SELECT * FROM kna1 INTO TABLE i_kna1.
    To create an Object of type Docking Container
    CREATE OBJECT g_dock
    EXPORTING
    side = cl_gui_docking_container=>dock_at_top
    extension = 200 .
    To Create an Object of Type Split Container. Here we can see that the Docking *Container Created above has been used as a parent .
    CREATE OBJECT g_split
    EXPORTING
    parent = g_dock
    orientation = 1 .
    Easy Split container splits one Control into 2 manageable controls, each of them is used * to handle one GUI Container each
    g_cont1 = g_split->top_left_container.
    g_cont2 = g_split->bottom_right_container.
    To Create an Object of type Grid . Here we can see that the Left Split Container * Created above has been used as a parent .
    CREATE OBJECT g_grid1
    EXPORTING
    i_parent = g_cont1 .
    To Create an Object of type Grid . Here we can see that the Right Split Container * Created above has been used as a parent .
    CREATE OBJECT g_grid2
    EXPORTING
    i_parent = g_cont2 .
    The method of Grid Control Object is used to display the Data.
    CALL METHOD g_grid1->set_table_for_first_display
    EXPORTING
    i_structure_name = 'MARA'
    CHANGING
    it_outtab = i_mara[] .
    The method of Grid Control Object is used to display the Data.
    CALL METHOD g_grid2->set_table_for_first_display
    EXPORTING
    i_structure_name = 'KNA1'
    CHANGING
    it_outtab = i_kna1[] .
    Regards
    Hari

  • Object Oriented ALV

    Hi All,
    I want to know the advantages of using OOPS ALV over the normal ALV function modules and how should we decide whether we need to use Object oriented ALV or normal ALV.
    Regards,
    S.Subasree

    HI
    please check out the following  links
    http://www.sapgenie.com/abap/controls/alvgrid.htm
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIDOCK/BCCIDOCK.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIGOF/BCCIGOF.pdf
    hope this helps
    regards
    Aakash Banga

  • Module pool  with object oriented programming

    can anyone send me links for module pool with object oriented programming.

    hi,
    some helful links.
    Go through the below links,
    For Materials:
    1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
    2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    1) http://www.erpgenie.com/sap/abap/OO/index.htm
    2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    <u>Sample std pgms.</u>
    ABAP_OBJECTS_ENJOY_0           Template for Solutions of ABAP Object Enjoy Course
    ABAP_OBJECTS_ENJOY_1           Model Solution 1: ABAP Objects Enjoy Course      
    ABAP_OBJECTS_ENJOY_2           Model Solution 2: ABAP Objects Enjoy Course      
    ABAP_OBJECTS_ENJOY_3           Model Solution 3: ABAP Objects Enjoy Course      
    ABAP_OBJECTS_ENJOY_4           Model Solution 4: ABAP Objects Enjoy Course      
    ABAP_OBJECTS_ENJOY_5           Model Solution 5: ABAP Objects Enjoy Course      
    DEMO_ABAP_OBJECTS              Complete Demonstration for ABAP Objects          
    DEMO_ABAP_OBJECTS_CONTROLS     GUI Controls on Screen                           
    DEMO_ABAP_OBJECTS_EVENTS       Demonstration of Events in ABAP Objects          
    DEMO_ABAP_OBJECTS_GENERAL      ABAP Objects Demonstration                       
    DEMO_ABAP_OBJECTS_INTERFACES   Demonstration of Interfaces in ABAP Objects      
    DEMO_ABAP_OBJECTS_METHODS      Demonstration of Methods in ABAP Objects         
    DEMO_ABAP_OBJECTS_SPLIT_SCREEN Splitter Control on Screen
    Rgds
    Reshma

  • ExternalInterface.call problem with object-orientation

    Hi
    I am using an swf inside a PDF. In a PDF-context the ExternalInterface-class works much the same as it does within a website. So far calling a function in the document-script works.
    The thing now is, that I really try to use an object-oriented approach as often as I can. In this case I have a function I could call using
    var jsCaller:Object = ExternalInterface.call("myFunction",parameters);
    This works as expected.
    However, I have now made that function a method in an object, so I can access it within JS using dot-notation: myCoolObject.myFunction(); This works as well, so the problem is not the function itself. However, the call
    var jsCaller:Object = ExternalInterface.call("myCoolObject.myFunction",parameters);
    does not work.
    This means there's either something I'm missing, or it's a limitation of ExternalInterface, or it's a limitation of externalInterface in a pdf-context.
    Anyone to enlighten me?

    If EI calls eval it should be able to resolve the object-path. However, this doesn't seem to be the case. Also note that my parameter is an array, so this probably wouldn't work, even if the syntax did.
    Anyway, I tested your syntax in my PDF, and it showed the same behaviour as before (i.e. the function in which the EI-call was placed could not be executed, and acrobat claimed there was no such function). It didn't work with my normal function, and not even with a simple console.println-statement that way. So in PDFs it definitely doesn't work like that.
    But thanks for the suggestion!

  • Error for object oriented alv running in background.

    Hi all,
    I have an  ALV report done using object oriented functionality.
    When I am trying to run that report in background , it is giving me error.
    I want to know why it is happening and how it can be corrected.
    Regards,
       Vaibhav.

    Create a docky container :
    c_docking_cont TYPE REF TO   cl_gui_docking_container.
       *For background execution
        IF sy-batch EQ c_x.
          CREATE OBJECT c_alv
            EXPORTING
              i_parent = c_docking_cont.
        ENDIF.
       ALV for display field details
        CALL METHOD c_alv->set_table_for_first_display
          EXPORTING
            is_layout            = t_lay
          CHANGING
            it_outtab            = t_table[]
            it_fieldcatalog      = t_field_cat.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    Edited by: Madhavi t on Nov 2, 2009 1:34 PM

  • Help with object oriented concepts

    I am a senior highschool student and although I know Java syntax, I learned with Pascal and other procedural languages so I have a difficult time thinking in OOP concepts (which I will have to learn for college classes). So for practice I went to my college's website and found an assignment on the intro course to programming: [Here are the assignment instructions.|http://www.cs.gsu.edu/knguyen/teaching/2009/spring/csc2010/proj.pdf]
    My question is, how can I make my program illustrate more object oriented concepts?
    Links:
    ode-help.110mb.com/javaproject.java_

    Just a few comments (not necessarily about OO and in no particular order):
    It's probably not worth it to make constants for the letter A or the plus sign. Make constants for values people would not understand:
    // Ok
    public static final int ANSWER_TO_THE_UNIVERSE = 42;'
    // Probably overkill
    public static final int FORTY_TWO = 42;
    Good job on having DecimalFormat as a regular instance variable rather than static (since it is not thread-safe)
    Good job initializing your object in a consistent state (via the ctor). Now, make as many variables final as you can. Immutable objects are good:[www.javapractices.com/topic/TopicAction.do?Id=29]
    Not sure why you declared repeat() to return the boxed version of boolean, just use a primitive
    You have a run() method but are not implementing Runnable. Not that it is required, but usually when I see run(), I think of threading
    This is a matter of style, but you don't need to name the arguments in the ctor differently than the instance variables that get assigned. You can very easily say:
    // Note that it is final.  Make things immutable when you can.
    private final String bar;
    public Foo(final String bar) {
       // Note:  I don't need a different name here.  This is purely a matter of personal style.
       this.bar = bar;
    Consider a while loop in run() rather than a do-loop. What happens if you get no input the first time around?
    Java naming conventions dictate that classes start with a capital letter. Generally, an underscore is not used, camel-case is. So, your class should be JavaProject.
    Consider making an object for the arguments that are passed into input. Maybe call it GradeCategory, or whatever.
    That new object GradeCategory can have the output() method.
    For method names, also follow conventions using camel case. So get_double should be getDouble().
    Consider reworking such that you use an array or a collection of GradeCategory. You might want to then have an add method in your JavaProject. The add method should ensure the total weight of grades does not exceed 100%.
    You can rework the output method of JavaProject to iterate over your GradeCategory objects, calling their own output() methods. Perhaps it also first checks that the weight of all grades equals 100%.Just a few thoughts.
    - Saish

  • Working with Object Relational model and Eclipse

    Hello,
    I have mad some types and typed tables in a schema on oracle 10g.
    My database respects the Object Relational model, in which I work with VARRAY, TYPES, NESTED TABLES, PL/SQL,...
    I have already install Enterprise Pack for Eclipse, and also have the Weblogic server, And I can generate tables. But the problem is that it gives to me this tables with wrong types, until they contains in fact other tables as Objet column, and also the types are not supported.
    Please need a help !
    Thank's in advance :)

    nhauge wrote:
    Hi,
    I want to make sure I understand the problem but will try to give you some information as well. So you have an Oracle 10g database in which you are using the object-relational database model with VARRAY's, etc. You say you are also trying to generate tables, but the generation is not working correctly. Are you using the "Generate tables from entities..." functionality? What is the source of the generated tables? I assume you generating from some type of JPA entity? Could you give a small example of the source you are generating from?
    In order to generate proper tables of this type, you would need to be using special TopLink/EclipseLink annotations such as @Array so the persistence provider would know that they are "special" and not just regular entities that would create standard relational tables.
    Neil
    Thank you for your replay,
    well I'm generating that with "Generate tables from entities" of eclipse link.
    this is an example of what I have in the database:
    [DB-SCRIPT|http://www.mediafire.com/view/?n3knwz1o4ggk50n]
    and this is what is generated(eclipselink-orm.xml):
    <?xml version="1.0" encoding="UTF-8"?>
    <entity-mappings version="1.2" xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_1_2.xsd">
         <entity class="model.Chefterritoire" access="VIRTUAL">
              <attributes>
                   <id name="idChef" attribute-type="long">
                        <column name="ID_CHEF"/>
                   </id>
                   <basic name="lesterritoires" attribute-type="Object">
                   </basic>
                   <basic name="nomChef" attribute-type="String">
                        <column name="NOM_CHEF"/>
                   </basic>
                   <basic name="tel" attribute-type="java.math.BigDecimal">
                   </basic>
              </attributes>
         </entity>
         <entity class="model.Client" access="VIRTUAL">
              <attributes>
                   <id name="idClient" attribute-type="long">
                        <column name="ID_CLIENT"/>
                   </id>
                   <basic name="adresseClient" attribute-type="String">
                        <column name="ADRESSE_CLIENT"/>
                   </basic>
                   <basic name="dateP" attribute-type="java.util.Date">
                        <column name="DATE_P"/>
                        <temporal>DATE</temporal>
                   </basic>
                   <basic name="lescommandes" attribute-type="Object">
                   </basic>
                   <basic name="nomClient" attribute-type="String">
                        <column name="NOM_CLIENT"/>
                   </basic>
                   <basic name="profession" attribute-type="String">
                   </basic>
                   <basic name="refrepresentant" attribute-type="Object">
                   </basic>
                   <basic name="telClient" attribute-type="java.math.BigDecimal">
                        <column name="TEL_CLIENT"/>
                   </basic>
              </attributes>
         </entity>
         <entity class="model.Commande" access="VIRTUAL">
              <attributes>
                   <id name="idCommande" attribute-type="long">
                        <column name="ID_COMMANDE"/>
                   </id>
                   <basic name="dateCommande" attribute-type="java.util.Date">
                        <column name="DATE_COMMANDE"/>
                        <temporal>DATE</temporal>
                   </basic>
                   <basic name="dateLivraison" attribute-type="java.util.Date">
                        <column name="DATE_LIVRAISON"/>
                        <temporal>DATE</temporal>
                   </basic>
                   <basic name="refreleve" attribute-type="Object">
                   </basic>
                   <basic name="refrepresentant" attribute-type="Object">
                   </basic>
                   <basic name="refvehicule" attribute-type="Object">
                   </basic>
                   <basic name="reprise" attribute-type="String">
                   </basic>
              </attributes>
         </entity>
         <entity class="model.Constructeur" access="VIRTUAL">
              <attributes>
                   <id name="idConstructeur" attribute-type="long">
                        <column name="ID_CONSTRUCTEUR"/>
                   </id>
                   <basic name="adresseConstructeur" attribute-type="String">
                        <column name="ADRESSE_CONSTRUCTEUR"/>
                   </basic>
                   <basic name="lesreleves" attribute-type="Object">
                   </basic>
                   <basic name="nomConstructeur" attribute-type="String">
                        <column name="NOM_CONSTRUCTEUR"/>
                   </basic>
                   <basic name="refvehucule" attribute-type="Object">
                   </basic>
              </attributes>
         </entity>
         <entity class="model.LesccommandesN" access="VIRTUAL">
              <table name="LESCCOMMANDES_N"/>
              <attributes>
              </attributes>
         </entity>
         <entity class="model.LescommandessN" access="VIRTUAL">
              <table name="LESCOMMANDESS_N"/>
              <attributes>
              </attributes>
         </entity>
         <entity class="model.LescommandesN" access="VIRTUAL">
              <table name="LESCOMMANDES_N"/>
              <attributes>
              </attributes>
         </entity>
         <entity class="model.LesoptionsN" access="VIRTUAL">
              <table name="LESOPTIONS_N"/>
              <attributes>
              </attributes>
         </entity>
         <entity class="model.LesrepresentantsN" access="VIRTUAL">
              <table name="LESREPRESENTANTS_N"/>
              <attributes>
              </attributes>
         </entity>
         <entity class="model.LessclientsN" access="VIRTUAL">
              <table name="LESSCLIENTS_N"/>
              <attributes>
              </attributes>
         </entity>
         <entity class="model.LesscommandesN" access="VIRTUAL">
              <table name="LESSCOMMANDES_N"/>
              <attributes>
              </attributes>
         </entity>
         <entity class="model.LesterritoiresN" access="VIRTUAL">
              <table name="LESTERRITOIRES_N"/>
              <attributes>
              </attributes>
         </entity>
         <entity class="model.LesvehiculesN" access="VIRTUAL">
              <table name="LESVEHICULES_N"/>
              <attributes>
              </attributes>
         </entity>
         <entity class="model.Modele" access="VIRTUAL">
              <attributes>
                   <id name="idModele" attribute-type="long">
                        <column name="ID_MODELE"/>
                   </id>
                   <basic name="couleurExterieure" attribute-type="String">
                        <column name="COULEUR_EXTERIEURE"/>
                   </basic>
                   <basic name="couleurInterieure" attribute-type="String">
                        <column name="COULEUR_INTERIEURE"/>
                   </basic>
                   <basic name="lesoptions" attribute-type="Object">
                   </basic>
                   <basic name="lesvehicules" attribute-type="Object">
                   </basic>
                   <basic name="prix" attribute-type="double">
                   </basic>
              </attributes>
         </entity>
         <entity class="model.Option" access="VIRTUAL">
              <table name="OPTIONS"/>
              <attributes>
                   <id name="idOption" attribute-type="long">
                        <column name="ID_OPTION"/>
                   </id>
                   <basic name="nomOption" attribute-type="String">
                        <column name="NOM_OPTION"/>
                   </basic>
                   <basic name="refmodele" attribute-type="Object">
                   </basic>
              </attributes>
         </entity>
         <entity class="model.Rapportvisite" access="VIRTUAL">
              <attributes>
                   <id name="idRapport" attribute-type="long">
                        <column name="ID_RAPPORT"/>
                   </id>
                   <basic name="dateVisite" attribute-type="java.util.Date">
                        <column name="DATE_VISITE"/>
                        <temporal>DATE</temporal>
                   </basic>
                   <basic name="frais" attribute-type="double">
                   </basic>
                   <basic name="refclient" attribute-type="Object">
                   </basic>
                   <basic name="refrepresentant" attribute-type="Object">
                   </basic>
                   <basic name="resultat" attribute-type="String">
                   </basic>
              </attributes>
         </entity>
         <entity class="model.Releve" access="VIRTUAL">
              <attributes>
                   <id name="idReleve" attribute-type="long">
                        <column name="ID_RELEVE"/>
                   </id>
                   <basic name="dateDebut" attribute-type="java.util.Date">
                        <column name="DATE_DEBUT"/>
                        <temporal>DATE</temporal>
                   </basic>
                   <basic name="dateFin" attribute-type="java.util.Date">
                        <column name="DATE_FIN"/>
                        <temporal>DATE</temporal>
                   </basic>
                   <basic name="lescommandes" attribute-type="Object">
                   </basic>
                   <basic name="refconst" attribute-type="Object">
                   </basic>
              </attributes>
         </entity>
         <entity class="model.RelevesN" access="VIRTUAL">
              <table name="RELEVES_N"/>
              <attributes>
              </attributes>
         </entity>
         <entity class="model.Remise" access="VIRTUAL">
              <attributes>
                   <id name="idRemise" attribute-type="long">
                        <column name="ID_REMISE"/>
                   </id>
                   <basic name="remise" attribute-type="double">
                   </basic>
              </attributes>
         </entity>
         <entity class="model.Representant" access="VIRTUAL">
              <attributes>
                   <id name="idRepresentant" attribute-type="long">
                        <column name="ID_REPRESENTANT"/>
                   </id>
                   <basic name="lesclients" attribute-type="Object">
                   </basic>
                   <basic name="lescommandes" attribute-type="Object">
                   </basic>
                   <basic name="nomRepresentant" attribute-type="String">
                        <column name="NOM_REPRESENTANT"/>
                   </basic>
                   <basic name="refterritoire" attribute-type="Object">
                   </basic>
                   <basic name="typeRep" attribute-type="String">
                        <column name="TYPE_REP"/>
                   </basic>
              </attributes>
         </entity>
         <entity class="model.Territoire" access="VIRTUAL">
              <attributes>
                   <id name="idTerritoire" attribute-type="long">
                        <column name="ID_TERRITOIRE"/>
                   </id>
                   <basic name="lesrepresentants" attribute-type="Object">
                   </basic>
                   <basic name="nomTerritoire" attribute-type="String">
                        <column name="NOM_TERRITOIRE"/>
                   </basic>
                   <basic name="refchef" attribute-type="Object">
                   </basic>
              </attributes>
         </entity>
         <entity class="model.Vehicule" access="VIRTUAL">
              <attributes>
                   <id name="idVehicule" attribute-type="long">
                        <column name="ID_VEHICULE"/>
                   </id>
                   <basic name="lescommandes" attribute-type="Object">
                   </basic>
                   <basic name="nomVehicule" attribute-type="String">
                        <column name="NOM_VEHICULE"/>
                   </basic>
                   <basic name="refavoir" attribute-type="Object">
                   </basic>
                   <basic name="refmodele" attribute-type="Object">
                   </basic>
              </attributes>
         </entity>
         <entity class="model.Visiteav" access="VIRTUAL">
              <attributes>
                   <id name="idVisiteav" attribute-type="long">
                        <column name="ID_VISITEAV"/>
                   </id>
                   <basic name="dateDebut" attribute-type="java.util.Date">
                        <column name="DATE_DEBUT"/>
                        <temporal>DATE</temporal>
                   </basic>
                   <basic name="dateFin" attribute-type="java.util.Date">
                        <column name="DATE_FIN"/>
                        <temporal>DATE</temporal>
                   </basic>
                   <basic name="refclient" attribute-type="Object">
                   </basic>
                   <basic name="refrepresentant" attribute-type="Object">
                   </basic>
              </attributes>
         </entity>
    </entity-mappings>

Maybe you are looking for

  • (Restoring) backup taking forever

    Hi, I've a big problem with my iPhone 4 and iTunes. I've read discussion on a similar problem, without finding an answer that could work with me. Today I tried to sync my iPhone 4 (iOS 5) via iTunes/cable. The backup phase was lasting forever. I trie

  • Handling Unit Error

    Hi All, The scenario is STO from Plant(2003) to Plant(2002) within company and sales from Plant 2002 to customer. VA01(Plant2002-no stock)->ME21N->VL10B(with HU-from Plant 2003)->VF01(JEX)->MIGO(GR w.r.t delivery,selecting via.HU)> VL02N-from Plant 2

  • Can an error be forced in the Post method of Create Purch. Req. ME51N

    Hello Developers, I need to prevent the Posting from ME51N after displaying errors in custom code. I created an enhancement at the beginning of the Post method to perform edits but even after a message type "E" occurs the PR number displays on the sc

  • Mvc4How does on replace ValidateAntiForgeryTokenAttribute.Salt Property with AntiForgeryConfig.AdditionalDataProvider ??? ‎

    I updated to mvc 4 and got this error that : ValidateAntiForgeryTokenAttribute.Salt Property (System [ObsoleteAttribute("The 'Salt' property is deprecated. To specify custom data to be embedded within the token, use the static AntiForgeryConfig.Addit

  • Need an example about Yokogawa 7651's labview VI

    hi, highly respected gurus:            I am a new guy of labview, and now I need to use Yokogawa 7651 and Keithley 196 to make an I-V curve to perform the restistance measurment. That's to say, I need to tell tell my Yokogawa 7651 to produce an volta