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: 

I want to use top-of-page event in my program

Former Member
0 Kudos

Hi,

I am using slis type pools.Can anyone describe me how to write the code to diaplay the top-of-page

With Regards

Ansuman Parhi

6 REPLIES 6

Former Member
0 Kudos

Former Member
0 Kudos

hi. i am sending the simple alv report where i have used top of page. refer this. reward if helpful.

TABLES: vbrk,

vbrp.

type-pools: slis.

types: begin of gs_vbrk,

vbeln TYPE vbrk-vbeln,

waerk TYPE vbrk-waerk,

fkdat TYPE vbrk-fkdat,

kunag TYPE vbrk-kunag,

end of gs_vbrk.

data: it_vbrk type standard table of gs_vbrk,

wa_vbrk type gs_vbrk.

types: begin of gs_vbrp,

VBELN type vbrp-VBELN, "sales order

MATNR type vbrp-MATNR, "material no

ARKTX type vbrp-ARKTX, "material description

ntgew type vbrp-ntgew, "quantity

gewei type vbrp-gewei, "quantity unit

netwr type vbrp-netwr, "currency

WERKS type vbrp-WERKS, "plant

end of gs_vbrp.

data: it_vbrp type standard table of gs_vbrp,

wa_vbrp type gs_vbrp.

****************************************************

types: begin of gs_final0,

vbeln TYPE vbrk-vbeln,

waerk TYPE vbrk-waerk,

fkdat TYPE vbrk-fkdat,

kunag TYPE vbrk-kunag,

MATNR type vbrp-MATNR, "material no

ARKTX type vbrp-ARKTX, "material description

ntgew type vbrp-ntgew, "quantity

gewei type vbrp-gewei, "quantity unit

netwr type vbrp-netwr, "currency

WERKS type vbrp-WERKS, "plant

end of gs_final0.

data: it_final0 type standard table of gs_final0,

wa_final0 type gs_final0.

*******************************************************

data: fcat type slis_t_fieldcat_alv,

wa_fcat type slis_fieldcat_alv.

data: lyout type slis_layout_alv,

event type slis_t_event,

wa_event type slis_alv_event.

*******************************************************

select-options: s_vbeln for vbrk-vbeln,

s_waerk for vbrk-waerk,

s_fkdat for vbrk-fkdat,

s_kunag for vbrk-kunag.

*****************************************************

select vbeln

waerk

fkdat

kunag from vbrk into table it_vbrk where vbeln in s_vbeln.

select VBELN

MATNR

ARKTX

ntgew

gewei

netwr

WERKS from vbrp into table it_vbrp for all entries in it_vbrk where vbeln eq it_vbrk-vbeln.

loop at it_vbrk into wa_vbrk.

move wa_vbrk-vbeln to wa_final0-vbeln.

move wa_vbrk-waerk to wa_final0-waerk.

move wa_vbrk-fkdat to wa_final0-fkdat.

move wa_vbrk-kunag to wa_final0-kunag.

read table it_vbrp into wa_vbrp with key wa_vbrk-vbeln.

move wa_vbrp-MATNR to wa_final0-MATNR.

move wa_vbrp-ARKTX to wa_final0-ARKTX.

move wa_vbrp-ntgew to wa_final0-ntgew.

move wa_vbrp-gewei to wa_final0-gewei.

move wa_vbrp-netwr to wa_final0-netwr.

move wa_vbrp-WERKS to wa_final0-WERKS.

append wa_final0 to it_final0.

clear wa_final0.

endloop.

define imacro.

wa_fcat-fieldname = &1.

wa_fcat-tabname = &2.

wa_fcat-reptext_ddic = &3.

wa_fcat-col_pos = &4.

append wa_fcat to fcat.

clear wa_fcat.

end-of-definition.

imacro 'VBELN' 'it_final0' 'PO Document' '1'.

imacro 'WAERK' 'it_final0' 'Doc. date' '2'.

imacro 'FKDAT' 'it_final0' 'customer' '3'.

imacro 'KUNAG' 'it_final0' 'user' '4'.

imacro 'MATNR' 'it_final0' 'material no.' '5'.

imacro 'ARKTX' 'it_final0' 'Mat. description' '6'.

imacro 'NTGEW' 'it_final0' 'quantity' '7'.

imacro 'GEWEI' 'it_final0' 'quantity unit' '8'.

imacro 'NETWR' 'it_final0' 'net price' '9'.

imacro 'WERKS' 'it_final0' 'plant' '10'.

****************DEFINE LAYOUT

lyout-zebra = 'X'.

lyout-colwidth_optimize = 'X'.

wa_event-name = 'TOP_OF_PAGE'.

wa_event-form = 'RUD'.

append wa_event to event.

clear wa_event.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = sy-cprog

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER'

  • I_CALLBACK_TOP_OF_PAGE = 'MY NAME'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'I M THAT'

  • I_GRID_SETTINGS =

IS_LAYOUT = lyout

IT_FIELDCAT = fcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = 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

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = it_final0

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

data: list_header type slis_t_listheader,

wa_list_header type slis_listheader.

WA_list_header-typ = 'S'.

wa_list_header-KEY = 'DATE::'.

wa_list_header-info = sy-datum.

APPEND wa_list_header TO LIST_HEADER.

CLEAR WA_LIST_HEADER.

WA_list_header-typ = 'S'.

wa_list_header-KEY = 'USER::'.

wa_list_header-info = sy-UNAME.

APPEND wa_list_header TO LIST_HEADER.

CLEAR WA_LIST_HEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = list_header

I_LOGO = 'ENJOY'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

ENDFORM.

Former Member
0 Kudos

Hi,

we can use dynamic document, which can be implemented through the class CL_DD_DOCUMENT. As dynamic documents use HTML viewer control so instead of triggering the TOP_OF_PAGE event we should trigger event of HTML TOP_OF_PAGE.

First create a subroutine for top of page in HTML format and send that name in I_CALLBACK_HTML_TOP_OF_PAGE parameter of ALV function module. The input parameter for this subroutine will be a variable of class CL_DD_DOCUMENT.

*-----------------------------------------------------------------*
*       FORM html_top_of_page                                     *
*-----------------------------------------------------------------*
FORM html_top_of_page USING top TYPE REF TO cl_dd_document.
  data: l_text(255) type c.
 do 180 times.  l_text+sy-index(1) = '*'.
 enddo.  CALL METHOD top->add_text 
EXPORTING
 text = 'Hello world '
   sap_style = 'heading' .
CALL METHOD top->add_gap 
EXPORTING 
         width = 200.
CALL METHOD top->add_picture 
EXPORTING 
  picture_id = 'ENJOYSAP_LOGO'.

 CALL METHOD top->NEW_LINE( ).
CALL METHOD top->add_text 
EXPORTING  
     text = l_text.ENDFORM.

* Display ALV grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
          i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE'
          i_callback_program          = g_repid
          i_structure_name            = 'SFLIGHT'
     TABLES
          t_outtab                    = gt_outtab.

Hope this would be helpful

Regards

Narin Nandivada

Former Member
0 Kudos

hi buddy,

the top-of-page event gets triggered at the first write statment in the program.

if the report doesnt have any write statement the top-of-page event will not get triggered.

you can define any statement or title in the top-of-page event and when the programs gives an output it will be displayed at the top of the output screen.

if this also doesnt solve your problem then please revert back i will send you a very simple code to use it.

thanks,

Ankit

Former Member
0 Kudos

Hi,

Please Refer this Sample COde For Events Raised In ALV

*&---------------------------------------------------------------------*
*& Report  ZALL_ALV_EVENTS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  z50818_all_alv_events.
tables: vbap.
type-pools: slis.
*-----------------work area--------------
***** WORKAREA FOR FIELD CATALOG TABLE.
data: wa_fldcat type slis_fieldcat_alv.

***** WORKAREA FOR EVENTS TABLE.
data: wa_events type slis_alv_event.

***** WORKAREA FOR LAYOUT TABLE.
data: wa_layout type slis_layout_alv.

***** WORKAREA FOR PRINT SETTINGS.
data: wa_print  type slis_print_alv.


**------------------VARIABLE DECLARATIONS.----------------------**
data: v_cprog type sy-cprog,                 " REPORT ID.
      v_repid like sy-repid,
      v_uname type sy-uname.                 " USER NAME.
**-------------- INTERNAL TABLES DECLARATION.--------------**
***** INTERNAL TABLE TO HOLD THE SELECTED RECORDS
data: begin of it_final occurs 0,
      vbeln type vbap-vbeln,
      posnr type vbap-posnr,
      matnr type vbap-matnr,
      arktx type vbap-arktx,
      end of it_final.
***** INTERNAL TABLE FOR FIELD CATALOG.
data : it_fldcat type slis_t_fieldcat_alv.

***** INTERNAL TABLE FOR EVENTS
data : it_events type slis_t_event.
**** Modify the events table.

  perform sub_modify_events.

wa_events-name = 'END OF lIST EVENT RAISED'.
wa_events-form = 'SUB_FRM_END'.
append wa_events to it_events.

**------------------------SELECTION CRITERIA.------------------------**

selection-screen: begin of block b1 with frame title text-001.
select-options s_vbeln for vbap-vbeln.
selection-screen: end of block b1.

*----------------------------------------------------------------------*
*  I N I T I A L I Z A T I O N                                         *
*----------------------------------------------------------------------*
initialization.

  v_uname = sy-uname.
  v_repid = sy-repid.
  v_cprog = sy-cprog.
**---------------------START-OF-SELECTION.---------------------------**

start-of-selection.

**** Selection of data from the database
perform get_data.
perform alv_list_disp.

**** Modify the field catalog.

  perform sub_modify_fldcat.
**** Build the events.

  perform sub_events.



*&---------------------------------------------------------------------*
*&      Form  get_data
*&---------------------------------------------------------------------*
form get_data.
select vbeln
       posnr
       matnr
       arktx
       from vbap
       into table it_final
       where vbeln in s_vbeln.
endform.                    " get_data
*&---------------------------------------------------------------------*
*&      Form  sub_modify_fldcat
*&---------------------------------------------------------------------*
form sub_modify_fldcat.
loop at it_fldcat into wa_fldcat.
    case wa_fldcat-fieldname.

     when 'VBELN'.
        wa_fldcat-seltext_m = 'Sales Document'.
        wa_fldcat-col_pos = 1.
        wa_fldcat-key = 'X'.

     when 'MATNR'.
        wa_fldcat-seltext_m = 'Material Number'.
        wa_fldcat-col_pos = 2.
        wa_fldcat-key = space.
    when 'POSNR'.
        wa_fldcat-seltext_m = 'Sales Document Item'.
        wa_fldcat-col_pos = 3.
        wa_fldcat-key = space.

  when 'ARKTX'.
        wa_fldcat-seltext_m = 'Short text for sales order item'.
        wa_fldcat-col_pos = 4.
        wa_fldcat-key = space.

endcase.
    modify it_fldcat from wa_fldcat.

  endloop.


  call function 'REUSE_ALV_FIELDCATALOG_MERGE'
   exporting
     i_program_name               = v_repid
     i_internal_tabname           = it_final
*     I_STRUCTURE_NAME             = I_STRUCTURE_NAME
*     I_CLIENT_NEVER_DISPLAY       = 'X'
*     I_INCLNAME                   = I_INCLNAME
*     I_BYPASSING_BUFFER           = I_BYPASSING_BUFFER
*     I_BUFFER_ACTIVE              = I_BUFFER_ACTIVE
    changing
      ct_fieldcat                  = wa_fldcat
*   EXCEPTIONS
*     INCONSISTENT_INTERFACE       = 1
*     PROGRAM_ERROR                = 2
*     OTHERS                       = 3
            .
  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.                    " sub_modify_fldcat

*&---------------------------------------------------------------------*
*&      Form  alv_list_disp
*&---------------------------------------------------------------------*
form alv_list_disp.
sort it_final.
call function 'REUSE_ALV_LIST_DISPLAY'
 exporting
*   I_INTERFACE_CHECK              = ' '
*   I_BYPASSING_BUFFER             = I_BYPASSING_BUFFER
*   I_BUFFER_ACTIVE                = ' '
  i_callback_program             = v_cprog
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   I_STRUCTURE_NAME               = I_STRUCTURE_NAME
*   is_layout                      = wa_layout
   it_fieldcat                    = it_fldcat
*   IT_EXCLUDING                   = IT_EXCLUDING
*   IT_SPECIAL_GROUPS              = IT_SPECIAL_GROUPS
*   IT_SORT                        = IT_SORT
*   IT_FILTER                      = IT_FILTER
*   IS_SEL_HIDE                    = IS_SEL_HIDE
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     = IS_VARIANT
*   it_events                      = it_events
*   IT_EVENT_EXIT                  = IT_EVENT_EXIT
*   IS_PRINT                       = IS_PRINT
*   IS_REPREP_ID                   = IS_REPREP_ID
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   IR_SALV_LIST_ADAPTER           = IR_SALV_LIST_ADAPTER
*   IT_EXCEPT_QINFO                = IT_EXCEPT_QINFO
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        = E_EXIT_CAUSED_BY_CALLER
*   ES_EXIT_CAUSED_BY_USER         = ES_EXIT_CAUSED_BY_USER
  tables
    t_outtab                       = it_final
* 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.                    " alv_list_disp
*&---------------------------------------------------------------------*
*&      Form  sub_events
*&---------------------------------------------------------------------*
form sub_events.

  call function 'REUSE_ALV_EVENTS_GET'
* EXPORTING
*   I_LIST_TYPE           = 1
   importing
     et_events             = it_events
   exceptions
     list_type_wrong       = 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.                    " sub_events
*&---------------------------------------------------------------------*
*&      Form  sub_modify_events
*&---------------------------------------------------------------------*
form sub_modify_events.
read table it_events into wa_events
                       with key name = slis_ev_top_of_page.
  if sy-subrc = 0.
    wa_events-form = 'SUB_FRM_TOP'.
    modify it_events from wa_events index sy-tabix.
  endif.
read table it_events into wa_events
                        with key name = slis_ev_user_command.
  if sy-subrc = 0.
    move 'DISPLAY' to wa_events-form.
    modify it_events from wa_events index sy-tabix.
  endif.
  read table it_events into wa_events
                        with key name = slis_ev_end_of_page .
  if sy-subrc = 0.
   wa_events-form = 'SUB_PAGE_END'.
    modify it_events from wa_events index sy-tabix.
  endif.

endform.                    " sub_modify_events

form sub_frm_end.
  write : 'END OF lIST EVENT RAISED'.
endform.                    "SUB_FRM_END

form sub_frm_top.
  write : 'TOP-OF-PAGE EVENT RAISED'.
endform.                    "SUB_FRM_TOP

form sub_page_end.
  write : 'END-OF-PAGE EVENT RAISED'.
endform.

form display using l_ucomm like sy-ucomm
                            l_selfield type slis_selfield.
  case l_ucomm.
    when 'CREATEPO'.
      write :/12 'Ashok ',
             /10 'Parupalli'.
    when '&IC1'.
      write: 'ASSD'.
  endcase.
endform.                    "display_xyz

form sub_layout .

  wa_layout-zebra = 'X'.
  wa_layout-colwidth_optimize = 'X'.

endform.                    " SUB_LAYOUT

Reward All Helpfull Answers

Regards

Fareedas

Former Member
0 Kudos

Hi,

Here the sample code.

*----


*

    • STRUCTURE DECLARATIONS*

    • INTERNAL TABLE DECLARATIONS*

    • WORKAREA DECLARATIONS*

    • TYPE-POOLS DECLARATION*

*----


*

TYPE-POOLS : slis.

TYPES : BEGIN OF st_ekko,

ebeln TYPE ekko-ebeln, "Purchasing Document Number

bstyp TYPE ekko-bstyp, "Purchasing Document Category

bsart TYPE ekko-bsart, "Purchasing Document Type

aedat TYPE ekko-aedat, "record created on

ernam TYPE ekko-ernam, "Person who Created the Object

check(1),

END OF st_ekko.

TYPES : BEGIN OF st_ekpo,

ebeln TYPE ekko-ebeln,

ebelp TYPE ekpo-ebelp, "Item Number of Purchasing Document

ematn TYPE ekpo-ematn, "Material number

matkl TYPE ekpo-matkl, "Material group

netpr TYPE ekpo-netpr, "Net price in purchasing document

END OF st_ekpo.

TYPES : BEGIN OF st_ebeln,

ebeln TYPE ekpo-ebeln,

END OF st_ebeln.

TYPES : BEGIN OF st_eine,

ebeln TYPE ekko-ebeln,

ekorg TYPE eine-ekorg,

ekgrp TYPE eine-ekgrp,

END OF st_eine.

TYPES : BEGIN OF st_check,

check(1),

END OF st_check.

DATA : it_ekpo TYPE STANDARD TABLE OF st_ekpo,

it_ekko TYPE STANDARD TABLE OF st_ekko,

wa_ekko LIKE LINE OF it_ekko,

it_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat LIKE LINE OF it_fieldcat,

wa_layout TYPE slis_layout_alv,

it_events TYPE slis_t_event,

st_event LIKE LINE OF it_events,

*it_listheadr TYPE slis_t_listheader ,*

*wa_listheadr LIKE LINE OF it_listheadr,*

st_printparams TYPE slis_print_alv,

it_sortinfo TYPE slis_t_sortinfo_alv,

wa_sortinfo LIKE LINE OF it_sortinfo,

it_ekposortinfo TYPE slis_t_sortinfo_alv,

wa_ekposortinfo LIKE LINE OF it_ekposortinfo,

it_filter TYPE slis_t_filter_alv,

it_ebeln TYPE STANDARD TABLE OF st_ebeln,

it_eine TYPE STANDARD TABLE OF st_eine,

wa_eine TYPE st_eine,

it_popup TYPE STANDARD TABLE OF st_eine,

wa_popup TYPE st_eine,

it_check TYPE STANDARD TABLE OF st_check,

wa_check TYPE st_check.

DATA : v_ebeln TYPE ekko-ebeln.

*----


*

    • SELECTION-SCREEN*

*----


*

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE tit.

SELECT-OPTIONS: so_ebeln FOR v_ebeln OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b.

*----


*

    • INITIALIZATION*

*----


*

INITIALIZATION.

tit = text-000.

*----


*

    • AT SELECTION-SCREEN ON*

*----


*

AT SELECTION-SCREEN ON so_ebeln.

PERFORM validate_ebeln.

*----


*

    • START-OF-SELECTION*

*----


*

START-OF-SELECTION.

PERFORM get_ekko_data.

PERFORM get_eine_data.

*----


*

    • END-OF-SELECTION*

*----


*

END-OF-SELECTION.

PERFORM populate_fieldcat1.

PERFORM populate_layout.

PERFORM get_eventlist.

PERFORM get_ekkosortinfo.

PERFORM ekkodisplay_onalv.

*&----


*

*& Form POPULATE_FIELDCAT1

*&----


*

FORM populate_fieldcat1.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_l = text-004.

wa_fieldcat-no_zero = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'BSTYP'.

wa_fieldcat-seltext_l = text-005.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'BSART'.

wa_fieldcat-seltext_l = text-006.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'AEDAT'.

wa_fieldcat-seltext_l = text-007.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'ERNAM'.

wa_fieldcat-seltext_l = text-008.

APPEND wa_fieldcat TO it_fieldcat.

ENDFORM. "POPULATE_FIELDCAT1

*&----


*

*& Form populate_fieldcat2

*&----


*

FORM populate_fieldcat2 .

CLEAR wa_fieldcat.

CLEAR it_fieldcat.

REFRESH it_fieldcat.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_l = text-004.

wa_fieldcat-hotspot = 'X'.

    • wa_fieldcat-no_zero = 'X'.*

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'EBELP'.

wa_fieldcat-seltext_l = text-009.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'EMATN'.

wa_fieldcat-seltext_l = text-010.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'MATKL'.

wa_fieldcat-seltext_l = text-011.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'NETPR'.

wa_fieldcat-seltext_l = text-012.

wa_fieldcat-datatype = 'CURR'. "Obligatory to perform SUM

wa_fieldcat-do_sum = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

ENDFORM. "populate_fieldcat2

*&----


*

*& Form GET_EVENTLIST

*&----


*

FORM get_eventlist.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = it_events[]

EXCEPTIONS

list_type_wrong = 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.

READ TABLE it_events WITH KEY name = slis_ev_pf_status_set INTO st_event.

IF sy-subrc EQ 0.

st_event-form = 'SET_PF_STATUS1'.

APPEND st_event TO it_events.

CLEAR st_event.

ENDIF.

READ TABLE it_events WITH KEY name = slis_ev_end_of_page INTO st_event.

IF sy-subrc EQ 0.

st_event-form = 'END_OF_PAGE'.

APPEND st_event TO it_events.

CLEAR st_event.

ENDIF.

ENDFORM. "GET_EVENTLIST

*&----


*

*& Form ekpodisplay_onalv

*&----


*

FORM ekpodisplay_onalv .

IF it_ekpo[] IS INITIAL.

MESSAGE 'NO DATA FOUND' TYPE 'I'.

ELSE.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_pf_status_set = 'SET_PF_STATUS'

i_callback_user_command = 'AT_USER_COMMAND1'

*i_callback_top_of_page = 'TOP_OF_PAGE'*

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '*

    • I_CALLBACK_HTML_END_OF_LIST = ' '*

    • I_STRUCTURE_NAME = I_STRUCTURE_NAME*

    • I_BACKGROUND_ID = ' '*

    • I_GRID_TITLE = I_GRID_TITLE*

    • I_GRID_SETTINGS = I_GRID_SETTINGS*

is_layout = wa_layout

it_fieldcat = it_fieldcat

    • IT_EXCLUDING = IT_EXCLUDING*

    • IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS*

it_sort = it_ekposortinfo[]

    • IT_FILTER = IT_FILTER*

    • IS_SEL_HIDE = IS_SEL_HIDE*

    • I_DEFAULT = 'X'*

    • I_SAVE = ' '*

    • IS_VARIANT = IS_VARIANT*

    • it_events = it_events*

    • IT_EVENT_EXIT = IT_EVENT_EXIT*

    • IS_PRINT = IS_PRINT*

    • IS_REPREP_ID = IS_REPREP_ID*

    • I_SCREEN_START_COLUMN = 0*

    • I_SCREEN_START_LINE = 0*

    • I_SCREEN_END_COLUMN = 0*

    • I_SCREEN_END_LINE = 0*

    • I_HTML_HEIGHT_TOP = 0*

    • I_HTML_HEIGHT_END = 0*

    • IT_ALV_GRAPHICS = IT_ALV_GRAPHICS*

    • IT_HYPERLINK = IT_HYPERLINK*

    • IT_ADD_FIELDCAT = IT_ADD_FIELDCAT*

    • IT_EXCEPT_QINFO = IT_EXCEPT_QINFO*

    • IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER*

    • IMPORTING*

    • E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER*

    • ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER*

TABLES

t_outtab = it_ekpo

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.

ENDIF.

ENDFORM. "ekpodisplay_onalv

*&----


*

*& Form SET_PF_STATUS1

*&----


*

FORM set_pf_status1 USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'MENU' excluding rt_extab. "Copy from SALV .

ENDFORM. "SET_PF_STATUS1

*&----


*

*& Form SET_PF_STATUS

*&----


*

FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'STANDARD' excluding rt_extab. "Copy from SALV .

ENDFORM. "SET_PF_STATUS

*&----


*

*& Form AT_user_command

*&----


*

FORM at_user_command USING r_ucomm LIKE sy-ucomm

* rs_selfield TYPE slis_selfield.*

CASE r_ucomm.

WHEN '&IC1'.

IF rs_selfield-fieldname EQ 'EBELN'.

READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.

SELECT ebeln ebelp ematn matkl netpr

FROM ekpo

INTO TABLE it_ekpo

WHERE ebeln EQ wa_ekko-ebeln.

PERFORM populate_fieldcat2.

PERFORM populate_layout2.

PERFORM get_ekposortinfo.

PERFORM ekpodisplay_onalv.

ELSE.

MESSAGE i020(z50871msg) WITH text-013.

ENDIF.

WHEN 'SE16'.

CALL TRANSACTION 'SE16'.

WHEN 'SE37'.

CALL TRANSACTION 'SE37'.

WHEN 'DISP'.

PERFORM get_popupdata.

PERFORM get_popupfcat.

PERFORM display_popup.

ENDCASE.

ENDFORM. "AT_user_command

*&----


*

*& Form TOP_OF_PAGE

*&----


*

FORM top_of_page.

REFRESH it_listheadr.

wa_listheadr-typ = 'H'.

wa_listheadr-info = text-001.

APPEND wa_listheadr TO it_listheadr.

CLEAR wa_listheadr.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheadr[]

i_logo = 'ENJOYSAP_LOGO'. "From OAER transaction

ENDFORM. "TOP_OF_PAGE

&----


*& Form build_print_params

&----


FORM build_print_params.

st_printparams-reserve_lines = '3'. "Lines reserved for footer

st_printparams-no_coverpage = 'X'.

ENDFORM. "build_print_params

&----


*& Form end_of_page

&----


FORM end_of_page.

REFRESH it_listheadr.

wa_listheadr-typ = 'H'.

wa_listheadr-info = sy-pagno.

APPEND wa_listheadr TO it_listheadr.

CLEAR wa_listheadr.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheadr[].

ENDFORM. "end_of_page

&----


*& Form GET_EKPOSORTINFO

&----


FORM get_ekposortinfo.

wa_ekposortinfo-up = 'X'.

wa_ekposortinfo-spos = 1.

wa_ekposortinfo-fieldname = 'EBELP'.

wa_ekposortinfo-tabname = 'EKPO'.

APPEND wa_ekposortinfo TO it_ekposortinfo.

CLEAR wa_ekposortinfo.

wa_ekposortinfo-up = 'X'.

wa_ekposortinfo-spos = 2.

wa_ekposortinfo-fieldname = 'EMATN'.

wa_ekposortinfo-tabname = 'EKPO'.

APPEND wa_ekposortinfo TO it_ekposortinfo.

CLEAR wa_ekposortinfo.

ENDFORM. "GET_EKPOSORTINFO

*

&----


*& Form POPULATE_LAYOUT

&----


FORM populate_layout.

wa_layout-colwidth_optimize = 'X'. "column width

wa_layout-zebra = 'X'.

  • wa_layout-no_hline = 'X'.

  • wa_layout-no_vline = 'X'.

  • wa_layout-cell_merge = 'X'.

wa_layout-box_fieldname = 'CHECK'.

wa_layout-box_tabname = 'IT_EKKO'.

wa_layout-window_titlebar = 'PURCHASE ORDER HEADER DETAILS'.

ENDFORM. "POPULATE_LAYOUT

&----


*& Form get_EKKOsortinfo

&----


FORM get_ekkosortinfo.

wa_sortinfo-up = 'X'.

wa_sortinfo-spos = 1.

wa_sortinfo-fieldname = 'EBELN'.

wa_sortinfo-tabname = 'EKKO'.

APPEND wa_sortinfo TO it_sortinfo.

CLEAR wa_sortinfo.

wa_sortinfo-up = 'X'.

wa_sortinfo-spos = 2.

wa_sortinfo-fieldname = 'BSTYP'.

wa_sortinfo-tabname = 'EKKO'.

APPEND wa_sortinfo TO it_sortinfo.

CLEAR wa_sortinfo.

wa_sortinfo-up = 'X'.

wa_sortinfo-spos = 3.

wa_sortinfo-fieldname = 'AEDAT'.

wa_sortinfo-tabname = 'EKKO'.

APPEND wa_sortinfo TO it_sortinfo.

CLEAR wa_sortinfo.

ENDFORM. "get_EKKOsortinfo

&----


*& Form EKKODISPLAY_ONALV

&----


FORM ekkodisplay_onalv.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_pf_status_set = 'SET_PF_STATUS1'

i_callback_user_command = 'AT_USER_COMMAND'

is_layout = wa_layout

it_fieldcat = it_fieldcat

it_sort = it_sortinfo[]

it_filter = it_filter

it_events = it_events[]

TABLES

t_outtab = it_ekko[]

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. "EKKODISPLAY_ONALV

&----


*& Form validate_ebeln

&----


FORM validate_ebeln.

SELECT ebeln

FROM ekpo

INTO TABLE it_ebeln

WHERE ebeln IN so_ebeln.

IF sy-subrc NE 0.

MESSAGE e020(z50871msg) WITH text-014.

ENDIF.

ENDFORM. "validate_ebeln

&----


*& Form populate_layout2

&----


FORM populate_layout2 .

CLEAR wa_layout.

wa_layout-colwidth_optimize = 'X'. "column width

  • wa_layout-zebra = 'X'.

  • wa_layout-no_hline = 'X'.

  • wa_layout-no_vline = 'X'.

  • wa_layout-cell_merge = 'X'.

wa_layout-window_titlebar = 'PURCHASE ORDER DETAILS SECOND SCREEN'.

ENDFORM. " populate_layout2

&----


*& Form GET_POPUPDATA

&----


FORM get_popupdata .

LOOP AT it_ekko INTO wa_ekko WHERE check = 'X'.

READ TABLE it_eine INTO wa_eine WITH KEY ebeln = wa_ekko-ebeln.

IF sy-subrc NE 0.

MESSAGE i020(z50871msg) WITH text-015 wa_ekko-ebeln .

ELSE.

wa_popup-ebeln = wa_eine-ebeln.

wa_popup-ekorg = wa_eine-ekorg.

wa_popup-ekgrp = wa_eine-ekgrp.

APPEND wa_popup TO it_popup.

ENDIF.

ENDLOOP.

ENDFORM. " GET_POPUPDATA

&----


*& Form GET_POPUPFCAT

&----


FORM get_popupfcat .

CLEAR wa_fieldcat.

REFRESH it_fieldcat.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_l = text-004.

wa_fieldcat-hotspot = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'EKORG'.

wa_fieldcat-seltext_l = text-016.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'EKGRP'.

wa_fieldcat-seltext_l = text-017.

APPEND wa_fieldcat TO it_fieldcat.

ENDFORM. " GET_POPUPFCAT

&----


*& Form DISPLAY_POPUP

&----


FORM display_popup .

LOOP AT it_ekko INTO wa_ekko WHERE check EQ 'X'.

wa_check-check = wa_ekko-check.

APPEND wa_check TO it_check.

ENDLOOP.

IF it_check[] IS INITIAL.

MESSAGE i020(z50871msg) WITH text-018.

ENDIF.

IF NOT it_popup[] IS INITIAL.

CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

EXPORTING

i_title = text-003

i_allow_no_selection = 'X'

i_scroll_to_sel_line = 'X'

i_tabname = 'IT_POPUP'

it_fieldcat = it_fieldcat

i_callback_program = sy-repid

TABLES

t_outtab = it_popup

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.

ENDIF.

REFRESH it_check.

REFRESH it_popup.

ENDFORM. " DISPLAY_POPUP

&----


*& Form get_ekko_data

&----


FORM get_ekko_data .

SELECT ebeln bstyp bsart aedat ernam

FROM ekko

INTO CORRESPONDING FIELDS OF TABLE it_ekko

WHERE ebeln IN so_ebeln.

IF sy-subrc NE 0.

MESSAGE e020(z50871msg) WITH text-019.

ENDIF.

ENDFORM. " get_ekko_data

&----


*& Form get_eine_data

&----


FORM get_eine_data .

SELECT ebeln ekorg ekgrp

FROM eine

INTO TABLE it_eine

WHERE ebeln IN so_ebeln.

ENDFORM. " get_eine_data

&----


*& Form at_user_command1

&----


FORM at_user_command1 USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN 'SE16'.

CALL TRANSACTION 'SE16'.

WHEN 'SE37'.

CALL TRANSACTION 'SE37'.

ENDCASE.

ENDFORM. "at_user_command1

Regards

Sandeep Reddy