Skip to Content
author's profile photo
Former Member

OO ALV

Hi...

I would like to learn some basic OO ALV.

Could anyone pass on some basic programs and tutorials....

I have been through DWDM transaction for sample programs. I need simpler ones

regards,

Karen

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on Sep 27, 2007 at 02:45 PM

    Hi Karen i m giving u below a simple oops alv program with some basic settings to perform.

    <code>

    &----


    *& Report Z_DEMO_ALVGRID

    *&

    &----


    *&

    *&

    &----


    report z_demo_alvgrid.

    *REPORT Z_50804_DEMO_ALVGRID.

    • TABLE DECLARATION

    tables : vbak.

    • GLOBAL DECLARATIONS

    data :ok_code like sy-ucomm,

    it_order like table of vbak.

    • DEFINITION OF THE CLASS C1

    class c1 definition.

    public section.

    methods : get_data.

    endclass. "c1 DEFINITION

    • IMPLEMENTATION OF THE CLASS C1

    class c1 implementation.

    method get_data.

    select * from vbak into table it_order.

    *

    endmethod. "get_data

    endclass. "c1 IMPLEMENTATION

    start-of-selection.

    data : obj type ref to c1.

    create object obj.

    call method obj->get_data.

    data :g_container type scrfname value 'GRID_CON',

    it_grid1 type ref to cl_gui_alv_grid,

    it_container type ref to cl_gui_custom_container.

    call screen 1001.

    &----


    *& Module STATUS_1001 OUTPUT

    &----


    • text

    ----


    module status_1001 output.

    set pf-status 'SALE'.

    if it_container is initial.

    create object it_container

    exporting

    • parent =

    container_name = g_container

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

    endif.

    create object it_grid1

    exporting

    • i_shellstyle = 0

    • i_lifetime =

    i_parent = it_container

    • i_appl_events = space

    • i_parentdbg =

    • i_applogparent =

    • i_graphicsparent =

    • i_name =

    • i_fcat_complete = space

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

    call method it_grid1->set_table_for_first_display

    exporting

    • i_buffer_active =

    • i_bypassing_buffer =

    • i_consistency_check =

    i_structure_name = 'VBAK'

    • 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 =

    • ir_salv_adapter =

    changing

    it_outtab = it_order

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

    • SET TITLEBAR 'xxx'.

    endmodule. " STATUS_1001 OUTPUT

    &----


    *& Module USER_COMMAND_1001 INPUT

    &----


    • text

    ----


    module user_command_1001 input.

    case ok_code.

    when 'EXIT'.

    perform exit_program.

    when 'BACK' or 'CANCEL'.

    leave to screen 0.

    endcase.

    clear ok_code.

    endmodule. " USER_COMMAND_1001 INPUT

    &----


    *& Form EXIT_PROGRAM

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form exit_program .

    leave program.

    endform. " EXIT_PROGRAM

    </code>

    • In the call screen 100 just go to screen painter, click on layout and the in the left buttons from down in the 2nd position you will be having a button called "custom control" so you to click on that and drop that on ur screen and give some name as "grid_con" which ur passing in ur program at

    g_container type scrfname value 'GRID_CON',

    and then set the PBO and PAI by double clicking on them in the flow logic of screen painter and save and activate the screen.

    then save and activate ur main program and execute.

    u will get the output accordingly.

    i hope it helps , if you find any problems do post that.

    do reward points if you find it helpful.

    thanks & regards,

    rajesh

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 03:37 AM
    "Developing ALV grid reports using the object methods functionality

    The ALV object Grid methods allow the same functionality as ALV grid report function modules but are displayed within a screen (dialog program). SAP has provided a suit of programs which demonstrate how to For examples see standard SAP programs as detailed below:

    BCALV_GRID_01 This program illustrates how the events for print processing PRINT_TOP_OF_PAGE,

    PRINT_END_OF_PAGE, PRINT_TOP_OF_LIST,PRINT_END_OF_LIST are handled. The

    corresponding handler methods control the appearance of the list printed.

    BCALV_GRID_02 Show a detail list in an amodal window. There is no second dynro needed in contrast to

    BCALV_GRID_03.

    BCALV_GRID_03 This program implements a function on event DOUBLE_CLICK. According to the selected line data

    from table SBOOK is selected and displayed by a second ALV Control in a dialog dynpro.

    BCALV_GRID_04 Illustrates the use of exceptions (lights or leds). According to the values of SFLIGHT-SEATSOCC, the

    lights are set to 1 (red), 2 (yellow) or 3 (green).

    BCALV_GRID_05 Demonstrate the creation of an own toolbar button.

    BCALV_GRID_06 Demonstrate the creation of an own context menu.

    BCALV_GRID_07 Append a menu button to the standard toolbar.

    BCALV_GRID_08 Append a menu with default button to the standard toolbar. It is exactly the same as

    BCALVC_TB_WITH_MENU except for methods HANDLE_MENU_BUTTON and HANDLE_TOOLBAR.

    Editable ALV grids

    BCALV_EDIT_01 This report illustrates the simplest case of using an editable/noneditable ALV Grid Control.

    BCALV_EDIT_02 This report illustrates how to set chosen cells of an ALV Grid Control editable.

    BCALV_EDIT_03 In this example the user may change values of fields SEATSOCC (occupied seats) and/or PLANETYPE.

    The report checks the input value(s) semantically and provides protocol messages in case of error

    BCALV_EDIT_04 This report illustrates how to add and remove lines to a table using the ALV Grid Control and how to

    implement the saving of the new data.

    BCALV_EDIT_05 This example shows how to use checkboxes within an ALV Grid Control. You learn:

    (1) how to define a column for editable checkboxes for an attribute of your list

    (2) how to evaluate the checked checkboxes

    (3) how to switch between editable and non-editable checkboxes

    BCALV_EDIT_06 This example shows how to define a dropdown listbox for all cells of one column in an editable ALV

    Grid Control.

    BCALV_EDIT_07 This example shows how to define dropdown listboxes for particular cells of your output table.

    BCALV_EDIT_08 This report implements an ALV Grid Control with an application specific F4 help. The following aspects

    are dealt with:

    (1) how to replace the standard f4 help

    (2) how to pass the selected value to the ALV Grid Control

    (3) how to build an f4 help, whose value range depend on a value of another cell.

    Reward points if it is usefull ...

    Girish

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 27, 2007 at 01:31 PM

    Please do a forum" target="_blank">www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_forums&query=oo+alv&adv=true&sdn_author_name=">forum search before asking a question.

    This question has been answered hundreds of times.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 27, 2007 at 02:15 PM

    Hello Karen

    Have a look at my sample reports <b>ZUS_SDN_TWO_ALV_GRIDS</b> and <b>ZUS_SDN_THREE_ALV_GRIDS</b> in thread

    displaying data in oops

    I have posted several other simplified ALV reports which show some basics of ALV programming. Simply search the SDN forums for <b>ZUS_SDN</b>.

    Regards

    Uwe

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 28, 2007 at 03:55 AM
    Add comment
    10|10000 characters needed characters exceeded