Monday, December 20, 2010
Please check the sample program .

REPORT ztest_program.
DATA:
    BEGIN OF it_data OCCURS 0,
      header1 TYPE char50,
      header2 TYPE char50,
      arbgb TYPE t100-arbgb,
      msgnr TYPE t100-msgnr,
      text TYPE t100-text,
    END OF it_data.
*ALV Declarations
TYPE-POOLS:slis.
TYPES:
    ty_fieldcat          TYPE slis_fieldcat_alv,
    ty_events            TYPE slis_alv_event,
    ty_layout            TYPE slis_layout_alv.
DATA:
    wa_fieldcat          TYPE ty_fieldcat,
    wa_events            TYPE ty_events,
    wa_layout            TYPE ty_layout.
DATA:
    it_events            TYPE STANDARD TABLE OF ty_events,
    it_fieldcat          TYPE STANDARD TABLE OF ty_fieldcat.
DATA:
    g_program            TYPE sy-repid.

START-OF-SELECTION.
  SELECT * FROM t100 INTO CORRESPONDING FIELDS OF TABLE it_data
  UP TO 20 ROWS WHERE sprsl = sy-langu.
*Fieldcatalog.
  PERFORM fieldcatalog
  USING:                            "Field Lengths
  1 1 'HEADER1' 'IT_DATA' 'HEADER1' '30',
  1 2 'HEADER2' 'IT_DATA' 'HEADER2' '73',
  2 3 'ARBGB'   'IT_DATA' 'ARBGB'   '20',
  2 4 'MSGNR'   'IT_DATA' 'MSGNR'   '10',
  2 5 'TEXT'    'IT_DATA' 'TEXT'    '73'.
  wa_layout-info_fieldname = 'COLOR'.
  g_program = sy-repid.
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      i_callback_program = g_program
      is_layout          = wa_layout
      it_fieldcat        = it_fieldcat
      it_events          = it_events
    TABLES
      t_outtab           = it_data
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.
*&---------------------------------------------------------------------*
*&      Form  FIELDCATALOG
*&---------------------------------------------------------------------*
FORM fieldcatalog USING row_pos col_pos field table f_txt outputlen.
  wa_fieldcat-row_pos   = row_pos.
  wa_fieldcat-col_pos   = col_pos.
  wa_fieldcat-fieldname = field.
  wa_fieldcat-tabname   = table.
  wa_fieldcat-seltext_l = f_txt.
  wa_fieldcat-outputlen = outputlen.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR  wa_fieldcat.
ENDFORM.                    " FIELDCATALOG


0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.