Skip to Content
author's profile photo
Former Member

alv reports in dialog programming

Hi

how to use alv reports in dialog programming?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • author's profile photo
    Former Member
    Oct 11, 2007 at 02:31 PM

    Hi,

    http://www.geocities.com/mpioud/Abap_programs.html

    http://www.sapdevelopment.co.uk/reporting/reportinghome.htm

    Simple ALV report

    http://www.sapgenie.com/abap/controls/alvgrid.htm

    http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox

    ALV

    1. Please give me general info on ALV.

    http://www.sapfans.com/forums/viewtopic.php?t=58286

    http://www.sapfans.com/forums/viewtopic.php?t=76490

    http://www.sapfans.com/forums/viewtopic.php?t=20591

    http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.

    2. How do I program double click in ALV?

    http://www.sapfans.com/forums/viewtopic.php?t=11601

    http://www.sapfans.com/forums/viewtopic.php?t=23010

    3. How do I add subtotals (I have problem to add them)...

    http://www.sapfans.com/forums/viewtopic.php?t=20386

    http://www.sapfans.com/forums/viewtopic.php?t=85191

    http://www.sapfans.com/forums/viewtopic.php?t=88401

    http://www.sapfans.com/forums/viewtopic.php?t=17335

    4. How to add list heading like top-of-page in ABAP lists?

    http://www.sapfans.com/forums/viewtopic.php?t=58775

    http://www.sapfans.com/forums/viewtopic.php?t=60550

    http://www.sapfans.com/forums/viewtopic.php?t=16629

    5. How to print page number / total number of pages X/XX in ALV?

    http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)

    6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.

    http://www.sapfans.com/forums/viewtopic.php?t=64320

    http://www.sapfans.com/forums/viewtopic.php?t=44477

    7. How can I set the cell color in ALV?

    http://www.sapfans.com/forums/viewtopic.php?t=52107

    8. How do I print a logo/graphics in ALV?

    http://www.sapfans.com/forums/viewtopic.php?t=81149

    http://www.sapfans.com/forums/viewtopic.php?t=35498

    http://www.sapfans.com/forums/viewtopic.php?t=5013

    9. How do I create and use input-enabled fields in ALV?

    http://www.sapfans.com/forums/viewtopic.php?t=84933

    http://www.sapfans.com/forums/viewtopic.php?t=69878

    10. How can I use ALV for reports that are going to be run in background?

    http://www.sapfans.com/forums/viewtopic.php?t=83243

    http://www.sapfans.com/forums/viewtopic.php?t=19224

    11. How can I display an icon in ALV? (Common requirement is traffic light icon).

    http://www.sapfans.com/forums/viewtopic.php?t=79424

    http://www.sapfans.com/forums/viewtopic.php?t=24512

    12. How can I display a checkbox in ALV?

    http://www.sapfans.com/forums/viewtopic.php?t=88376

    http://www.sapfans.com/forums/viewtopic.php?t=40968

    http://www.sapfans.com/forums/viewtopic.php?t=6919

    Go thru these programs they may help u to try on some hands on

    ALV Demo program

    BCALV_DEMO_HTML

    BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode

    BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode

    BCALV_GRID_DEMO Simple ALV Control Call Demo Program

    BCALV_TREE_DEMO Demo for ALV tree control

    BCALV_TREE_SIMPLE_DEMO

    BC_ALV_DEMO_HTML_D0100

    1->go to Screen Painter, choose the column which you need to make as drop down.

    2->Click F2 to go tothe properties screen.

    3->Select Listbox or Listbox with Key for the DROPDOWN field (3rd field in properties tab)

    4->give value for the FCODE field also, to track the actions in SY_UCOMM when the user selects the value.

    5->in the ABAP code, you need to include the logic to populate values for this drop down. You can use the function module VRM_SET_VALUES to populate the listbox in each line of the table control. The fucntion module has to be called in the PBO module, which is defined inside the loop...endloop statement in the flow logic.

    6->for changing the values based on user selection, you can include the code in the PAI module, checking SY_UCOMM or OK_CODE.

    check this link:

    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCDWBTUT/BCDWBTUT.pdf

    http://help.sap.com/saphelp_40b/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/applet.htm

    Have a look at these good links-

    http://www.allsaplinks.com/dialog_programming.html

    http://sap.mis.cmich.edu/sap-abap/abap09/

    http://www.sapdevelopment.co.uk/dialog/dialoghome.htm

    http://help.sap.com/saphelp_webas630/helpdata/en/9f/db9cdc35c111d1829f0000e829fbfe/content.htm

    http://sap.mis.cmich.edu/abap-00/

    http://www.allsaplinks.com/files/using_table_in_screen.pdf

    http://help.sap.com/saphelp_46c/helpdata/en/08/bef2dadb5311d1ad10080009b0fb56/content.htm

    http://www.sapgenie.com/links/abap.htm

    http://help.sap.com/saphelp_nw04/helpdata/en/c9/5472fc787f11d194c90000e8353423/frameset.htm

    http://www.sapdevelopment.co.uk/dialog/dialoghome.htm

    http://help.sap.com

    http://www.sapgenie.com/abap/example_code.htm

    http://help.sap.com/saphelp_47x200/helpdata/en/52/670ba2439b11d1896f0000e8322d00/frameset.htm

    http://www.allsaplinks.com/dialog_programming.html

    http://www.sapbrain.com/TUTORIALS/default.html

    http://www.sappoint.com/abap/spmp.pdf

    http://sappoint.com/abap.html

    http://www.sap-img.com/abap.htm

    http://sap.ittoolbox.com/code/archives.asp?i=10&t=450&a=t

    http://www.sapdevelopment.co.uk/dialog/dialoghome.htm

    http://www.sap-img.com/abap/

    http://www.sapdevelopment.co.uk/dialog/dialoghome.htm

    http://www.sap-img.com/

    http://www.sappoint.com/faq/faqdiapr.pdf

    http://www.allsaplinks.com/dialog_programming.html

    Regards,

    Padmam.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 11, 2007 at 02:32 PM

    create a custom container and insert an instance of cl_gui_alv_grid. in it.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 11, 2007 at 02:32 PM

    Using OO ALV...You create a dynpro screen, a custom container, named

    CUSTOM_ALV

    in my example...and your done -:)

    *&---------------------------------------------------------------------*
    *& Report  ZDUMMY_ATG_2
    *&
    *&---------------------------------------------------------------------*
    REPORT zdummy_atg_2.
    
    TYPES: BEGIN OF ty_scarr,
           carrid TYPE scarr-carrid,
           carrname TYPE scarr-carrname,
           currcode TYPE scarr-currcode,
           END OF ty_scarr.
    
    DATA: t_spfli TYPE STANDARD TABLE OF spfli,
          w_spfli LIKE LINE OF t_spfli,
          lt_f4 TYPE lvc_t_f4 WITH HEADER LINE,
          return_tab TYPE STANDARD TABLE OF ddshretval WITH HEADER LINE,
          t_custom_scarr TYPE STANDARD TABLE OF ty_scarr WITH HEADER LINE,
          t_stable TYPE STANDARD TABLE OF lvc_s_stbl WITH HEADER LINE.
    
    FIELD-SYMBOLS: <fs_spfli> LIKE LINE OF t_spfli,
                   <fs_scarr> LIKE LINE OF t_custom_scarr.
    
    CLASS cl_gui_object DEFINITION LOAD.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    INCLUDE <cl_alv_control>.
    
    DATA: ok_code LIKE sy-ucomm,
          gt_fieldcat TYPE lvc_t_fcat,
          gt_sort TYPE lvc_t_sort,
          event_receiver TYPE REF TO lcl_event_receiver,
          gs_layout TYPE lvc_s_layo,
          mycontainer TYPE scrfname VALUE 'CUSTOM_ALV',
          custom_container TYPE REF TO cl_gui_custom_container,
          grid1 TYPE REF TO cl_gui_alv_grid,
          gs_variant TYPE disvariant,
          x_save,
          w_error TYPE c,
          l_valid(1) TYPE c.
    
    *---------------------------------------------------------------------*
    *       CLASS LCL_EVENT_RECEIVER DEFINITION
    *---------------------------------------------------------------------*
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS: handle_data_changed
          FOR EVENT data_changed OF cl_gui_alv_grid
          IMPORTING er_data_changed,
          handle_f4_help
          FOR EVENT onf4 OF cl_gui_alv_grid
          IMPORTING e_fieldname es_row_no er_event_data.
    ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION
    
    *---------------------------------------------------------------------*
    *       CLASS lcl_event_receiver IMPLEMENTATION
    *---------------------------------------------------------------------*
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_data_changed.
        PERFORM data_changed USING er_data_changed.
      ENDMETHOD.                    "HANDLE_DATA_CHANGED
      METHOD handle_f4_help.
        PERFORM handle_onf4 USING e_fieldname es_row_no.
        er_event_data->m_event_handled = 'X'.
      ENDMETHOD.                    "HANDLE_F4_HELP
    ENDCLASS.                    "LCL_EVENT_RECEIVER IMPLEMENTATION
    
    *&---------------------------------------------------------------------*
    *&      START-OF-SELECTION                                             *
    *&---------------------------------------------------------------------*
    START-OF-SELECTION.
    
      PERFORM cargar_customs.
      PERFORM cargar_datos.
      PERFORM fill_layout.
      PERFORM fill_catalog.
      PERFORM llamar_alv.
    
      CALL SCREEN 0100.
    
    *&---------------------------------------------------------------------*
    *&      Form  CARGAR_DATOS                                             *
    *&---------------------------------------------------------------------*
    FORM cargar_datos.
    
      SELECT mandt carrid connid countryfr cityfrom
             airpfrom countryto cityto airpto
             fltime deptime arrtime distance
             distid fltype period
      INTO TABLE t_spfli
      FROM spfli.
    
    ENDFORM.                    " CARGAR_DATOS
    
    *&---------------------------------------------------------------------*
    *&      Form  CARGAR_CUSTOMS                                           *
    *&---------------------------------------------------------------------*
    FORM cargar_customs.
    
      SELECT carrid carrname currcode
      INTO TABLE t_custom_scarr
      FROM scarr.
    
    ENDFORM.                    " CARGAR_DATOS
    
    *&---------------------------------------------------------------------*
    *&      Form  FILL_LAYOUT                                              *
    *&---------------------------------------------------------------------*
    FORM fill_layout.
    
      gs_layout-sel_mode = 'A'.
    
    ENDFORM.                    " FILL_LAYOUT
    
    *&---------------------------------------------------------------------*
    *&      Form  FILL_CATALOG                                             *
    *&---------------------------------------------------------------------*
    FORM fill_catalog.
    
      DATA: gs_fieldcat TYPE lvc_s_fcat.
    
      CLEAR gs_fieldcat.
      gs_fieldcat-col_pos   = 1.
      gs_fieldcat-fieldname = 'CARRID'.
      gs_fieldcat-reptext   = 'Compañia'.
      gs_fieldcat-tabname   = 'T_SPFLI'.
      gs_fieldcat-edit      = 'X'.
      gs_fieldcat-f4availabl = 'X'.
      gs_fieldcat-outputlen = '8'.
      APPEND gs_fieldcat TO gt_fieldcat.
    
      CLEAR gs_fieldcat.
      gs_fieldcat-col_pos   = 2.
      gs_fieldcat-fieldname = 'CONNID'.
      gs_fieldcat-reptext   = 'Conexión'.
      gs_fieldcat-tabname   = 'T_SPFLI'.
      gs_fieldcat-edit      = 'X'.
      gs_fieldcat-outputlen = '8'.
      APPEND gs_fieldcat TO gt_fieldcat.
    
      CLEAR gs_fieldcat.
      gs_fieldcat-col_pos   = 3.
      gs_fieldcat-fieldname = 'COUNTRYFR'.
      gs_fieldcat-reptext   = 'País'.
      gs_fieldcat-tabname   = 'T_SPFLI'.
      gs_fieldcat-edit      = 'X'.
      gs_fieldcat-outputlen = '4'.
      APPEND gs_fieldcat TO gt_fieldcat.
    
      CLEAR gs_fieldcat.
      gs_fieldcat-col_pos   = 4.
      gs_fieldcat-fieldname = 'CITYFROM'.
      gs_fieldcat-reptext   = 'Ciudad Salida'.
      gs_fieldcat-tabname   = 'T_SPFLI'.
      gs_fieldcat-edit      = space.
      gs_fieldcat-outputlen = '20'.
      APPEND gs_fieldcat TO gt_fieldcat.
    
      CLEAR gs_fieldcat.
      gs_fieldcat-col_pos   = 5.
      gs_fieldcat-fieldname = 'AIRPFROM'.
      gs_fieldcat-reptext   = 'Arp. Salida'.
      gs_fieldcat-tabname   = 'T_SPFLI'.
      gs_fieldcat-edit      = 'X'.
      gs_fieldcat-outputlen = '10'.
      APPEND gs_fieldcat TO gt_fieldcat.
    
      CLEAR gs_fieldcat.
      gs_fieldcat-col_pos   = 6.
      gs_fieldcat-fieldname = 'COUNTRYTO'.
      gs_fieldcat-reptext   = 'País'.
      gs_fieldcat-tabname   = 'T_SPFLI'.
      gs_fieldcat-edit      = 'X'.
      gs_fieldcat-outputlen = '4'.
      APPEND gs_fieldcat TO gt_fieldcat.
    
      CLEAR gs_fieldcat.
      gs_fieldcat-col_pos   = 7.
      gs_fieldcat-fieldname = 'CITYTO'.
      gs_fieldcat-reptext   = 'Ciudad Llegada'.
      gs_fieldcat-tabname   = 'T_SPFLI'.
      gs_fieldcat-edit      = space.
      gs_fieldcat-outputlen = '20'.
      APPEND gs_fieldcat TO gt_fieldcat.
    
    ENDFORM.                    " FILL_CATALOG
    
    *&---------------------------------------------------------------------*
    *&      Form  LLAMAR_ALV                                               *
    *&---------------------------------------------------------------------*
    FORM llamar_alv.
    
      IF custom_container IS INITIAL.
        CREATE OBJECT custom_container
          EXPORTING
            container_name              = mycontainer
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5.
      ENDIF.
    
      CREATE OBJECT grid1
        EXPORTING
          i_parent = custom_container.
    
      CREATE OBJECT event_receiver.
    
      lt_f4-fieldname = 'CARRID'.
      lt_f4-register = 'X' .
      lt_f4-getbefore = 'X' .
      lt_f4-chngeafter = 'X' .
      APPEND lt_f4.
    
      SET HANDLER event_receiver->handle_data_changed FOR grid1.
      SET HANDLER event_receiver->handle_f4_help FOR grid1.
    
      CALL METHOD grid1->register_f4_for_fields
        EXPORTING
          it_f4 = lt_f4[].
    
      IF sy-batch IS INITIAL.
        CALL METHOD grid1->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_modified.
      ENDIF.
    
      CALL METHOD grid1->set_table_for_first_display
        EXPORTING
          is_variant      = gs_variant
          i_save          = x_save
          i_default       = 'X'
          is_layout       = gs_layout
        CHANGING
          it_fieldcatalog = gt_fieldcat
          it_sort         = gt_sort[]
          it_outtab       = t_spfli[].
    
      CALL METHOD grid1->set_ready_for_input
        EXPORTING
          i_ready_for_input = 1.
    
    ENDFORM.                    " LLAMAR_ALV
    
    *&---------------------------------------------------------------------*
    *&      Form  HANDLE_ONF4                                              *
    *&---------------------------------------------------------------------*
    FORM handle_onf4 USING p_e_fieldname
                           p_es_row_no STRUCTURE lvc_s_roid.
    
      CASE p_e_fieldname.
        WHEN 'CARRID'.
          CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
            EXPORTING
              retfield        = 'CARRID'
              value_org       = 'S'
            TABLES
              value_tab       = t_custom_scarr
              return_tab      = return_tab
            EXCEPTIONS
              parameter_error = 1
              no_values_found = 2
              OTHERS          = 3.
    
          IF NOT return_tab[] IS INITIAL.
            READ TABLE return_tab INDEX 1.
            READ TABLE t_spfli INDEX p_es_row_no-row_id
            ASSIGNING <fs_spfli>.
            <fs_spfli>-carrid = return_tab-fieldval.
            CALL METHOD grid1->refresh_table_display
              EXPORTING
                is_stable = t_stable.
          ENDIF.
    
      ENDCASE.
    
    ENDFORM.                    " HANDLE_ONF4
    
    *&---------------------------------------------------------------------*
    *&      Module  STATUS_0100  OUTPUT                                    *
    *&---------------------------------------------------------------------*
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'MAIN_STATUS'.
    *  SET TITLEBAR 'xxx'.
    
    ENDMODULE.                 " STATUS_0100  OUTPUT
    
    *&---------------------------------------------------------------------*
    *&      Module  USER_COMMAND_0100  INPUT                               *
    *&---------------------------------------------------------------------*
    MODULE user_command_0100 INPUT.
    
      ok_code = sy-ucomm.
    
      CASE ok_code.
        WHEN 'BACK' OR 'STOP' OR 'CANCEL'.
          SET SCREEN 0.
          LEAVE SCREEN.
        WHEN 'SAVE'.
          CALL METHOD grid1->check_changed_data
            IMPORTING
              e_valid = l_valid.
          IF l_valid EQ 'X'.
            PERFORM grabar_datos.
          ENDIF.
      ENDCASE.
    
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    
    *&---------------------------------------------------------------------*
    *&      Form  DATA_CHANGED                                             *
    *&---------------------------------------------------------------------*
    FORM data_changed USING rr_data_changed TYPE REF TO
                                            cl_alv_changed_data_protocol.
    
      DATA: w_new,
            ls_mod_cells TYPE lvc_s_modi,
            ls_cells TYPE lvc_s_modi.
    
      DATA: l_carrid TYPE spfli-carrid.
    
      CLEAR l_carrid.
    
      LOOP AT rr_data_changed->mt_good_cells INTO ls_mod_cells.
    
        CASE ls_mod_cells-fieldname.
          WHEN 'CARRID'.
            CALL METHOD rr_data_changed->get_cell_value
              EXPORTING
                i_row_id    = ls_mod_cells-row_id
                i_fieldname = ls_mod_cells-fieldname
              IMPORTING
                e_value     = l_carrid.
            IF l_carrid IS INITIAL.
              CALL METHOD rr_data_changed->add_protocol_entry
                EXPORTING
                  i_msgid     = '0K'
                  i_msgno     = '000'
                  i_msgty     = 'E'
                  i_msgv1     = 'Seleccione algún código'
                  i_fieldname = ls_mod_cells-fieldname
                  i_row_id    = ls_mod_cells-row_id.
              w_error = 'X'.
            ELSE.
              READ TABLE t_custom_scarr WITH KEY carrid = l_carrid
              ASSIGNING <fs_scarr>.
              IF sy-subrc NE 0.
                CALL METHOD rr_data_changed->add_protocol_entry
                  EXPORTING
                    i_msgid     = '0K'
                    i_msgno     = '000'
                    i_msgty     = 'E'
                    i_msgv1     = 'Código ingresado no existe'
                    i_fieldname = ls_mod_cells-fieldname
                    i_row_id    = ls_mod_cells-row_id.
                w_error = 'X'.
              ENDIF.
            ENDIF.
        ENDCASE.
    
      ENDLOOP.
    
    ENDFORM.                    " DATA_CHANGED
    
    *&---------------------------------------------------------------------*
    *&      Form  GRABAR_DATOS                                             *
    *&---------------------------------------------------------------------*
    FORM grabar_datos.
    
      LOOP AT t_spfli ASSIGNING <fs_spfli>.
        w_spfli = <fs_spfli>.
        MODIFY spfli FROM w_spfli.
        IF sy-subrc EQ 0.
          COMMIT WORK.
        ELSE.
          ROLLBACK WORK.
        ENDIF.
      ENDLOOP.
    
    ENDFORM.                    " GRABAR_DATOS
    

    Greetings,

    Blag.

    Add comment
    10|10000 characters needed characters exceeded