Popoulate ALV Grid with internal table

Question:
New to ALV GRID,
can somebody help me how to populate the ALV grid with internal table..any eg...
Thanks
Answer:
I have internal table with the fields from different table
Answer:
...then you can get help from different threads
/forums/viewtopic.php?t=58278&highlight=%2Afieldcatalog%2A

Incho
Answer:
I wrote a subroutine that I include to any of my ALV programs to set up my field catalog.
*-------------------------------------------------------------------
***INCLUDE ZNHPYALV .
*         z n (include) h (hr) py (payroll) ALV (Abap List Variant)
* Subroutines to assist in ALV display
*-----------------------------------------------------------------------
* History:
* Was internal to ZHHRI003
* DV2K9xxxxx 02/03/xx GossG  * Design for Pension reporting.
* DV2K9XXXXX 02/06/26 GossG  * Separate for generic use
*-----------------------------------------------------------------------
*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
*
* Mainline program needs
* type-pools: slis.
* data: it_fieldcat type slis_t_fieldcat_alv.
*
*///////////////////////////////////////////////////////////////////////
*---------------------------------------------------------------------
*      Form  fc      (Field Cat Build)
*
*      (null table & field means restart new fieldcat list)
*---------------------------------------------------------------------
*      -->p_table  itab name
*      -->p_field  itab field
*      -->p_name   column heading to be shown (or defaults to p_field)
*      -->p_size   default width of this column (or default)
*----------------------------------------------------------------------
FORM fc USING value(p_table) value(p_field) value(p_name) value(p_size).
  STATICS col LIKE sy-cucol.                                "int4
  DATA wa_fieldcat TYPE LINE OF slis_t_fieldcat_alv..
  FIELD-SYMBOLS: <fieldname>.
  IF p_table IS INITIAL AND p_field IS INITIAL.
    REFRESH it_fieldcat.
    MOVE 1 TO col.
  ELSE.
    IF p_name IS INITIAL.
      ASSIGN LOCAL COPY OF p_field(*) TO <fieldname>.
    ELSE.
      ASSIGN LOCAL COPY OF p_name(*)  TO <fieldname>.
    ENDIF.
    TRANSLATE p_table TO UPPER CASE.
    TRANSLATE p_field TO UPPER CASE.
*   Field size is still buggy.  For now, '10' is a compromise default
*   Determine field size default
    IF p_size IS INITIAL.
      MOVE 10 TO p_size.
    ENDIF.
*    ASSIGN COMPONENT p_field OF STRUCTURE p_table TO <field>.
*    IF p_size IS INITIAL.
*      DESCRIBE FIELD <field> LENGTH p_size.
*    ENDIF.
    CLEAR                 wa_fieldcat.
    MOVE col          TO  wa_fieldcat-col_pos.
    MOVE p_size       TO  wa_fieldcat-outputlen.
    MOVE p_field      TO: wa_fieldcat-fieldname,
                          wa_fieldcat-ref_fieldname.
    MOVE p_table      TO  wa_fieldcat-ref_tabname.
    MOVE <fieldname>  TO: wa_fieldcat-seltext_s,
                          wa_fieldcat-seltext_m,
                          wa_fieldcat-seltext_l.
    MOVE 'L'          TO  wa_fieldcat-ddictxt.
    APPEND                wa_fieldcat TO it_fieldcat.
    ADD p_size TO col.
  ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM alv
*---------------------------------------------------------------------*
*       It turned out to be easier to call alv directly from program.
*       Suitable example code is below.
*       (Grid Title may be removed, yielding 1 or 2 more data lines)
*---------------------------------------------------------------------*
**   display table according to field catalog.
*  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
*       EXPORTING
*            it_fieldcat   = it_fieldcat
*            i_grid_title  = 'Annual Update for Beneficiaries'
*       TABLES
*            t_outtab      = it_table
*       exceptions
*            program_error = 1
*            others        = 2.
*  IF sy-subrc <> 0.
*    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*  ENDIF. "error in alv
*----------------------------------------------------------------------
it is then called by
*&---------------------------------------------------------------------
*&      Form  alv_event (display event info as ALV)
*----------------------------------------------------------------------
*  -->  (implicit)  data in it_out
*----------------------------------------------------------------------
FORM alv_event.
* Only want Events List when "technical information" is requested.
  CHECK yn_tech EQ yes.
  DESCRIBE TABLE it_0000 LINES nn_0000.
  IF nn_0000 EQ 0.
    MESSAGE i065(f0) WITH text-006.
  ELSE.
    MOVE 'Events list' TO wa_alv_head.
*   clear fieldcat table before use.
    PERFORM fc USING ' ' ' '  ' ' 0.      "clear fieldcat
*   build field cat with  table  field  heading     size
    PERFORM fc USING 'it_0000': 'pernr' 'PerNr'   8,
                                'endda' 'End'     8,
                                'begda' 'Start'   8,
                                'seqnr' 'Rec#'    1,
                                'itxex' 'T'       1,
                                'massn' 'Ty'      2,
                                'massg' 'Rsn'     2,
                                'stat1' 'C'       1,
                                'stat2' 'E'       1,
                                'stat3' 'S'       1,
                                'ltext' 'Infotype 0000 long text' 40.
*   display table according to field catalog.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
         EXPORTING
              i_grid_title  = wa_alv_head
              it_fieldcat   = it_fieldcat
         TABLES
              t_outtab      = it_0000
         EXCEPTIONS
              program_error = 1
              OTHERS        = 2.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF. "error in alv
  ENDIF.
ENDFORM.                    " alv_event
and, finally, the following is in the data area of the calling program.
* for ALV
TYPE-POOLS: slis.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv.
INCLUDE znhpyalv.
Answer:
There is a great document on www.sapgenie.com

called abap hints and tips version 3.

More Articles:

where to get SAPScript Made Easy 4.6?
Schema Programming.?
Problem with batch-input transaction KP06?
pu12 - interface toolbox change validation?
Program Enqueue?
BDC PROBLEM?