Application Development and Automation 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: 
Read only

alv

Former Member
0 Likes
598

sir,

i write a program in classical report...now i need to change the report in alv.

pls explain sir....

sir,

i write a program in classical report...now i need to change the report in alv.

pls explain sir....

5 REPLIES 5
Read only

Former Member
0 Likes
580

Build the field cataloggue to the final internal table

if there are any write and skip statements in your code pls comment it

and pass the final internal tbale to the function module

reuse alv grid display

as per your requrement

Read only

p291102
Active Contributor
0 Likes
580

Hi,

Following this is the basic alv report.

REPORT YMS_ALVDEMO .

TYPE-POOLS : SLIS.

TABLES : QALS.

DATA : BEGIN OF T_OUT OCCURS 0,

MATNR LIKE QALS-MATNR, "MATERIAL

WERK LIKE QALS-WERK, "PLANT

ART LIKE QALS-ART, "Inspaction Lot Type

OBJNR LIKE QALS-OBJNR, "Object Number

END OF T_OUT.

DATA : I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

I_LAYOUT TYPE SLIS_LAYOUT_ALV,

GS_LAYOUT TYPE LVC_S_LAYO,

G_REPID TYPE SY-REPID,

LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

SELECT-OPTIONS:S_PRFLOS FOR QALS-PRUEFLOS.

INITIALIZATION.

G_REPID = SY-REPID.

I_LAYOUT-ZEBRA = 'X'.

I_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

START-OF-SELECTION.

PERFORM FETCH_DATA.

END-OF-SELECTION.

PERFORM FILL_FIELDCAT.

PERFORM DISPLAY_ALV.

&----


*& Form FETCH_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FETCH_DATA .

SELECT MATNR WERK ART OBJNR

FROM QALS

INTO TABLE T_OUT

WHERE PRUEFLOS IN S_PRFLOS.

ENDFORM. " FETCH_DATA

&----


*& Form FILL_FIELDCAT

&----


  • text

----


FORM FILL_FIELDCAT .

REFRESH I_FIELDCAT[].

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = G_REPID

I_INTERNAL_TABNAME = 'T_OUT'

I_INCLNAME = G_REPID

CHANGING

CT_FIELDCAT = I_FIELDCAT[]

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3.

ENDFORM. " FILL_FIELDCAT

&----


*& Form display_alv

&----


  • text

----


FORM DISPLAY_ALV .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

IS_LAYOUT = I_LAYOUT

IT_FIELDCAT = I_FIELDCAT[]

TABLES

T_OUTTAB = T_OUT

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

ENDFORM. " display_alv

Thanks,

Sankar M

Read only

Former Member
0 Likes
580

Hello Sankar,

Right now you are having the internal table that u r displaying.

1. For ALV u need to have the type pools.

type-pools: slis.    " Type pool for ALV

2. U need data fields used for ALV Call.

* Data Fields used for ALV call - Simple List

data: g_f_repid     like  sy-repid,
      g_t_fieldcat  type  slis_t_fieldcat_alv,
      g_r_fieldcat  type  slis_fieldcat_alv,
      g_t_events    type  slis_t_event,
      g_r_events    type  slis_alv_event,
      g_r_layout    type  slis_layout_alv.

data: g_r_x_variant   like  disvariant,
      g_r_variant     like  disvariant.

data: g_f_exit(1),
      g_f_save(1).

3.U need to set the field catalog... like this...

  data: l_r_fieldcat type slis_fieldcat_alv.

  clear : g_t_fieldcat,
          g_t_fieldcat[].

* Check - box
  l_r_fieldcat-tabname        = 'G_T_ITAB'.
  l_r_fieldcat-fieldname      = 'SEL'.
  l_r_fieldcat-col_pos        = 1.
  l_r_fieldcat-checkbox       = 'X'.
  l_r_fieldcat-input          = 'X'.

  append l_r_fieldcat to g_t_fieldcat.
  clear l_r_fieldcat.

* Plant
  l_r_fieldcat-tabname        = 'G_T_ITAB'.
  l_r_fieldcat-fieldname      = 'WERKS'.
  l_r_fieldcat-ref_tabname    = 'MARC'.
  l_r_fieldcat-ref_fieldname  = 'WERKS'.
*  l_r_fieldcat-no_out         = ' '.
*  l_r_fieldcat-input          = ' '.
*  l_r_fieldcat-key            = 'X'.
  l_r_fieldcat-col_pos        = 2.

  append l_r_fieldcat to g_t_fieldcat.
  clear l_r_fieldcat.

4. U need to set the alv parameters.

* Events
  refresh : g_t_events.
  clear   : g_r_events.

* TOP OF PAGE event for standard header
  g_r_events-name = 'TOP_OF_PAGE'.
  g_r_events-form = 'TOP_OF_PAGE'.
  append g_r_events to g_t_events.

* Attributes for layout
  g_r_layout-zebra = 'X'.
  g_r_layout-min_linesize = 119.
  g_r_layout-colwidth_optimize = 'X'.

* Field having checkbox
  g_r_layout-box_fieldname = 'SEL'.
* Field havind checkbox internal table name
  g_r_layout-box_tabname = 'G_T_ITAB'.

5. Then u need to call the function: REUSE_ALV_LIST_DISPLAY. Here u need to pass your final internal table to the function ( shown in bolds).

g_f_repid = sy-repid.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

*    I_INTERFACE_CHECK              = ' '
*    I_BYPASSING_BUFFER             =
*    I_BUFFER_ACTIVE                = ' '
*                    i_callback_program             = g_f_repid
                    i_callback_pf_status_set       = 'PF_STATUS_SET'
                    i_callback_user_command        = 'USER_COMMAND'
*    I_STRUCTURE_NAME               =
                    is_layout                      = g_r_layout
                    it_fieldcat                    = g_t_fieldcat[]
*    IT_EXCLUDING                   =
*    IT_SPECIAL_GROUPS              =
*    IT_SORT                        =
*    IT_FILTER                      =
*    IS_SEL_HIDE                    =
*    I_DEFAULT                      = 'X'
*    I_SAVE                         = ' '
                    is_variant                     = g_r_variant
                    it_events                      = g_t_events[]
*    IT_EVENT_EXIT                  =
*    IS_PRINT                       =
*    IS_REPREP_ID                   =
*    I_SCREEN_START_COLUMN          = 0
*    I_SCREEN_START_LINE            = 0
*    I_SCREEN_END_COLUMN            = 0
*    I_SCREEN_END_LINE              = 0
*    IMPORTING
*      E_EXIT_CAUSED_BY_CALLER        =
*      ES_EXIT_CAUSED_BY_USER         =
                   tables
                     t_outtab                       =<b> g_t_itab</b>
                   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.

You can have code for USER_COMMAND and PF_STATUS_SET in the functions of USER_COMMAND and PF_STATUS_SET.

Thats it.

For reference i'm pasting my entair code. Here My Internal table is G_T_ITAB. See how i'm printing it through ALV. Just have as a reference.

report z_alv_ex1 .

*SET TITLEBAR 'T_MATNR'.


*-----------------------------------------------------------------------
* TYPE-POOLS
*-----------------------------------------------------------------------

type-pools: slis.    " Type pool for ALV

*-----------------------------------------------------------------------
* TABLE USED
*-----------------------------------------------------------------------

tables: mara,    " General Material Data
        makt,    " Material Descriptions
        mard,    " Storage Location Data for Material
        marc,    " Plant Data for Material
        t001w.   " Plants/Branches

*-----------------------------------------------------------------------
* INTERNAL TABLES
*-----------------------------------------------------------------------

data: begin of g_t_itab occurs 0,           " TO HOLD
        sel          type c,
        lgort        like mard-lgort,       " storage location
        werks        like marc-werks,       " plant
        labst        like mard-labst,       " stock
        matnr        like mara-matnr,       " material number
        land1        like t001w-land1,      " country i.e. branches
      end of g_t_itab.

data: begin of g_t_detail occurs 0,         " TO HOLD
         matnr like mara-matnr,             " material number
      end of g_t_detail.

data: begin of g_t_makt occurs 0,           " TO HOLD
         matnr like makt-matnr,             " material number
         maktx like makt-maktx,             " material description
         spras like makt-spras,             " language key
      end of g_t_makt.

data: l_t_makt like makt occurs 0           " internal table with
      with header line.                     " same structure like MAKT


* Data Fields used for ALV call - Simple List

data: g_f_repid     like  sy-repid,
      g_t_fieldcat  type  slis_t_fieldcat_alv,
      g_r_fieldcat  type  slis_fieldcat_alv,
      g_t_events    type  slis_t_event,
      g_r_events    type  slis_alv_event,
      g_r_layout    type  slis_layout_alv.

data: g_r_x_variant   like  disvariant,
      g_r_variant     like  disvariant.

data: g_f_exit(1),
      g_f_save(1).

*-----------------------------------------------------------------------
* SELECTION SCREEN
*-----------------------------------------------------------------------

selection-screen begin of block b1 with frame title text-001.
select-options:  s_matnr for mara-matnr,
                 s_werks for marc-werks.

parameter: p_gerplt as checkbox user-command r1.
selection-screen end of block b1.

*-----------------------------------------------------------------------
* START OF SELECTION
*-----------------------------------------------------------------------
start-of-selection.
  perform get_data.

*-----------------------------------------------------------------------
* AT SELECTION SCREEN
*-----------------------------------------------------------------------
at selection-screen on s_matnr.
  if not ( s_werks is initial ).
    perform validation.
  endif.

at selection-screen output.
  loop at screen.
    if screen-group1 eq 'G' and p_gerplt = 'X'.
      screen-input = 0.
      refresh s_werks.
    endif.
    modify screen.
  endloop.

*-----------------------------------------------------------------------
* INITIALIZATION
*-----------------------------------------------------------------------
initialization.
  perform initial_selection_screen.

*-----------------------------------------------------------------------
* AT LINE SELECTION
*-----------------------------------------------------------------------
*AT LINE-SELECTION.
*  PERFORM at_line_selection.

*-----------------------------------------------------------------------
* END OF SELECTION
*-----------------------------------------------------------------------
end-of-selection.
  perform set_alv_parameters.
  perform display_list.

*---------------------------------------------------------------------*
*       FORM get_data                                                 *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form get_data.

  if p_gerplt = 'X'.
    select b~lgort c~werks b~labst a~matnr d~land1
        from mara as a
        inner join mard as b
        on a~matnr = b~matnr
        inner join marc as c
        on b~matnr = c~matnr
        inner join t001w as d
        on c~werks = d~werks
        into corresponding fields of table g_t_itab
        where
        a~matnr in s_matnr and
        d~land1 eq 'DE'.
  else.
    select b~lgort c~werks b~labst a~matnr
        from mara as a
        inner join mard as b
        on a~matnr = b~matnr
        inner join marc as c
        on b~matnr = c~matnr
        into corresponding fields of table g_t_itab
        where
        a~matnr in s_matnr and
        c~werks in s_werks.
  endif.

endform.

*---------------------------------------------------------------------*
*       FORM set_alv_parameters                                       *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form set_alv_parameters.

  perform set_fieldcatlog.

* Events
  refresh : g_t_events.
  clear   : g_r_events.

* TOP OF PAGE event for standard header
  g_r_events-name = 'TOP_OF_PAGE'.
  g_r_events-form = 'TOP_OF_PAGE'.
  append g_r_events to g_t_events.

* Attributes for layout
  g_r_layout-zebra = 'X'.
  g_r_layout-min_linesize = 119.
  g_r_layout-colwidth_optimize = 'X'.

* Field having checkbox
  g_r_layout-box_fieldname = 'SEL'.
* Field havind checkbox internal table name
  g_r_layout-box_tabname = 'G_T_ITAB'.

endform.


*---------------------------------------------------------------------*
*       FORM display_list                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form display_list.

  g_f_repid = sy-repid.

  call function 'REUSE_ALV_LIST_DISPLAY'
      exporting

*    I_INTERFACE_CHECK              = ' '
*    I_BYPASSING_BUFFER             =
*    I_BUFFER_ACTIVE                = ' '
*                    i_callback_program             = g_f_repid
                    i_callback_pf_status_set       = 'PF_STATUS_SET'
                    i_callback_user_command        = 'USER_COMMAND'
*    I_STRUCTURE_NAME               =
                    is_layout                      = g_r_layout
                    it_fieldcat                    = g_t_fieldcat[]
*    IT_EXCLUDING                   =
*    IT_SPECIAL_GROUPS              =
*    IT_SORT                        =
*    IT_FILTER                      =
*    IS_SEL_HIDE                    =
*    I_DEFAULT                      = 'X'
*    I_SAVE                         = ' '
                    is_variant                     = g_r_variant
                    it_events                      = g_t_events[]
*    IT_EVENT_EXIT                  =
*    IS_PRINT                       =
*    IS_REPREP_ID                   =
*    I_SCREEN_START_COLUMN          = 0
*    I_SCREEN_START_LINE            = 0
*    I_SCREEN_END_COLUMN            = 0
*    I_SCREEN_END_LINE              = 0
*    IMPORTING
*      E_EXIT_CAUSED_BY_CALLER        =
*      ES_EXIT_CAUSED_BY_USER         =
                   tables
                     t_outtab                       = g_t_itab
                   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.

endform.


*---------------------------------------------------------------------*
*       FORM set_fieldcatlog                                          *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form set_fieldcatlog.

  data: l_r_fieldcat type slis_fieldcat_alv.

  clear : g_t_fieldcat,
          g_t_fieldcat[].

* Check - box
  l_r_fieldcat-tabname        = 'G_T_ITAB'.
  l_r_fieldcat-fieldname      = 'SEL'.
  l_r_fieldcat-col_pos        = 1.
  l_r_fieldcat-checkbox       = 'X'.
  l_r_fieldcat-input          = 'X'.

  append l_r_fieldcat to g_t_fieldcat.
  clear l_r_fieldcat.

* Plant
  l_r_fieldcat-tabname        = 'G_T_ITAB'.
  l_r_fieldcat-fieldname      = 'WERKS'.
  l_r_fieldcat-ref_tabname    = 'MARC'.
  l_r_fieldcat-ref_fieldname  = 'WERKS'.
*  l_r_fieldcat-no_out         = ' '.
*  l_r_fieldcat-input          = ' '.
*  l_r_fieldcat-key            = 'X'.
  l_r_fieldcat-col_pos        = 2.

  append l_r_fieldcat to g_t_fieldcat.
  clear l_r_fieldcat.

* Storage Location
  l_r_fieldcat-tabname        = 'G_T_ITAB'.
  l_r_fieldcat-fieldname      = 'LGORT'.
  l_r_fieldcat-ref_tabname    = 'MARD'.
  l_r_fieldcat-ref_fieldname  = 'LGORT'.
  l_r_fieldcat-col_pos        = 3.

  append l_r_fieldcat to g_t_fieldcat.
  clear l_r_fieldcat.

* Material Number
  l_r_fieldcat-tabname        = 'G_T_ITAB'.
  l_r_fieldcat-fieldname      = 'MATNR'.
  l_r_fieldcat-ref_tabname    = 'MARA'.
  l_r_fieldcat-ref_fieldname  = 'MATNR'.
  l_r_fieldcat-col_pos        = 4.

  append l_r_fieldcat to g_t_fieldcat.
  clear l_r_fieldcat.

* Stock (Un Restricted)
  l_r_fieldcat-tabname        = 'G_T_ITAB'.
  l_r_fieldcat-fieldname      = 'LABST'.
  l_r_fieldcat-ref_tabname    = 'MARD'.
  l_r_fieldcat-ref_fieldname  = 'LABST'.
  l_r_fieldcat-col_pos        = 5.

  append l_r_fieldcat to g_t_fieldcat.
  clear l_r_fieldcat.

endform.

*---------------------------------------------------------------------*
*       FORM top_of_page                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form top_of_page.

  write: 'TOP OF PAGE'.

endform.


*---------------------------------------------------------------------*
*       FORM user_command                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  I_F_UCOMM                                                     *
*  -->  I_R_SELFIELD                                                  *
*---------------------------------------------------------------------*
form user_command using i_f_ucomm     like  sy-ucomm
                        i_r_selfield  type  slis_selfield.

  if i_f_ucomm = 'DESCR'.
    perform display_mat_desc.
  endif.

endform.


*---------------------------------------------------------------------*
*       FORM pf_status_set                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  I_T_EXTAB                                                     *
*---------------------------------------------------------------------*
form pf_status_set using i_t_extab type slis_t_extab.

  set pf-status 'S_MATNR'.

endform.

*---------------------------------------------------------------------*
*       FORM display_mat_desc                                         *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form display_mat_desc.

  read table g_t_itab with key sel = 'X'.
  if sy-subrc ne 0.
    message e001(00) with text-002.
  endif.

  clear   : g_t_makt.
  refresh : g_t_makt.

  loop at g_t_itab where sel eq 'X'.
    select matnr maktx spras
    from makt
    appending table g_t_makt
    where
    matnr eq g_t_itab-matnr.
  endloop.

  loop at g_t_makt.
    write: / g_t_makt-matnr, g_t_makt-maktx, g_t_makt-spras.
  endloop.

endform.

*---------------------------------------------------------------------*
*       FORM initial_selection_screen                                 *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form initial_selection_screen.
  s_matnr-sign = 'I'.
  s_matnr-option = 'EQ'.
  s_matnr-low = '000000000000000012'.
  s_matnr-high = ' '.

  append s_matnr.
  clear s_matnr.

  s_matnr-sign = 'I'.
  s_matnr-option = 'NE'.
  s_matnr-low = '000000000000000002'.
  s_matnr-high = ' '.

  append s_matnr.
  clear s_matnr.

  s_matnr-sign = 'I'.
  s_matnr-option = 'EQ'.
  s_matnr-low = '000000000000000015'.
  s_matnr-high ='000000000010000012'.

  append s_matnr.
  clear s_matnr.
endform.

*---------------------------------------------------------------------*
*       FORM validation                                               *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form validation.
  select single * from marc
                where matnr in s_matnr and
                      werks in s_werks.
  if sy-subrc ne 0.
    message e047(m3).
  endif.
endform.

Reward If Helpful.

Regards

--

Sasidhar Reddy Matli.

Read only

Former Member
0 Likes
580

Hi Sankar,

Follow the below code for alv.

Call the functions reuse_

alv_grid_display to view your output in grid format.

Pass your itab as an import parameter.

&----


*& Report ZREPORT2SJ *

*& *

&----


*& *

*& *

&----


REPORT zreport2sj.

TABLES : ekko,ekpo.

TYPE-POOLS : slis.

DATA : total TYPE i.

DATA : BEGIN OF itab2 OCCURS 0,

ekorg LIKE ekko-ekorg,

ebeln LIKE ekko-ebeln,

lifnr LIKE ekko-lifnr,

zterm LIKE ekko-zterm,

matnr LIKE ekpo-matnr,

menge LIKE ekpo-menge,

netpr LIKE ekpo-netpr,

END OF itab2.

DATA : w_report_id LIKE sy-repid.

DATA : w_title TYPE lvc_title VALUE 'PURCHASE ORDER DETAIL REPORT'.

DATA : w_fieldcat TYPE slis_t_fieldcat_alv.

data : w_header type slis_t_listheader.

data : w_layout type slis_layout_alv.

data : w_sort type SLIS_T_SORTINFO_ALV.

data : w_event type slis_t_event.

START-OF-SELECTION.

SELECT-OPTIONS : date foR ekko-aedat.

SELECT ekkoebeln ekkolifnr ekkoekorg ekkozterm ekpomatnr ekpomenge ekpo~netpr

INTO CORRESPONDING FIELDS OF TABLE itab2 FROM ( ekko INNER JOIN ekpo ON ekkoebeln = ekpoebeln )

WHERE ekko~aedat IN date AND

ekko~bstyp EQ 'F' AND

ekko~bsart EQ 'ZWT' AND

ekko~statu EQ '9' .

sort itab2 by ekorg.

w_report_id = sy-repid.

PERFORM fieldcat CHANGING w_fieldcat.

perform build_layout changing w_layout.

perform sort changing w_sort.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = w_report_id

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = w_title

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = w_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = W_SORT[]

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = w_event

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = itab2.

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

&----


*& Form fieldcat

&----


  • text

----


  • <--P_W_fieldcat text

----


FORM fieldcat CHANGING p_w_fieldcat.

PERFORM event USING 'EBELN' 'itab2' 'po num' '' '' ''.

PERFORM event USING 'LIFNR' 'itab2' 'vendor num' '' '' ''.

PERFORM event USING 'EKORG' 'itab2' 'purchase org' '' '' ''.

PERFORM event USING 'ZTERM' 'itab2' 'payment term' '' '' ''.

PERFORM event USING 'MATNR' 'itab2' 'material num' '' '' ''.

PERFORM event USING 'MENGE' 'itab2' 'qty' 'X' 'QUAN' ''.

PERFORM event USING 'NETPR' 'itab2' 'net value' 'X' 'CURR' ''.

ENDFORM. " fieldcat

&----


*& Form build_layout

&----


  • text

----


  • <--P_W_LAYOUT text

----


form build_layout changing p_w_layout.

clear w_layout.

w_layout-zebra = 'X'.

w_layout-colwidth_optimize = 'X'.

endform. " build_layout

&----


*& Form sort

&----


  • text

----


  • <--P_W_sort text

----


form sort changing p_w_sort.

data : ws_sort type slis_sortinfo_alv .

ws_sort-FIELDNAME = 'EKORG'.

ws_sort-SPOS = 1.

ws_SORT-down = 'X'.

ws_SORT-SUBTOT = 'X'.

append ws_sort to w_sort.

endform. " sort

&----


*& Form event_table

&----


  • text

----


  • <--P_W_EVENT text

----


*& Form event

&----


  • text

----


  • -->P_0212 text

  • -->P_0213 text

  • -->P_0214 text

  • -->P_0215 text

  • -->P_0216 text

  • -->P_0217 text

----


form event using value(p_0212)

value(p_0213)

value(p_0214)

value(p_0215)

value(p_0216)

value(p_0217).

DATA: l_line_fieldcat TYPE slis_fieldcat_alv.

CLEAR l_line_fieldcat.

l_line_fieldcat-fieldname = p_0212.

l_line_fieldcat-ref_tabname = p_0213.

l_line_fieldcat-seltext_m = p_0214.

l_line_fieldcat-do_sum = p_0215.

l_line_fieldcat-datatype = p_0216.

l_line_fieldcat-key = p_0217.

APPEND l_line_fieldcat TO w_fieldcat.

endform. " event

Hopethis might be useful.

Regards,

subashini.J

Read only

aris_hidalgo
Contributor
0 Likes
580

Hi,

You can look at ALV examples and use them as reference in your reports by typing

ALV or BCALV in SE38.

Hope it helps...

P.S. Please award points if it helps...