ALV totals with REUSE_ALV_GRID_DISPLAY function
Hi folks, I am using the function REUSE_ALV_GRID_DISPLAY to display a report. One column called 'Perc Left' has been defined as a total using the do_sum = 'X' field in the field catalog. Not what I really want...
My issue is that when the totals are displayed I want this column to use a formula based on 2 other results from the total line. Is it possible to change the totals using something like events etc. Or is this not possible using the REUSE_ALV_GRID_DISPLAY function ?
Cheers
Dave
Thanks Srinivas, I didn't want the user to execute a function after the list is displayed for this. What I need is for the report to be executed and before the initial list is displayed I need some way to intercept and recalculate one of the columns on the total line. Unless I am misinterpreting the help for this it_event_exit internal table. I tried it and it does not go to the USER COMMAND section until after the basic list with the totals is displayed. At this point its too late and the wrong total has been presented to the user.
Hope this clarifies.
Dave
Similar Messages
-
Button in ALV toolbar with REUSE_ALV_GRID_DISPLAY
Hello friends,
I am Displaying ALV using REUSE_ALV_GRID_IDSPLAY. i need to add a button in grid toolbar.
i am doing it by adding a new ZSTATUS in SET PF_STATUS. but the problem is that it is removing the standard buttons.
i want to add button without removing the standard butttons.
Please help.
thanx in advance.
Krishan Kumarhai friends.......
i had tried to add custom button to the reuse_alv_grid_display.please send the coding...
REPORT ZHAJI_SAMPLE.
tables:lfa1.
TYPE-POOLS : slis.
SELECT-OPTIONS: lifnr FOR lfa1-lifnr.
types:begin of fs,
flag type c,
lifnr type lfa1-lifnr,
land1 type lfa1-land1,
name1 type lfa1-name1,
end of fs.
data: itab type table of fs,
wa type fs.
data: fcat type slis_t_fieldcat_alv,
fcat1 type slis_fieldcat_alv.
data: rt_extab type slis_t_extab.
*CONSTANTS : c_check(1) VALUE 'X'.
select lifnr land1 name1 from lfa1 into corresponding FIELDS OF table
itab where lifnr IN
lifnr.
perform sub.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'sy-repid'
I_CALLBACK_PF_STATUS_SET = 'PF'
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'vendor details'
I_GRID_SETTINGS =
IS_LAYOUT = LAYOUT
IT_FIELDCAT = fcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = I_EVENT
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = itab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
form sub.
fcat1-fieldname = 'FLAG'.
fcat1-tabname = 'TAB'.
*fcat1-COL_POS = 1.
fcat1-checkbox = 'X'.
fcat1-edit = 'X'.
append fcat1 to fcat.
CLEAR FCAT1.
fcat1-fieldname = 'LIFNR'.
fcat1-ref_tabname = 'LFA1'.
fcat1-ref_fieldname = 'LIFNR'.
FCAT1-outputlen = 10.
append fcat1 to fcat.
CLEAR FCAT1.
fcat1-fieldname = 'NAME1'.
fcat1-ref_tabname = 'LFA1'.
fcat1-ref_fieldname = 'NAME1'.
append fcat1 to fcat.
CLEAR FCAT1.
fcat1-fieldname = 'LAND1'.
fcat1-ref_tabname = 'LFA1'.
fcat1-ref_fieldname = 'LAND1'.
append fcat1 to fcat.
CLEAR FCAT1.
endform.
form PF USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZHAJI_P1' .
ENDFORM.
just give the fine coding -
REUSE_ALV_GRID_DISPLAY function
Hello,
with 'REUSE_ALV_GRID_DISPLAY'function, once displayed,
I need to show in a label, a field from the List, is there a way to do this. I did try and see if a user command occurs , when I select a line, but there was not one generated.
ThanksHi sims,
when I select a line, but there was not one generated.
Event will occur when we DOUBLE-CLICK
a line.
1. There are some parameters
in the FM which are passed,
and a new FORM has to be written.
2. Just copy paste this code in new program.
3. It will display list of company.
On double-clicking on the alv,
it will again display the clicked company code.
Important code has been marked.
4.
REPORT abc.
TYPE-POOLS : slis.
Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
Display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
CALL BACK FORM
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
READ TABLE itab INDEX whatrow-tabindex.
WRITE itab-bukrs.
ENDFORM. "ITAB_user_command
regards,
amit m.
regards,
amit m. -
Display totals with currency sign in ALV
Hi,
I have to display totals with currency sign in ALV.
column1 colums2
10 USD
20 USD
30 USD
40 USD
100 USD
Can anybody help on this.
Regsrds,
Zak.Hi,
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'. "Display column total
fieldcatalog-datatype = 'CURR'. "
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
Thanks
Vikranth -
ALV Totals , Subtotals for a particular field in ALV Grid report
Hi,
I have an issue in ALV totals and subtotals.
Scenario is like this.
i have a vendor data to be pulled out of SAP and to be shown in the form of report.
i am populating all the data and doing do_sum based on Vendor ( has expansin & collapse option ) and display the number of reports .
Vendor -
100
Vendor1 -
1
Vendor2----
2.
Vendor100----
100.
but my problem is in the same report i have a date field .
if i have a five vendors created on 03/03/2008. in the same report for the date field having ( expansion & collapse ) , when i expand based on that date can i be able to sum up all the vendors created on 03/03/2008 and display in the same report along with the vendor count.
Let me know . Thank you in advance
Regards,
RyHi Roby,
Have a look at this sample code
It will help u,
REPORT ZIN_FI_AGEING
message-id zbdc
no standard page heading.
Title : For Ageing Details
Author :
Date : 22/11/2004
Transport/Correction Id :
Clarify case ID :
Application : FI
Program Type :
Frequency :
Purpose :
Comments :
Request No :
TABLES DELCARATIONS
Tables: zzgeinz9a, "Actual line item table
t001. "Plants/Branches
ALV TTPE DELCARATIONS
type-pools: slis.
*Type Declarations for Field Catalog
data : i_fldcat_head type slis_t_fieldcat_alv,
wa_fldcat_head type slis_fieldcat_alv.
*Type Declarations for ALV Events
data : i_events type slis_t_event,
wa_event like line of i_events.
*Type Declarations for Layout Design
data : wa_layout type slis_layout_alv.
*Type Declarations for Sorting Fields
data: it_sort type slis_sortinfo_alv occurs 0 with header line.
*Type Declarations for Displaying Images on Grid
data : i_comment type slis_t_listheader,
wa_comment type slis_listheader.
*Type Declarations for Grouping fields
data : wa_group type slis_sp_group_alv,
i_group type slis_t_sp_group_alv.
DATA DELCARATIONS
data: v_flag, "Status Flag
v_repid like sy-repid, "Program Name
p_year(4) type c, "Year
v_due_days type i. "To hold the due days
CONSTANTS DELCARATIONS
constants: c_x type c value 'X',
c_bukrs(4) type c value '0373'.
INTERNAL TABLES DELCARATIONS
*--Internal table to hold the required data
data: begin of it_final_vendor occurs 0,
rzzlifnr like zzgeinz9a-rzzlifnr, "Vendor
name1 like lfa1-name1, "Vendor Name
docnr like zzgeinz9a-DOCNR, "Accounting Doc No
refdocnr like zzgeinz9a-REFDOCNR, "Reference document no
belnr like bkpf-belnr, "FI Doc No
doc_date like bkpf-awkey, "Document Date
zbd1t like bsik-zbd1t, "Cash discount days 1
bldat like bkpf-bldat, "Document Date
due_date like bkpf-bldat, "Due Date
due_days type i, "Due Days
rzz_ebeln like zzgeinz9a-rzz_ebeln, "P.O. Ref No
not_due like zzgeinz9a-hsl, "Not Yet Due
hsl like zzgeinz9a-hsl, "local currency
found type c, "Existance Flag
end of it_final_vendor.
data: begin of it_final_vendor_temp occurs 0,
rzzlifnr like zzgeinz9a-rzzlifnr, "Vendor
name1 like lfa1-name1, "Vendor Name
belnr like bkpf-belnr, "FI Doc No
bldat like bkpf-bldat, "Document Date
rzz_ebeln like zzgeinz9a-rzz_ebeln, "P.O. Ref No
hsl like zzgeinz9a-hsl, "local currency
due_date like bkpf-bldat, "Due Date
due_days type i, "Due Days
not_due like zzgeinz9a-hsl, "Not Yet Due
buck_0_30 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_31_60 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_61_90 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_91_180 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_180 like zzgeinz9a-hsl, "Invoiceamt in localcurr
docnr like zzgeinz9a-DOCNR, "Accounting Doc No
refdocnr like zzgeinz9a-REFDOCNR, "Reference document no
doc_date like bkpf-awkey, "Document Date
found type c, "Existance Flag
end of it_final_vendor_temp.
data: begin of it_final_customer occurs 0,
rzzkunnr like zzgeinz9a-rzzkunnr, "Customer
name1 like kna1-name1, "Customer Name
docnr like zzgeinz9a-DOCNR, "Accounting Doc No
refdocnr like zzgeinz9a-REFDOCNR, "Reference document no
belnr like bkpf-belnr, "FI Doc No
doc_date like bkpf-awkey, "Document Date
zbd1t like bsik-zbd1t, "Cash discount days 1
bldat like bkpf-bldat, "Document Date
due_date like bkpf-bldat, "Due Date
due_days type i, "Due Days
rzz_ebeln like zzgeinz9a-rzz_ebeln, "P.O. Ref No
not_due like zzgeinz9a-hsl, "Not Yet Due
hsl like zzgeinz9a-hsl, "local currency
found type c, "Existance Flag
end of it_final_customer.
data: begin of it_final_customer_temp occurs 0,
rzzkunnr like zzgeinz9a-rzzkunnr, "Customer
name1 like kna1-name1, "Customer Name
belnr like bkpf-belnr, "FI Doc No
bldat like bkpf-bldat, "Document Date
rzz_ebeln like zzgeinz9a-rzz_ebeln, "P.O. Ref No
hsl like zzgeinz9a-hsl, "local currency
due_date like bkpf-bldat, "Due Date
due_days type i, "Due Days
not_due like zzgeinz9a-hsl, "Not Yet Due
buck_0_30 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_31_60 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_61_90 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_91_180 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_180 like zzgeinz9a-hsl, "Invoiceamt in localcurr
docnr like zzgeinz9a-DOCNR, "Accounting Doc No
refdocnr like zzgeinz9a-REFDOCNR, "Reference document no
doc_date like bkpf-awkey, "Document Date
found type c, "Existance Flag
end of it_final_customer_temp.
*--Internal Table to hold the Cash discount days 1 for Vendors
data: begin of it_final_bsik occurs 0,
belnr like bsik-belnr,
zbd1t like bsik-zbd1t,
end of it_final_bsik.
*--Internal Table to hold the Cash discount days 1 for Customers
data: begin of it_final_bsid occurs 0,
belnr like bsid-belnr,
zbd1t like bsid-zbd1t,
end of it_final_bsid.
INITIALIZATION
v_repid = sy-repid.
SELECTION SCREEN
selection-screen: begin of block b1 with frame title text-h01.
selection-screen skip.
select-options: s_vendor for zzgeinz9a-rzzlifnr modif id ven.
parameters: p_comp1 like t001-bukrs modif id ven.
parameters: p_rundt1 like bkpf-bldat modif id ven.
select-options: s_cust for zzgeinz9a-rzzkunnr modif id cst.
parameters: p_comp2 like t001-bukrs modif id cst.
parameters: p_rundt2 like bkpf-bldat modif id cst.
selection-screen skip.
selection-screen: begin of block b2 with frame title text-h02.
parameters : p_vendor radiobutton group gr1 default 'X'
user-command test,
p_cust radiobutton group gr1.
selection-screen: end of block b2.
selection-screen: end of block b1.
**************************AT Selection Screen OutPut ******************
at selection-screen output.
loop at screen.
if p_cust = 'X'.
if screen-group1 = 'VEN'.
screen-active = '0'.
screen-input = '0'.
screen-output = '0'.
screen-invisible = '0'.
endif.
elseif p_vendor = 'X'.
if screen-group1 = 'CST'.
screen-active = '0'.
screen-input = '0'.
screen-output = '0'.
screen-invisible = '0'.
endif.
endif.
modify screen.
endloop.
SELECTION SCREEN ON
at selection-screen on s_vendor.
*--Validating Vendor
if not s_vendor[] is initial.
perform validate_s_vendor.
endif.
at selection-screen on s_cust.
*--Validating Customer
if not s_cust[] is initial.
perform validate_s_cust.
endif.
at selection-screen on p_comp1.
*--Validating Company Code.
if not p_comp1 is initial.
perform validate_p_comp1.
endif.
at selection-screen on p_comp2.
*--Validating Company Code.
if not p_comp2 is initial.
perform validate_p_comp2.
endif.
START OF SELECTION
start-of-selection.
if p_vendor = 'X'.
perform get_vendor_data.
elseif p_cust = 'X'.
perform get_customer_data.
endif.
END OF SELECTION
end-of-selection.
if p_vendor = 'X'.
*--Generating the output for vendor
perform generate_field_catalog_vendor.
perform get_events_vendor.
perform generate_layout_vendor.
perform generate_sort_vendor.
perform generate_group_vendor.
perform disp_alv_grid_vendor.
elseif p_cust = 'X'.
*--Generating the output for customer
perform generate_field_catalog_cust.
perform get_events_customer.
perform generate_layout_customer.
perform generate_sort_customer.
perform generate_group_customer.
perform disp_alv_grid_customer.
endif.
*& Form validate_s_vendor
Validating the Vendor
form validate_s_vendor.
select rzzlifnr up to 1 rows
into (zzgeinz9a-rzzlifnr)
from zzgeinz9a
where rzzlifnr in s_vendor.
endselect.
if sy-subrc ne 0.
message e004 with 'Invalid Range of Vendor'(002)
s_vendor-low 'To'(006) s_vendor-high.
endif.
endform. " validate_s_vendor
*& Form validate_s_cust
Validating the Customer
form validate_s_cust.
select rzzkunnr up to 1 rows
into (zzgeinz9a-rzzkunnr)
from zzgeinz9a
where rzzkunnr in s_cust.
endselect.
if sy-subrc ne 0.
message e004 with 'Invalid Range of Customer'(005)
s_cust-low 'To'(006) s_cust-high.
endif.
endform. " validate_s_cust
*& Form validate_p_comp1
Validating the Company Code
form validate_p_comp1.
select single bukrs
into (t001-bukrs)
from t001
where bukrs eq p_comp1.
if sy-subrc ne 0.
message e004 with 'Company Code'(004) p_comp1 'Does not Exists'(003)
endif.
endform. " validate_p_comp1
*& Form validate_p_comp2
Validating the Company Code
form validate_p_comp2.
select single bukrs
into (t001-bukrs)
from t001
where bukrs eq p_comp2.
if sy-subrc ne 0.
message e004 with 'Company Code'(004) p_comp2 'Does not Exists'(003)
endif.
endform. " validate_p_comp2
*& Form get_vendor_data
Getting the Vendor Related Docs
form get_vendor_data.
select a~rzzlifnr
b~name1
a~docnr
a~refdocnr
a~rzz_ebeln
a~hsl
into corresponding fields of table it_final_vendor
from zzgeinz9a as a
inner join lfa1 as b
on arzzlifnr = blifnr
where rzzlifnr in s_vendor
and rbukrs eq p_comp1.
if sy-subrc eq 0.
v_flag = 'X'.
p_year = sy-datum+0(4).
perform get_doc_date using p_comp1
p_year.
perform move_records.
sort it_final_vendor by rzzlifnr.
perform generate_data.
else.
v_flag = space.
endif.
endform. " get_vendor_data
*& Form get_customer_data
Getting the Customer Related Docs
form get_customer_data.
select a~rzzkunnr
b~name1
a~docnr
a~refdocnr
a~rzz_ebeln
a~hsl
into corresponding fields of table it_final_customer
from zzgeinz9a as a
inner join kna1 as b
on arzzkunnr = bkunnr
where rzzkunnr in s_cust
and rbukrs eq p_comp2.
if sy-subrc eq 0.
v_flag = 'X'.
p_year = sy-datum+0(4).
perform get_doc_date_cust using p_comp2
p_year.
perform move_records_cust.
sort it_final_customer by rzzkunnr.
perform generate_data_cust.
else.
v_flag = space.
endif.
endform. " get_customer_data
*& Form get_doc_date
Getting the Document Date and FI Doc No
-->P_P_COMP1 Company Code
-->P_P_YEAR Fiscal Year
form get_doc_date using p_p_comp1
p_p_year.
loop at it_final_vendor.
concatenate it_final_vendor-refdocnr '*' into
it_final_vendor-doc_date.
modify it_final_vendor index sy-tabix.
endloop.
clear it_final_vendor.
data: v_doc_date(11) type c,
v_belnr like bkpf-belnr,
v_bldat like bkpf-bldat.
loop at it_final_vendor.
concatenate it_final_vendor-refdocnr '%' into v_doc_date.
select single belnr
bldat
into corresponding fields of it_final_vendor
from bkpf
where bukrs eq p_p_comp1
and gjahr eq p_p_year
and awkey like v_doc_date.
modify it_final_vendor.
endloop.
clear:it_final_vendor.
endform. " get_doc_date
*& Form move_records
Moving records to final internal table
form move_records.
*--Checking the existance of belnr in bsik
clear it_final_vendor.
select belnr
zbd1t
into table it_final_bsik
from bsik
for all entries in it_final_vendor
where belnr eq it_final_vendor-belnr
and bukrs eq c_bukrs.
clear it_final_bsik.
loop at it_final_vendor.
read table it_final_bsik with key belnr = it_final_vendor-belnr.
if sy-subrc eq 0.
it_final_vendor-zbd1t = it_final_bsik-zbd1t.
it_final_vendor-due_date = it_final_vendor-bldat +
it_final_bsik-zbd1t.
it_final_vendor-found = 'X'.
modify it_final_vendor.
endif.
endloop.
endform. " move_records
*& Form generate_data
Segregating the records based on due_date
form generate_data.
delete it_final_vendor[] where found ne 'X'.
sort it_final_vendor by belnr.
loop at it_final_vendor.
if it_final_vendor-due_date > p_rundt1.
move-corresponding it_final_vendor to it_final_vendor_temp.
move it_final_vendor-hsl to it_final_vendor_temp-not_due.
elseif it_final_vendor-due_date < p_rundt1.
it_final_vendor-due_days = p_rundt1 - it_final_vendor-DUE_DATE.
endif.
*--filling 0-30 bucket.
if it_final_vendor-due_days ge 0 AND it_final_vendor-due_days le 30.
move-corresponding it_final_vendor to it_final_vendor_temp.
move it_final_vendor-hsl to it_final_vendor_temp-buck_0_30.
*--filling 31-60 bucket.
elseif it_final_vendor-due_days ge 31 AND it_final_vendor-due_days le 60
move-corresponding it_final_vendor to it_final_vendor_temp.
move it_final_vendor-hsl to it_final_vendor_temp-buck_31_60.
*--filling 61-90 bucket.
elseif it_final_vendor-due_days ge 61 AND it_final_vendor-due_days le 90
move-corresponding it_final_vendor to it_final_vendor_temp.
move it_final_vendor-hsl to it_final_vendor_temp-buck_61_90.
*--filling 91-180 bucket.
elseif it_final_vendor-due_days ge 91 AND it_final_vendor-due_days
le 180.
move-corresponding it_final_vendor to it_final_vendor_temp.
move it_final_vendor-hsl to it_final_vendor_temp-buck_91_180.
*--filling 180 bucket.
elseif it_final_vendor-due_days gt 180.
move-corresponding it_final_vendor to it_final_vendor_temp.
move it_final_vendor-hsl to it_final_vendor_temp-buck_180.
endif.
append it_final_vendor_temp.
clear it_final_vendor_temp.
endloop.
endform. " generate_data
*& Form DISP_ALV_GRID_VENDOR
Displaying the output in grid For Vendor
form DISP_ALV_GRID_VENDOR.
*--Generating the OUTPUT GRID FOR VENDOR
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 = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = wa_layout
IT_FIELDCAT = i_fldcat_head
IT_EXCLUDING =
IT_SPECIAL_GROUPS = i_group
IT_SORT = it_sort[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = i_events
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = it_final_vendor_temp
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. " DISP_ALV_GRID
*& Form get_doc_date_cust
text
-->P_P_COMP2 Company Code
-->P_P_YEAR Fiscal Year
form get_doc_date_cust using p_p_comp2
p_p_year.
loop at it_final_customer.
concatenate it_final_customer-refdocnr '*' into
it_final_customer-doc_date.
modify it_final_customer index sy-tabix.
endloop.
clear it_final_customer.
data: v_doc_date(11) type c,
v_belnr like bkpf-belnr,
v_bldat like bkpf-bldat.
loop at it_final_customer.
concatenate it_final_customer-refdocnr '%' into v_doc_date.
select single belnr
bldat
into corresponding fields of it_final_customer
from bkpf
where bukrs eq p_p_comp2
and gjahr eq p_p_year
and awkey like v_doc_date.
modify it_final_customer.
endloop.
clear:it_final_customer.
endform. " get_doc_date_cust
*& Form move_records_cust
Moving Customer Data to Final Internal Table
form move_records_cust.
*--Checking the existance of belnr in bsid
select belnr
zbd1t
into table it_final_bsid
from bsid
for all entries in it_final_customer
where belnr eq it_final_customer-belnr
and bukrs eq c_bukrs.
clear it_final_bsid.
loop at it_final_customer.
read table it_final_bsid with key belnr = it_final_customer-belnr.
if sy-subrc eq 0.
it_final_customer-zbd1t = it_final_bsid-zbd1t.
it_final_customer-due_date = it_final_customer-bldat +
it_final_bsid-zbd1t.
it_final_customer-found = 'X'.
modify it_final_customer.
endif.
endloop.
endform. " move_records_cust
*& Form generate_data_cust
Generating the Customer Output
form generate_data_cust.
delete it_final_customer[] where found ne 'X'.
sort it_final_customer by belnr.
loop at it_final_customer.
if it_final_customer-due_date > p_rundt2.
move-corresponding it_final_customer to it_final_customer_temp.
move it_final_customer-hsl to it_final_customer_temp-not_due.
elseif it_final_customer-due_date < p_rundt2.
it_final_customer-due_days = p_rundt2 - it_final_customer-DUE_DATE.
endif.
*--filling 0-30 bucket.
if it_final_customer-due_days ge 0 AND it_final_customer-due_days le 30
move-corresponding it_final_customer to it_final_customer_temp.
move it_final_customer-hsl to it_final_customer_temp-buck_0_30.
*--filling 31-60 bucket.
elseif it_final_customer-due_days ge 31 AND it_final_customer-due_days
le 60
move-corresponding it_final_customer to it_final_customer_temp.
move it_final_customer-hsl to it_final_customer_temp-buck_31_60.
*--filling 61-90 bucket.
elseif it_final_customer-due_days ge 61 AND it_final_customer-due_days
le 90
move-corresponding it_final_customer to it_final_customer_temp.
move it_final_customer-hsl to it_final_customer_temp-buck_61_90.
*--filling 91-180 bucket.
elseif it_final_customer-due_days ge 91 AND
it_final_customer-due_days
le 180.
move-corresponding it_final_customer to it_final_customer_temp.
move it_final_customer-hsl to it_final_customer_temp-buck_91_180.
*--filling 180 bucket.
elseif it_final_customer-due_days gt 180.
move-corresponding it_final_customer to it_final_customer_temp.
move it_final_customer-hsl to it_final_customer_temp-buck_180.
endif.
append it_final_customer_temp.
clear it_final_customer_temp.
endloop.
endform. " generate_data_cust
*& Form generate_field_catalog_vendor
Generating the Field Catalog for Vendor
form generate_field_catalog_vendor.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = v_repid
I_INTERNAL_TABNAME = 'IT_FINAL_VENDOR_TEMP'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = v_repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = i_fldcat_head
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.
if not i_fldcat_head[] is initial.
loop at i_fldcat_head into wa_fldcat_head.
case wa_fldcat_head-fieldname.
when 'RZZLIFNR'.
wa_fldcat_head-col_pos = '1'.
wa_fldcat_head-ref_tabname = ' '.
wa_fldcat_head-seltext_m = 'Vendor No'(001).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '12'.
when 'NAME1'.
wa_fldcat_head-col_pos = '2'.
wa_fldcat_head-seltext_m = 'Vendor Name'(007).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '35'.
when 'BELNR'.
wa_fldcat_head-col_pos = '3'.
wa_fldcat_head-seltext_m = 'Invoice No'(008).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '12'.
wa_fldcat_head-KEY = ' '.
when 'BLDAT'.
wa_fldcat_head-col_pos = '4'.
wa_fldcat_head-seltext_m = 'Document Date'(009).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '13'.
wa_fldcat_head-ref_tabname = ' '.
when 'RZZ_EBELN'.
wa_fldcat_head-col_pos = '5'.
wa_fldcat_head-seltext_m = 'PO.Ref.No'(010).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '13'.
wa_fldcat_head-ref_tabname = ' '.
when 'HSL'.
wa_fldcat_head-col_pos = '6'.
wa_fldcat_head-seltext_m = 'Invoice Amount'(011).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'DUE_DATE'.
wa_fldcat_head-col_pos = '7'.
wa_fldcat_head-seltext_m = 'Due Date'(012).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '12'.
wa_fldcat_head-ref_tabname = ' '.
when 'DUE_DAYS'.
wa_fldcat_head-col_pos = '8'.
wa_fldcat_head-seltext_m = 'Due Days'(013).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '9'.
when 'NOT_DUE'.
wa_fldcat_head-col_pos = '9'.
wa_fldcat_head-seltext_m = 'Not Due'(014).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_0_30'.
wa_fldcat_head-col_pos = '10'.
wa_fldcat_head-seltext_m = '0 To 30'(015).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_31_60'.
wa_fldcat_head-col_pos = '11'.
wa_fldcat_head-seltext_m = '31 To 60'(016).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_61_90'.
wa_fldcat_head-col_pos = '12'.
wa_fldcat_head-seltext_m = '61 To 90'(017).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_91_180'.
wa_fldcat_head-col_pos = '13'.
wa_fldcat_head-seltext_m = '91 To 180'(018).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_180'.
wa_fldcat_head-col_pos = '14'.
wa_fldcat_head-seltext_m = 'Beyond 180'(019).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'DOCNR'.
wa_fldcat_head-no_out = 'X'.
when 'REFDOCNR'.
wa_fldcat_head-no_out = 'X'.
when 'DOC_DATE'.
wa_fldcat_head-no_out = 'X'.
when 'FOUND'.
wa_fldcat_head-no_out = 'X'.
endcase.
modify i_fldcat_head from wa_fldcat_head index sy-tabix.
endloop.
endif.
endform. " generate_field_catalog_vendor
*& Form get_events_vendor
Getting ALV Events
form get_events_vendor.
call function 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
importing
et_events = i_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.
if not i_events[] is initial.
read table i_events into wa_event with key name = 'TOP_OF_PAGE'(024)
wa_event-form = 'GENERATE_USERCOMMAND'.
modify i_events from wa_event index sy-tabix.
read table i_events into wa_event with key name = 'END_OF_LIST'(025)
wa_event-form = 'GENERATE_USERCOMMAND_FOOTER'.
modify i_events from wa_event index sy-tabix.
endif.
endform. " get_events_vendor
*& Form GENERATE_USERCOMMAND
Displaying Header-Text and Logo on Grid
form generate_usercommand .
clear i_comment[].
wa_comment-typ = 'H'.
wa_comment-info = 'Vendor Ageing Report'(026).
append wa_comment to i_comment.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = i_comment
i_logo = 'ENJOYSAP_LOGO'
I_END_OF_LIST_GRID = 'X'
endform. " GENERATE_USERCOMMAND
*& Form GENERATE_USERCOMMAND_FOOTER
Displaying Footer-Text on Grid
form generate_usercommand_footer.
clear i_comment[].
clear wa_comment.
wa_comment-typ = 'S'.
wa_comment-key = 'GE-Betz'(027).
append wa_comment to i_comment.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = i_comment
I_LOGO = ''
i_end_of_list_grid = 'X'.
endform. " GENERATE_USERCOMMAND_FOOTER
*& Form generate_layout_vendor
Generating the ALV Layout
form generate_layout_vendor.
WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. "OPTIMIZING FIELD WIDTH
wa_layout-zebra = 'X'. "PUTTING ZEBRA COLORS
wa_layout-confirmation_prompt = 'X'. "DISPLAYS CONFIRMATION DIALOG
wa_layout-totals_text = 'Totals'(028). "DISPLAYS TOTALS TEXT
wa_layout-subtotals_text = 'Sub Totals'(029)."DISPLAYS SUBTOTALS TEXT
endform. " generate_layout_vendor
*& Form generate_sort_vendor
Sorting the Internal Table by Vendor
form generate_sort_vendor.
it_sort-fieldname = 'RZZLIFNR'.
it_sort-tabname = 'IT_FINAL_VENDOR_TEMP'.
it_sort-up = 'X'.
it_sort-subtot = 'X'.
append it_sort.
endform. " generate_sort_vendor
*& Form generate_group_vendor
Grouping the Data
form generate_group_vendor.
clear i_group.
wa_group-sp_group = 'A'.
wa_group-text = 'RZZLIFNR'.
append wa_group to i_group.
endform. " generate_group_vendor
*& Form GENERATE_FIELD_CATALOG_CUST
Generating Field Catalog for Customer
form GENERATE_FIELD_CATALOG_CUST.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = v_repid
I_INTERNAL_TABNAME = 'IT_FINAL_CUSTOMER_TEMP'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = v_repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = i_fldcat_head
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.
if not i_fldcat_head[] is initial.
loop at i_fldcat_head into wa_fldcat_head.
case wa_fldcat_head-fieldname.
when 'RZZKUNNR'.
wa_fldcat_head-col_pos = '1'.
wa_fldcat_head-ref_tabname = ' '.
wa_fldcat_head-seltext_m = 'Customer No'(020).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '12'.
when 'NAME1'.
wa_fldcat_head-col_pos = '2'.
wa_fldcat_head-seltext_m = 'Customer Name'(021).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '35'.
when 'BELNR'.
wa_fldcat_head-col_pos = '3'.
wa_fldcat_head-seltext_m = 'Invoice No'(008).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '12'.
wa_fldcat_head-KEY = ' '.
when 'BLDAT'.
wa_fldcat_head-col_pos = '4'.
wa_fldcat_head-seltext_m = 'Document Date'(009).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '13'.
wa_fldcat_head-ref_tabname = ' '.
when 'RZZ_EBELN'.
wa_fldcat_head-col_pos = '5'.
wa_fldcat_head-seltext_m = 'PO.Ref.No'(010).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '13'.
wa_fldcat_head-ref_tabname = ' '.
when 'HSL'.
wa_fldcat_head-col_pos = '6'.
wa_fldcat_head-seltext_m = 'Invoice Amount'(011).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'DUE_DATE'.
wa_fldcat_head-col_pos = '7'.
wa_fldcat_head-seltext_m = 'Due Date'(012).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '12'.
wa_fldcat_head-ref_tabname = ' '.
when 'DUE_DAYS'.
wa_fldcat_head-col_pos = '8'.
wa_fldcat_head-seltext_m = 'Due Days'(013).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '9'.
when 'NOT_DUE'.
wa_fldcat_head-col_pos = '9'.
wa_fldcat_head-seltext_m = 'Not Due'(014).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_0_30'.
wa_fldcat_head-col_pos = '10'.
wa_fldcat_head-seltext_m = '0 To 30'(015).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_31_60'.
wa_fldcat_head-col_pos = '11'.
wa_fldcat_head-seltext_m = '31 To 60'(016).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_61_90'.
wa_fldcat_head-col_pos = '12'.
wa_fldcat_head-seltext_m = '61 To 90'(017).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_91_180'.
wa_fldcat_head-col_pos = '13'.
wa_fldcat_head-seltext_m = '91 To 180'(018).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_180'.
wa_fldcat_head-col_pos = '14'.
wa_fldcat_head-seltext_m = 'Beyond 180'(019).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'DOCNR'.
wa_fldcat_head-no_out = 'X'.
when 'REFDOCNR'.
wa_fldcat_head-no_out = 'X'.
when 'DOC_DATE'.
wa_fldcat_head-no_out = 'X'.
when 'FOUND'.
wa_fldcat_head-no_out = 'X'.
endcase.
modify i_fldcat_head from wa_fldcat_head index sy-tabix.
endloop.
endif.
endform. " GENERATE_FIELD_CATALOG_CUST
*& Form get_events_customer
Getting ALV Events
form get_events_customer.
call function 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
importing
et_events = i_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.
if not i_events[] is initial.
read table i_events into wa_event with key name = 'TOP_OF_PAGE'(024)
wa_event-form = 'GENERATE_USERCOMMAND_CUST'.
modify i_events from wa_event index sy-tabix.
read table i_events into wa_event with key na -
Create a Procedural ALV Report with editable fields and save the changes
Hi,
I am new to ABAP. I have created a Procedural ALV Report with 3 fields. I want to make 2 fields editable. When executed, if the fields are modified, I want to save the changes. All this I want to do without using OO concepts. Please help . Also, I checked out the forum and also the examples
BCALV_TEST_GRID_EDIT_01
BCALV_TEST_GRID_EDIT_02
BCALV_TEST_GRID_EDIT_04_FORMS
BCALV_TEST_GRID_EDITABLE
BCALV_EDIT_01
BCALV_EDIT_02
BCALV_EDIT_03
BCALV_EDIT_04
BCALV_EDIT_05
BCALV_EDIT_06
BCALV_EDIT_07
BCALV_EDIT_08
BCALV_FULLSCREEN_GRID_EDIT
But all these are using OO Concepts.
Please help.
Regards,
SmruthiTABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) TYPE c, "Used to store row color attributes
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-edit = 'X'
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-info_fieldname = 'LINE_COLOR'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_pf_status_set = 'STATUS'
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
DATA: ld_color(1) TYPE c.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekko.
LOOP AT it_ekko INTO wa_ekko.
ld_color = ld_color + 1.
IF ld_color = 8.
ld_color = 1.
ENDIF.
CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
MODIFY it_ekko FROM wa_ekko.
ENDLOOP.
ENDFORM. " DATA_RETRIEVAL
FORM top-of-page *
FORM top-of-page.
WRITE:/ 'This is First Line of the Page'.
ENDFORM.
FORM status *
FORM status USING rt_extab TYPE slis_t_extab. .
SET PF-STATUS 'ALV'.
ENDFORM.
FORM USER_COMMAND *
--> RF_UCOMM *
--> RS *
FORM user_command USING rf_ucomm LIKE sy-ucomm
rs TYPE slis_selfield.
DATA ref1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref1.
CALL METHOD ref1->check_changed_data.
CASE rf_ucomm.
when 'SAVE'.
get all the modified entries and store them in an internal table and udpate them in to the required transaction or your custom table.
endcase.
endform.
ENDFORM.
here u need to 2 performs for PF status and USER_COMMAND in the ALV parameters.
create a custom PF status and create push buttons and assign your ok codes in your PF status.
if the field has to be edited in the ALV then pass EDIT = 'X' for that field in the fieldcatlog preparation.
Hope this will help you.
Regards,
phani. -
hai
i done alv report with total and subtotal , but the text for the total and subtotal
which iam specified in layout are not displayed in a report.
plz help me..hi,
*& Report Z_REPT_ALV_EX1 *
report ZALV_GEN line-count 36(5)
line-size 225
no standard page heading.
Report name: Puchase Order Report for ALV practice *
Program ID : Z_REPT_ALV_EX1_TG *
Author : ADCDEV ( T G Santosh ) *
Date : Sep 09, 2004 *
*..Type Definitions for ALV Report
type-pools slis.
Tables Declaration
tables : lfa1,
lfb1,
lfm1.
Data Declaration
data : v_lifnr like lfa1-lifnr,
v_bukrs like lfb1-bukrs,
v_ekorg like lfm1-ekorg,
v_ktokk like lfa1-ktokk,
v_repid like sy-repid.
Internal Tables
data : begin of it_details occurs 0,
lifnr like lfa1-lifnr,
bukrs like lfb1-bukrs,
ekorg like lfm1-ekorg,
ktokk like lfa1-ktokk,
name1 like lfa1-name1,
stras like lfa1-stras,
ragio like lfa1-regio,
pfach like lfa1-pfach,
pstl2 like lfa1-pstl2,
pstlz like lfa1-pstlz,
telf1 like lfa1-telf1,
end of it_details.
data: it_fieldcatalog type slis_t_fieldcat_alv,
it_fieldcatalog1 type slis_t_fieldcat_alv,
wa_fieldcatalog type slis_fieldcat_alv,
wa_layout type slis_layout_alv,
it_events type slis_t_event,
wa_events type slis_alv_event,
it_sort type slis_t_sortinfo_alv,
wa_sort type slis_sortinfo_alv occurs 0 with header line.
Initialization
v_repid = sy-repid.
Selecton Screen
selection-screen begin of block blk1 with frame title text-001.
select-options : s_lifnr for lfa1-lifnr,
s_bukrs for lfb1-bukrs,
s_ekorg for lfm1-ekorg,
s_ktokk for lfa1-ktokk.
selection-screen end of block blk1.
selection-screen begin of block blk2 with frame title text-002.
parameter : block radiobutton group g1,
grid radiobutton group g1.
selection-screen end of block blk2.
At Selecton Screen
select single lifnr
from lfa1
into v_lifnr
where lifnr in s_lifnr.
if sy-subrc <> 0.
message i101(zsantosh) with 'v_lifnr' .
write : 'not a valid number', v_lifnr.
else.
select single bukrs
from lfb1
into v_bukrs
where bukrs in s_bukrs.
if sy-subrc <> 0.
message i101(zsantosh) with 'Company Code'.
else.
select single ekorg
from lfm1
into v_ekorg
where ekorg in s_ekorg.
if sy-subrc <> 0.
message i101(zsantosh) with 'Purchasing Organisation'.
else.
select single ktokk
from lfa1
into v_ktokk
where ktokk in s_ktokk.
if sy-subrc <> 0.
message i101(zsantosh) with 'Vendor Group'.
endif.
endif.
endif.
endif.
Start of Selection
start-of-selection.
select a1~lifnr
b1~bukrs
m1~ekorg
a1~ktokk
a1~name1
a1~stras
a1~regio
a1~pfach
a1~pstl2
a1~pstlz
a1~telf1
into table it_details
from lfa1 as a1
join lfb1 as b1 on a1lifnr = b1lifnr
join lfm1 as m1 on a1lifnr = m1lifnr
where a1~lifnr in s_lifnr and
b1~bukrs in s_bukrs and
m1~ekorg in s_ekorg and
a1~ktokk in s_ktokk.
clear wa_sort.
wa_sort-spos = 1.
wa_sort-fieldname = 'LIFNR'.
wa_sort-tabname = 'IT_DETAILS'.
wa_sort-up = 'X'.
append wa_sort to it_sort.
clear wa_sort.
wa_sort-spos = 2.
wa_sort-fieldname = 'BUKRS'.
wa_sort-tabname = 'IT_DETAILS'.
wa_sort-up = 'X'.
append wa_sort to it_sort.
clear wa_sort.
wa_sort-spos = 3.
wa_sort-fieldname = 'EKORG'.
wa_sort-tabname = 'IT_DETAILS'.
wa_sort-up = 'X'.
append wa_sort to it_sort.
End of selection
end-of-selection.
perform fill_fieldcat.
loop at it_fieldcatalog into wa_fieldcatalog.
if wa_fieldcatalog-fieldname = 'RAGIO'.
wa_fieldcatalog-intlen = 2.
wa_fieldcatalog-ref_fieldname = ''.
wa_fieldcatalog-ref_tabname = ''.
wa_fieldcatalog-ddic_outputlen = 2.
endif.
wa_fieldcatalog-ref_fieldname = ''.
wa_fieldcatalog-ref_tabname = ''.
modify it_fieldcatalog from wa_fieldcatalog.
endloop.
perform fill_layout.
if block = 'X'.
perform list_block_display.
elseif grid = 'X'.
perform list_grid_display.
endif.
*& Form FILL_FIELDCAT
text
--> p1 text
<-- p2 text
form fill_fieldcat .
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = v_repid
i_internal_tabname = 'IT_DETAILS'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = v_repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = it_fieldcatalog
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. " FILL_FIELDCAT
*& Form FILL_LAYOUT
text
--> p1 text
<-- p2 text
form fill_layout .
wa_layout-zebra = 'X'.
wa_layout-totals_text = 'TOTAL'.
wa_layout-colwidth_optimize = 'X'.
endform. " FILL_LAYOUT
*& Form list_block_display
text
--> p1 text
<-- p2 text
form list_block_display .
call function 'REUSE_ALV_BLOCK_LIST_INIT'
exporting
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
IT_EXCLUDING =
call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = wa_layout
it_fieldcat = it_fieldcatalog
i_tabname = 'IT_DETAILS'
it_events = it_events
it_sort = it_sort
I_TEXT = ' '
tables
t_outtab = it_details
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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " list_block_display
*& Form LIST_GRID_DISPLAY
text
--> p1 text
<-- p2 text
form list_grid_display .
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 = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
i_structure_name = 'IT_DETAILS'
I_BACKGROUND_ID = ' '
i_grid_title = 'DETAILS IN GRID DISPLAY'
I_GRID_SETTINGS =
is_layout = wa_layout
it_fieldcat = it_fieldcatalog
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = it_sort
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = it_details
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. " LIST_GRID_DISPLAY
regards,
deepthi reddy -
ALV totals row ,should not download in EXCEL
Hello ,
I have developed a ALV report with subtotals.
In the output, it will display an extra row with the Grand total, but when we try to downalod into Local PC excel file,
it is downlaoding the totals row also. But the requirement is not to download that.
Any option is there to not to downlad that row ?
Let me know if anything needed.
Thanks,
AVHi,
I will suggest one thing.
<li>Define layout structure
DATA: wa_layout type SLIS_LAYOUT_ALV.
<li>One checkbox on selection-screen for with or without total line.
PARAMETERS: p_check AS CHECKBOX.
<li>Now set the below on based on checkbox value
IF p_check = 'X'. "Lets say without total line.
wa_layout-no_totalline = 'X'.
ENDIF.
<li>Now pass wa_layout through REUSE* function module.
Thanks
Venkat.O -
Print or download ALV report with sort options
Dear friends,
How i can download into excel or print ALV report with sort options, like customer name column with similar values should not repeat in the print out or download file.
Regards,
Praveen LoboHi Praveen,
Use this code, its working:-
*FOR SORTING DATA
DATA : it_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv.
* SORT W.R.T. CUSTOMER NAME
wa_sort-spos = 1.
wa_sort-fieldname = 'NAME1'. "field customer name
wa_sort-tabname = 'IT_KNA1'. "internal table with records
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
"this will sort the ALV o/p for customer with same name
"now the name will not be repeated
"records with same name will be grouped
* DISPLAY RECORDS IN ALV GRID
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid "report id
it_fieldcat = it_field "field catalog
it_sort = it_sort "sort info
TABLES
t_outtab = it_kna1 "internal table
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
Hope this solves your problem.
Thanks & Regards,
Tarun Gambhir
Edited by: Tarun Gambhir on Dec 31, 2008 1:13 PM -
ALV Grid with rows sticked together
Hi,
Is there any chance to get two <b>rows</b> of an ALV grid sticked together.
This means if the user selects the first row, the second one is automatically selected too. On the other hand, selecting the second row should select the first too.
This also applies if the users deletes one of the two rows.
Using FM REUSE_ALV_GRID_DISPLAY btw. and grouping is not useful in this case.
Thanks,
MichaelHello,
I am not sure if that could be done dynamically however what can be done is when he selects some row and tries to process an event you can check whether the other row is ticked and then pop up a message asking the user the other row will also be selected does he want to proceed with his event of deletion.
So for eg..
*Function Call for ALV List Display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_pf_status_set = 'F_PF_ALV_100'
i_callback_user_command = 'F_USER_COMMAND_2A'
it_fieldcat = i_fieldcat[]
i_save = 'A'
TABLES
t_outtab = i_inci
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.
and then in the call back user command routine
FORM f_user_command_2a USING wa_ucomm TYPE sy-ucomm
wa_selfield TYPE slis_selfield.
CASE wa_ucomm.
WHEN 'DELETE'.
pop up a dialog box and notify this line will also be selected and delete do you want to proceed... yes delete both lines no... deselect the earlier line... i hope you are using a checkbox in alv...
Regards,
Shekhar Kulkarni -
HOW TO USE OOBJECT ORIENTD ALV INSTED OF REUSE_ALV_GRID_DISPLAY
Pls help me to implement the object oriented ALV Insted of REUSE_ALV_GRID_DISPLAY.
Pls find the report below its working fine but we want the OBJECT ORIENTD ALV.
THNAKS
TYPE-POOLS: slis. " ALV Global types
tables:pa0001,
pa0315,
pa0007,
disvariant.
Selection-Screen
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
*SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: s_pernr FOR pa0001-pernr OBLIGATORY
. " Personnel No
SELECT-OPTIONS: s_orgeh FOR pa0001-orgeh . " Organization unit
SELECT-OPTIONS: s_werks FOR pa0001-werks. " Personnel Area
SELECT-OPTIONS: s_plans FOR pa0001-plans. " Position
SELECT-OPTIONS: s_ebeln FOR pa0315-ebeln. " Purchase order
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK b2k2 WITH FRAME TITLE text-002.
*SELECT-OPTIONS: s_var FOR disvariant-variant.
PARAMETERS: p_disva1 LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK b2k2.
Type Definition *
TYPES :
BEGIN OF ty_pa0001_pa0002,
pernr TYPE pa0001-pernr , " Personnel no.
endda TYPE pa0001-endda , " end date
begda TYPE pa0001-begda , " start date
bukrs TYPE pa0001-bukrs , " company code
werks TYPE pa0001-werks , " Personnnel area
persg TYPE pa0001-persg , " Employee group
persk TYPE pa0001-persk , " Employee subgroup
btrtl TYPE pa0001-btrtl , " Personnnel subarea
abkrs TYPE pa0001-abkrs , " Payroll area
kostl TYPE pa0001-kostl , " cost center
orgeh TYPE pa0001-orgeh , " Organizational Unit
plans TYPE pa0001-plans , " Position
nachn TYPE pa0002-nachn , " Last name
vorna TYPE pa0002-vorna , " First name
midnm TYPE pa0002-midnm , " Middle name
END OF ty_pa0001_pa0002 ,
BEGIN OF ty_pa0315,
pernr TYPE pa0315-pernr , " Personnel no.
kostl TYPE pa0315-kostl , " Sending cost center
lstar TYPE pa0315-lstar , " Activity type
werks TYPE pa0315-werks , " Plant
lifnr TYPE pa0315-lifnr , " Vendor number
ebeln TYPE pa0315-ebeln , " Sending pruchase ord
ebelp TYPE pa0315-ebelp , " Sending PO item
lstnr TYPE pa0315-lstnr , " Activity number
END OF ty_pa0315,
BEGIN OF ty_pa0007,
pernr TYPE pa0007-pernr,
schkz TYPE pa0007-schkz,
END OF ty_pa0007,
BEGIN OF ty_t527x,
orgeh TYPE t527x-orgeh,
orgtx TYPE t527x-orgtx,
END OF ty_t527x,
BEGIN OF ty_t528t,
plans TYPE t528t-plans,
plstx TYPE t528t-plstx,
END OF ty_t528t,
BEGIN OF ty_final,
pernr TYPE pa0001-pernr , " Personnel no.
nachn TYPE pa0002-nachn , " Last name
vorna TYPE pa0002-vorna , " First name
midnm TYPE pa0002-midnm , " Middle name
bukrs TYPE pa0001-bukrs , " company code
werks TYPE pa0001-werks , " Personnnel area
persg TYPE pa0001-persg , " Employee group
persk TYPE pa0001-persk , " Employee subgroup
btrtl TYPE pa0001-btrtl , " Personnnel subarea
abkrs TYPE pa0001-abkrs , " Payroll area
kostl TYPE pa0001-kostl , " cost center
orgeh TYPE pa0001-orgeh , " Organizational Unit
orgtx TYPE t527x-orgtx , " Organizational text
plans TYPE pa0001-plans , " Position
plstx TYPE t528t-plstx , " Position text
schkz TYPE pa0007-schkz , " Work schedule rule
kostl TYPE pa0315-kostl , " Sending cost center
lstar TYPE pa0315-lstar , " Activity type
werks_p TYPE pa0315-werks , " Plant
lifnr TYPE pa0315-lifnr , " Vendor number
ebeln TYPE pa0315-ebeln , " Sending pruchase ord
ebelp TYPE pa0315-ebelp , " Sending PO item
lstnr TYPE pa0315-lstnr , " Activity number
begda TYPE pa0001-begda , " start date
endda TYPE pa0001-endda , " end date
END OF ty_final.
Data Declaration *
DATA :
t_pa0001_pa0002 TYPE STANDARD TABLE OF ty_pa0001_pa0002 ,
w_pa0001_pa0002 TYPE ty_pa0001_pa0002 ,
t_pa0315 TYPE STANDARD TABLE OF ty_pa0315 ,
w_pa0315 TYPE ty_pa0315 ,
t_pa0007 TYPE STANDARD TABLE OF ty_pa0007 ,
w_pa0007 TYPE ty_pa0007 ,
t_t527x TYPE STANDARD TABLE OF ty_t527x ,
w_t527x TYPE ty_t527x ,
t_t528t TYPE STANDARD TABLE OF ty_t528t ,
w_t528t TYPE ty_t528t ,
t_final TYPE STANDARD TABLE OF ty_final ,
w_final TYPE ty_final .
START-OF-SELECTION .
SELECT a~pernr
a~endda
a~begda
a~bukrs
a~werks
a~persg
a~persk
a~btrtl
a~abkrs
a~kostl
a~orgeh
a~plans
b~nachn
b~vorna
b~midnm
INTO TABLE t_pa0001_pa0002
FROM pa0001 AS a INNER JOIN pa0002 AS b
ON apernr = bpernr
WHERE a~pernr IN s_pernr
AND a~werks IN s_werks
AND a~orgeh IN s_orgeh
AND a~plans IN s_plans.
SORT t_pa0001_pa0002 BY pernr .
IF NOT t_pa0001_pa0002[] IS INITIAL .
SELECT pernr
kostl
lstar
werks
lifnr
ebeln
ebelp
lstnr
FROM pa0315
INTO TABLE t_pa0315
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE pernr = t_pa0001_pa0002-pernr
AND kostl = t_pa0001_pa0002-kostl
AND ebeln IN s_ebeln.
SELECT pernr
schkz
FROM pa0007
INTO TABLE t_pa0007
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE pernr = t_pa0001_pa0002-pernr.
SELECT orgeh
orgtx
FROM t527x
INTO TABLE t_t527x
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE orgeh = t_pa0001_pa0002-orgeh.
SELECT plans
plstx
FROM t528t
INTO TABLE t_t528t
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE plans = t_pa0001_pa0002-plans.
ENDIF.
Merging data of t_pa0001_pa0002,t_pa0315 & t_pa0007 into t_final.
LOOP AT t_pa0001_pa0002 INTO w_pa0001_pa0002 .
MOVE-CORRESPONDING w_pa0001_pa0002 TO w_final.
READ TABLE t_pa0315 INTO w_pa0315 WITH KEY pernr =
w_pa0001_pa0002-pernr
kostl = w_pa0001_pa0002-kostl.
IF sy-subrc = 0.
w_final-kostl = w_pa0315-kostl.
w_final-lstar = w_pa0315-lstar.
w_final-werks_p = w_pa0315-werks.
w_final-lifnr = w_pa0315-lifnr.
w_final-ebeln = w_pa0315-ebeln.
w_final-ebelp = w_pa0315-ebelp.
w_final-lstnr = w_pa0315-lstnr.
ENDIF.
READ TABLE t_pa0007 INTO w_pa0007 WITH KEY pernr =
w_pa0001_pa0002-pernr.
IF sy-subrc = 0.
w_final-schkz = w_pa0007-schkz.
ENDIF.
READ TABLE t_t527x INTO w_t527x WITH KEY orgeh = w_pa0001_pa0002-orgeh
IF sy-subrc = 0.
w_final-orgtx = w_t527x-orgtx.
ENDIF.
READ TABLE t_t528t INTO w_t528t WITH KEY plans =
w_pa0001_pa0002-plans.
IF sy-subrc = 0.
w_final-plstx = w_t528t-plstx.
ENDIF.
APPEND w_final to t_final.
ENDLOOP.
PERFORM f_display_data.
FORM f_display_data.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
Build the field catalog
m_fieldcat 'PERNR' 'PA0001'.
m_fieldcat 'NACHN' 'PA0002'.
m_fieldcat 'VORNA' 'PA0002'.
m_fieldcat 'MIDNM' 'PA0002'.
m_fieldcat 'BUKRS' 'PA0001'.
m_fieldcat 'WERKS' 'PA0001'.
m_fieldcat 'PERSG' 'PA0001'.
m_fieldcat 'PERSK' 'PA0001'.
m_fieldcat 'BTRTL' 'PA0001'.
m_fieldcat 'ABKRS' 'PA0001'.
m_fieldcat 'ORGEH' 'PA0001'.
m_fieldcat 'ORGTX' 'T527X'.
m_fieldcat 'PLANS' 'PA0001'.
m_fieldcat 'PLSTX' 'T528T'.
m_fieldcat 'SCHKZ' 'PA0007'.
m_fieldcat 'KOSTL' 'PA0315'.
m_fieldcat 'LSTAR' 'PA0315'.
m_fieldcat 'WERKS' 'PA0315'.
m_fieldcat 'LIFNR' 'PA0315'.
m_fieldcat 'EBELN' 'PA0315'.
m_fieldcat 'EBELP' 'PA0315'.
m_fieldcat 'LSTNR' 'PA0315'.
m_fieldcat 'BEGDA' 'PA0001'.
m_fieldcat 'ENDDA' 'PA0001'.
ls_fieldcat-col_pos = '1'.
ls_fieldcat-fieldname = 'PERNR'.
ls_fieldcat-tabname = 't_FINAL'.
*ls_fieldcat-rollname = 'PERNR'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '2'.
ls_fieldcat-fieldname = 'NACHN'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0002'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '3'.
ls_fieldcat-fieldname = 'VORNA'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0002'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '4'.
ls_fieldcat-fieldname = 'MIDNM'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0002'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '5'.
ls_fieldcat-fieldname = 'BUKRS'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '6'.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '7'.
ls_fieldcat-fieldname = 'PERSG'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '8'.
ls_fieldcat-fieldname = 'PERSK'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '9'.
ls_fieldcat-fieldname = 'BTRTL'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '10'.
ls_fieldcat-fieldname = 'ABKRS'.
ls_fieldcat-tabname = 'T_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '11'.
ls_fieldcat-fieldname = 'ORGEH'.
ls_fieldcat-tabname = 'T_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '12'.
ls_fieldcat-fieldname = 'ORGTX'.
ls_fieldcat-tabname = 'T_FINAL'.
ls_fieldcat-ref_tabname = 'T527X'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '13'.
ls_fieldcat-fieldname = 'PLANS'.
ls_fieldcat-tabname = 'T_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '14'.
ls_fieldcat-fieldname = 'PLSTX'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'T528T'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '15'.
ls_fieldcat-fieldname = 'SCHKZ'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0007'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '16'.
ls_fieldcat-fieldname = 'KOSTL'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '17'.
ls_fieldcat-fieldname = 'LSTAR'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '18'.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '19'.
ls_fieldcat-fieldname = 'LIFNR'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '20'.
ls_fieldcat-fieldname = 'EBELN'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '21'.
ls_fieldcat-fieldname = 'EBELP'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '22'.
ls_fieldcat-fieldname = 'LSTNR'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '23'.
ls_fieldcat-fieldname = 'BEGDA'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '24'.
ls_fieldcat-fieldname = 'ENDDA'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
*DATA: v_repid TYPE sy-repid.
v_repid = sy-repid.
*Display the list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_program = v_repid
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = lt_fieldcat
TABLES
t_outtab = t_final.
ENDFORM. " F_DISPLAY_DATAHi,
<b>Sample programs on ALV Grid</b>
report zbnstest.
* TABLES AND DATA DECLARATION.
*TABLES: mara,makt.",marc.
data syrepid like sy-repid.
data sydatum(10). " LIKE sy-datum.
data sypagno(3) type n.
* WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
* GROUP (TYPE-POOLS--------->SLIS)
type-pools : slis.
* INTERNAL TABLE DECLARATION.
* INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
data: begin of t_mara occurs 0,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
matkl like mara-matkl,
end of t_mara.
* INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
data : begin of t_marc occurs 0,
matnr like mara-matnr,
werks like marc-werks,
minbe like marc-minbe.
data: end of t_marc.
* INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
data : begin of t_makt occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
spras like makt-spras,
end of t_makt.
* INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
data: begin of itab1 occurs 0,
matnr like mara-matnr,
meins like mara-meins,
maktx like makt-maktx,
spras like makt-spras,
werks like marc-werks,
minbe like marc-minbe,
end of itab1.
* THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
* AND THE LAYOUT FOR THE ALV.
* HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
* WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
* OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
* THIS IS DONE TO MAKE THE CODE SIMPLER.
* OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
* PROGRAMS.
* IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
* MORE TABLES AND CREATE A STRUCTURE
* IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
* LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
fieldlayout type slis_layout_alv.
* DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
* TOP-OF-PAGE ETC.
data : eventstab type slis_t_event with header line.
* DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
data : heading type slis_t_listheader with header line.
data : heading1 type slis_t_listheader with header line.
data : heading2 type slis_t_listheader with header line.
data : heading3 type slis_t_listheader with header line.
data : heading4 type slis_t_listheader with header line.
data : heading5 type slis_t_listheader with header line.
data : heading6 type slis_t_listheader with header line.
data : heading7 type slis_t_listheader with header line.
data : heading8 type slis_t_listheader with header line.
* STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
data : colorstruct type slis_coltypes.
* INITIALIZATION. *
initialization.
syrepid = sy-repid.
sypagno = sy-pagno.
clear fieldcatalog.
* START-OF-SELECTION. *
start-of-selection.
* SUBROUTINE TO POPULATE THE COLORSTRUCT
perform fill_colorstruct using colorstruct.
* SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
perform populate_fieldcatalog.
* SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
* INTERNAL TABLE.
perform selectdata_and_sort.
* SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
perform populate_layout using fieldlayout.
* SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
perform merge_fieldcatalog.
* SUBROUTINE TO POPULATE THE EVENTSTAB.
perform fill_eventstab tables eventstab.
* SUBROUTINE TO POPULATE THE HEADING TABLES.
perform fill_headingtable tables heading using 'HEADING'.
perform fill_headingtable tables heading1 using 'HEADING1'.
perform fill_headingtable tables heading2 using 'HEADING2'.
perform fill_headingtable tables heading3 using 'HEADING3'.
perform fill_headingtable tables heading4 using 'HEADING4'.
perform fill_headingtable tables heading5 using 'HEADING5'.
perform fill_headingtable tables heading6 using 'HEADING6'.
perform fill_headingtable tables heading7 using 'HEADING7'.
perform fill_headingtable tables heading8 using 'HEADING8'.
* SUBROUTINE TO DISPLAY THE LIST.
perform display_alv_list.
* FORMS
* IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
* OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
* COLUMN JUSTIFICATION.
form populate_fieldcatalog.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATNR' 'X' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MEINS' ' '.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MAKTX' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MTART' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATKL' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'SPRAS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'WERKS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MINBE' ' ' .
endform. " POPULATE_FIELDCATALOG
* FORM FILL_FIELDS_OF_FIELDCATALOG *
* --> FIELDCATALOG *
* --> P_TABNAME *
* --> P_FIELDNAME *
* --> P_KEY *
* --> P_KEY *
form fill_fields_of_fieldcatalog tables fieldcatalog
structure fieldcatalog
using p_tabname
p_fieldname
p_key.
* p_no_out.
fieldcatalog-tabname = p_tabname.
fieldcatalog-fieldname = p_fieldname.
fieldcatalog-key = p_key.
fieldcatalog-emphasize = '1234'.
*fieldcatalog-no_out = p_no_out.
append fieldcatalog.
endform. " FILL_FIELDSOFFIELDCATALOG
* FORM POPULATE_LAYOUT *
* --> FIELDLAYOUT *
form populate_layout using fieldlayout type slis_layout_alv.
fieldlayout-f2code = '&ETA' .
fieldlayout-zebra = 'X'.
* FOR THE WINDOW TITLE.
fieldlayout-window_titlebar = 'ALV with Events'.
fieldlayout-colwidth_optimize = 'X'.
fieldlayout-no_vline = ' '.
*fieldlayout-no_input = 'X'.
fieldlayout-confirmation_prompt = ''.
fieldlayout-key_hotspot = 'X'.
* This removes the column headings if the flag is set to 'X'
fieldlayout-no_colhead = ' '.
*fieldlayout-hotspot_fieldname = 'MAKTX'.
fieldlayout-detail_popup = 'X'.
* fieldlayout-coltab_fieldname = 'X'.
endform. " POPULATE_LAYOUT
* FORM SELECTDATA_AND_SORT *
form selectdata_and_sort.
select matnr meins mtart matkl from mara
into corresponding fields of t_mara
up to 500 rows .
select matnr maktx spras from makt
into corresponding fields of t_makt
where matnr = t_mara-matnr and
spras = sy-langu.
select matnr werks minbe from marc
into corresponding fields of t_marc
where matnr = t_mara-matnr.
append t_marc.
endselect.
append t_makt.
endselect.
append t_mara.
endselect.
perform populate_itab1.
sort itab1 by matnr.
endform. " SELECTDATA_AND_SORT
* FORM MERGE_FIELDCATALOG *
form merge_fieldcatalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = syrepid
i_internal_tabname = 'ITAB1'
* i_structure_name = 'COLORSTRUCT'
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = syrepid
changing
ct_fieldcat = fieldcatalog[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
endform. " MERGE_FIELDCATALOG
* IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
* FOLLOWS:-
* i_callback_program --> CALLING PROGRAM NAME
* i_structure_name --> STRUCTURE NAME.
* is_layout --> LAYOUT NAME.
* it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
form display_alv_list.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
* I_INTERFACE_CHECK = ' '
i_callback_program = syrepid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
i_structure_name = 'ITAB1'
is_layout = fieldlayout
it_fieldcat = fieldcatalog[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
* TOOL BAR
i_save = 'A'
* IS_VARIANT = ' '
it_events = eventstab[]
* IT_EVENT_EXIT =
* 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 =
tables
t_outtab = itab1
exceptions
program_error = 1
others = 2.
endform. " DISPLAY_ALV_LIST
*& Form POPULATE_ITAB1
* text
* --> p1 text
* <-- p2 text
form populate_itab1.
loop at t_mara.
loop at t_makt where matnr = t_mara-matnr.
loop at t_marc where matnr = t_mara-matnr.
move-corresponding t_mara to itab1.
move-corresponding t_makt to itab1.
move-corresponding t_marc to itab1.
append itab1.
endloop.
endloop.
endloop.
endform. " POPULATE_ITAB1
*& Form FILL_EVENTSTAB
* text
* -->P_EVENTSTAB text *
form fill_eventstab tables p_eventstab structure eventstab.
* WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
* INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
* AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
* EVENTS NAME.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_eventstab[]
exceptions
list_type_wrong = 1
others = 2.
* BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
* THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
* WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
* FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
* IS DYNAMICALY CALLED.
read table p_eventstab with key name = slis_ev_top_of_page.
if sy-subrc = 0 .
move 'TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_coverpage.
if sy-subrc = 0 .
move 'TOP_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_coverpage .
if sy-subrc = 0 .
move 'END_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_top_of_page.
if sy-subrc = 0 .
move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_end_of_page.
if sy-subrc = 0 .
move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_list_modify.
if sy-subrc = 0 .
move 'LIST_MODIFY' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_list.
if sy-subrc = 0 .
move 'TOP_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_page.
if sy-subrc = 0 .
move 'END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_list .
if sy-subrc = 0 .
move 'END_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
endform. " FILL_EVENTSTAB
*& Form FILL_HEADINGTABLE
* text
* -->P_HEADING text *
form fill_headingtable tables p_heading structure heading
using tablename.
case tablename.
when 'HEADING'.
p_heading-typ = 'H'.
concatenate
' REPORT NAME:-' syrepid
' ABB Industry Pte Ltd' into p_heading-info.
append p_heading.
write sy-datum using edit mask '__/__/____' to sydatum.
concatenate
' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
into p_heading-info.
append p_heading.
when 'HEADING1'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-COVER-PAGE'.
append p_heading.
when 'HEADING2'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-COVER-PAGE'.
append p_heading.
when 'HEADING3'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
append p_heading.
when 'HEADING4'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-END-OF-PAGE'.
append p_heading.
* WHEN 'HEADING5'.
* P_HEADING-TYP = 'H'.
* P_HEADING-INFO = 'LIST-MODIFY'.
* APPEND P_HEADING.
when 'HEADING6'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-PAGE'.
append p_heading.
when 'HEADING7'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-LIST'.
append p_heading.
when 'HEADING8'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-LIST'.
append p_heading.
endcase.
endform. " FILL_HEADINGTABLE
* FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading[]
exceptions
others = 1.
endform.
*& Form FILL_COLORSTRUCT
* text
* -->P_COLORSTRUCT text *
form fill_colorstruct using p_colorstruct type slis_coltypes .
p_colorstruct-heacolfir-col = 6.
p_colorstruct-heacolfir-int = 1.
p_colorstruct-heacolfir-inv = 1.
endform. " FILL_COLORSTRUCT
* FORM TOP_OF_COVERPAGE *
form top_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading1[]
exceptions
others = 1.
endform.
* FORM END_OF_COVERPAGE *
form end_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading2[]
exceptions
others = 1.
endform.
* FORM FOREIGN_TOP_OF_PAGE *
form foreign_top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading3[]
exceptions
others = 1.
endform.
* FORM FOREIGN_END_OF_PAGE *
form foreign_end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading4[]
exceptions
others = 1.
endform.
* FORM LIST_MODIFY *
*FORM LIST_MODIFY.
* CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
* EXPORTING
* IT_LIST_COMMENTARY = HEADING5[]
* EXCEPTIONS
* OTHERS = 1.
*ENDFORM.
* FORM END_OF_PAGE *
form end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading6[]
exceptions
others = 1.
endform.
* FORM END_OF_LIST *
form end_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading7[]
exceptions
others = 1.
endform.
* FORM TOP_OF_LIST *
form top_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading8[]
exceptions
others = 1.
endform.
*--- End of Program
Regards
Sudheer -
OO ALV grid with a header line is this possible?
Howdy!
I have a requirement where I need to produce an ALV grid with the following format:
<b>Text 1 Text 2 Text 3 Text 4
Text 6
Col_1 Col_2 Col_3 Col_4 Col_5 Col_6 Col_7 Col_8 Col_9
Cell conents -
Cell conents -
Cell conents -
Cell conents -
Cell conents -
</b>
Anyone got any idea on how to get the 'TEXT' fields into the ALV grid? These are dynamic texts that would basically display details of data entered in the selection screen.
The ALV title line is limited to 70 characters and I can't think of another way of doing this.
The texts need to appear on the ALV grid becasue the user would like to download them to Excel in addition to the ALV cell contents using the standard ALV functionality.
Any ideas would be appreciated!
Message was edited by: RobertI'm thinking that this may not work because it is not a full screen grid and the grid container does not care about the container on top of it so, it most likely would not print it. Implement this example program, you can see how this would work for you if you were using the FM.
report zrich_0001
no standard page heading.
* Global ALV Data Declarations
type-pools slis.
data: begin of i_alv occurs 0,
matnr type mara-matnr,
end of i_alv.
* Miscellanous Data Declarations
data: fieldcat type slis_t_fieldcat_alv,
events type slis_t_event,
list_top_of_page type slis_t_listheader,
top_of_page type slis_formname value 'TOP_OF_PAGE'.
start-of-selection.
perform initialization.
perform get_data.
perform call_alv.
end-of-selection.
* Form Initialization
form initialization.
clear i_alv. refresh i_alv.
perform eventtab_build using events[].
endform.
* Form Get_Data
form get_data.
select matnr into table i_alv
from mara up to 100 rows.
endform.
* CALL_ALV
form call_alv.
data: variant type disvariant.
data: repid type sy-repid.
repid = sy-repid.
variant-report = sy-repid.
variant-username = sy-uname.
perform build_field_catalog.
perform comment_build using list_top_of_page[].
* Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
i_callback_program = repid
is_variant = variant
it_events = events[]
i_save = 'U'
tables
t_outtab = i_alv.
endform.
* EVENTTAB_BUILD
form eventtab_build using events type slis_t_event.
* Registration of events to happen during list display
data: tmp_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = events.
read table events with key name = slis_ev_top_of_page
into tmp_event.
if sy-subrc = 0.
move top_of_page to tmp_event-form.
append tmp_event to events.
endif.
endform.
* BUILD_FIELD_CATALOG
form build_field_catalog.
clear: fieldcat. refresh: fieldcat.
data: tmp_fc type slis_fieldcat_alv.
tmp_fc-reptext_ddic = 'Material'.
tmp_fc-fieldname = 'MATNR'.
tmp_fc-tabname = 'I_ALV'.
tmp_fc-outputlen = 18.
append tmp_fc to fieldcat.
endform.
* COMMENT_BUILD
form comment_build using list_top_of_page type
slis_t_listheader.
data: tmp_line type slis_listheader.
clear tmp_line.
tmp_line-typ = 'H'.
tmp_line-info = 'Here is a line of text'.
append tmp_line to list_top_of_page.
clear tmp_line.
tmp_line-typ = 'S'.
tmp_line-key = 'Key1'.
tmp_line-info = 'Here is a value'.
append tmp_line to list_top_of_page.
clear tmp_line.
tmp_line-typ = 'S'.
tmp_line-key = 'Key2'.
tmp_line-info = 'Here is another value'.
append tmp_line to list_top_of_page.
endform.
* TOP_OF_PAGE
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = list_top_of_page.
endform.
Regards,
Rich Heilman -
Hi All,
How to display Totals and Sub Totals in ALV Report using REUSE_ALV_GRID_DISPLAY with Field Symbol
Please find the below link for source code of the program
http://www.sapfans.com/forums/viewtopic.php?f=13&t=357372
Please do the needful
Thanks in Advance
Sekhar
Locking this thread, as you have already opened another post with the same topic.
Edited by: Vijay Babu Dudla on Jan 9, 2012 8:40 AMHi,
We can get the sum of the columns by customizing the field catalog. If we make DO_SUM = 'X' for a field in field catalog, its sum is displayed in ALV output.
These totals will not be stored in any variables. If we want to calculate percentage, we have to write code to calculate the sum and calculate percentage. We can display the total in the event <b>END_OF_LIST </b> .
Regards,
Sailaja. -
ALV dynamic with deep structure
Hi All,
I need to program an ALV Report with a deep structure based on a outbound proxy structure, so I should pass to ALV function or ALV Method a dynamic table and a dynamic structure.
I tried to do it but I got a dump using this function module REUSE_ALV_GRID_DISPLAY with these parameters: STRUCTURE_NAME and T_OUTTAB.
Please, some suggestions about this.
Thanks in advance.
Alexis.Hi Vasanth
this is my example:
DATA: tl_proxy TYPE TABLE OF zpidt_operacion.
DATA: sl_proxy TYPE zpidt_operacion.
sl_proxy-dt_operacion-dt_cab_operacion-vkorg = '0001'.
APPEND sl_proxy TO tl_proxy.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = 'ZPIDT_OPERACION'
TABLES
t_outtab = tl_proxy
EXCEPTIONS
program_error = 1
OTHERS = 2.
Please, could you tell me how I have to do it.
Thanks,
Alexis. -
ALV Hierarchical With multiple boxes
Hello.
I have an alv hierarchical with multiple boxes.
Can I insert a buttom in Gui status of alv that allows me to expand all the boxes of hierarchy?
Regards
AngelaHi Narendra,
Try this program:
TABLES : sflight.
TYPE-POOLS: slis.
DATA : w_repid LIKE sy-repid.
w_repid = sy-repid.
DATA: BEGIN OF it_sflight OCCURS 0,
checkbox(1),
carrid LIKE sflight-carrid,
END OF it_sflight.
*layout
DATA: wa_layout TYPE slis_layout_alv.
*field catalog
DATA: it_fieldcatalog TYPE slis_t_fieldcat_alv,
wa_fieldcatalog TYPE slis_fieldcat_alv.
START-OF-SELECTION.
SELECT carrid FROM sflight
INTO CORRESPONDING FIELDS OF TABLE it_sflight.
END-OF-SELECTION.
CLEAR it_fieldcatalog.
REFRESH it_fieldcatalog.
wa_fieldcatalog-fieldname = 'CHECKBOX'.
wa_fieldcatalog-outputlen = '3'.
wa_fieldcatalog-col_pos = '1'.
wa_fieldcatalog-seltext_m = 'Chk'.
wa_fieldcatalog-checkbox = 'X'.
wa_fieldcatalog-edit = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'CARRID'.
wa_fieldcatalog-outputlen = '10'.
wa_fieldcatalog-col_pos = '2'.
wa_fieldcatalog-seltext_m = 'Carrid'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
is_layout = wa_layout
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = it_fieldcatalog
TABLES
t_outtab = it_sflight
EXCEPTIONS
program_error = 1
OTHERS = 2.
*& Form USER_COMMAND
FORM user_command USING p_ucomm TYPE sy-ucomm
p_selfld TYPE slis_selfield.
CASE p_ucomm.
WHEN '&DATA_SAVE'.
DATA ref1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref1.
CALL METHOD ref1->check_changed_data.
LOOP AT it_sflight WHERE checkbox = 'X'.
DELETE it_sflight INDEX sy-tabix.
ENDLOOP.
p_selfld-refresh = 'X'.
ENDCASE.
ENDFORM. "user_command
Hope this helps you.
Regards,
Chandra Sekhar
Maybe you are looking for
-
Can I hide the set time in the event boxes in Week View?
Can I hide the set time in the event boxes in the Week View?
-
I bought IPROXIFY throught APP STORE and it does not work. I contacted the creator and he has not answered. How can I get my money back? and please take him down of your page as we (users) think that we are buying products that worked backed up by MA
-
ITunes won't stop creating duplicates and triplicates in my library!
My issue is that iTunes is creating duplicates of my songs. Over and over and over again. I have the preferences set so that it is saving everything in one folder, etc. It still happens. In fact, not only are there duplicates, there are 4 and 5 copie
-
Explorer hang & right click hour glass
Windows SErver 2012 R2 terminal server. All clients having the same issue. When right clicking an icon on the desktop to bring up menu (cut, copy, paste, etc.) or right clicking from Explorer the system goes to an hour glass. I have downloaded and ra
-
My MacBook Pro is slow, activity monitor says crash report using CPU
Hi, my MacBook Pro is running very slow. My activity monitor says high CPU usage by crash report. When i look at the system log MediaTek.winmax appears repeatedly with the word bug close by. I am not so good with computers (got this far by searching