How Alternate rows to be colored in an ALV Grid report?
How Alternate rows to be colored in an ALV Grid report?
hi,
try this
TABLES: 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.
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.
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-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-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
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form 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.
*Populate field with color attributes
LOOP AT it_ekko INTO wa_ekko.
Populate color variable with colour properties
Char 1 = C (This is a color property)
Char 2 = 3 (Color codes: 1 - 7)
Char 3 = Intensified on/off ( 1 or 0 )
Char 4 = Inverse display on/off ( 1 or 0 )
i.e. wa_ekko-line_color = 'C410'
ld_color = ld_color + 1.
Only 7 colours so need to reset color value
IF ld_color = 8.
ld_color = 1.
ENDIF.
CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
wa_ekko-line_color = 'C410'.
MODIFY it_ekko FROM wa_ekko.
ENDLOOP.
ENDFORM. " DATA_RETRIEVAL
Similar Messages
-
How to show alternate rows in different colors?
How to show alternate rows in different colors?
Thanksyou should put these kind of stmt in the if condition for even row and odd row
<xsl:attribute xdofo:ctx="block" name="background-color">yellow</xsl:attribute>
this should help you
Re: About highlight row
http://blogs.oracle.com/xmlpublisher/2007/08/09
http://garethroberts.blogspot.com/2007/09/bi-publisher-color-list-and-cell.html -
Query result Alternate row with different color
hello
can anyone help me on a query result.
i wish to have a :
query result Alternate row with different color .
ex.
first row light grey
second row darker grey.
and repeats itself up to the last record/row.
thanks<tr> <!------------------------------I replaced with
<tr bgcolor="<cfif currentrow mod
2>##D3D3D3<cfelse>##F5F5F5</cfif>">
<td>
#MYARRAY[x][2].CNO#
</td>
<td align="center">
#MYARRAY[x][2].CDCDTt#
</td>
<td>
#MYARRAY[x][2].PADESC#
</td>
<td align="center">
#MYARRAY[x][2].INc#
</td>
<td align="center">
#MYARRAY[x][2].Exp#
</td>
<cfset thirdArray = MYARRAY[x][3]>
<cfif NOT arraylen(thirdArray)>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<cfelse>
<cfloop index="z" from="1" to="3">
<cfif z GT arraylen(thirdArray)>
<td> </td>
<td> </td>
<cfelse>
<td>
#thirdArray[z][2]#
</td>
<td>
#thirdArray[z][3]#
</td>
</cfif>
</cfloop>
<cfif arrayLen(thirdArray) gt 3>
<td nowrap="nowrap">
<cfloop index="z" from="4" to="#arraylen(thirdArray)#">
#thirdArray[z][2]# - #thirdArray[z][3]#<BR />
</cfloop>
</td>
</cfif>
</cfif>
</tr>
I got this error.
Variable CURRENTROW is undefined -
How to get the alv grid report in another screen when double click on basic
Hi.
I have created an alv report using class cl_gui_alv_grid.I got another report in the same screen,when double clicked on basic list(using double_click event).I want to get this report in another screen.What i have to do?(In classical reports i worked with sy-lsind = 1 ,but how to do here?)
How to set color to the selected rows in the alv grid report?I worked with change_data_from_inside method of cl_gui_alv_grid.But it didn't work out..
With Regards,
Ramana.On double click event . you will have to call another screen say 9000.
now within screen 900 PBO.. you will have to prepare the fieldcatalog/layout.. and the table to be displayed there.
in PAI of screen 9000, you can return to the original ALV.
method double_click.
call screen 9000.
endmethod.
" now in PBO create a module display_alv2
module display_alv2.
'prepare the fieldcat/layout info for new alv
'add the data to the new ALV table
'instantiate the grid call.. etc
'call the ALV
endmodule
"in PAI
module exit.
case sy-ucomm.
when 'ENT1'.
leave to screen 0.
endcase.
endmodule
while preparing the field catalog you can mention the EMPHASIZE field, whish will give color to tht column
E.g
*--Service Order
ls_fieldcat-tabname = 'IT_FINAL_VALID'.
ls_fieldcat-fieldname = 'AUFNR'.
ls_fieldcat-scrtext_m = 'Service Order'.
ls_fieldcat-ref_table = 'AUFK'.
ls_fieldcat-ref_field = 'AUFNR'.
ls_fieldcat-col_pos = 1.
ls_fieldcat-outputlen = 12.
ls_fieldcat-emphasize = 'C400'. "This will add color to the cell
APPEND ls_fieldcat TO fcat_valid.
Hope this helps. -
How to enable excel downloading in ALV grid report.
Hi all,
How to enable excal downing in ALV grid report?
Thanks in Advance.
Siva Sankar.hi
check the following code
Example of a Simple ALV Grid Report
REPORT ZTUFI091 .
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic requirement for this demo is to display a number of *
*& fields from the EKKO table. *
*REPORT zdemo_alvgrid .
TABLES: 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,
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,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
form build_fieldcatalog.
There are a number of ways to create a fieldcat.
For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.
Beware though, you need to ensure that all fields required are
populated. When using some of functionality available via ALV, such as
total. You may need to provide more information than if you were
simply displaying the result
I.e. Field type may be required in-order for
the 'TOTAL' function to work.
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-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-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
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_top_of_page = 'TOP-OF-PAGE' "see FORM
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_events
is_print = gd_prntparams
i_save = 'X'
is_variant = z_template
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
endform. " DATA_RETRIEVAL
Form TOP-OF-PAGE *
ALV Report Header *
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
i_logo = 'Z_LOGO'.
endform.
FORM USER_COMMAND *
--> R_UCOMM *
--> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Check function code
CASE r_ucomm.
WHEN '&IC1'.
Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
*& Form BUILD_EVENTS
Build events table
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*& Form BUILD_PRINT_PARAMS
Setup print parameters
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*& Form END_OF_PAGE
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
*& Form END_OF_LIST
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform.
hope it will help you
regards
sreelatha gullapalli -
How to devide the top of page in alv grid display
hi all
in the alv grid display am getting the page number and total number of pages in the left hand side
but what i need is i need in the right hand side
how to get thatHi,
PLease refer to the code below:
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic requirement for this demo is to display a number of *
*& fields from the EKKO table. *
REPORT zdemo_alvgrid .
TABLES: 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,
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,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
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-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-do_sum = 'X'.
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-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
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_top_of_page = 'TOP-OF-PAGE' "see FORM
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_events
is_print = gd_prntparams
i_save = 'X'
* is_variant = z_template
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
endform. " DATA_RETRIEVAL
* Form TOP-OF-PAGE *
* ALV Report Header *
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
* Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
* i_logo = 'Z_LOGO'.
endform.
* FORM USER_COMMAND *
* --> R_UCOMM *
* --> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
* Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
*& Form BUILD_EVENTS
* Build events table
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*& Form BUILD_PRINT_PARAMS
* Setup print parameters
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*& Form END_OF_PAGE
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
*& Form END_OF_LIST
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform.
Thanks,
Sriram Ponna. -
How to keep track of the changes done in ALV GRID Report
Hi Experts,
how to keep track of the changed record in ALV GRID Report. how to set the field to be editable even for the entire row also. Can anybody guide along with code also?...
Valuable answers will be rewarded.
Thanks,
Satish.Hi,
Access the table through SM30. It comes blank as standard. Click "New Entries" and make entries for changes to be tracked. For example, whenever an org. unit changes 002 and 003 relationship, you will make entries like:
01 O 1001 B002 Activate box checked
01 O 1001 B003 Activate box checked
Here, 01 is your active plan version, O is org. unit, 1001 is infotype and B002 and B003 are the subtypes. You can also use * for infotype and subtype which means every change will be logged.
If you then run the report RHCDOC_DISPLAY through SA38, it will pick up all the changes pertaining to B002 and B003 relationship for org. units (in the above example).
Similarly, you can set up this table for other object types.
For more information, follow SPRO>Personnel Management>OM>Basic Settings>Activate change documents and go through the documentation for that node. Also, read up the documentation for the report.
Hope this helps.
Donnie -
How to handle user command method in module ALV Grid
HI Experts,
I have 3 containers grid.
GR_GRID TYPE REF TO CL_GUI_ALV_GRID,
GR_GRID1 TYPE REF TO CL_GUI_ALV_GRID,
GR_GRID2 TYPE REF TO CL_GUI_ALV_GRID.
Please advise me how can I insert, save, delete 3 Module ALV Grid in method user command. How can i get which grid button (save, insert, delete) is clicked and how can i control those grid.
Thks in advance.
CLASS LCL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS :
HANDLE_TOOLBAR
FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
IMPORTING E_OBJECT E_INTERACTIVE SENDER,
HANDLE_USER_COMMAND
FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID
IMPORTING E_UCOMM,
HANDLE_DATA_CHANGED
FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID
IMPORTING ER_DATA_CHANGED
E_ONF4
E_ONF4_BEFORE
E_ONF4_AFTER,
HANDLE_DOUBLE_CLICK
FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW
E_COLUMN,
HANDLE_HOTSPOT_CLICK
FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID
E_COLUMN_ID
ES_ROW_NO.
ENDCLASS. "(LCL_EVENT_RECEIVER DEFINITION)
METHOD HANDLE_USER_COMMAND.
CLEAR G_CODE.
G_CODE = E_UCOMM.
CASE G_CODE.
WHEN 'INSERT'.
MESSAGE 'insert' TYPE 'I'.
APPEND INITIAL LINE TO GT_MAIN.
WHEN 'SAVE'.
MODIFY ZTNBOOK FROM GT_MAIN.
MESSAGE 'save' TYPE 'I'.
WHEN 'DELETE'.
DELETE FROM ZTNBOOK WHERE B_ID EQ GT_ZTBOOK-B_ID.
MESSAGE 'delete' TYPE 'I'.
ENDCASE.
IF NOT G_CODE IS INITIAL.
PBO, PAI
CALL METHOD CL_GUI_CFW=>SET_NEW_OK_CODE
EXPORTING
NEW_CODE = G_CODE.
CLEAR G_CODE.
ENDIF.
ENDMETHOD.Hi,
Before posting, Search in SDN.
See the below tread it will help you.
Re: Get table for cl_gui_alv_grid -
How to add a push button on an ALV grid ?
Hi,
How to add a push button on an ALV grid, using ON_TOOLBAR, ON_USERCOMMAND Methods. Clicking on that push button, a new screen has to be displayed.Hi,
Assuming that you want to have a "push-button" column, i.e. push-buttons within an ALV grid then you need to implement the following steps:
(1) Set the style of the column as button
ls_fcat-style = CL_GUI_ALV_GRID => MC_STYLE_BUTTON.
(2) When the user pushes the button event BUTTON_CLICK is triggered. Thus, define an appropriate event handler method.
<b>Reward points</b>
Regards -
How to send ALV Grid report to Email?
hai all,
How to send ALV Grid report to Email.
please its very urgent.....Hi,
when u run the Alv, u will button 'Mail Recepiant' in tool bar.When u click it and enter to new screen, go to the Recipient Tab(down) enter ur maild id and click 'Send' button on tool bar.
or.
if u want to send the Alv content to mail id thru prg, go thru the following code.
TABLES
TABLES: BSID. " Accounting: Secondary Index for Customers.
TYPE-POOLS
TYPE-POOLS: SLIS.
INTERNAL TABLES
Internal table to hold Customer data.
DATA: BEGIN OF TB_BSID OCCURS 0,
BUKRS LIKE BSID-BUKRS, " Company code
KUNNR LIKE BSID-KUNNR, " Customer number
AUGDT LIKE BSID-AUGDT, " Clearing Date
BLDAT LIKE BSID-BLDAT, " Doc date in document
SHKZG LIKE BSID-SHKZG, " Debit/credit indicator
DMBTR LIKE BSID-DMBTR, " Amount in local currency
ZFBDT LIKE BSID-ZFBDT, " Baseline date for due date calc
ZBD1T LIKE BSID-ZBD1T, " Cash discount days 1
ZBD2T LIKE BSID-ZBD2T, " Cash discount days 2
ZBD3T LIKE BSID-ZBD3T, " Net Payment Terms Period
REBZG LIKE BSID-REBZG, " No Of the Inv the Tran Belongs to
REBZT LIKE BSID-REBZT, " Follow-On Document Type
END OF TB_BSID.
Internal table to hold Open Items.
DATA: TB_BSID_OPEN LIKE TABLE OF TB_BSID WITH HEADER LINE.
Internal table to hold Cleared Items.
DATA: TB_BSAD_CLEAR LIKE TABLE OF TB_BSID WITH HEADER LINE.
Internal table to hold General Data in Customer Master
DATA: BEGIN OF TB_KNA1 OCCURS 0,
KUNNR LIKE KNA1-KUNNR, " Customer Number
NAME1 LIKE KNA1-NAME1, " Name Line 1
TELF1 LIKE KNA1-TELF1, " Telephone Number
ADRNR LIKE KNA1-ADRNR, " Address
END OF TB_KNA1.
Internal table to hold Customer Master (Company Code)
DATA: BEGIN OF TB_KNB1 OCCURS 0,
KUNNR LIKE KNB1-KUNNR, " Customer Number
BUKRS LIKE KNB1-BUKRS, " Company code
ERDAT LIKE KNB1-ERDAT, " Rec Created Date
ZAMIB LIKE KNB1-ZAMIB, " DMS Managed Indicator
END OF TB_KNB1.
Internal table to hold Final Output Data
DATA: BEGIN OF TB_FINAL OCCURS 0,
KUNNR LIKE KNA1-KUNNR, " Customer Number
NAME1 LIKE KNA1-NAME1, " Name Line 1
ADDRESS1(25) TYPE C, " Address line 1
ADDRESS2(25) TYPE C, " Address line 2
ADDRESS3(25) TYPE C, " Address line 3
ADDRESS4(25) TYPE C, " Address line 4
PHONE LIKE KNA1-TELF1, " Telephone Number
DAYS_SLOW(3) TYPE C, " Days Slow
LAST_DATE(8) TYPE C, " Date of Last Invoice
AVG(4) TYPE C, " Average Days to Pay
CURRENT(10) TYPE N, " Current
AVG_1_30(10) TYPE N, " 1-30 past due
AVG_31_60(10) TYPE N, " 31-60 past due
AVG_61_90(10) TYPE N, " 61-90 past due
AVG_90G(10) TYPE N, " 90+ past due
END OF TB_FINAL.
ALV Internal tables
DATA : TB_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, " Field Catalog
TB_EVENTS TYPE SLIS_T_EVENT, " ALV Events
TB_COMMENTS TYPE SLIS_T_LISTHEADER. " Comment
Internal tables for the sending mail data
DATA: TB_OBJPACK TYPE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,
TB_OBJHEAD TYPE SOLISTI1 OCCURS 1 WITH HEADER LINE,
TB_OBJTXT TYPE SOLISTI1 OCCURS 10 WITH HEADER LINE,
TB_RECLIST TYPE SOMLRECI1 OCCURS 5 WITH HEADER LINE,
TB_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
TB_DOC_CHNG TYPE SODOCCHGI1.
Internal table to get mail Receivers Address
DATA: TB_ZRECEIVE LIKE YSMTP_ADDRESS OCCURS 0 WITH HEADER LINE.
STRUCTURES
DATA: X_SADR TYPE SADR, " For Address
X_FIELDCAT TYPE SLIS_FIELDCAT_ALV, " For Field Catalog
X_LAYOUT TYPE SLIS_LAYOUT_ALV, " For Layout
X_EVENTS TYPE SLIS_ALV_EVENT, " For Events
X_COMMENTS TYPE SLIS_LISTHEADER, " For Comments
X_ADDR1_SEL LIKE ADDR1_SEL, " For Address
WA_FAEDE TYPE FAEDE. " For FAEDE struct
VARIABLES
DATA: G_REPID LIKE SY-REPID, " Prog ID
G_DAYS_SLOW(3) TYPE N, " Days Slow
G_OPEN TYPE I, " Counter
G_AVG(4) TYPE C, " Avg Days
G_COUNT TYPE I, " Counter
G_TITLE TYPE SOLISTI1-LINE, " Description
G_TAB_LINES TYPE SY-TABIX, " Internal data count
G_REC_COUNT TYPE I, " Total records
G_CURR_BAL TYPE N, " Account balance
G_FILE_NAME LIKE EDI_PATH-PTHNAM. " Output File Name
CONSTANTS
CONSTANTS: C_D TYPE C VALUE 'D', " Account type
C_X TYPE C VALUE 'X', " Check Value
C_0(4) TYPE N VALUE '0.00', " Constant for char
C_1(2) TYPE C VALUE '01', " Posting key const
C_H TYPE C VALUE 'H', " For Commenet-Type
C_TXT(3) TYPE N VALUE 'TXT', " File type
C_RAW(3) TYPE C VALUE 'RAW', " File type
C_DELIMITER TYPE X VALUE '09', " ASCII CODE LINE
C_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
C_INTERFACE TYPE YWFSALOFFICNOTIF-INTERFACE_ID VALUE 'AP',
C_FILENAME(20) TYPE N VALUE 'TEXT.TXT'," File name
C_TITLE(30) TYPE N VALUE 'Z21614_DB_CREDIT_AGENCY',
C_Z001 TYPE RF035-RASID VALUE 'Z001'." Net 30/60/90/120/150
SELECTION SCREEN.
Selection Screen for Selection Criteria.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
SELECT-OPTIONS: S_BUKRS FOR BSID-BUKRS OBLIGATORY, " Company Code
S_BLDAT FOR BSID-BLDAT," OBLIGATORY, " Doc Date
S_KUNNR FOR BSID-KUNNR, " Cust No
S_ZUONR FOR BSID-ZUONR. " Assignment
PARAMETERS: P_GRACE(2) TYPE N OBLIGATORY, " Grace Days
P_ZAMIB LIKE KNB1-ZAMIB AS CHECKBOX. " DMS Indicator
SELECTION-SCREEN END OF BLOCK B1.
Selection Screen for Output Options.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-T02.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 01.
PARAMETERS: P_REPORT RADIOBUTTON GROUP R1. " Report Only
SELECTION-SCREEN COMMENT 5(25) TEXT-016.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 01.
PARAMETERS: P_DOWN RADIOBUTTON GROUP R1. " Dwnld to Unix
SELECTION-SCREEN COMMENT 5(25) TEXT-017.
SELECTION-SCREEN POSITION 30.
PARAMETERS: P_FILE LIKE FILENAME-FILEINTERN DEFAULT
'Z21614_DB_CREDIT_AGENCY'. " File Name
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
Selection Screen for E-mail.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-T03.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 01.
PARAMETERS: P_EMAIL AS CHECKBOX. " E-mail
SELECTION-SCREEN COMMENT 5(25) TEXT-018.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B3.
INITIALIZATION
INITIALIZATION.
G_REPID = SY-REPID.
AT SELECTION SCREEN. *
AT SELECTION-SCREEN.
Validation of selection screen entries
perform validate_data.
START-OF-SELECTION
START-OF-SELECTION.
Select Data from Customer Master (Company Code)
PERFORM SELECT_KNB1.
Select Custmer Open Items.
PERFORM SELECT_CUSTOMER_OPEN_ITEMS.
Select Custmer Cleared Items.
PERFORM SELECT_CUSTOMER_CLEARED_ITEMS.
Select General Data in Customer Master
PERFORM SELECT_KNA1.
Populate Final Output Data.
PERFORM POPULATE_TB_FINAL.
End of selection *
END-OF-SELECTION.
If both display report and send email is checked
IF P_REPORT = C_X AND P_EMAIL = C_X.
MESSAGE E999 WITH
'Select One Among Report Only & Send E-mail'(023).
When Radiobutton for Email or if the program is run background
ELSEIF ( P_EMAIL = C_X OR SY-BATCH = C_X ).
To send the mail
PERFORM SEND_EMAIL.
ELSEIF P_REPORT = C_X .
To display the Final Output data using ALV's
PERFORM DISPLAY_ALV_REPORT.
ENDIF.
Transfering data to file when downloading to Unix
IF P_DOWN = C_X.
IF G_REC_COUNT IS INITIAL.
MESSAGE I999 WITH
'No Records Found For Selection Criteria'(024).
EXIT.
ELSE.
IF NOT G_FILE_NAME IS INITIAL.
Trasefering data to file
PERFORM TRANSFER_DATA_FILE.
Interface Audit report
PERFORM WRITE_REPORT.
ENDIF.
ENDIF.
ENDIF.
F O R M S
*& Form VALIDATE_DATA
Validating selection-screen entries
FORM VALIDATE_DATA.
Local variables
DATA : L_BUKRS LIKE BSEG-BUKRS, " For Company Code
L_KUNNR LIKE BSEG-KUNNR. " For Customer Number
Validate the Company code.
SELECT SINGLE BUKRS
INTO L_BUKRS
FROM T001
WHERE BUKRS IN S_BUKRS.
IF SY-SUBRC <> 0.
MESSAGE E999 WITH 'Enter valid Company Code'(025).
ENDIF.
Validate the Customer number
IF NOT S_KUNNR[] IS INITIAL.
SELECT SINGLE KUNNR
INTO L_KUNNR
FROM KNA1
WHERE KUNNR IN S_KUNNR.
IF SY-SUBRC <> 0.
MESSAGE E999 WITH 'Enter valid Customer Number'(026).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_DATA
*& Form SELECT_KNB1
Select Data from Customer Master (Company Code)
FORM SELECT_KNB1 .
CLEAR: TB_KNB1,
TB_KNB1[].
SELECT KUNNR
BUKRS
ERDAT
ZAMIB
FROM KNB1
INTO TABLE TB_KNB1
WHERE BUKRS IN S_BUKRS
AND KUNNR IN S_KUNNR.
IF SY-SUBRC = 0.
Sort TB_KNB1 by Customer no & Rec Created Date
SORT TB_KNB1 BY KUNNR ERDAT DESCENDING.
ENDIF.
ENDFORM. " SELECT_KNB1
*& Form SELECT_CUSTOMER_OPEN_ITEMS
Select Custmer Open Items.
FORM SELECT_CUSTOMER_OPEN_ITEMS .
CLEAR: TB_BSID,
TB_BSID[].
SELECT A~BUKRS
B~KUNNR
B~AUGDT
B~BLDAT
B~SHKZG
B~DMBTR
B~ZFBDT
B~ZBD1T
B~ZBD2T
B~ZBD3T
B~REBZG
B~REBZT
INTO TABLE TB_BSID
FROM BKPF AS A JOIN BSID AS B
ON ABUKRS = BBUKRS
AND ABELNR = BBELNR
AND AGJAHR = BGJAHR
WHERE A~BUKRS IN S_BUKRS
AND A~BLDAT IN S_BLDAT
AND B~KUNNR IN S_KUNNR
AND B~ZUONR IN S_ZUONR
AND B~BSCHL = C_1.
IF SY-SUBRC = 0.
DMS Managed Indicator = X.
IF P_ZAMIB = C_X.
LOOP AT TB_KNB1 WHERE ZAMIB = SPACE.
DELETE TB_BSID WHERE BUKRS = TB_KNB1-BUKRS
AND KUNNR = TB_KNB1-KUNNR.
ENDLOOP.
ENDIF.
Transfering Open Items from TB_BSID to TB_BSID_OPEN
TB_BSID_OPEN[] = TB_BSID[].
ENDIF.
ENDFORM. " SELECT_CUSTOMER_OPEN_ITEMS
*& Form SELECT_CUSTOMER_CLEARED_ITEMS
Select Custmer Cleared Items.
FORM SELECT_CUSTOMER_CLEARED_ITEMS .
CLEAR: TB_BSAD_CLEAR,
TB_BSAD_CLEAR[].
SELECT A~BUKRS
B~KUNNR
B~AUGDT
B~BLDAT
B~SHKZG
B~DMBTR
B~ZFBDT
B~ZBD1T
B~ZBD2T
B~ZBD3T
B~REBZG
B~REBZT
INTO TABLE TB_BSAD_CLEAR
FROM BKPF AS A JOIN BSAD AS B
ON ABUKRS = BBUKRS
AND ABELNR = BBELNR
AND AGJAHR = BGJAHR
WHERE A~BUKRS IN S_BUKRS
AND A~BLDAT IN S_BLDAT
AND B~KUNNR IN S_KUNNR
AND B~ZUONR IN S_ZUONR
AND B~BSCHL = C_1.
IF SY-SUBRC = 0.
DMS Managed Indicator = X.
IF P_ZAMIB = C_X.
LOOP AT TB_KNB1 WHERE ZAMIB = SPACE.
DELETE TB_BSID WHERE BUKRS = TB_KNB1-BUKRS
AND KUNNR = TB_KNB1-KUNNR.
ENDLOOP.
ENDIF.
Sort TB_BSID_CLEAR by Customer number
SORT TB_BSAD_CLEAR BY KUNNR.
ENDIF.
Append lines of TB_BSID_CLEAR to table TB_BSID
APPEND LINES OF TB_BSAD_CLEAR TO TB_BSID.
Sort TB_BSID by Cust num AND Doc date in document
SORT TB_BSID BY KUNNR BLDAT.
ENDFORM. " SELECT_CUSTOMER_CLEARED_ITEMS
*& Form SELECT_KNA1
Select General Data in Customer Master
FORM SELECT_KNA1.
CLEAR: TB_KNA1,
TB_KNA1[].
SELECT KUNNR
NAME1
TELF1
ADRNR
INTO TABLE TB_KNA1
FROM KNA1
WHERE KUNNR IN S_KUNNR.
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM. " SELECT_KNA1
*& Form POPULATE_TB_FINAL
Populate Final Output Data.
FORM POPULATE_TB_FINAL.
Local variable
DATA: L_DAYS_SLOW(3) TYPE N. " Days Slow
CLEAR: TB_FINAL,
TB_FINAL[].
LOOP AT TB_KNA1.
Move-corresponding TB_KNA1 to TB_FINAL.
TB_FINAL-KUNNR = TB_KNA1-KUNNR. " Customer Number
TB_FINAL-NAME1 = TB_KNA1-NAME1. " Name Line 1
TB_FINAL-PHONE = TB_KNA1-TELF1. " Telephone Number
To get Customer Address.
PERFORM GET_CUSTOMER_ADDRESS.
To get Date of Last Invoice.
READ TABLE TB_BSID WITH KEY KUNNR = TB_KNA1-KUNNR.
IF SY-SUBRC = 0.
TB_FINAL-LAST_DATE = TB_BSID-BLDAT.
ENDIF.
To get past due and current details.
PERFORM GET_PAST_DUE_CURRENT.
To get Days Slow.
CLEAR WA_FAEDE .
LOOP AT TB_BSID_OPEN WHERE KUNNR = TB_KNA1-KUNNR.
WA_FAEDE-SHKZG = TB_BSID-SHKZG.
WA_FAEDE-ZFBDT = TB_BSID-ZFBDT.
WA_FAEDE-ZBD1T = TB_BSID-ZBD1T.
WA_FAEDE-ZBD2T = TB_BSID-ZBD2T.
WA_FAEDE-ZBD3T = TB_BSID-ZBD3T.
WA_FAEDE-REBZG = TB_BSID-REBZG.
WA_FAEDE-REBZT = TB_BSID-REBZT.
WA_FAEDE-KOART = C_D.
To Determine Due Date.
CALL FUNCTION 'DETERMINE_DUE_DATE'
EXPORTING
I_FAEDE = WA_FAEDE
IMPORTING
E_FAEDE = WA_FAEDE
EXCEPTIONS
ACCOUNT_TYPE_NOT_SUPPORTED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
CLEAR WA_FAEDE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR: L_DAYS_SLOW.
L_DAYS_SLOW = SY-DATUM - WA_FAEDE-NETDT - P_GRACE.
G_DAYS_SLOW = G_DAYS_SLOW + ABS( L_DAYS_SLOW ).
G_OPEN = G_OPEN + 1.
ENDLOOP.
IF G_OPEN IS INITIAL.
TB_FINAL-DAYS_SLOW = G_DAYS_SLOW / G_OPEN. " Days Slow
ENDIF.
To get Average days to Pay.
PERFORM GET_AVG_DAYS_PAY.
Calculating total records .
G_REC_COUNT = G_REC_COUNT + 1.
APPEND TB_FINAL.
CLEAR TB_FINAL.
ENDLOOP.
Current account balance.
G_CURR_BAL = TB_FINAL-CURRENT + TB_FINAL-AVG_1_30 +
TB_FINAL-AVG_31_60 +
TB_FINAL-AVG_61_90 +
TB_FINAL-AVG_90G .
ENDFORM. " POPULATE_TB_FINAL
*& Form GET_PAST_DUE_CURRENT
To get past due and current details.
FORM GET_PAST_DUE_CURRENT.
Local Varaibles.
DATA: L_RF035_SFAE1 TYPE RF035-SFAE1,
L_RF035_SFAE2 TYPE RF035-SFAE2,
L_RF035_SFAE3 TYPE RF035-SFAE3,
L_RF035_SFAE4 TYPE RF035-SFAE4,
L_RF035_SFAE5 TYPE RF035-SFAE5,
L_RF035_SFAE6 TYPE RF035-SFAE6,
L_RF035_SFAEL TYPE RF035-SFAEL,
L_RF035_SNFA1 TYPE RF035-SNFA1,
L_RF035_SNFA2 TYPE RF035-SNFA2,
L_RF035_SNFA3 TYPE RF035-SNFA3,
L_RF035_SNFA4 TYPE RF035-SNFA4,
L_RF035_SNFA5 TYPE RF035-SNFA5,
L_RF035_SNFA6 TYPE RF035-SNFA6,
L_RF035_SNFAE TYPE RF035-SNFAE.
LOOP AT TB_KNB1 WHERE KUNNR = TB_KNA1-KUNNR.
CALL FUNCTION 'CUSTOMER_DUE_DATE_ANALYSIS'
EXPORTING
BUKRS = TB_KNB1-BUKRS
KKBER = ' '
KUNNR = TB_KNB1-KUNNR
RASID = C_Z001
IMPORTING
SFAE1 = L_RF035_SFAE1
SFAE2 = L_RF035_SFAE2
SFAE3 = L_RF035_SFAE3
SFAE4 = L_RF035_SFAE4
SFAE5 = L_RF035_SFAE5
SFAE6 = L_RF035_SFAE6
SFAEL = L_RF035_SFAEL
SNFA1 = L_RF035_SNFA1
SNFA2 = L_RF035_SNFA2
SNFA3 = L_RF035_SNFA3
SNFA4 = L_RF035_SNFA4
SNFA5 = L_RF035_SNFA5
SNFA6 = L_RF035_SNFA6
SNFAE = L_RF035_SNFAE
EXCEPTIONS
INVALID_RASTER = 1
NO_OPEN_ITEMS = 2
OTHERS = 3
IF SY-SUBRC = 0.
TB_FINAL-AVG_1_30 = TB_FINAL-AVG_1_30 + L_RF035_SFAE1.
TB_FINAL-AVG_31_60 = TB_FINAL-AVG_31_60 + L_RF035_SFAE2.
TB_FINAL-AVG_61_90 = TB_FINAL-AVG_61_90 + L_RF035_SFAE3.
TB_FINAL-AVG_90G = TB_FINAL-AVG_90G + L_RF035_SFAE4
+ L_RF035_SFAE5
+ L_RF035_SFAE6.
TB_FINAL-CURRENT = TB_FINAL-CURRENT + L_RF035_SNFAE.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
ENDFORM. " GET_PAST_DUE_CURRENT
*& Form GET_CUSTOMER_ADDRESS
To get Customer Address.
FORM GET_CUSTOMER_ADDRESS.
X_ADDR1_SEL-ADDRNUMBER = TB_KNA1-ADRNR.
CALL FUNCTION 'ADDR_GET'
EXPORTING
ADDRESS_SELECTION = X_ADDR1_SEL
IMPORTING
SADR = X_SADR
EXCEPTIONS
PARAMETER_ERROR = 1
ADDRESS_NOT_EXIST = 2
VERSION_NOT_EXIST = 3
INTERNAL_ERROR = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ADDRESS LINE 1.
TB_FINAL-ADDRESS1 = X_SADR-STRAS.
ADDRESS LINE 2.
CONCATENATE X_SADR-PFACH 'CODE' X_SADR-PSTL2 INTO TB_FINAL-ADDRESS2
SEPARATED BY SPACE.
ADDRESS LINE 3.
CONCATENATE X_SADR-ORT01 X_SADR-ORT02 ',' X_SADR-REGIO X_SADR-PSTLZ
INTO TB_FINAL-ADDRESS3 SEPARATED BY SPACE.
ADDRESS LINE 4.
TB_FINAL-ADDRESS4 = X_SADR-LAND1.
ENDFORM. " GET_CUSTOMER_ADDRESS
*& Form GET_AVG_DAYS_PAY
To get Average days to Pay.
FORM GET_AVG_DAYS_PAY.
*Local variable
DATA: L_DAYS TYPE N . " Number of Days
LOOP AT TB_BSAD_CLEAR WHERE KUNNR = TB_KNA1-KUNNR.
L_DAYS = TB_BSAD_CLEAR-AUGDT - TB_BSAD_CLEAR-BLDAT.
G_AVG = G_AVG + L_DAYS.
G_COUNT = G_COUNT + 1.
ENDLOOP.
IF NOT G_COUNT IS INITIAL.
TB_FINAL-AVG = G_AVG / G_COUNT. " Average days to Pay.
ENDIF.
ENDFORM. " GET_AVG_DAYS_PAY
*& Form DISPLAY_ALV_REPORT
text
FORM DISPLAY_ALV_REPORT.
For Populating Field Catalog.
PERFORM RPT_BUILD_FIELDCATLOG.
For Modifying Field Catalog.
PERFORM RPT_MODIFY_FIELDCATLOG.
For TOP_OF_PAGE Event.
PERFORM RPT_GET_EVENTS.
For Displaying Output in Grid Format.
PERFORM RPT_GRID_DISPLAY.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form RPT_BUILD_FIELDCATLOG
text
FORM RPT_BUILD_FIELDCATLOG.
To build the Field Catlog.
DATA : L_TABNAME TYPE SLIS_TABNAME. " Table Name
L_TABNAME = 'TB_FINAL'.
REFRESH : TB_FIELDCAT.
CLEAR : TB_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = G_REPID
I_INTERNAL_TABNAME = L_TABNAME
I_INCLNAME = G_REPID
CHANGING
CT_FIELDCAT = TB_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " RPT_BUILD_FIELDCATLOG
*& Form RPT_MODIFY_FIELDCATLOG
text
FORM RPT_MODIFY_FIELDCATLOG.
Getting the Header Text for the Coloumns
DATA : L_TABIX LIKE SY-TABIX, " Index
L_DDICTXT TYPE C VALUE 'L'. " Flag
Getting the Header Text for the Coloumns
LOOP AT TB_FIELDCAT INTO X_FIELDCAT.
CLEAR L_TABIX.
L_TABIX = SY-TABIX.
CASE X_FIELDCAT-FIELDNAME.
WHEN 'KUNNR'. " Customer Number
X_FIELDCAT-SELTEXT_L = 'Customer Number'(001).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'NAME1'. " Name Line 1
X_FIELDCAT-SELTEXT_L = 'Name'(002).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'ADDRESS1'. " Address line 1
X_FIELDCAT-SELTEXT_L = 'Address 1'(003).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'ADDRESS2'. " Address line 2
X_FIELDCAT-SELTEXT_L = 'Address 2'(004).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'ADDRESS3'. " Address line 3
X_FIELDCAT-SELTEXT_L = 'Address 3'(005).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'ADDRESS4'. " Address line 4
X_FIELDCAT-SELTEXT_L = 'Address 4'(006).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'PHONE'. " Telephone Number
X_FIELDCAT-SELTEXT_L = 'Telephone Number'(007).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'DAYS_SLOW'. " Days Slow
X_FIELDCAT-SELTEXT_L = 'Days Slow'(008).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'LAST_DATE'. " Date of Last Invoice
X_FIELDCAT-SELTEXT_L = 'Date of Last Invoice'(009).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AVG'. " Average Days to Pay
X_FIELDCAT-SELTEXT_L = 'Average Days to Pay'(010).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'CURRENT'. " Current
X_FIELDCAT-SELTEXT_L = 'Aging Category 1'(011).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AVG_1_30'. " 1-30 past due
X_FIELDCAT-SELTEXT_L = 'Aging Category 2'(012).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AVG_31_60'. " 31-60 past due
X_FIELDCAT-SELTEXT_L = 'Aging Category 3'(013).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AVG_61_90'. " 61-90 past due
X_FIELDCAT-SELTEXT_L = 'Aging Category 4'(014).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AVG_90G'. " 90+ past due
X_FIELDCAT-SELTEXT_L = 'Aging Category 5'(015).
X_FIELDCAT-DDICTXT = L_DDICTXT.
ENDCASE.
MODIFY TB_FIELDCAT FROM X_FIELDCAT INDEX L_TABIX.
ENDLOOP.
ENDFORM. " RPT_MODIFY_FIELDCATLOG
*& Form RPT_GET_EVENTS
text
FORM RPT_GET_EVENTS.
DATA : L_TABIX TYPE SY-TABIX. " Index
CLEAR : TB_EVENTS,
TB_EVENTS[].
To get the events from this function module
for ALV display
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = TB_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE I999 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Modifing Top of Page event
READ TABLE TB_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO X_EVENTS.
IF SY-SUBRC = 0.
CLEAR L_TABIX.
L_TABIX = SY-TABIX.
X_EVENTS-FORM = C_TOP_OF_PAGE.
MODIFY TB_EVENTS FROM X_EVENTS INDEX L_TABIX.
CLEAR X_EVENTS.
ENDIF.
ENDFORM. " RPT_GET_EVENTS
*& Form TOP_OF_PAGE
Top Of Page for the ALV format
FORM TOP_OF_PAGE.
REFRESH TB_COMMENTS.
For heading
CLEAR X_COMMENTS.
X_COMMENTS-TYP = C_H.
X_COMMENTS-INFO = 'D&B Credit Agency Interface'(019).
APPEND X_COMMENTS TO TB_COMMENTS.
This module outputs formatted simple header information at TOP-OF-PAGE
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = TB_COMMENTS.
ENDFORM. " TOP_OF_PAGE
*& Form RPT_GRID_DISPLAY
text
FORM RPT_GRID_DISPLAY.
Layout Settings
CLEAR X_LAYOUT.
X_LAYOUT-ZEBRA = 'X'.
X_LAYOUT-COLWIDTH_OPTIMIZE = C_X.
X_LAYOUT-NO_COLHEAD = SPACE.
To Display the Output in ALV Format
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
IS_LAYOUT = X_LAYOUT
IT_FIELDCAT = TB_FIELDCAT
IT_EVENTS = TB_EVENTS
TABLES
T_OUTTAB = TB_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " RPT_GRID_DISPLAY
*& Form SEND_EMAIL
text
--> p1 text
<-- p2 text
FORM SEND_EMAIL.
Prepare the mail
PERFORM SEND_MAIL USING C_INTERFACE.
Sending the mail to Receivers
PERFORM SENDING_MAIL.
ENDFORM. " SEND_EMAIL
*& Form SEND_MAIL
Sending the Mail
FORM SEND_MAIL USING P_C_INTERFACE TYPE YWFSALOFFICNOTIF-INTERFACE_ID.
Populating Report name
G_TITLE = C_TITLE.
PERFORM POPULATE_EMAIL_REF_DATA USING G_TITLE.
IF NOT G_REC_COUNT IS INITIAL.
To populate the data to table tb_objbin
PERFORM POPULATE_DATA_OBJBIN.
To get the attached file for the mail
CLEAR G_TAB_LINES.
DESCRIBE TABLE TB_OBJBIN LINES G_TAB_LINES.
TB_OBJHEAD = C_FILENAME.
APPEND TB_OBJHEAD.
CLEAR TB_OBJHEAD.
Creation of the entry for the mail
TB_OBJPACK-TRANSF_BIN = C_X.
TB_OBJPACK-HEAD_START = C_1.
TB_OBJPACK-HEAD_NUM = C_1.
TB_OBJPACK-BODY_START = C_1.
TB_OBJPACK-BODY_NUM = G_TAB_LINES.
TB_OBJPACK-DOC_TYPE = C_TXT.
TB_OBJPACK-OBJ_NAME = G_REPID.
TB_OBJPACK-OBJ_DESCR = 'Interface Audit Report'(020).
TB_OBJPACK-DOC_SIZE = G_TAB_LINES * 255.
APPEND TB_OBJPACK.
ENDIF.
ENDFORM. " SEND_MAIL
*& Form SENDING_MAIL
FORM SENDING_MAIL.
Function Module to send mail along with attached file
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = TB_DOC_CHNG
TABLES
PACKING_LIST = TB_OBJPACK
OBJECT_HEADER = TB_OBJHEAD
CONTENTS_BIN = TB_OBJBIN
CONTENTS_TXT = TB_OBJTXT
RECEIVERS = TB_RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
CASE SY-SUBRC.
WHEN 0.
MESSAGE S999 WITH 'Mail has been sucessfully sent'(029).
WHEN 1.
MESSAGE S999 WITH 'Too Many Parameters'(030).
WHEN 2.
MESSAGE S999 WITH 'Doc Could Not Be Sent'(031).
WHEN 4.
MESSAGE S999 WITH 'No Authority To Send'(032).
WHEN 99.
MESSAGE S999 WITH 'Error While Sending'(033).
ENDCASE.
ENDFORM. " SENDING_MAIL
*& Form POPULATE_EMAIL_REF_DATA
Poplulating the body of the mail
FORM POPULATE_EMAIL_REF_DATA USING TEXT TYPE SOLISTI1-LINE.
Setting up Mail Subject
TB_DOC_CHNG-OBJ_DESCR = 'Interface Audit Report'(020).
Populating body of the mail
TB_OBJTXT-LINE = 'Interface Audit Report'(020).
APPEND TB_OBJTXT.
CLEAR: TB_OBJTXT.
DESCRIBE TABLE TB_OBJTXT LINES G_TAB_LINES.
READ TABLE TB_OBJTXT INDEX G_TAB_LINES.
*To determine the document size
TB_DOC_CHNG-DOC_SIZE = ( G_TAB_LINES - 1 ) * 255 + STRLEN( TB_OBJTXT ).
Creation of the entry for the Mail Contents
CLEAR TB_OBJPACK-TRANSF_BIN.
TB_OBJPACK-HEAD_START = C_1.
TB_OBJPACK-HEAD_NUM = C_0.
TB_OBJPACK-BODY_START = C_1.
TB_OBJPACK-BODY_NUM = G_TAB_LINES.
TB_OBJPACK-DOC_TYPE = C_RAW.
APPEND TB_OBJPACK.
ENDFORM. " POPULATE_EMAIL_REF_DATA
*& Form POPULATE_DATA_OBJBIN
Populating table for file attachment -
How to make 1st column as header in ALV grid
Hi Experts,
How to make 1st column as header in ALV grid as attached. Please help.
Thanks in advance.Hi manoj,
Try with,
FM REUSE_ALV_HIERSEQ_LIST_DISPLAY
Regards,
Venkat. -
How to change the selected row color in an alv grid display ?
Hello ,
I WANT TO CHANGE THE COLOR OF THE SELECTED RECORDS IN AN ALV GRID DISPLAY ?
ITS URGENT..
WILL BE REWARDED...hai Ssnagh Samala
EXicut This report >
Hope It Will Meet U r Requirement.
If Found Helpfull Reward.
REPORT zcuitest_alv_07.
Use of colours in ALV grid (cell, line and column) *
Table
TABLES : mara.
Type
TYPES : BEGIN OF ty_mara,
matnr LIKE mara-matnr,
matkl LIKE mara-matkl,
counter(4) TYPE n,
free_text(15) TYPE c,
color_line(4) TYPE c, " Line color
color_cell TYPE lvc_t_scol, " Cell color
END OF ty_mara.
Structures
DATA : wa_mara TYPE ty_mara,
wa_fieldcat TYPE lvc_s_fcat,
is_layout TYPE lvc_s_layo,
wa_color TYPE lvc_s_scol.
Internal table
DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
it_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,
it_color TYPE TABLE OF lvc_s_scol.
Variables
DATA : okcode LIKE sy-ucomm,
w_alv_grid TYPE REF TO cl_gui_alv_grid,
w_docking_container TYPE REF TO cl_gui_docking_container.
PARAMETERS : p_column AS CHECKBOX,
p_line AS CHECKBOX,
p_cell AS CHECKBOX.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
PERFORM fill_catalog.
PERFORM fill_layout.
CALL SCREEN 2000.
*& Module status_2000 OUTPUT
text
MODULE status_2000 OUTPUT.
SET PF-STATUS '2000'.
ENDMODULE. " status_2000 OUTPUT
*& Module user_command_2000 INPUT
text
MODULE user_command_2000 INPUT.
DATA : w_okcode LIKE sy-ucomm.
MOVE okcode TO w_okcode.
CLEAR okcode.
CASE w_okcode.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " user_command_2000 INPUT
*& Module alv_grid OUTPUT
text
MODULE alv_grid OUTPUT.
IF w_docking_container IS INITIAL.
PERFORM create_objects.
PERFORM display_alv_grid.
ENDIF.
ENDMODULE. " alv_grid OUTPUT
*& Form create_objects
text
--> p1 text
<-- p2 text
FORM create_objects.
Ratio must be included in http://5..95
CREATE OBJECT w_docking_container
EXPORTING
ratio = 95
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
CREATE OBJECT w_alv_grid
EXPORTING
i_parent = w_docking_container.
ENDFORM. " create_objects
*& Form display_alv_grid
text
--> p1 text
<-- p2 text
FORM display_alv_grid.
CALL METHOD w_alv_grid->set_table_for_first_display
EXPORTING
is_layout = is_layout
CHANGING
it_outtab = it_mara
it_fieldcatalog = it_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
ENDFORM. " display_alv_grid
*& Form get_data
text
--> p1 text
<-- p2 text
FORM get_data.
SELECT * FROM mara UP TO 5 ROWS.
CLEAR : wa_mara-color_line, wa_mara-color_cell.
MOVE-CORRESPONDING mara TO wa_mara.
ADD 1 TO wa_mara-counter.
MOVE 'Blabla' TO wa_mara-free_text.
IF wa_mara-counter = '0002'
AND p_line = 'X'.
Color line
MOVE 'C410' TO wa_mara-color_line.
ELSEIF wa_mara-counter = '0004'
AND p_cell = 'X'.
Color cell
MOVE 'FREE_TEXT' TO wa_color-fname.
MOVE '5' TO wa_color-color-col.
MOVE '1' TO wa_color-color-int.
MOVE '1' TO wa_color-color-inv.
APPEND wa_color TO it_color.
wa_mara-color_cell] = it_color[.
ENDIF.
APPEND wa_mara TO it_mara.
ENDSELECT.
ENDFORM. " get_data
*& Form fill_catalog
text
--> p1 text
<-- p2 text
FORM fill_catalog.
Colour code : *
Colour is a 4-char field where : *
- 1st char = C (color property) *
- 2nd char = color code (from 0 to 7) *
0 = background color *
1 = blue *
2 = gray *
3 = yellow *
4 = blue/gray *
5 = green *
6 = red *
7 = orange *
- 3rd char = intensified (0=off, 1=on) *
- 4th char = inverse display (0=off, 1=on) *
Colour overwriting priority : *
1. Line *
2. Cell *
3. Column *
DATA : w_position TYPE i VALUE '1'.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'MATNR' TO wa_fieldcat-fieldname.
MOVE 'MARA' TO wa_fieldcat-ref_table.
MOVE 'MATNR' TO wa_fieldcat-ref_field.
APPEND wa_fieldcat TO it_fieldcat.
ADD 1 TO w_position.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'MATKL' TO wa_fieldcat-fieldname.
MOVE 'MARA' TO wa_fieldcat-ref_table.
MOVE 'MATKL' TO wa_fieldcat-ref_field.
Color column
IF p_column = 'X'.
MOVE 'C610' TO wa_fieldcat-emphasize.
ENDIF.
APPEND wa_fieldcat TO it_fieldcat.
ADD 1 TO w_position.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'COUNTER' TO wa_fieldcat-fieldname.
MOVE 'N' TO wa_fieldcat-inttype.
MOVE '4' TO wa_fieldcat-intlen.
MOVE 'Counter' TO wa_fieldcat-coltext.
APPEND wa_fieldcat TO it_fieldcat.
ADD 1 TO w_position.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'FREE_TEXT' TO wa_fieldcat-fieldname.
MOVE 'C' TO wa_fieldcat-inttype.
MOVE '20' TO wa_fieldcat-intlen.
MOVE 'Text' TO wa_fieldcat-coltext.
APPEND wa_fieldcat TO it_fieldcat.
ENDFORM. " fill_catalog
*& Form fill_layout
text
--> p1 text
<-- p2 text
FORM fill_layout.
Field that identify color line in internal table
MOVE 'COLOR_LINE' TO is_layout-info_fname.
Field that identify cell color in inetrnal table
MOVE 'COLOR_CELL' TO is_layout-ctab_fname.
ENDFORM. " fill_layout
Regards.
Eshwar. -
How to display a row after a subtotal field in ALV Grid
Hi All,
My requirement is to print a extra row with values and constant text after printing subtotal values in ALV Grid.
e.g. TOTAL 12.23 ---> Subtotal field
Tax 5.2 ---> extra row after subtotal field.
Please help me....
Thanks in advance.
Regards
AjayHi
You can try using INSERT <WA> OR INSERT INITIAL LINE .
fill the wa with tax value.
INSERT <wa> into table < internal table >
A row will be inserted into internal table with the values.
Try this and let me know.
Thanks
Hariharan -
How to make the first row selected before the display of ALV grid
Hello Experts,
I created a ALV grid using custom container in a screen . Now i want do the follwing:
1. i want that, the <b>first line must be selected before the display of ALV.</b>
2. I have selection buttons . But i dont want the multiselect button and the
standard toolbar in the ALV grid.
Could any one please help me regarding the above?
Thanks & Regards
Sudhansucan u pls explain in more details with an example?
I am telling u the scenario.
1. i have a screen(Modal dialog Box) containing ALV grid with selection buttons for each row (top part) and a subscreen(second part).
Now when i click on a selection button, it will display the corresponding values in the subscreen.
When this screen will display for the first time , then first row of the ALV grid should be selected and the corresponding values should be displayed in the subscreen.
i wrote the following code in the PAI. But when i select a record its not triggering the PAI.
DATA:
gi_index_rows TYPE lvc_t_row, " Internal table for indexes of selected rows
g_selected_row LIKE lvc_s_row, " Information about 1 row
l_lines TYPE i.
CLEAR g_wa_vdmeko.
*get selected row
CALL METHOD g_alv_grid->get_selected_rows
IMPORTING
et_index_rows = gi_index_rows.
DESCRIBE TABLE gi_index_rows LINES l_lines.
LOOP AT gi_index_rows INTO g_selected_row.
READ TABLE g_int_vdmeko INDEX g_selected_row-index INTO g_wa_vdmeko.
SELECT SINGLE *
FROM vdmepov
WHERE bukrs = g_wa_vdmeko-bukrs AND
styp = g_wa_vdmeko-styp AND
sbez = g_wa_vdmeko-sbez AND
svym = g_wa_vdmeko-svym AND
svnr = g_wa_vdmeko-svnr.
ENDLOOP.
I am displayinng the ALV using method "set_alv_for_first_display".
Please help if u have any idea..................
Thanks
Sudhansu -
How can I use hotspot click in an ALV grid?
Hello,
I have a table that is displayed in an ALV grid and I would like to have one of the columns as clickable icons.
For example:
Print | Doc. Type | Name
(icon) | .docx | first
(icon) | .pdf | second ... and so on.
I would like to click in the icon (Print column) and execute an action, but no matter what I do I can't set the action.
I know that is not just setting "fieldcatalog-hotspot='X'", but I don't know how to use a hotspot handler.
Here's some of the code I have:
TYPES: BEGIN OF ty_docs,
print LIKE ICON-ID,
doc_type LIKE table_doc-TYPE,
name LIKE table_doc-NAME,
END OF ty_docs.
DATA: oref_dock TYPE REF TO cl_gui_docking_container,
oref_alv TYPE REF TO cl_gui_alv_grid,
i_fieldcat TYPE lvc_t_fcat,
aux_fieldcat TYPE lvc_s_fcat,
aux_lay TYPE lvc_s_layo,
i_exclude TYPE TABLE OF syucomm,
i_docs TYPE ty_docs,
t_docs LIKE TABLE OF i_docs.
AT SELECTION-SCREEN OUTPUT.
APPEND 'ONLI' TO i_exclude.
APPEND 'SJOB' TO i_exclude.
APPEND 'PRIN' TO i_exclude.
CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
EXPORTING
p_status = sy-pfkey
p_program = sy-repid
TABLES
p_exclude = i_exclude.
AT SELECTION-SCREEN.
CHECK sy-ucomm = space.
SELECT
icon~ID AS print
doc~TYPE AS doc_type
doc~NAME as name
INTO CORRESPONDING FIELDS OF TABLE t_docs
FROM table_doc AS doc
INNER JOIN ICON AS icon
ON icon~NAME EQ 'ICON_PRINT'
GROUP BY icon~ID doc~TYPE doc~NAME.
IF sy-subrc = 0.
IF oref_dock IS NOT BOUND.
CREATE OBJECT oref_dock
EXPORTING
repid = sy-repid
dynnr = sy-dynnr
side = cl_gui_docking_container=>dock_at_bottom
ratio = 90
EXCEPTIONS
OTHERS = 1.
ENDIF.
IF oref_alv IS NOT BOUND.
CHECK oref_dock IS BOUND.
CREATE OBJECT oref_alv
EXPORTING
i_parent = oref_dock
EXCEPTIONS
OTHERS = 1.
CHECK oref_alv IS BOUND.
aux_fieldcat-fieldname = 'PRINT'.
aux_fieldcat-coltext = 'Print'.
aux_fieldcat-ref_table = 't_docs'.
aux_fieldcat-ref_field = 't_docs-print'.
aux_fieldcat-edit = ''.
aux_fieldcat-just = 'C'.
aux_fieldcat-hotspot = 'X'.
aux_fieldcat-outputlen = 10.
aux_fieldcat-col_pos = 0.
APPEND aux_fieldcat TO i_fieldcat.
CLEAR aux_fieldcat.
aux_fieldcat-fieldname = 'TYPE'.
aux_fieldcat-coltext = 'Doc. Type'.
aux_fieldcat-ref_table = 't_docs'.
aux_fieldcat-ref_field = 't_docs-doc_type'.
aux_fieldcat-edit = ''.
aux_fieldcat-outputlen = 15.
aux_fieldcat-col_pos = 1.
APPEND aux_fieldcat TO i_fieldcat.
CLEAR aux_fieldcat.
aux_fieldcat-fieldname = 'NAME'.
aux_fieldcat-coltext = 'Name'.
aux_fieldcat-ref_table = 't_docs'.
aux_fieldcat-ref_field = 't_docs-name'.
aux_fieldcat-edit = ''.
aux_fieldcat-outputlen = 12.
aux_fieldcat-col_pos = 2.
APPEND aux_fieldcat TO i_fieldcat.
CLEAR aux_fieldcat.
aux_lay-grid_title = 'Docs'.
aux_lay-edit = ''.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ty_docs'
i_internal_tabname = 't_docs'
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
OTHERS = 3.
CALL METHOD oref_alv->set_table_for_first_display
EXPORTING
i_structure_name = 'ty_docs'
is_layout = aux_lay
CHANGING
it_fieldcatalog = i_fieldcat
it_outtab = t_docs
EXCEPTIONS
OTHERS = 1.
ELSE.
CALL METHOD oref_alv->refresh_table_display
EXCEPTIONS
OTHERS = 1.
ENDIF.
ENDIF.
Thank you so much in advance!Hi,
After creating grid set the even handler for hot spot.
SET HANDLER lcl_event_receiver=>handle_hotspot_click FOR alv_grid.
Try this code:
TABLES: mara,t001l.
DATA: BEGIN OF i_alv OCCURS 0,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
groes TYPE mara-groes,
maktx TYPE makt-maktx,
END OF i_alv.
DATA: wa_alv LIKE LINE OF i_alv.
DATA: alv_container TYPE REF TO cl_gui_docking_container.
DATA: alv_grid TYPE REF TO cl_gui_alv_grid.
DATA: layout TYPE lvc_s_layo.
DATA: fieldcat TYPE lvc_t_fcat.
DATA: gt_t001l TYPE STANDARD TABLE OF t001l.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
*-->Method for User command
CLASS-METHODS :
handle_hotspot_click FOR EVENT hotspot_click OF
cl_gui_alv_grid
IMPORTING E_ROW_ID e_column_id.
ENDCLASS. "lcl_event_receiver DEFINITION
* CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_hotspot_click.
READ TABLE i_alv INTO wa_alv
INDEX e_row_id-index
TRANSPORTING matnr.
SET PARAMETER ID 'MAT' FIELD wa_alv-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
PARAMETERS: p_check TYPE matnr.
INITIALIZATION.
PERFORM get_data.
AT SELECTION-SCREEN OUTPUT.
* START-OF-SELECTION.
DATA: variant TYPE disvariant.
DATA: repid TYPE sy-repid.
repid = sy-repid.
variant-report = sy-repid.
variant-username = sy-uname.
layout-zebra = 'X'.
layout-edit_mode = 'X'.
CHECK alv_container IS INITIAL.
CREATE OBJECT alv_container
EXPORTING repid = repid
dynnr = sy-dynnr
side = alv_container->dock_at_right
extension = 350.
CREATE OBJECT alv_grid
EXPORTING
i_parent = alv_container.
* Set event handler
SET HANDLER lcl_event_receiver=>handle_hotspot_click FOR alv_grid.
* ALV Specific. Data selection.
* Populate Field Catalog
PERFORM get_fieldcatalog.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
is_layout = layout
is_variant = variant
i_save = 'U'
i_structure_name = 'I_ALV'
CHANGING
it_outtab = i_alv[]
it_fieldcatalog = fieldcat[].
START-OF-SELECTION.
* FORM GET_DATA
FORM get_data.
SELECT * INTO CORRESPONDING FIELDS OF TABLE i_alv
FROM mara
INNER JOIN makt
ON mara~matnr = makt~matnr
UP TO 100 ROWS
WHERE makt~spras = sy-langu.
SORT i_alv ASCENDING BY matnr.
ENDFORM. "get_data
* Form Get_Fieldcatalog - Set Up Columns/Headers
FORM get_fieldcatalog.
DATA: ls_fcat TYPE lvc_s_fcat.
REFRESH: fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '18'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-hotspot = 'X'.
ls_fcat-col_pos = '1'.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Type'.
ls_fcat-fieldname = 'MTART'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '10'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = '2'.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Group'.
ls_fcat-fieldname = 'MATKL'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '12'.
ls_fcat-col_pos = '3'.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Size'.
ls_fcat-fieldname = 'GROES'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '30'.
ls_fcat-col_pos = '4'.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Description'.
ls_fcat-fieldname = 'MAKTX'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '40'.
ls_fcat-col_pos = '5'.
APPEND ls_fcat TO fieldcat.
ENDFORM. "get_fieldcatalog
Hope this solves your problem....
Maybe you are looking for
-
I movies synced to cloud do not show up on all devices
I have been putting old home videos into iMovie and some show up in my theater on my Mac, others on my iPad and still others on my Apple TV. Not all videos in all places. Some duplicates, but others only show up on one device. When I try to downlo
-
OIM11g: Error while running AD Reconcilliation Schedule Job
Hi All, I am using OIM 11g BP05 and have deployed AD connector 11.1.1.5.0 using connector server. While running the AD Group/Organization/User Reconcilliation schedule job, I am getting below error in connector logs: 11/8/2012 4:25:59 PM <ERROR>: Cla
-
When dialing, 7, 8 and 9 keys not working.
In some applications, there is a row of the touch screen that is not working. When I am dialing a phone number, the 7, 8, and 9 keys will not work, it goes to the row above or below it. However, when I am choosing from a list, like in Settings, I do
-
Different chargers it is an inconvenience
a note to development team: different charger connection types is inconvenience. through the time nokia turned to be a my family (whole large family - including aunts and uncles) phone. one of the motives (not main but important) for choosing nokia w
-
I had my iPhone stolen and I wonder if I would be possible to completely lock the device, preventing the thief turned the phone again?