Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Report using oops

Former Member
0 Kudos

Hi Experts,

Am trying to display simple reprt using report, actually i dnt want to displayy using oops through module pool programming.

please look my below code. am not able to dispaly the report.

plz correct.

tables: vbak.

types: begin of ty_data,
         vbeln type vbeln,
         auart type AUART, " Sales Document Type
         vkorg type VKORG, "Sales Organization
*        VTWEG type VTWEG, "Distribution Channel
*        SPART type SPART, "Ditvision
        end of ty_data.
data: it_data type table of ty_data,
       wa_data like line of it_data,
       it_fcat type LVC_T_FCAT,
       wa_fcat type LVC_S_FCAT.
*      gv_repid TYPE sy-repid,
*      gv_dynnr TYPE sy-dynnr.
data: oref_cc type ref to cl_gui_container,
*      oref_dc type ref to cl_gui_docking_container,
       oref_grid type ref to cl_gui_alv_grid.
select-options s_vbeln for vbak-vbeln obligatory.
start-of-selection.
perform preapre_data.
*perform prepare_layout.
perform prepare_fieldcatalog.
perform display_alv.
*&---------------------------------------------------------------------*
*&      Form  PREAPRE_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM PREAPRE_DATA .
  select vbeln auart vkorg  from vbak
         into table it_data
         where vbeln in s_vbeln.
  if it_data[] is initial.
    leave to list-processing.
  endif.
ENDFORM.                    " PREAPRE_DATA
*&---------------------------------------------------------------------*
*&      Form  PREPARE_LAYOUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM PREPARE_LAYOUT .

ENDFORM.                    " PREPARE_LAYOUT
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM DISPLAY_ALV .

   CREATE OBJECT OREF_GRID
     EXPORTING
       I_PARENT          = CL_GUI_CUSTOM_CONTAINER=>DEFAULT_SCREEN.
   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 OREF_GRID->SET_TABLE_FOR_FIRST_DISPLAY
   EXPORTING
*    I_BUFFER_ACTIVE               =
*    I_BYPASSING_BUFFER            =
*    I_CONSISTENCY_CHECK           =
*    I_STRUCTURE_NAME              =
*    IS_VARIANT                    =
*    I_SAVE                        = 'X'
     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_data
     IT_FIELDCATALOG               = it_fcat
*    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.

oref_grid->refresh_table_display( ).

ENDFORM.                    " DISPLAY_ALV
*&---------------------------------------------------------------------*
*&      Form  PREPARE_FIELDCATALOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM PREPARE_FIELDCATALOG .
  wa_fcat-tabname = 'IT_DATA'.
  wa_fcat-fieldname = 'VBELN' .
  wa_fcat-outputlen = '6' .
  wa_fcat-coltext = 'Sales Order'.
  append wa_fcat to it_fcat.
  clear wa_fcat.
  wa_fcat-tabname = 'IT_DATA'.
  wa_fcat-fieldname = 'AUART' .
  wa_fcat-outputlen = '12' .
  wa_fcat-coltext = 'Sales Doc Type'.
  append wa_fcat to it_fcat.
  clear wa_fcat.
  wa_fcat-tabname = 'IT_DATA'.
  wa_fcat-fieldname = 'VKORG' .
  wa_fcat-outputlen = '12' .
  wa_fcat-coltext = 'Sales Orga'.
  append wa_fcat to it_fcat.
  clear wa_fcat.
ENDFORM.                    " PREPARE_FIELDCATALOG

5 REPLIES 5

Former Member
0 Kudos

Srinath,

Your getting any error can you please debug the program then you can find the issue..

Then you can post the issue what you faced...

Thanks,

Raj

0 Kudos

am not getting any error...

data is not displaying...i mean the grid itself not displaying..

0 Kudos

Hi Srinath,

Your program is correct. You where missing the following point

1. Call screen 100 before call perform display alv. Double click on screen number. it will asked for create the screen 100. give the description and click on yes.

2. Create the container on the screen.

3. Givet the container name as define name in the program.

Kind Regards

Ravishankar

0 Kudos

hi Ravishankar,

I know that procedure...am trying to display alv on selection screen itself,

any how thanks for your reply.

Thanks

Srinath P

0 Kudos

Hiii, 

       1) In SE38 search salv* you will get several example of class CL_SALV_TABLE with this class you do not need to create container .

http://wiki.sdn.sap.com/wiki/display/Snippets/TOP+OF+PAGE+AND+END+OF+PAGE+IN+CLASS+cl_salv_table

2) You can use docking container for displaying data on same selection screen .

    http://zevolving.com/2008/10/display-alv-report-output-in-the-same-selection-screen/

Search on Google - displaying alv on same selection screen