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
1,086

Hi All,

How to use Interactive reports in ALVs.

Regards,

Srik

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,064

Hi Srik,

Here is the sample code for interactive ALV report.

report znd_alvinteractive

no standard page heading line-size 650

message-id zz_9838.

type-pools: slis.

*type declaration for values from ekko

types: begin of i_ekko,

ebeln like ekko-ebeln,

aedat like ekko-aedat,

bukrs like ekko-bukrs,

bsart like ekko-bsart,

lifnr like ekko-lifnr,

end of i_ekko.

data: it_ekko type standard table of i_ekko initial size 0,

wa_ekko type i_ekko.

*type declaration for values from ekpo

types: begin of i_ekpo,

ebeln like ekpo-ebeln,

ebelp like ekpo-ebelp,

matnr like ekpo-matnr,

menge like ekpo-menge,

meins like ekpo-meins,

netpr like ekpo-netpr,

end of i_ekpo.

types: begin of i_eipa,

ebeln like eipa-ebeln,

ebelp like eipa-ebelp,

werks like eipa-werks,

ekorg like eipa-ekorg,

end of i_eipa.

data: it_ekpo type standard table of i_ekpo initial size 0,

wa_ekpo type i_ekpo .

data: it_eipa type standard table of i_eipa initial size 0,

wa_eipa type i_eipa.

*variable for Report ID

data: v_repid like sy-repid .

*declaration for fieldcatalog

data: i_fieldcat type slis_t_fieldcat_alv,

wa_fieldcat type slis_fieldcat_alv.

data: it_listheader type slis_t_listheader.

  • declaration for events table where user comand or set PF status will

  • be defined

data: v_events type slis_t_event,

wa_event type slis_alv_event.

  • declartion for layout

data: alv_layout type slis_layout_alv.

  • declaration for variant(type of display we want)

data: i_variant type disvariant,

i_variant1 type disvariant,

i_save(1) type c.

*PARAMETERS : p_var TYPE disvariant-variant.

*Title displayed when the alv list is displayed

data: i_title_ekko type lvc_title value 'FIRST LIST DISPLAYED'.

data: i_title_ekpo type lvc_title value 'SECONDRY LIST DISPLAYED'.

data: i_title_eipa type lvc_title value 'THIRD LIST DISPLAYED'.

initialization.

v_repid = sy-repid.

perform build_fieldcatlog.

perform event_call.

perform populate_event.

start-of-selection.

perform data_retrieval.

perform build_listheader using it_listheader.

perform display_alv_report.

*&----


*& Form BUILD_FIELDCATLOG

*&----


  • Fieldcatalog has all the field details from ekko

*----


form build_fieldcatlog.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_m = 'PO NO.'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'AEDAT'.

wa_fieldcat-seltext_m = 'DATE.'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'BUKRS'.

wa_fieldcat-seltext_m = 'COMPANY CODE'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'BUKRS'.

wa_fieldcat-seltext_m = 'DOCMENT TYPE'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'LIFNR'.

wa_fieldcat-no_out = 'X'.

wa_fieldcat-seltext_m = 'VENDOR CODE'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

endform. "BUILD_FIELDCATLOG

*&----


*& Form EVENT_CALL

*&----


  • we get all events - TOP OF PAGE or USER COMMAND in table v_events

*----


form event_call.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = v_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. "EVENT_CALL

*&----


*& Form POPULATE_EVENT

*&----


    • Events populated for TOP OF PAGE & USER COMAND

*----


form populate_event.

read table v_events into wa_event with key name = 'TOP_OF_PAGE'.

if sy-subrc eq 0.

wa_event-form = 'TOP_OF_PAGE'.

modify v_events from wa_event transporting form where name =

wa_event-form.

endif.

read table v_events into wa_event with key name = 'USER_COMMAND'.

if sy-subrc eq 0.

wa_event-form = 'USER_COMMAND'.

modify v_events from wa_event transporting form where name =

wa_event-name.

endif.

endform. "POPULATE_EVENT

*&----


*& Form data_retrieval

*&----


  • retreiving values from the database table ekko

*----


form data_retrieval.

select ebeln aedat bukrs bsart lifnr from ekko into table it_ekko.

endform. "data_retrieval

*&----


*& Form bUild_listheader

*&----


  • text

*----


  • -->I_LISTHEADEtext

*----


form build_listheader using i_listheader type slis_t_listheader.

data hline type slis_listheader.

hline-info = 'this is my first alv pgm'.

hline-typ = 'H'.

endform. "build_listheader

*&----


*& Form display_alv_report

*&----


  • text

*----


form display_alv_report.

v_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

i_grid_title = i_title_ekko

  • I_GRID_SETTINGS =

  • IS_LAYOUT = ALV_LAYOUT

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • i_default = 'ZLAY1'

i_save = 'A'

  • is_variant = i_variant

it_events = v_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. "display_alv_report

*&----


*& Form TOP_OF_PAGE

*&----


  • text

*----


form top_of_page.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = it_listheader

  • i_logo =

  • I_END_OF_LIST_GRID =

.

endform. "TOP_OF_PAGE

*&----


*& Form USER_COMMAND

*&----


  • text

*----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

*----


form user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

case r_ucomm.

when '&IC1'.

read table it_ekko into wa_ekko index rs_selfield-tabindex.

perform build_fieldcatlog_ekpo.

perform event_call_ekpo.

perform populate_event_ekpo.

perform data_retrieval_ekpo.

perform build_listheader_ekpo using it_listheader.

perform display_alv_ekpo.

when '&IC2'.

read table it_ekpo into wa_ekpo index rs_selfield-tabindex.

perform build_fieldcatlog_eipa.

perform event_call_eipa.

perform populate_event_eipa.

perform data_retrieval_eipa.

perform build_listheader_eipa using it_listheader.

perform display_alv_eipa.

endcase.

endform. "user_command

*&----


*& Form BUILD_FIELDCATLOG_EKPO

*&----


  • text

*----


form build_fieldcatlog_ekpo.

wa_fieldcat-tabname = 'IT_EKPO'.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_m = 'PO NO.'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKPO'.

wa_fieldcat-fieldname = 'EBELP'.

wa_fieldcat-seltext_m = 'LINE NO'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'I_EKPO'.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-seltext_m = 'MATERIAL NO.'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'I_EKPO'.

wa_fieldcat-fieldname = 'MENGE'.

wa_fieldcat-seltext_m = 'QUANTITY'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'I_EKPO'.

wa_fieldcat-fieldname = 'MEINS'.

wa_fieldcat-seltext_m = 'UOM'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'I_EKPO'.

wa_fieldcat-fieldname = 'NETPR'.

wa_fieldcat-seltext_m = 'PRICE'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

endform. "BUILD_FIELDCATLOG_EKPO

*&----


*& Form event_call_ekpo

*&----


  • we get all events - TOP OF PAGE or USER COMMAND in table v_events

*----


form event_call_ekpo.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = v_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. "event_call_ekpo

*&----


*& Form POPULATE_EVENT

*&----


  • Events populated for TOP OF PAGE & USER COMAND

*----


form populate_event_ekpo.

read table v_events into wa_event with key name = 'TOP_OF_PAGE'.

if sy-subrc eq 0.

wa_event-form = 'TOP_OF_PAGE'.

modify v_events from wa_event transporting form where name =

wa_event-form.

endif.

if sy-subrc eq 0.

read table v_events into wa_event with key name = 'USER_COMMAND'.

wa_event-form = 'USER_COMMAND'.

modify v_events from wa_event transporting form where name =

wa_event-name.

endif.

endform. "POPULATE_EVENT

*&----


*& Form TOP_OF_PAGE

*&----


  • text

*----


form f_top_of_page.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = it_listheader

  • i_logo =

  • I_END_OF_LIST_GRID =

.

endform. "TOP_OF_PAGE

*&----


*& Form USER_COMMAND

*&----


  • text

*----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

*----


*retreiving values from the database table ekko

form data_retrieval_ekpo.

select ebeln ebelp matnr menge meins netpr from ekpo into table it_ekpo.

endform. "DATA_RETRIEVAL_EKPO

&----


*& Form BUILD_LISTHEADER_EKPO

&----


  • text

----


  • -->I_LISTHEADER text

----


form build_listheader_ekpo using i_listheader type slis_t_listheader.

data: hline1 type slis_listheader.

hline1-typ = 'H'.

hline1-info = 'CHECKING PGM'.

endform. "BUILD_LISTHEADER_EKPO

&----


*& Form DISPLAY_ALV_EKPO

&----


  • text

----


form display_alv_ekpo.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = i_title_ekpo

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

i_save = 'A'

  • IS_VARIANT =

it_events = v_events

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.

endform. "DISPLAY_ALV_EKPO

"DISPLAY_ALV_EKPO

&----


*& Form BUILD_FIELDCATLOG_EIPA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_fieldcatlog_eipa .

wa_fieldcat-tabname = 'IT_Eipa'.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_m = 'PO NO.'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_Eipa'.

wa_fieldcat-fieldname = 'EBELP'.

wa_fieldcat-seltext_m = 'LINE NO'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_Eipa'.

wa_fieldcat-fieldname = 'werks'.

wa_fieldcat-seltext_m = 'plant'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_Eipa'.

wa_fieldcat-fieldname = 'ekorg'.

wa_fieldcat-seltext_m = 'sales org'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

endform. " BUILD_FIELDCATLOG_EIPA

&----


  • & Form EVENT_CALL_EIPA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form event_call_eipa .

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = v_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. " EVENT_CALL_EIPA

&----


*& Form POPULATE_EVENT_EIPA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form populate_event_eipa .

read table v_events into wa_event with key name = 'TOP_OF_PAGE'.

if sy-subrc eq 0.

wa_event-form = 'TOP_OF_PAGE'.

modify v_events from wa_event transporting form where name =

wa_event-form.

endif.

endform. " POPULATE_EVENT_EIPA

&----


*& Form DATA_RETRIEVAL_EIPA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form data_retrieval_eipa .

select ebeln ebelp werks ekorg from eipa into table it_eipa.

endform. " DATA_RETRIEVAL_EIPA

&----


*& Form BUILD_LISTHEADER_EIPA

&----


  • text

----


  • -->P_IT_LISTHEADER text

----


form build_listheader_eipa using p_it_listheader.

data: hline1 type slis_listheader.

hline1-typ = 'H'.

hline1-info = 'CHECKING PGM'.

endform. " BUILD_LISTHEADER_EIPA

&----


*& Form DISPLAY_ALV_EIPA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_alv_eipa .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = i_title_eipa

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

i_save = 'A'

  • IS_VARIANT =

it_events = v_events

tables

t_outtab = it_eipa

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.

Regards,

Charumathi.B

Hi All,

How to use Interactive reports in ALVs.

Regards,

Srik

8 REPLIES 8
Read only

dhruv_shah3
Active Contributor
0 Likes
1,064

Hi,

The Name itself suggest that it will have some interaction with the Users.

When there are some requirements that clicking one one line item other data should be displayed then we should use the Interactive Report.

sy-lsind : contains the level of report (from 0 to 21)

Interactive Report Events:

AT LINE-SELECTION : This Event triggers when we double click a line on the list, when the event is triggered a new sublist is going to be generated. Under this event what ever the statements that are been return will be displayed on newly generated sublist.

AT PFn: For predefined function keys...

AT USER-COMMAND : It provides user functions keys.

TOP-OF-PAGE DURING LINE-SELECTION :top of page event for secondary list.

Logical Database ReportsEdit section

Logical database is another tool for ABAP reports. Using LDB we can provide extra features for ABAP reports.

HTH,

Regards,

Dhruv Shah

Read only

Former Member
0 Likes
1,065

Hi Srik,

Here is the sample code for interactive ALV report.

report znd_alvinteractive

no standard page heading line-size 650

message-id zz_9838.

type-pools: slis.

*type declaration for values from ekko

types: begin of i_ekko,

ebeln like ekko-ebeln,

aedat like ekko-aedat,

bukrs like ekko-bukrs,

bsart like ekko-bsart,

lifnr like ekko-lifnr,

end of i_ekko.

data: it_ekko type standard table of i_ekko initial size 0,

wa_ekko type i_ekko.

*type declaration for values from ekpo

types: begin of i_ekpo,

ebeln like ekpo-ebeln,

ebelp like ekpo-ebelp,

matnr like ekpo-matnr,

menge like ekpo-menge,

meins like ekpo-meins,

netpr like ekpo-netpr,

end of i_ekpo.

types: begin of i_eipa,

ebeln like eipa-ebeln,

ebelp like eipa-ebelp,

werks like eipa-werks,

ekorg like eipa-ekorg,

end of i_eipa.

data: it_ekpo type standard table of i_ekpo initial size 0,

wa_ekpo type i_ekpo .

data: it_eipa type standard table of i_eipa initial size 0,

wa_eipa type i_eipa.

*variable for Report ID

data: v_repid like sy-repid .

*declaration for fieldcatalog

data: i_fieldcat type slis_t_fieldcat_alv,

wa_fieldcat type slis_fieldcat_alv.

data: it_listheader type slis_t_listheader.

  • declaration for events table where user comand or set PF status will

  • be defined

data: v_events type slis_t_event,

wa_event type slis_alv_event.

  • declartion for layout

data: alv_layout type slis_layout_alv.

  • declaration for variant(type of display we want)

data: i_variant type disvariant,

i_variant1 type disvariant,

i_save(1) type c.

*PARAMETERS : p_var TYPE disvariant-variant.

*Title displayed when the alv list is displayed

data: i_title_ekko type lvc_title value 'FIRST LIST DISPLAYED'.

data: i_title_ekpo type lvc_title value 'SECONDRY LIST DISPLAYED'.

data: i_title_eipa type lvc_title value 'THIRD LIST DISPLAYED'.

initialization.

v_repid = sy-repid.

perform build_fieldcatlog.

perform event_call.

perform populate_event.

start-of-selection.

perform data_retrieval.

perform build_listheader using it_listheader.

perform display_alv_report.

*&----


*& Form BUILD_FIELDCATLOG

*&----


  • Fieldcatalog has all the field details from ekko

*----


form build_fieldcatlog.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_m = 'PO NO.'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'AEDAT'.

wa_fieldcat-seltext_m = 'DATE.'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'BUKRS'.

wa_fieldcat-seltext_m = 'COMPANY CODE'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'BUKRS'.

wa_fieldcat-seltext_m = 'DOCMENT TYPE'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'LIFNR'.

wa_fieldcat-no_out = 'X'.

wa_fieldcat-seltext_m = 'VENDOR CODE'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

endform. "BUILD_FIELDCATLOG

*&----


*& Form EVENT_CALL

*&----


  • we get all events - TOP OF PAGE or USER COMMAND in table v_events

*----


form event_call.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = v_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. "EVENT_CALL

*&----


*& Form POPULATE_EVENT

*&----


    • Events populated for TOP OF PAGE & USER COMAND

*----


form populate_event.

read table v_events into wa_event with key name = 'TOP_OF_PAGE'.

if sy-subrc eq 0.

wa_event-form = 'TOP_OF_PAGE'.

modify v_events from wa_event transporting form where name =

wa_event-form.

endif.

read table v_events into wa_event with key name = 'USER_COMMAND'.

if sy-subrc eq 0.

wa_event-form = 'USER_COMMAND'.

modify v_events from wa_event transporting form where name =

wa_event-name.

endif.

endform. "POPULATE_EVENT

*&----


*& Form data_retrieval

*&----


  • retreiving values from the database table ekko

*----


form data_retrieval.

select ebeln aedat bukrs bsart lifnr from ekko into table it_ekko.

endform. "data_retrieval

*&----


*& Form bUild_listheader

*&----


  • text

*----


  • -->I_LISTHEADEtext

*----


form build_listheader using i_listheader type slis_t_listheader.

data hline type slis_listheader.

hline-info = 'this is my first alv pgm'.

hline-typ = 'H'.

endform. "build_listheader

*&----


*& Form display_alv_report

*&----


  • text

*----


form display_alv_report.

v_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

i_grid_title = i_title_ekko

  • I_GRID_SETTINGS =

  • IS_LAYOUT = ALV_LAYOUT

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • i_default = 'ZLAY1'

i_save = 'A'

  • is_variant = i_variant

it_events = v_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. "display_alv_report

*&----


*& Form TOP_OF_PAGE

*&----


  • text

*----


form top_of_page.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = it_listheader

  • i_logo =

  • I_END_OF_LIST_GRID =

.

endform. "TOP_OF_PAGE

*&----


*& Form USER_COMMAND

*&----


  • text

*----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

*----


form user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

case r_ucomm.

when '&IC1'.

read table it_ekko into wa_ekko index rs_selfield-tabindex.

perform build_fieldcatlog_ekpo.

perform event_call_ekpo.

perform populate_event_ekpo.

perform data_retrieval_ekpo.

perform build_listheader_ekpo using it_listheader.

perform display_alv_ekpo.

when '&IC2'.

read table it_ekpo into wa_ekpo index rs_selfield-tabindex.

perform build_fieldcatlog_eipa.

perform event_call_eipa.

perform populate_event_eipa.

perform data_retrieval_eipa.

perform build_listheader_eipa using it_listheader.

perform display_alv_eipa.

endcase.

endform. "user_command

*&----


*& Form BUILD_FIELDCATLOG_EKPO

*&----


  • text

*----


form build_fieldcatlog_ekpo.

wa_fieldcat-tabname = 'IT_EKPO'.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_m = 'PO NO.'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKPO'.

wa_fieldcat-fieldname = 'EBELP'.

wa_fieldcat-seltext_m = 'LINE NO'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'I_EKPO'.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-seltext_m = 'MATERIAL NO.'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'I_EKPO'.

wa_fieldcat-fieldname = 'MENGE'.

wa_fieldcat-seltext_m = 'QUANTITY'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'I_EKPO'.

wa_fieldcat-fieldname = 'MEINS'.

wa_fieldcat-seltext_m = 'UOM'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'I_EKPO'.

wa_fieldcat-fieldname = 'NETPR'.

wa_fieldcat-seltext_m = 'PRICE'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

endform. "BUILD_FIELDCATLOG_EKPO

*&----


*& Form event_call_ekpo

*&----


  • we get all events - TOP OF PAGE or USER COMMAND in table v_events

*----


form event_call_ekpo.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = v_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. "event_call_ekpo

*&----


*& Form POPULATE_EVENT

*&----


  • Events populated for TOP OF PAGE & USER COMAND

*----


form populate_event_ekpo.

read table v_events into wa_event with key name = 'TOP_OF_PAGE'.

if sy-subrc eq 0.

wa_event-form = 'TOP_OF_PAGE'.

modify v_events from wa_event transporting form where name =

wa_event-form.

endif.

if sy-subrc eq 0.

read table v_events into wa_event with key name = 'USER_COMMAND'.

wa_event-form = 'USER_COMMAND'.

modify v_events from wa_event transporting form where name =

wa_event-name.

endif.

endform. "POPULATE_EVENT

*&----


*& Form TOP_OF_PAGE

*&----


  • text

*----


form f_top_of_page.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = it_listheader

  • i_logo =

  • I_END_OF_LIST_GRID =

.

endform. "TOP_OF_PAGE

*&----


*& Form USER_COMMAND

*&----


  • text

*----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

*----


*retreiving values from the database table ekko

form data_retrieval_ekpo.

select ebeln ebelp matnr menge meins netpr from ekpo into table it_ekpo.

endform. "DATA_RETRIEVAL_EKPO

&----


*& Form BUILD_LISTHEADER_EKPO

&----


  • text

----


  • -->I_LISTHEADER text

----


form build_listheader_ekpo using i_listheader type slis_t_listheader.

data: hline1 type slis_listheader.

hline1-typ = 'H'.

hline1-info = 'CHECKING PGM'.

endform. "BUILD_LISTHEADER_EKPO

&----


*& Form DISPLAY_ALV_EKPO

&----


  • text

----


form display_alv_ekpo.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = i_title_ekpo

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

i_save = 'A'

  • IS_VARIANT =

it_events = v_events

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.

endform. "DISPLAY_ALV_EKPO

"DISPLAY_ALV_EKPO

&----


*& Form BUILD_FIELDCATLOG_EIPA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_fieldcatlog_eipa .

wa_fieldcat-tabname = 'IT_Eipa'.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_m = 'PO NO.'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_Eipa'.

wa_fieldcat-fieldname = 'EBELP'.

wa_fieldcat-seltext_m = 'LINE NO'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_Eipa'.

wa_fieldcat-fieldname = 'werks'.

wa_fieldcat-seltext_m = 'plant'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_Eipa'.

wa_fieldcat-fieldname = 'ekorg'.

wa_fieldcat-seltext_m = 'sales org'.

append wa_fieldcat to i_fieldcat.

clear wa_fieldcat.

endform. " BUILD_FIELDCATLOG_EIPA

&----


  • & Form EVENT_CALL_EIPA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form event_call_eipa .

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = v_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. " EVENT_CALL_EIPA

&----


*& Form POPULATE_EVENT_EIPA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form populate_event_eipa .

read table v_events into wa_event with key name = 'TOP_OF_PAGE'.

if sy-subrc eq 0.

wa_event-form = 'TOP_OF_PAGE'.

modify v_events from wa_event transporting form where name =

wa_event-form.

endif.

endform. " POPULATE_EVENT_EIPA

&----


*& Form DATA_RETRIEVAL_EIPA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form data_retrieval_eipa .

select ebeln ebelp werks ekorg from eipa into table it_eipa.

endform. " DATA_RETRIEVAL_EIPA

&----


*& Form BUILD_LISTHEADER_EIPA

&----


  • text

----


  • -->P_IT_LISTHEADER text

----


form build_listheader_eipa using p_it_listheader.

data: hline1 type slis_listheader.

hline1-typ = 'H'.

hline1-info = 'CHECKING PGM'.

endform. " BUILD_LISTHEADER_EIPA

&----


*& Form DISPLAY_ALV_EIPA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_alv_eipa .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = i_title_eipa

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

i_save = 'A'

  • IS_VARIANT =

it_events = v_events

tables

t_outtab = it_eipa

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.

Regards,

Charumathi.B

Read only

Former Member
0 Likes
1,064

Hi

Check out the below program in the link

http://www.sap-img.com/abap/an-interactive-alv-report.htm

Read only

Former Member
0 Likes
1,064

HI,

Please refer to the link below:

http://www.sapdev.co.uk/reporting/alv/alvgrid_enhanced.htm

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,064

sample program

&----


*& Report ZCHECKALV_EXAMPLE *

*& *

&----


*& *

*& *

&----


REPORT zcheckalv_example

NO STANDARD PAGE HEADING.

Tables

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

TABLES sflight.

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

Includes

INCLUDE <icon>.

INCLUDE <symbol>.

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

Type-Pools

TYPE-POOLS: slis.

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

Constants

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

CONSTANTS: c_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'

.

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

Intenal Table for ALV

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

DATA: i_fieldcat TYPE slis_t_fieldcat_alv,

i_layout TYPE slis_layout_alv,

i_sp_group TYPE slis_t_sp_group_alv,

i_events TYPE slis_t_event,

i_print TYPE slis_print_alv,

i_sort TYPE slis_t_sortinfo_alv.

DATA: i_list_top_of_page TYPE slis_t_listheader.

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

*Internal Table for data to be displayed

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

DATA: BEGIN OF i_sflight OCCURS 0.

INCLUDE STRUCTURE sflight.

DATA: box,

lights.

DATA: END OF i_sflight.

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

Variable

DATA: w_repid LIKE sy-repid,

w_boxnam TYPE slis_fieldname VALUE 'BOX',

w_f2code LIKE sy-ucomm VALUE '&ETA',

w_lignam TYPE slis_fieldname VALUE 'LIGHTS',

w_save(1) TYPE c,

w_default(1) TYPE c,

w_exit(1) TYPE c,

i_variant LIKE disvariant,

i_variant1 LIKE disvariant.

Selection Screen

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

SELECT-OPTIONS s_carrid FOR sflight-carrid.

SELECT-OPTIONS s_connid FOR sflight-connid.

SELECT-OPTIONS s_fldate FOR sflight-fldate.

*SELECTION-SCREEN SKIP 1.

PARAMETERS: p_maxrow TYPE i DEFAULT 30."to limit the selection

SELECTION-SCREEN SKIP 1.

Variant for ALV display

SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE text-000.

PARAMETERS: p_varnt LIKE disvariant-variant.

SELECTION-SCREEN END OF BLOCK 0.

Layout of the report display

SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.

PARAMETERS: p_zebra AS CHECKBOX DEFAULT ' ', "Striped pattern

p_nocolh AS CHECKBOX DEFAULT ' ', "No column heading

p_novlin AS CHECKBOX DEFAULT ' ', "No vertical lines

p_colopt AS CHECKBOX DEFAULT ' ', "Optimizes col. wd

p_keyhot AS CHECKBOX DEFAULT ' ', "Key fields hot

p_noinpt AS CHECKBOX DEFAULT ' '. "No field for input

SELECTION-SCREEN END OF BLOCK a.

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.

PARAMETERS: p_lights AS CHECKBOX DEFAULT 'X',

p_lightc AS CHECKBOX DEFAULT 'X'.

SELECTION-SCREEN END OF BLOCK b.

SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-003.

PARAMETERS: p_totonl AS CHECKBOX DEFAULT ' ',

p_totext(60),

p_sttext(60).

SELECTION-SCREEN END OF BLOCK c.

SELECTION-SCREEN BEGIN OF BLOCK d WITH FRAME TITLE text-004.

PARAMETERS: p_chkbox AS CHECKBOX DEFAULT 'X',

p_detpop AS CHECKBOX DEFAULT 'X',

p_groupb AS CHECKBOX DEFAULT ' ',

p_groups AS CHECKBOX DEFAULT ' '.

SELECTION-SCREEN END OF BLOCK d.

SELECTION-SCREEN BEGIN OF BLOCK e WITH FRAME TITLE text-005.

PARAMETERS: p_print AS CHECKBOX DEFAULT ' ',

p_nosinf AS CHECKBOX DEFAULT ' ',

p_nocove AS CHECKBOX DEFAULT ' ',

p_nonewp AS CHECKBOX DEFAULT ' ',

p_nolinf AS CHECKBOX DEFAULT ' ',

p_reserv TYPE i.

SELECTION-SCREEN END OF BLOCK e.

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

AT SELECTION-SCREEN.

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

Process on value request (list of possible variants)

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varnt.

PERFORM f4_for_variant.

PAI

AT SELECTION-SCREEN.

PERFORM pai_of_selection_screen.

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

*INITIALIZATION.

INITIALIZATION.

w_repid = sy-repid.

Set Options: save variant userspecific or general

'A or 'U' are for user-specific variants list

'X' or 'space' for general

w_save = 'A'.

PERFORM variant_init.

Get default variant

i_variant1 = i_variant.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

i_save = w_save

CHANGING

cs_variant = i_variant1

EXCEPTIONS

not_found = 2.

IF sy-subrc = 0.

p_varnt = i_variant1-variant.

ENDIF.

Getting Events

PERFORM eventtab_build USING i_events.

Even Top of Page

PERFORM comment_build USING i_list_top_of_page.

Creating Special Group

PERFORM sp_group_build USING i_sp_group.

Mentioning Sort Details

PERFORM t_sort_build USING i_sort.

Filling Fieldcatalog

PERFORM fieldcat_init USING i_fieldcat.

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

*START-OF-SELECTION

START-OF-SELECTION.

PERFORM selection.

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

*END-OF-SELECTION

END-OF-SELECTION.

Creating Layout for Report

PERFORM layout_build USING i_layout. "wg. Parameters

Mentioning Print Parameters

PERFORM print_build USING i_print. "wg. Parameters

Display Report

PERFORM disply_report.

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

-


FORM F4_FOR_VARIANT *

-


FORM f4_for_variant.

*

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = i_variant

i_save = w_save

it_default_fieldcat =

IMPORTING

e_exit = w_exit

es_variant = i_variant1

EXCEPTIONS

not_found = 2.

IF sy-subrc = 2.

MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

IF w_exit = space.

p_varnt = i_variant1-variant.

ENDIF.

ENDIF.

ENDFORM. "f4_for_variant

&----


*& Form PAI_OF_SELECTION_SCREEN

&----


to check whether right variant is entered on the selection scr

-


FORM pai_of_selection_screen.

*

IF NOT p_varnt IS INITIAL.

MOVE i_variant TO i_variant1.

MOVE p_varnt TO i_variant1-variant.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

i_save = w_save

CHANGING

cs_variant = i_variant1.

i_variant = i_variant1.

ELSE.

PERFORM variant_init.

ENDIF.

ENDFORM. " PAI_OF_SELECTION_SCREEN

&----


*& Form VARIANT_INIT

-


FORM variant_init.

CLEAR i_variant.

i_variant-report = w_repid.

ENDFORM. " VARIANT_INIT

-


FORM EVENTTAB_BUILD *

-


--> l_EVENTS *

-


FORM eventtab_build USING l_events TYPE slis_t_event.

DATA: ls_event TYPE slis_alv_event.

*

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = l_events.

READ TABLE l_events WITH KEY name = slis_ev_top_of_page INTO ls_event.

IF sy-subrc = 0.

MOVE c_formname_top_of_page TO ls_event-form.

APPEND ls_event TO l_events.

ENDIF.

ENDFORM. "eventtab_build

-


FORM TOP_OF_PAGE *

-


........ *

-


FORM top_of_page.

*

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

i_logo = 'ENJOYSAP_LOGO'

it_list_commentary = i_list_top_of_page.

ENDFORM. "top_of_page

-


FORM COMMENT_BUILD *

-


--> L_TOP_OF_PAGE *

-


FORM comment_build USING l_top_of_page TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader.

***Header

CLEAR ls_line.

ls_line-typ = 'H'.

LS_LINE-KEY: not used for this type

ls_line-info = 'Heading list'.

APPEND ls_line TO l_top_of_page.

***Selection

CLEAR ls_line.

ls_line-typ = 'S'.

ls_line-key = 'Key 1'.

ls_line-info = 'Information'.

APPEND ls_line TO l_top_of_page.

ls_line-key = 'Key 2'.

APPEND ls_line TO l_top_of_page.

***Action

CLEAR ls_line.

ls_line-typ = 'A'.

LS_LINE-KEY: not used for this type

ls_line-info = 'Status list'.

APPEND ls_line TO l_top_of_page.

ENDFORM. "comment_build

-


FORM SP_GROUP_BUILD *

-


--> L_SP_GROUP *

-


FORM sp_group_build USING l_sp_group TYPE slis_t_sp_group_alv.

DATA: ls_sp_group TYPE slis_sp_group_alv.

*Fields are assigned to the special group

CLEAR ls_sp_group.

ls_sp_group-sp_group = 'A'.

ls_sp_group-text = 'Reservation status'.

APPEND ls_sp_group TO l_sp_group.

CLEAR ls_sp_group.

ls_sp_group-sp_group = 'B'.

ls_sp_group-text = 'Flight charges'.

APPEND ls_sp_group TO l_sp_group.

ENDFORM. "sp_group_build

-


FORM T_SORT_BUILD *

-


FORM t_sort_build USING l_sort TYPE slis_t_sortinfo_alv.

DATA: ls_sort TYPE slis_sortinfo_alv.

ls_sort-fieldname = 'CARRID'.

ls_sort-spos = 1.

ls_sort-up = 'X'.

ls_sort-subtot = 'X'.

APPEND ls_sort TO l_sort.

ENDFORM. "t_sort_build

-


FORM FIELDCAT_INIT *

-


--> L_FIELDCAT *

-


FORM fieldcat_init USING l_fieldcat TYPE slis_t_fieldcat_alv.

DATA: ls_fieldcat TYPE slis_fieldcat_alv.

*

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'SEATSOCC'.

*The field is not displayed in the initial output, can be interactively

chosen for display

ls_fieldcat-no_out = 'X'.

*This field is assigned to a special group with tech. key 'A' and can be

*displayed using the special group buttons

ls_fieldcat-sp_group = 'A'.

*The field cannot be summed irrespective of its data type

ls_fieldcat-no_sum = 'X'.

APPEND ls_fieldcat TO l_fieldcat.

*

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'SEATSMAX'.

ls_fieldcat-no_out = 'X'.

ls_fieldcat-sp_group = 'A'.

APPEND ls_fieldcat TO l_fieldcat.

*

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'PRICE'.

ls_fieldcat-no_out = 'X'.

ls_fieldcat-sp_group = 'B'.

APPEND ls_fieldcat TO l_fieldcat.

*

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'CARRID'.

ls_fieldcat-outputlen = 7.

APPEND ls_fieldcat TO l_fieldcat.

ENDFORM. "fieldcat_init

-


FORM SELECTION *

-


FORM selection.

SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE i_sflight

UP TO p_maxrow ROWS WHERE carrid IN s_carrid

AND connid IN s_connid AND fldate IN s_fldate.

PERFORM data_add TABLES i_sflight.

ENDFORM. "selection

-


FORM DATA_ADD *

-


--> L_SFLIGHT

-


FORM data_add TABLES l_sflight STRUCTURE i_sflight.

LOOP AT l_sflight.

IF sy-tabix > 10.

l_sflight-box = 'X'.

l_sflight-lights = '3'.

ELSE.

IF sy-tabix = 1.

l_sflight-lights = '2'.

ELSE.

l_sflight-lights = '1'.

ENDIF.

ENDIF.

MODIFY l_sflight.

ENDLOOP.

ENDFORM. "data_add

-


FORM LAYOUT_BUILD *

-


<-> LS_LAYOUT *

-


FORM layout_build USING ls_layout TYPE slis_layout_alv.

ls_layout-f2code = w_f2code.

ls_layout-zebra = p_zebra.

ls_layout-colwidth_optimize = p_colopt.

IF p_chkbox = 'X'.

*Fieldname for check box on the report output

ls_layout-box_fieldname = w_boxnam.

ELSE.

ls_layout-box_fieldname = space.

ENDIF.

ls_layout-no_input = p_noinpt.

ls_layout-no_vline = p_novlin.

ls_layout-no_colhead = p_nocolh.

IF p_lights = 'X' OR p_lightc = 'X'.

**Fieldname for lights on the report output

ls_layout-lights_fieldname = w_lignam.

ELSE.

CLEAR ls_layout-lights_fieldname.

ENDIF.

ls_layout-lights_condense = p_lightc.

ls_layout-totals_text = p_totext.

ls_layout-subtotals_text = p_sttext.

ls_layout-totals_only = p_totonl.

ls_layout-key_hotspot = p_keyhot.

ls_layout-detail_popup = p_detpop.

ls_layout-group_change_edit = p_groups.

E05_LS_LAYOUT-GROUP_BUTTONS = P_GROUPB.

ls_layout-group_buttons = 'X'.

ENDFORM. "layout_build

-


FORM PRINT_BUILD *

-


........ *

-


FORM print_build USING l_print TYPE slis_print_alv.

*

l_print-print = p_print.

l_print-no_print_selinfos = p_nosinf.

l_print-no_coverpage = p_nocove.

l_print-no_new_page = p_nonewp.

l_print-no_print_listinfos = p_nolinf.

l_print-reserve_lines = p_reserv.

l_print-print = p_print.

ENDFORM. "print_build

&----


*& Form disply_report

&----


text

-


--> p1 text

<-- p2 text

-


FORM disply_report .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = w_repid

i_internal_tabname = 'I_SFLIGHT'

i_structure_name = 'SFLIGHT'

i_client_never_display = 'X'

i_inclname = w_repid

CHANGING

ct_fieldcat = i_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc 0.

MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Call ABAP/4 List Viewer

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_INTERFACE_CHECK = ' '

i_callback_program = w_repid

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 = 'SFLIGHT'

i_background_id = 'ALV_BACKGROUND'

I_GRID_TITLE =

I_GRID_SETTINGS =

is_layout = i_layout

it_fieldcat = i_fieldcat[]

IT_EXCLUDING =

it_special_groups = i_sp_group[]

it_sort = i_sort[]

IT_FILTER =

IS_SEL_HIDE =

I_DEFAULT = 'X'

i_save = w_save

is_variant = i_variant

it_events = i_events[]

IT_EVENT_EXIT =

is_print = i_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 = i_sflight

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.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = w_repid

i_structure_name = 'SFLIGHT'

is_layout = i_layout

it_fieldcat = i_fieldcat[]

IT_EXCLUDING =

it_special_groups = i_sp_group[]

it_sort = i_sort[]

IT_FILTER =

IS_SEL_HIDE =

i_default = W_DEFAULT

i_save = w_save

is_variant = i_variant

it_events = i_events[]

IT_EVENT_EXIT =

is_print = i_print

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 =

TABLES

t_outtab = i_sflight.

ENDFORM. " disply_report

Read only

Former Member
0 Likes
1,064

Hai Srik

This program displays the Purchase Order header details on the basic list and on double-clicking any of the record on the basic list, the item-level information is displayed on the secondary list.

REPORT ZPURCHASE_ORDER.

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

  • TYPE-POOLS DECLARATION

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

TYPE-POOLS:

SLIS.

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

  • DATA DECLARATIONS

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

DATA:

W_EBELN TYPE EKKO-EBELN,

W_PROG TYPE SY-REPID,

T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

FS_FIELDCAT LIKE LINE OF T_FIELDCAT,

T_EVENTCAT TYPE SLIS_T_EVENT,

W_EVENTCAT LIKE LINE OF T_EVENTCAT.

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

  • SELECT-OPTIONS DECLARATION

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

SELECT-OPTIONS:

S_EBELN FOR W_EBELN.

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

  • INTERNAL TABLE AND FIELD-STRING DECLARATIONS

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

DATA:

T_EKKO LIKE

STANDARD TABLE

OF EKKO,

FS_EKKO LIKE LINE OF T_EKKO.

DATA:

T_EKPO LIKE

STANDARD TABLE

OF EKPO,

FS_EKPO LIKE LINE OF T_EKPO.

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

  • START-OF-SELECTION

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

START-OF-SELECTION.

SELECT *

FROM EKKO

INTO TABLE T_EKKO

WHERE EBELN IN S_EBELN.

W_PROG = SY-REPID.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = W_PROG

I_CALLBACK_USER_COMMAND = 'PICK'

I_STRUCTURE_NAME = 'EKKO'

TABLES

T_OUTTAB = T_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.

&----


*& Form pick

&----


  • -->UCOMM text

  • -->SELFIELD text

----


FORM PICK USING COMMAND LIKE SY-UCOMM

SELFIELD TYPE SLIS_SELFIELD.

READ TABLE T_EKKO INTO FS_EKKO INDEX SELFIELD-TABINDEX.

CASE COMMAND.

WHEN '&IC1'.

SELECT *

FROM EKPO

INTO TABLE T_EKPO

WHERE EBELN EQ FS_EKKO-EBELN.

W_PROG = SY-REPID.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_STRUCTURE_NAME = 'EKPO'

CHANGING

CT_FIELDCAT = T_FIELDCAT

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.

DELETE T_FIELDCAT WHERE FIELDNAME EQ 'EBELN'.

DELETE T_FIELDCAT WHERE FIELDNAME EQ 'BUKRS'.

DELETE T_FIELDCAT WHERE FIELDNAME EQ 'LGORT'.

DELETE T_FIELDCAT WHERE FIELDNAME EQ 'WERKS'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = W_PROG

IT_FIELDCAT = T_FIELDCAT

IT_EVENTS = T_EVENTCAT

TABLES

T_OUTTAB = T_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.

ENDCASE. " CASE COMMAND

ENDFORM. " FORM PICK

FORM T_EVENTCAT.

W_EVENTCAT-NAME = 'TOP_OF_PAGE'.

W_EVENTCAT-FORM = 'TOP'.

APPEND W_EVENTCAT TO T_EVENTCAT.

ENDFORM.

FORM TOP.

READ TABLE T_EKPO INTO FS_EKPO INDEX 1.

WRITE:/ 'Purchase Document Number'(001),30 FS_EKPO-EBELN,

/ 'Company Code'(002), 30 FS_EKPO-BUKRS,

/ 'Plant'(003), 30 FS_EKPO-WERKS,

/ 'Storage Location'(004),30 FS_EKPO-LGORT.

ENDFORM.

Test Run:

Read only

Former Member
0 Likes
1,064

Hi

i am sending a sample code.

REPORT ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650

MESSAGE-ID ZZ_9838 .

TYPE-POOLS: SLIS.

*type declaration for values from ekko

TYPES: BEGIN OF I_EKKO,

EBELN LIKE EKKO-EBELN,

AEDAT LIKE EKKO-AEDAT,

BUKRS LIKE EKKO-BUKRS,

BSART LIKE EKKO-BSART,

LIFNR LIKE EKKO-LIFNR,

END OF I_EKKO.

DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,

WA_EKKO TYPE I_EKKO.

*type declaration for values from ekpo

TYPES: BEGIN OF I_EKPO,

EBELN LIKE EKPO-EBELN,

EBELP LIKE EKPO-EBELP,

MATNR LIKE EKPO-MATNR,

MENGE LIKE EKPO-MENGE,

MEINS LIKE EKPO-MEINS,

NETPR LIKE EKPO-NETPR,

END OF I_EKPO.

DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,

WA_EKPO TYPE I_EKPO .

*variable for Report ID

DATA: V_REPID LIKE SY-REPID .

*declaration for fieldcatalog

DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.

  • declaration for events table where user comand or set PF status will

  • be defined

DATA: V_EVENTS TYPE SLIS_T_EVENT,

WA_EVENT TYPE SLIS_ALV_EVENT.

  • declartion for layout

DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.

  • declaration for variant(type of display we want)

DATA: I_VARIANT TYPE DISVARIANT,

I_VARIANT1 TYPE DISVARIANT,

I_SAVE(1) TYPE C.

*PARAMETERS : p_var TYPE disvariant-variant.

*Title displayed when the alv list is displayed

DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.

DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.

INITIALIZATION.

V_REPID = SY-REPID.

PERFORM BUILD_FIELDCATLOG.

PERFORM EVENT_CALL.

PERFORM POPULATE_EVENT.

START-OF-SELECTION.

PERFORM DATA_RETRIEVAL.

PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.

PERFORM DISPLAY_ALV_REPORT.

&----


*& Form BUILD_FIELDCATLOG

&----


  • Fieldcatalog has all the field details from ekko

----


FORM BUILD_FIELDCATLOG.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'EBELN'.

WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'AEDAT'.

WA_FIELDCAT-SELTEXT_M = 'DATE.'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'BUKRS'.

WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'BUKRS'.

WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'LIFNR'.

WA_FIELDCAT-NO_OUT = 'X'.

WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDFORM. "BUILD_FIELDCATLOG

&----


*& Form EVENT_CALL

&----


  • we get all events - TOP OF PAGE or USER COMMAND in table v_events

----


FORM EVENT_CALL.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = V_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. "EVENT_CALL

&----


*& Form POPULATE_EVENT

&----


  • Events populated for TOP OF PAGE & USER COMAND

----


FORM POPULATE_EVENT.

READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'TOP_OF_PAGE'.

MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

WA_EVENT-FORM.

ENDIF.

READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'USER_COMMAND'.

MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

WA_EVENT-NAME.

ENDIF.

ENDFORM. "POPULATE_EVENT

&----


*& Form data_retrieval

&----


  • retreiving values from the database table ekko

----


FORM DATA_RETRIEVAL.

SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.

ENDFORM. "data_retrieval

&----


*& Form bUild_listheader

&----


  • text

----


  • -->I_LISTHEADEtext

----


FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

DATA HLINE TYPE SLIS_LISTHEADER.

HLINE-INFO = 'this is my first alv pgm'.

HLINE-TYP = 'H'.

ENDFORM. "build_listheader

&----


*& Form display_alv_report

&----


  • text

----


FORM DISPLAY_ALV_REPORT.

V_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = V_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

I_GRID_TITLE = I_TITLE_EKKO

  • I_GRID_SETTINGS =

  • IS_LAYOUT = ALV_LAYOUT

IT_FIELDCAT = I_FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • i_default = 'ZLAY1'

I_SAVE = 'A'

  • is_variant = i_variant

IT_EVENTS = V_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. "display_alv_report

&----


*& Form TOP_OF_PAGE

&----


  • text

----


FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = IT_LISTHEADER

  • i_logo =

  • I_END_OF_LIST_GRID =

.

ENDFORM. "TOP_OF_PAGE

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

CASE R_UCOMM.

WHEN '&IC1'.

READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.

PERFORM BUILD_FIELDCATLOG_EKPO.

PERFORM EVENT_CALL_EKPO.

PERFORM POPULATE_EVENT_EKPO.

PERFORM DATA_RETRIEVAL_EKPO.

PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.

PERFORM DISPLAY_ALV_EKPO.

ENDCASE.

ENDFORM. "user_command

&----


*& Form BUILD_FIELDCATLOG_EKPO

&----


  • text

----


FORM BUILD_FIELDCATLOG_EKPO.

WA_FIELDCAT-TABNAME = 'IT_EKPO'.

WA_FIELDCAT-FIELDNAME = 'EBELN'.

WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKPO'.

WA_FIELDCAT-FIELDNAME = 'EBELP'.

WA_FIELDCAT-SELTEXT_M = 'LINE NO'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'I_EKPO'.

WA_FIELDCAT-FIELDNAME = 'MATNR'.

WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'I_EKPO'.

WA_FIELDCAT-FIELDNAME = 'MENGE'.

WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'I_EKPO'.

WA_FIELDCAT-FIELDNAME = 'MEINS'.

WA_FIELDCAT-SELTEXT_M = 'UOM'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'I_EKPO'.

WA_FIELDCAT-FIELDNAME = 'NETPR'.

WA_FIELDCAT-SELTEXT_M = 'PRICE'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDFORM. "BUILD_FIELDCATLOG_EKPO

&----


*& Form event_call_ekpo

&----


  • we get all events - TOP OF PAGE or USER COMMAND in table v_events

----


FORM EVENT_CALL_EKPO.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = V_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. "event_call_ekpo

&----


*& Form POPULATE_EVENT

&----


  • Events populated for TOP OF PAGE & USER COMAND

----


FORM POPULATE_EVENT_EKPO.

READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'TOP_OF_PAGE'.

MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

WA_EVENT-FORM.

ENDIF.

ENDFORM. "POPULATE_EVENT

&----


*& Form TOP_OF_PAGE

&----


  • text

----


FORM F_TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = IT_LISTHEADER

  • i_logo =

  • I_END_OF_LIST_GRID =

.

ENDFORM. "TOP_OF_PAGE

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

----


*retreiving values from the database table ekko

FORM DATA_RETRIEVAL_EKPO.

SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.

ENDFORM.

FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

DATA: HLINE1 TYPE SLIS_LISTHEADER.

HLINE1-TYP = 'H'.

HLINE1-INFO = 'CHECKING PGM'.

ENDFORM.

FORM DISPLAY_ALV_EKPO.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = V_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = I_TITLE_EKPO

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = I_FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

I_SAVE = 'A'

  • IS_VARIANT =

IT_EVENTS = V_EVENTS

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.

ENDFORM.

Thanks&Regards,

Chaithanya.

Read only

Former Member
0 Likes
1,064

Hi Srik,

go to Tcode se38 and search for BCALV* theres lot of examples that SAP made to understand ALV concepts

Hope it helps you

Regards

Jaime