Icon display in alv report
Hi all,
I have a problem in alv report ,there are 5 fields to display and in 6th position i have to display an icon as red or green light according to data. How can i do that ? please help me .
Thanks and regards
Goutam
Hi goutam,
1. Simple
2. we have to use the layout for this purpose.
3. like this :
alvly-lights_fieldname = 'LT'.
alvly-lights_tabname = 'ITAB'.
4. Just copy paste to get a taste of it.
(important code has been highlighted)
REPORT abc.
TYPE-POOLS : slis.
DATA : alvly TYPE slis_layout_alv.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : BEGIN OF itab OCCURS 0,
<b> lt TYPE i,</b>
matnr LIKE mara-matnr,
END OF itab.
END-OF-SELECTION.
<b> itab-lt = 1.
APPEND itab.
itab-lt = 2.
APPEND itab.
itab-lt = 3.
APPEND itab.
itab-lt = 1.
APPEND itab.
itab-lt = 3.
APPEND itab.
itab-lt = 3.
APPEND itab.
itab-lt = 3.
APPEND itab.</b>
<b> alvly-lights_fieldname = 'LT'.
alvly-lights_tabname = 'ITAB'.</b>
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = alvfc
is_layout = alvly
i_save = 'A'
TABLES
t_outtab = itab.
regards,
amit m.
Similar Messages
-
Need to remove space for a field when displayed in ALV Report
Hi,
I have material field of length 18, but the content is only 10 char. I need to remove the extra space when it is displayed on ALV Report.
Is there any option in ALV field catalogueuse statement condense.
condense zmatnr.
also giv output lenth of alv column as 10. -
Hi,
What is the best way to display an ALV report in the Portal?
I would like the report to be displayed in the GUI of the Portal (meaning, I would like to work with WebDynpro or PDK or any other way such that the GUI will be identical to all the other Portal objects).
Thanks in advance,
AviadHi,
You can actually, as suggested by others, code the PDV_ALV found in the PDK yourself.
All you need is to understand the workflow of the BAPI called "PORTAL_ALV_QUERY_CALL".
This BAPI is configured to get the properties of a query and another BAPI (derived from Z_QUERY_SELECTIONS) which plants additional data in the original query.
For example - If you wish to activate a query called myQuery1 in the user group FI-AP with a variant called TEST between a date range selected by the portal user. The parameters passed to the BAPI are as follows -
"QUERY_NAME=myQuery1"
"QUERY_USERGROUP=FI-AP"
"QUERY_VARIANT=TEST"
"QUERY_CREATE_SELTAB_FM=Z_QUERY_SELECTIONS_1"
"FROM_DATE="
"TO_DATE="
What will happen in the background is that the query myQuery1 from the usergroup FI-AP will be activated using the variant TEST and using the QUERY_CREATE_SELTAB_FM value the date fileds will be assigned to their corresponding fields in the query. After the activation the BAPI will return a table with the result.
Hope it helps,
Aviad -
What is the difference between list display and grid display in alv report
Hai genious
i am a new of the abap, i dont know the alv report, i have a small doubt, can u please tell me what is the main difference between list display and grid display in alv report
thanks®ards
chinnuHi ,
1. For all practical purposes, they are the same.
2. Some differences:
a) from abap coding point of view,
alv list is done with Function modules,
alv gris can also be done with FM,
but can also be done using OO concepts.
b) Alv grid (using oo concept) requires
designing the screen layout .
Hence, in one screen, we can show more
then one alv grid
(we cannot show more than
one alv list on one screen)
c) ALV grid uses ActiveX controls
present on the Presentation Server.
Hence, it consumes More Memory
on the presentation server.
d) ALV LIST is Display Only.
Whereas
ALV Grid Can Be made EDITABLE for entry purpose.
e) In alv grid, these options are possible,
but not in alv list.
without horizontal lines
without vertical lines
without cell merging during sorts
display total lines above the entries
I hope it helps.
Regards,
Mamta
Edited by: Mamta Verma on Nov 27, 2008 6:41 AM -
How to display the alv report blocks wise with out using the blocked alv
Hi
How to display the alv report with out using the blocked alv function module.
Thanks
Chinnusee this Standard Program
RPR_ABAP_SOURCE_SCAN -
Sub total icon is not displaying in alv report output
Hi friends ,
In alv report display on menu bar the icon : subtotals is not displaying at the output , I should not give subtotal in each field catalog .
Plz give me solution, points will be rewarded.
with regards,
prasad.Hi,
I think u r using PF-STATUS parameter in function module,
if u use this parameter, you sholud give the icon name etc..
otherwise by default it will appear.
Check your code again.
Give me exact requirement, if possible paste the code.
Regards,
Chandu -
HI all,
I have developed an ALV Report. In the ALV display, i would like to sum see the Sum (Total) of few fields like Qty, Net value etc when i select that particular column and click the 'SUM" icon.
In my Report when i do so, the Program is displaying Runtime Error.
How to resolve this issue?
Any idea?
Regards
PavanYou must make sure that these columns are defined correctly in the field catalog and in the internal table. For example, make sure that the quantity field is typed as such in the internal table.
data: begin of itab occurs 0,
qty type p decimals 2,
end of itab.
And then in your field catalog, make sure that the DATATYPE is set correctly.
ls_fcat-datatype = 'QUAN'.
Do this may help your situation. Also make sure that the data in these columns is all numeric.
Regards,
Rich Heilman -
Hi All,
I have developed an ALV Report, where i am displaying few lines of Texts proir to the ALV Layout. Its working fine.
Now there is a requirement to display few more lines of Text at the bottom of the screen.
i.e Text1
Text2
ALV Layout
Text3
Text4.
How to make the Text3 and text4 lines to display at the bottome of the ALV Layout....?????
Regards
Pavancall function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_html_end_of_list = 'END_OF_LIST_HTML'
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
*& Form end_of_list_html
* output at the end of the list - not in printed output *
FORM end_of_list_html USING end TYPE REF TO cl_dd_document.
DATA: ls_text TYPE sdydo_text_element,
l_grid TYPE REF TO cl_gui_alv_grid,
f(14) TYPE c VALUE 'SET_ROW_HEIGHT'.
ls_text = 'Footer title'.
* adds and icon (red triangle)
CALL METHOD end->add_icon
EXPORTING
sap_icon = 'ICON_MESSAGE_ERROR_SMALL'.
* adds test (via variable)
CALL METHOD end->add_text
EXPORTING
text = ls_text
sap_emphasis = 'strong'.
* adds new line (start new line)
CALL METHOD end->new_line.
* display text(bold)
CALL METHOD end->add_text
EXPORTING
text = 'Bold text'
sap_emphasis = 'strong'.
* adds new line (start new line)
CALL METHOD end->new_line.
* display text(normal)
CALL METHOD end->add_text
EXPORTING
text = 'Normal text'.
* adds new line (start new line)
CALL METHOD end->new_line.
* display text(bold)
CALL METHOD end->add_text
EXPORTING
text = 'Yellow triangle'
sap_emphasis = 'strong'.
* adds and icon (yellow triangle)
CALL METHOD end->add_icon
EXPORTING
sap_icon = 'ICON_LED_YELLOW'.
* display text(normal)
CALL METHOD end->add_text
EXPORTING
text = 'More text'.
*set height of this section
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_grid.
CALL METHOD l_grid->parent->parent->(f)
EXPORTING
id = 3
height = 14.
ENDFORM. "end_of_list_html. -
Column Heading are not displayed in ALV Report using CL_SALV_DISPLAY?
Hi,
I am using CL_SALV_DISPLAY class to display data. I Created an Internal Table Dynamically based fieldcatalog which was prepared based data at run time. When i displayed data using CL_SALC_DISPALY data is display in output but column headings are not displayed.
can anyone suggest me how to display heading in ALV using CL_SALV_DISPLAY class, My code is
CLASS lcl_report DEFINITION
CLASS lcl_report DEFINITION.
PUBLIC SECTION.
METHODS:
display IMPORTING l_table TYPE string
l_fcat TYPE string.
ENDCLASS. "lcl_report DEFINITION
CLASS lcl_report IMPLEMENTATION
CLASS lcl_report IMPLEMENTATION.
METHOD display.
DATA: gr_table TYPE REF TO cl_salv_table.
DATA: gr_columns TYPE REF TO cl_salv_columns_table,
gr_column TYPE REF TO cl_salv_column_table,
ls_fcat TYPE slis_fieldcat_alv.
DATA: gr_display TYPE REF TO cl_salv_display_settings.
DATA: l_o_functions TYPE REF TO cl_salv_functions_list,
l_field TYPE string.
FIELD-SYMBOLS : <fs_table> TYPE STANDARD TABLE,
<ft_fcat> TYPE STANDARD TABLE.
Get the ALV object refering to the output table
ASSIGN (l_table) TO <fs_table>.
ASSIGN (l_fcat) TO <ft_fcat>.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = <fs_table> ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
Add basic default functionality in the ALV report
Functions
l_o_functions = gr_table->get_functions( ).
l_o_functions->set_all( abap_true ).
gr_columns = gr_table->get_columns( ).
gr_columns->set_headers_visible( abap_true ).
Display the list
gr_table->display( ).
ENDMETHOD. "extract
ENDCLASS. "lcl_report IMPLEMENTATION
*& start-of-selection declaration
START-OF-SELECTION.
PERFORM :
get store codes
get_storecodes USING p_stfile
CHANGING it_t001w,
fetching mard data
read_mard_data,
preparing fieldcatalog for Final Data
create_filedcat USING it_t001w
it_site
CHANGING it_fieldcat,
preparing structure & internal table for Final Data
create_final_table_structure USING it_fieldcat,
prepare output data
prepare_final_data.
*& end-of-selection declaration
END-OF-SELECTION.
PERFORM :
display data
display_data USING l_table
l_fcat.
*& Form get_storecodes
FORM get_storecodes USING p_p_stfile
CHANGING p_it_t001w LIKE it_t001w[].
DATA :
internal table for RAW
lt_raw TYPE truxs_t_text_data,
rs_site LIKE LINE OF rt_site,
l_index LIKE sy-tabix.
FIELD-SYMBOLS :
field symbol for it_t001w
<fs_t001w> LIKE LINE OF p_it_t001w.
calling function module to get Stores Data from File
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = lt_raw
i_filename = p_p_stfile
TABLES
i_tab_converted_data = p_it_t001w[]
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT.
ENDIF.
SORT p_it_t001w BY werks.
CLEAR rs_site.
rs_site-sign = 'I'.
rs_site-option = 'EQ'.
rs_site-low = p_dccode.
APPEND rs_site TO rt_site.
IF it_t001w[] IS NOT INITIAL.
LOOP AT p_it_t001w ASSIGNING <fs_t001w>.
l_index = sy-tabix.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = <fs_t001w>-werks
IMPORTING
output = <fs_t001w>-werks.
MODIFY p_it_t001w FROM <fs_t001w> INDEX l_index.
IF <fs_t001w>-werks GE s_site-low AND <fs_t001w>-werks LE s_site-high.
append site to ranges
CLEAR rs_site.
rs_site-sign = 'I'.
rs_site-option = 'EQ'.
rs_site-low = <fs_t001w>-werks.
APPEND rs_site TO rt_site.
CONTINUE.
ENDIF.
ENDLOOP.
SORT p_it_t001w BY werks.
SORT rt_site.
ENDIF.
ENDFORM. " get_storecodes
*& Form create_final_table_structure
FORM create_filedcat USING p_it_t001w LIKE it_t001w[]
p_it_site LIKE it_site[]
CHANGING p_it_fieldcat LIKE it_fieldcat[].
FIELD-SYMBOLS :
field symbol for p_it_t001w
<fs_t001w> LIKE LINE OF p_it_t001w,
field symbol for p_it_site
<fs_site> LIKE LINE OF p_it_site.
DATA :
fieldname
l_fieldname TYPE slis_fieldname,
workarea for site ranges
rs_site LIKE LINE OF rt_site.
CLEAR : l_fieldname, rs_site.
l_fieldname = p_dccode.
PERFORM
prepare fieldcatalog
build_fieldcatalog USING : 'MTART' 'CHAR' '5' ,
'MTBEZ' 'CHAR' '25' ,
'MATKL' 'CHAR' '6' ,
'WGBEZ' 'CHAR' '20' ,
'MATNR' 'CHAR' '18' ,
'MAKTX' 'CHAR' '30' ,
l_fieldname 'CHAR' '17' .
create header for excel
PERFORM create_excel_header USING : 'Division',
'Divsion Description',
'MC Code',
'MC Description',
'Article',
'Article Description',
l_fieldname.
loop for creating fieldcatalog
LOOP AT it_site ASSIGNING <fs_site>.
READ TABLE it_t001w ASSIGNING <fs_t001w> WITH KEY werks = <fs_site>-werks
BINARY SEARCH.
IF sy-subrc = 0 AND <fs_t001w> IS ASSIGNED AND
<fs_site> IS ASSIGNED AND <fs_site>-stock GT 0.
CLEAR : l_fieldname, rs_site.
l_fieldname = <fs_site>-werks.
prepare fieldcatalog
PERFORM build_fieldcatalog USING : l_fieldname 'CHAR' '17'.
create header for excel
PERFORM create_excel_header USING l_fieldname .
CONTINUE.
ENDIF.
ENDLOOP.
l_fcat = 'it_fieldcat[]'.
ENDFORM. " create_final_table_structure
*& Form build_fieldcatalog
FORM build_fieldcatalog USING p_fieldname TYPE slis_fieldname
p_datatype TYPE datatype_d
p_length TYPE intlen.
DATA : ls_fieldcat LIKE LINE OF it_fieldcat.
CLEAR : ls_fieldcat.
ls_fieldcat-fieldname = p_fieldname.
ls_fieldcat-datatype = p_datatype.
ls_fieldcat-intlen = p_length.
APPEND ls_fieldcat TO it_fieldcat.
ENDFORM. " build_fieldcatalog
*& Form create_final_table_structure
FORM create_final_table_structure USING p_it_fieldcat.
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = t_table.
ASSIGN t_table->* TO <ft_final>.
ENDFORM. " create_final_table_structure
*& Form create_excel_header
FORM create_excel_header USING p_p_fieldname.
DATA : ls_header LIKE LINE OF it_header.
CLEAR ls_header.
ls_header-col_name = p_p_fieldname.
APPEND ls_header TO it_header.
ENDFORM. " create_excel_header
*& Form prepare_final_data
FORM prepare_final_data .
DATA : l_matnr LIKE g_matnr,
l_werks LIKE g_werks,
l_index LIKE sy-tabix.
FIELD-SYMBOLS : <fs_mard> LIKE LINE OF it_mard.
Getting No. of Lines in IT_MARD internal table
DESCRIBE TABLE it_mard LINES g_lines.
LOOP AT it_mard ASSIGNING <fs_mard>.
l_index = sy-tabix.
IF l_matnr IS INITIAL.
l_matnr = <fs_mard>-matnr.
CLEAR : l_werks.
l_werks = <fs_mard>-werks.
UNASSIGN : <fs_value>, <fs_final>.
Create dynamic work area and assign to FS
CREATE DATA t_line LIKE LINE OF <ft_final>.
ASSIGN t_line->* TO <fs_final>.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_mard>-matnr.
ASSIGN COMPONENT l_werks OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_value> + <fs_mard>-labst.
getting Article Type,MC & its Descriptions
PERFORM get_other_data USING l_matnr
l_werks.
ELSEIF l_matnr <> <fs_mard>-matnr.
APPEND <fs_final> TO <ft_final>.
CLEAR l_matnr.
l_matnr = <fs_mard>-matnr.
CLEAR : l_werks.
l_werks = <fs_mard>-werks.
UNASSIGN : <fs_value>, <fs_final>.
Create dynamic work area and assign to FS
CREATE DATA t_line LIKE LINE OF <ft_final>.
ASSIGN t_line->* TO <fs_final>.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_mard>-matnr.
ASSIGN COMPONENT l_werks OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_value> + <fs_mard>-labst.
getting Article Type,MC & its Descriptions
PERFORM get_other_data USING l_matnr
l_werks.
ELSE.
CLEAR : l_werks.
l_werks = <fs_mard>-werks.
ASSIGN COMPONENT l_werks OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_value> + <fs_mard>-labst.
ENDIF.
IF l_index = g_lines.
APPEND <fs_final> TO <ft_final>.
ENDIF.
ENDLOOP.
l_table = '<ft_final>[]'.
ENDFORM. " prepare_final_data
*& Form get_other_data
FORM get_other_data USING p_l_matnr
p_l_werks.
FIELD-SYMBOLS : <fs_mara> LIKE LINE OF it_mara,
<fs_t023t> LIKE LINE OF it_t023t,
<fs_t134t> LIKE LINE OF it_t134t,
<fs_makt> LIKE LINE OF it_makt.
READ TABLE it_mara ASSIGNING <fs_mara> WITH KEY matnr = p_l_matnr. " BINARY SEARCH.
IF sy-subrc = 0 AND <fs_mara> IS ASSIGNED.
ASSIGN COMPONENT 'MTART' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_mara>-mtart.
ASSIGN COMPONENT 'MATKL' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_mara>-matkl.
READ TABLE it_makt ASSIGNING <fs_makt> WITH KEY matnr = <fs_mara>-matnr BINARY SEARCH.
IF sy-subrc = 0 AND <fs_makt> IS ASSIGNED.
ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_makt>-maktx.
ENDIF.
READ TABLE it_t023t ASSIGNING <fs_t023t> WITH KEY matkl = <fs_mara>-matkl BINARY SEARCH.
IF sy-subrc = 0 AND <fs_t023t> IS ASSIGNED.
ASSIGN COMPONENT 'WGBEZ' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_t023t>-wgbez.
ENDIF.
READ TABLE it_t134t ASSIGNING <fs_t134t> WITH KEY mtart = <fs_mara>-mtart BINARY SEARCH.
IF sy-subrc = 0 AND <fs_t134t> IS ASSIGNED.
ASSIGN COMPONENT 'MTBEZ' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_t134t>-mtbez.
ENDIF.
ENDIF.
ENDFORM. " get_other_data
*& Form display_data
text
FORM display_data USING p_l_table
p_l_fcat.
DATA:
Variable for Object Creation
o_report TYPE REF TO lcl_report.
CREATE OBJECT o_report.
o_report->display( EXPORTING l_table = p_l_table
l_fcat = p_l_fcat ).
ENDFORM. " display_dataI don't know how to read the code you pasted or I would have checked this myself.
Do your fields in the internal table reference dictionary objects or elementary types? If not using dictionary types, the column names will be blank by default. If you can't change your fields to be dictionary types, you can try this to change the column names:
I made a method inside my local class to add the names:
call method set_colname
EXPORTING iv_tab = alv_tab
iv_colid = 'xxxx' "fieldname from the table
iv_stxt = text-t54
iv_mtxt = text-t55
iv_ltxt = text-t55.
METHOD set_colname .
data:
alv_cols type REF TO cl_salv_columns_table,
alv_col type REF TO cl_salv_column.
TRY .
*... Change fieldnames
call METHOD iv_tab->get_columns RECEIVING value = alv_cols.
call method alv_cols->get_column EXPORTING columnname = iv_colid RECEIVING value = alv_col.
IF iv_stxt <> ''.
CALL METHOD alv_col->set_short_text EXPORTING value = iv_stxt.
ENDIF.
IF iv_mtxt <> ''.
CALL METHOD alv_col->set_medium_text EXPORTING value = iv_mtxt.
ENDIF.
IF iv_ltxt <> ''.
CALL METHOD alv_col->set_long_text EXPORTING value = iv_ltxt.
ENDIF.
CATCH cx_salv_not_found.
ENDTRY.
ENDMETHOD. "set_colname -
How can we split the grid display in alv reports.
hi everyone.i am trying to get the display of two reports in a single one using split screens.i had written a report for vendor balance.one for open and one for cleared items.how can i combine these two reports.
the field catalog was same for these two.
can anyone suggest me suitable way to perform.HI,
You can also try ALV Blocked display.
Pls Check following program
BCALV_TEST_BLOCK_LIST.
FM used are
call function 'REUSE_ALV_BLOCK_LIST_INIT'
exporting
i_callback_program = sy-repid.
call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = it_layout
it_fieldcat = fc
i_tabname = 'IT_VBRK1'
it_events = it_event
tables
t_outtab = it_vbrk1.
call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = it_layout
it_fieldcat = fc1
i_tabname = 'IT_VBRK2'
it_events = it_event
tables
t_outtab = it_vbrk2.
call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
form top_of_page1.
format color col_positive.
write: / 'FIRST BLOCK'.
endform. -
How to read complete line displayed thru ALV report on double click? urgent
Hi guys,
An ALV report is displayed using 'REUSE_ALV_LIST_DISPLAY' and i have a requirement such that i have to read the line item on which double click is done.
I have to fetch the line item, field by field and not by characters. I have attached the function code and all using PF status.
Please tell me an approach as how to fetch the line item on which double click is done.
Points will be rewarded.
Regards
RahulHi ..
i did report with belnr , bukrs , Gjahr . which will call the transcation code FB03 displaing thedocument ...
please cut and paste the report it will work ..
REPORT zdemo_alvgrid .
TABLES: bkpf . " ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
BUKRS like bkpf-BUKRS,
BELNR like bkpf-BELNR,
GJAHR like bkpf-GJAHR,
BLART like bkpf-BLART,
BLDAT like bkpf-BLDAT,
BUDAT like bkpf-BUDAT,
MONAT like bkpf-MONAT,
XBLNR like bkpf-XBLNR ,
* 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 = 'BUKRS'.
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 = 'BELNR'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'GJAHR'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'BLART'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'BLDAT'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'BUDAT'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MONAT'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'XBLNR'.
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 BUKRS
BELNR
GJAHR
BLART
BLDAT
BUDAT
MONAT
XBLNR up to 10 rows
from bkpf
into table it_ekko.
*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 = 'BELNR'.
* 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-bELNR .
SET PARAMETER ID 'MES' FIELD wa_ekko-bUKRS .
SET PARAMETER ID 'DES' FIELD wa_ekko-GJAHR .
* Sxecute transaction ME23N, and skip initial data entry screen
* CALL TRANSACTION 'FB03' AND SKIP first screen.
SUBMIT RFBUEB00
* WITH ALCUR ...
* WITH ARCHOBJ ...
* WITH ARCH_SEL ...
* WITH ARUSETYP ...
* WITH AUTBEXNO ...
* WITH AUTH_BUK ...
* WITH AUTH_LDR ...
* WITH BR_AWKEY ...
* WITH BR_AWSYS ...
* WITH BR_AWTYP ...
WITH BR_BELNR = wa_ekko-bELNR
* WITH BR_BLART ...
* WITH BR_BLDAT ...
* WITH BR_BUDAT ...
WITH BR_BUKRS = wa_ekko-bUKRS
* WITH BR_CPUDT ...
WITH BR_GJAHR = wa_ekko-GJAHR
* WITH BR_RLDNR ...
* WITH BR_SEQ ...
* WITH BR_USNAM ...
* WITH BR_XBLNR ...
* WITH EXCDT ...
* WITH P_STATS ...
* WITH STATISTK ...
* WITH STATUSD ...
* WITH STATUSL ...
* WITH STATUSM ...
* WITH STATUSS ...
* WITH STATUSV ...
* WITH TCODE ...
* WITH UNAME ...
* WITH XEMUCNV ...
* WITH XUSEAR ...
* WITH XUSEAS ...
* WITH XUSEDB
AND RETURN .
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.
reward points if it is usefull ...
Girish -
Displaying an ALV report using a saved layout.
Dear friends
In ALV report there are 2 standard buttons.
One says "select Layout CTRLF9" and another one says "Save Layout CTRLF10".
Using this I can select the layout and save it using some variable.
Now I want to create a field in the main screen so that when
I enter this saved name and run the ALV report, it should show
report using the layout I entered selected (which was saved earlier).
Where will this variable get saved and how can i access this and make it
display using this layout.
Any feed back will be greatly appreciated.
Thanks
RamHi Ram,
Try this code..
BR
Rakesh
**// INITIALIZATION.
initialization.
perform initialize_variables.
**// AT SELECTION-SCREEN.
at selection-screen.
if p_vari is initial.
variant_init.
endif.
perform check_email.
at selection-screen on value-request for p_vari.
alv_f4_for_variant. "#EC
at selection-screen on p_vari.
alv_pai_of_selection_screen.
M A C R O S *
define variant_init.
clear: disvariant,
vartext.
if v_pgm is initial.
disvariant-report = sy-cprog.
else.
disvariant-report = v_pgm.
endif.
end-of-definition.
define alv_f4_for_variant.
variant_init.
call function 'REUSE_ALV_VARIANT_F4'
exporting
is_variant = disvariant
i_save = xsave
importing
e_exit = i_exit
es_variant = disvariant
exceptions
not_found = 2.
if sy-subrc = 2.
message id sy-msgid type 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
elseif i_exit = space.
p_vari = disvariant-variant.
vartext = disvariant-text.
refresh i_dynpread.
i_dynpread-fieldname = 'VARTEXT'.
i_dynpread-fieldvalue = disvariant-text.
append i_dynpread.
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = v_pgm
dynumb = '1000'
tables
dynpfields = i_dynpread.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
else.
variant_init.
endif.
end-of-definition.
define alv_pai_of_selection_screen.
if not p_vari is initial.
move p_vari to disvariant-variant.
call function 'REUSE_ALV_VARIANT_EXISTENCE'
exporting
i_save = xsave
changing
cs_variant = disvariant.
vartext = disvariant-text.
else.
variant_init.
endif.
end-of-definition. -
0.00 is currency not displaying in ALV REPORT......
Hi All,
There is a currency field in the internal table which is not displaying only value 0.00 if the value is 0.03 then it is displaying in ALV.
I have checked the Internal Table passed in the FM: REUSE_ALV_LIST_DISPLAY but it is carrying the value 0.00. But while displaying it is not displaying in the report.
I have also checked the Field catalogue there is no such conditions mentioned.
Kindly help me.
Thanks in Advance.
MPHi MP,
while handling witht eh currency fields make sure that the following are taken care of
in the field catalog use:
gs_field-datatype = 'CURR'.
gs_field-inttype = 'C'.
also the following
fieldcatalog-no_zero = 'X'. should be taken care of otherwise it will not display the zeros appearing in the final internal table for ALV display.
Hope its helpful
Thanks,
Srikanth.P -
How can we update after the list displays in ALV report.
HI all sap gurus,
I have one ALV report, after executing the report list will displays there i need to update the data. please give me answer without oops concept.
thanks,
reddyYOu need to make some fields editable in order to update the data.
for that you should set the EDIT = 'X' in the field catalog for that column.
Regards,
Ravi -
New field category not display in ALV report
Hi,
Hi, I modifying an existing ALV report.
I have a problem to insert the new field into the ALV report.
The field and column title have been populated in alv field category correctly, but when FM 'REUSE_ALV_GRID_DISPLAY' executed, the new field and column didn't appear.
Anybody can help me.
Regards
Nislinahi
Add that new field in the fieldcatalog and populate the value in the value in the internal table.
loop at it_fieldcatalog into wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'NEW_FIELD'.
wa_fieldcatalog-outputlen = '15'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog,
endloop.
regards
ravish
<b>plz reward points if helpful</b>
Maybe you are looking for
-
SharePoint FBA with Sharepoint list
We have been searching for a good tutorial in setting up SharePoint FBA using a SharePoint list as the authentication source but there is very little out there. CodePlex has a project called SPListMP but we were not successful in getting it to run p
-
Push notifications and tag subscriptions suddenly stopped
Push notifications and registrations have suddenly stopped working (working fine for 4 months). I cannot figure out why. Can someone please help? The only change I made on the server is to delete the TodoItem table (from azure example, which I'm not
-
Can't play flv in acrobat pro 9
Hi, I want to play a flv clip in acrobat 9 pro. I can import it but if I want to play the clip I get only a grey square. I use adobe premiere pro cs4 to export the clip to flv. What I'm doing wrong? Thx
-
The brushes I have now have no texture at all. They use to when i first downloaded them but now they are just slaps of solid paint. It use to not be like this: [IMG]http://i1199.photobucket.com/albums/aa470/DragonKeeper222/Untitled-1-3.png[/IMG] Here
-
How can i find out what i can upgrade in my hardware? For a Pavilion p7-1254
OS : Windows 7 Ultimate Processor : AMD A6-3620 APU with Radeon HD Graphics 2.20 GHz RAM : 8 GB 64-bit OS