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: 

alv top-of-page

Former Member
0 Kudos
100

hi can anyone tell me how to give top-of-page in alv reports?

and also i have 3 tables like ekko lfa1 and adrc. how to get vendor address

for particular po number.

regards,

uttam

1 ACCEPTED SOLUTION

former_member194152
Contributor
0 Kudos
74

Hi,

You can use reuse_alv_events_get function module for trigger top of page in ALV.

and for address tou can use following limking...

ekko-lifnr = lfa1-lifnr...........get lfa1-adrnr

now

lfa1-adrnr = adrc-addrnumber

rewards if helpful.

Regards

Gagan

6 REPLIES 6

Former Member

Former Member
0 Kudos
74

Hi,

For top of page

FORM <b>Z_EVENTCAT </b> USING P_I_EVENTCAT TYPE SLIS_T_EVENT.

DATA: I_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = P_I_EVENTCAT

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.

CLEAR I_EVENT.

READ TABLE P_I_EVENTCAT WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO

I_EVENT.

IF SY-SUBRC = 0.

MOVE 'TOP_OF_PAGE' TO I_EVENT-FORM.

APPEND I_EVENT TO P_I_EVENTCAT.

ENDIF.

READ TABLE P_I_EVENTCAT WITH KEY NAME = SLIS_EV_PF_STATUS_SET INTO I_EVENT.

IF SY-SUBRC = 0.

MOVE 'SET_PF_STATUS' TO I_EVENT-FORM.

APPEND I_EVENT TO P_I_EVENTCAT.

ENDIF.

CLEAR I_EVENT.

READ TABLE P_I_EVENTCAT INTO I_EVENT WITH KEY NAME = SLIS_EV_USER_COMMAND .

IF SY-SUBRC = 0.

MOVE 'USER_COMMAND' TO I_EVENT-FORM.

APPEND I_EVENT TO P_I_EVENTCAT.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = V_PROGNAME

I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

<b> I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'</b> I_GRID_TITLE = V_GRIDTITLE

I_SAVE = 'A'

IS_LAYOUT = I_LAYOUT

IT_FIELDCAT = I_FIELDCAT[]

IT_SORT = I_SORTINFO

IT_EVENTS = I_EVENTCAT

FORM Z_GRIDTITLE .

V_GRIDTITLE = 'ALV FOR SALES ORDER DISPLAY'.

ENDFORM. " Z_GRIDTITLE

<b>*TOP OF PAGE.</b>

FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = I_LISTHEADER.

Regards,

Pritha.

Former Member
0 Kudos
74

Hi

Call function 'REUSE_ALV_EVENTS_GET' and code for the top-of-page event in a perform.

Check the code below ( with needed code in BOLD):

&----


*& Report Z_UP_MLA *

*& *

&----


*& *

*& *

&----


report z_up_mla.

type-pools : slis.

types : begin of t_file,

data(200) type c,

end of t_file.

data: tb_file type standard table of t_file with header line,

ls_events type slis_alv_event,

flag type i.

data: c_space type c value space.

data: begin of itab1 occurs 10,

brand(2) type c,

business_area(2) type c,

months(10) type c,

material(35) type c,

channel(40) type c,

sumofqty(30) type c,

sumofmrp_value(30) type c,

list_price(30) type c,

sumofdisc_val(30) type c,

sumofed_value(30) type c,

sumofnsv(30) type c,

sumoffabric_cost(30) type c,

trim_cost(30) type c,

sumofconvrcost(30) type c,

wash_wrfree(30) type c,

tap_vap(30) type c,

om(4) type c,

sumofother_var(30) type c,

sumoftotal_pc(30) type c,

sumofgross_profit(30) type c,

sumofdormancy(30) type c,

sumoftotal_vse(30) type c,

sumofcba(30) type c,

sumofadvt(30) type c,

sumofoverheads_direct(30) type c,

sumofoverheads_allocated(30) type c,

sumoflicensing_income(30) type c,

sumofles_depreciation(30) type c,

sumofless_interest_wc(30) type c,

sumofblock_interest(30) type c,

sumofbrand_depreciation(30) type c,

period(16) type c,

end of itab1.

data: lt_fieldcat type slis_fieldcat_alv occurs 0,

ls_fieldcat type slis_fieldcat_alv,

gs_layout type slis_layout_alv,

gt_events1 type slis_t_event,

gt_events2 type slis_t_event,

gt_events3 type slis_t_event.

data: itab2 like itab1 occurs 0 with header line,

itab3 like itab1 occurs 0 with header line.

call function 'GUI_UPLOAD'

exporting

filename = 'D:\last_year.csv'

filetype = 'ASC'

tables

data_tab = tb_file.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

loop at tb_file.

split tb_file at ',' into itab1-brand

itab1-business_area

itab1-months

itab1-material

itab1-channel

itab1-sumofqty

itab1-sumofmrp_value

itab1-list_price

itab1-sumofdisc_val

itab1-sumofed_value

itab1-sumofnsv

itab1-sumoffabric_cost

itab1-trim_cost

itab1-sumofconvrcost

itab1-wash_wrfree

itab1-tap_vap

itab1-om

itab1-sumofother_var

itab1-sumoftotal_pc

itab1-sumofgross_profit

itab1-sumofdormancy

itab1-sumoftotal_vse

itab1-sumofcba

itab1-sumofadvt

itab1-sumofoverheads_direct

itab1-sumofoverheads_allocated

itab1-sumoflicensing_income

itab1-sumofles_depreciation

itab1-sumofless_interest_wc

itab1-sumofblock_interest

itab1-sumofbrand_depreciation

itab1-period.

append itab1.

clear itab1.

endloop.

endif.

refresh tb_file.

call function 'GUI_UPLOAD'

exporting

filename = 'D:\budget.csv'

filetype = 'ASC'

tables

data_tab = tb_file.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

loop at tb_file.

split tb_file at ',' into itab2-brand

itab2-business_area

itab2-months

itab2-material

itab2-channel

itab2-sumofqty

itab2-sumofmrp_value

itab2-list_price

itab2-sumofdisc_val

itab2-sumofed_value

itab2-sumofnsv

itab2-sumoffabric_cost

itab2-trim_cost

itab2-sumofconvrcost

itab2-wash_wrfree

itab2-tap_vap

itab2-om

itab2-sumofother_var

itab2-sumoftotal_pc

itab2-sumofgross_profit

itab2-sumofdormancy

itab2-sumoftotal_vse

itab2-sumofcba

itab2-sumofadvt

itab2-sumofoverheads_direct

itab2-sumofoverheads_allocated

itab2-sumoflicensing_income

itab2-sumofles_depreciation

itab2-sumofless_interest_wc

itab2-sumofblock_interest

itab2-sumofbrand_depreciation

itab2-period.

append itab2.

clear itab2.

endloop.

endif.

refresh tb_file.

call function 'GUI_UPLOAD'

exporting

filename = 'D:\This_year.csv'

filetype = 'ASC'

tables

data_tab = tb_file.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

loop at tb_file.

split tb_file at ',' into itab3-brand

itab3-business_area

itab3-months

itab3-material

itab3-channel

itab3-sumofqty

itab3-sumofmrp_value

itab3-list_price

itab3-sumofdisc_val

itab3-sumofed_value

itab3-sumofnsv

itab3-sumoffabric_cost

itab3-trim_cost

itab3-sumofconvrcost

itab3-wash_wrfree

itab3-tap_vap

itab3-om

itab3-sumofother_var

itab3-sumoftotal_pc

itab3-sumofgross_profit

itab3-sumofdormancy

itab3-sumoftotal_vse

itab3-sumofcba

itab3-sumofadvt

itab3-sumofoverheads_direct

itab3-sumofoverheads_allocated

itab3-sumoflicensing_income

itab3-sumofles_depreciation

itab3-sumofless_interest_wc

itab3-sumofblock_interest

itab3-sumofbrand_depreciation

itab3-period.

append itab3.

clear itab3.

endloop.

endif.

perform modify_fieldcat using:

'ITAB1' 'BRAND' 'Brand',

'ITAB1' 'BUSINESS_AREA' 'Business Area',

'ITAB1' 'MONTHS' 'Months',

'ITAB1' 'MATERIAL' 'Material',

'ITAB1' 'CHANNEL' 'Channel',

'ITAB1' 'SUMOFQTY' 'Sum of Quantity',

'ITAB1' 'SUMOFMRP_VALUE' 'Sum of MRP Value',

'ITAB1' 'LIST_PRICE' 'List Price',

'ITAB1' 'SUMOFDISC_VAL' 'Sum of Disc Value',

'ITAB1' 'SUMOFED_VALUE' 'Sum of ED Value',

'ITAB1' 'SUMOFNSV' 'Sum of NSV',

'ITAB1' 'SUMOFFABRIC_COST' 'Sum of Fabric Cost',

'ITAB1' 'TRIM_COST' 'Trim Cost',

'ITAB1' 'SUMOFCONVRCOST' 'Sum of Convr Cost',

'ITAB1' 'WASH_WRFREE' 'Wash WR Free',

'ITAB1' 'TAP_VAP' 'Tap Vap',

'ITAB1' 'OM' 'OM',

'ITAB1' 'SUMOFOTHER_VAR' 'Sum of Other Var',

'ITAB1' 'SUMOFTOTAL_PC' 'Sum of Total PC',

'ITAB1' 'SUMOFGROSS_PROFIT' 'Sum of Gross Profit',

'ITAB1' 'SUMOFDORMANCY' 'Sum of Dormancy',

'ITAB1' 'SUMOFTOTAL_VSE' 'Sum of Total VSE',

'ITAB1' 'SUMOFCBA' 'Sum of CBA',

'ITAB1' 'SUMOFADVT' 'Sum of ADVT',

'ITAB1' 'SUMOFOVERHEADS_DIRECT' 'Sum of Overheads Direct',

'ITAB1' 'SUMOFOVERHEADS_ALLOCATED'

'Sum of Overheads Allocated',

'ITAB1' 'SUMOFLICENSING_INCOME' 'Sum of Licencing Income',

'ITAB1' 'SUMOFLES_DEPRECIATION' 'Sum of Les Depriciation',

'ITAB1' 'SUMOFLESS_INTEREST_WC' 'Sum of Les Interest WC',

'ITAB1' 'SUMOFBLOCK_INTEREST' 'Sum of Block Interest',

'ITAB1' 'SUMOFBRAND_DEPRECIATION' 'Sum of Brand Depriciation'

,

'ITAB1' 'PERIOD' 'Period'.

call function 'REUSE_ALV_BLOCK_LIST_INIT'

exporting

i_callback_program = sy-repid.

perform build_events using '1'

changing gt_events1.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = gs_layout

it_fieldcat = lt_fieldcat

i_tabname = 'ITAB1'

it_events = gt_events1

tables

t_outtab = itab1

exceptions

program_error = 1

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

perform build_events using '2'

changing gt_events2.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = gs_layout

it_fieldcat = lt_fieldcat

i_tabname = 'ITAB2'

it_events = gt_events2

tables

t_outtab = itab2

exceptions

program_error = 1

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

perform build_events using '3'

changing gt_events3.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = gs_layout

it_fieldcat = lt_fieldcat

i_tabname = 'ITAB3'

it_events = gt_events3

tables

t_outtab = itab3

exceptions

program_error = 1

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

call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'

  • EXPORTING

  • I_INTERFACE_CHECK = ' '

  • IS_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 =

  • ES_EXIT_CAUSED_BY_USER =

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

if sy-subrc = 0.

message i000(zdemo).

endif.

&----


*& Form modify_fieldcat

&----


  • text

----


  • -->P_0257 text

  • -->P_0258 text

----


form modify_fieldcat using pa_tabname type string

pa_fieldname type string

pa_seltext_m type string.

clear ls_fieldcat.

ls_fieldcat-tabname = pa_tabname.

ls_fieldcat-fieldname = pa_fieldname.

ls_fieldcat-seltext_m = pa_seltext_m.

ls_fieldcat-outputlen = '15'.

append ls_fieldcat to lt_fieldcat.

endform. " modify_fieldcat

<b>&----


*& Form top_of_page1

&----


form top_of_page1.

write: 'Last Year'.

endform. "TOP_OF_PAGE1

&----


*& Form top_of_page2

&----


form top_of_page2.

write: 'Budget'.

endform. "TOP_OF_PAGE2

&----


*& Form top_of_page3

&----


form top_of_page3.

write: 'This year'.

endform. "TOP_OF_PAGE3

&----


*& Form build_events

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_events using flag

changing pa_events type slis_t_event.

*Get all possible events

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = pa_events

exceptions

list_type_wrong = 1

others = 2.

if sy-subrc <> 0.

endif.

  • Specify events used in selection screen

read table pa_events with key name = slis_ev_top_of_page

into ls_events.

if sy-subrc = 0.

if flag = 1.

ls_events-form = 'TOP_OF_PAGE1'.

elseif flag = 2.

ls_events-form = 'TOP_OF_PAGE2'.

else.

ls_events-form = 'TOP_OF_PAGE3'.

endif.

modify pa_events from ls_events index sy-tabix.

clear ls_events.

endif.

endform. "build_events</b>

Thanks

Vasudha

Reward points if found useful

Message was edited by:

Vasudha L

former_member194152
Contributor
0 Kudos
75

Hi,

You can use reuse_alv_events_get function module for trigger top of page in ALV.

and for address tou can use following limking...

ekko-lifnr = lfa1-lifnr...........get lfa1-adrnr

now

lfa1-adrnr = adrc-addrnumber

rewards if helpful.

Regards

Gagan

Former Member
0 Kudos
74

Hi,

1.Select LIFNR from Table EKKO for PO EBELN.

2.Select ADRNR from Table LFA1 for LIFNR from 1.

3.Select Vendor Address from table ADRC for ADRNR from 2.

Regards,

Mukesh Kumar

former_member386202
Active Contributor
0 Kudos
74

Hi,

Refer this code.

&----


*& Form sub_top_of_page *

&----


  • This form is to build the Page Header *

----


FORM sub_top_of_page .

*--Local Variable

DATA : lv_title(120) TYPE c, " Title

lv_month(30) TYPE c,

lv_mont(30) TYPE c,

lv_bud(16) TYPE c.

*--Local Work Area

DATA : lwa_line TYPE slis_listheader. " Hold list header

  • CONCATENATE p_month 'to' s_hmonth INTO lv_month SEPARATED BY space.

  • IF NOT s_hmonth IS INITIAL.

  • lv_mont = lv_month.

  • ELSE.

lv_mont = p_month.

  • ENDIF.

*--Title Display

lwa_line-typ = 'H'. " header

lv_title = sy-title.

lwa_line-info = lv_title.

APPEND lwa_line TO it_header.

CLEAR lwa_line.

*--Month Display

lwa_line-typ = 'S'. " Item

WRITE: lv_mont TO lv_month.

lwa_line-key = text-024.

lwa_line-info = lv_month.

APPEND lwa_line TO it_header.

*--Budget Display

lwa_line-typ = 'S'. " Item

WRITE: p_bud TO lv_bud.

lwa_line-key = text-025.

lwa_line-info = lv_bud.

APPEND lwa_line TO it_header.

CLEAR: lwa_line,

lv_mont.

*--This funcation module will display the top of the page

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_header.

*--Free

FREE : it_header.

ENDFORM. "sub_top_of_page

Regards,

Prashant