How change standard field lable in alv grid display
Hi Experts,
How are you doing! I am having some doubts in the alv grid display, I am new to this concepts.
I want to display field lable manually, actually its taking from table field discription but I want to display one field name manually.
example code.
ls_fldcat-fieldname = 'BPKIND'.
ls_fldcat-ref_tabname = 'BUT000'.
ls_fldcat-ref_fieldname = 'BPKIND'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'PARTNER2'.
ls_fldcat-ref_tabname = 'BUT051'.
ls_fldcat-ref_fieldname = 'PARTNER2'.
Here I dont want to display 'PARTNER2' I need 'KEY ACCOUNT MANAGER'.
Please send me how to do this.
Surya Ramireddy.
Hi
Please check out this program.
Type-pools: slis.
Tables: likp.
Data: Begin of i_likp occurs 0,
vbeln like likp-vbeln,
ernam like likp-ernam,
erzet like likp-erzet,
erdat like likp-erdat,
End of i_likp.
Data: it_fieldcat type slis_t_fieldcat_alv,
wa_fieldcat type SLIS_FIELDCAT_ALV,
it_events type slis_t_event.
Selection-screen: Begin of block b1 with frame title text-001.
select-options: s_vbeln for likp-vbeln.
Selection-screen: End of block b1.
start-of-selection.
perform get_sales_header_data.
end-of-selection.
perform field_catalogue.
perform modify_field_catalogue.
perform display_alv_grid_display.
*& Form get_sales_header_data
text
--> p1 text
<-- p2 text
form get_sales_header_data .
select vbeln
ernam
erzet
erdat
into table i_likp
from likp
where vbeln in s_vbeln.
endform. " get_sales_header_data
*& Form field_catalogue
text
--> p1 text
<-- p2 text
form field_catalogue .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-repid
I_INTERNAL_TABNAME = 'I_LIKP'
I_INCLNAME = sy-repid
CHANGING
ct_fieldcat = it_fieldcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
endform. " field_catalogue
*& Form modify_field_catalogue
text
--> p1 text
<-- p2 text
form modify_field_catalogue .
loop at it_fieldcat into wa_fieldcat.
case wa_fieldcat-fieldname.
when 'VBELN'.
wa_fieldcat-col_pos = 1.
wa_fieldcat-seltext_l = 'Sales Doc Header No'.
wa_fieldcat-emphasize = 'C100'.
when 'ERNAM'.
wa_fieldcat-col_pos = 2.
wa_fieldcat-seltext_l = 'Created By'.
wa_fieldcat-emphasize = 'C200'.
when 'ERZET'.
wa_fieldcat-col_pos = 3.
wa_fieldcat-seltext_l = 'Entry Time'.
wa_fieldcat-emphasize = 'C300'.
when 'ERDAT'.
wa_fieldcat-col_pos = 4.
wa_fieldcat-seltext_l = 'Created On'.
wa_fieldcat-emphasize = 'C400'.
endcase.
modify it_fieldcat from wa_fieldcat.
endloop.
endform. " modify_field_catalogue
*& Form display_alv_grid_display
text
--> p1 text
<-- p2 text
form display_alv_grid_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IT_FIELDCAT = IT_FIELDCAT
TABLES
t_outtab = i_likp
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
endform. " display_alv_grid_display
Regards
Haritha.
Similar Messages
-
Field Catolgue in alv grid display
Hi Abapers,
I need to display the percentage rows with decimals and other rows without decimal . Is their any option in field catalog to do like this. Or tell me any other alternative to achieve this.
sno total col1 col2 col3
1 220 100 20 100
2 320 120 50 150
tot 540 220 70 250
per 40.74 1.87 and so on
or ,
I have two different internal tables how can i put it in one field catalog to pass it to alv grid display.
Regards,
PriyaDon't do total by your self in the Pogram.
in the Fieldcatalog there is an Attribute which will do total & Average .
Enable it so that from one internal table data it self it will do good.
example program
Below is an example ABAP program which will populate a simple internal table(it_ekpo) with data and
display it using the basic ALV grid functionality(including column total). The example details the main
sections of coding required to implement the ALV grid functionality:
Data declaration
Data retrieval
Build fieldcatalog
Build layout setup
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.
*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.
* 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'. "Display column total
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_XEVENTS
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
gowri
Message was edited by:
Gowri Krishna -
Error in field catalog in ALV grid display using classes at do_sum = "X'.
Hi,
I'm using classes in ALV Grid display.
the code for the field catalog is going to dump because of the statement in the field catalog for field 'netwr',do_sum = 'X'.
that do_sum = 'X' is not working and going to dump when executed.with out that do_sum it is working fine. the error in dump analysys is showing sap standard incude LSLVCF01.
assign component
<ls_fieldcat>-fieldname of structure rt_data to <g_field>.
if sy-subrc ne 0.
message x000(0k).
endif.
sy-subrc is 4 when the program is being executed.
CODE:
FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
ls_fcat-fieldname = 'VBELN1'.
ls_fcat-ref_field = 'VBELN'.
ls_fcat-ref_table = 'VBRK'.
ls_fcat-coltext = 'Invoice No'.
ls_fcat-seltext = 'Invoice No'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'BUDAT'.
ls_fcat-ref_table = 'BKPF'.
ls_fcat-coltext = 'Invoice Date'.
ls_fcat-seltext = 'Invoice Date'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'NETWR'.
ls_fcat-ref_field = 'NETWR'.
ls_fcat-ref_table = 'VBRK'.
ls_fcat-coltext = 'Value of Invoice'.
ls_fcat-seltext = 'Value of Invoice'.
ls_fcat-datatype = 'CURR'.
ls_fcat-do_sum = 'X'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ENDFORM.
can u please look in the code and rectify the error,
would appeciate ur response.
regards,
veera.Hi,
try this..
ls_fcat-fieldname = 'NETWR'.
ls_fcat-ref_field = 'NETWR'.
ls_fcat-ref_table = 'VBRK'.
ls_fcat-coltext = 'Value of Invoice'.
ls_fcat-seltext = 'Value of Invoice'.
ls_fcat-datatype = 'CURR'.
ls_fcat-do_sum = 'X'.
<b>ls_fcat-cfieldname = 'WAERS'.</b>
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
Regards
vijay -
How to color a row in ALV grid display
Hi,
A few rows in the output of ALV grid display should be shown in different color.How can I achieve this?Hi,
Try out this code
DATA : BEGIN OF G_T_CASH OCCURS 0,
PARTICULARS TYPE CHAR120,
AMOUNT1 TYPE CHAR20,
AMOUNT2 TYPE CHAR20,
AMOUNT3 TYPE CHAR20,
ROW_COLOR TYPE CHAR4,----
add this in the internal table for alv
END OF G_T_CASH.
CLEAR G_WA_CASH.
G_WA_CASH-PARTICULARS = 'Opening Cash Balance'.
G_WA_CASH-AMOUNT1 = G_DMBTR.
G_WA_CASH-AMOUNT2 = ''.
G_WA_CASH-AMOUNT3 = ''.
while appending other values also add the following code
G_WA_CASH-ROW_COLOR = 'C200'.----- C200 depicts light gray color
APPEND G_WA_CASH TO G_T_CASH.
add the following code in layout
MOVE 'ROW_COLOR' TO WA_LS_LAYOUT-INFO_FIELDNAME.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_BYPASSING_BUFFER = ' '
I_SAVE = 'A'
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = WA_LS_LAYOUT
IT_FIELDCAT = G_T_CATALOG
IT_EVENTS = GT_EVENTS
TABLES
T_OUTTAB = G_T_CASH[]
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.
Let me know if the problem still persist.
Regards,
Janaki -
How to capture the event in ALV grid display?
Hi experts,
How to capture the event in an ALV grid display which is editable. I have to capture the TAB key or ENTER key.
regards,
Arul Jothi.Hi Arul,
Take a look at sample program BCALV_EDIT_03. (Find string "register ENTER" in the program to see how to register)
Basically you have to Register edit events using method call REGISTER_EDIT_EVENT and then write a handler method for event DATA_CHANGED..
If you are using a REUSE..GRID fm then first get the grid reference using function module GET_GLOBALS_FROM_SLVC_FULLSCR and then repeat the above procedure..
Hope this helps..
Sri
Message was edited by: Srikanth Pinnamaneni -
How to focus a cell on ALV grid display
hi,
I need to set the focus to the first cell on the first row in the ALV grid.I am using object oriented ALV grid control.Can anyone help me out in this regard.
Regards,
Anil.Re: simple Grid display
Have a look at below links. It contains sample code for alv grid.
http://www.erpgenie.com/abap/controls/alvgrid.htm#Complete%20code%20for%20the%20ALV%20grid%20example
http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
http://sap.niraj.tripod.com/id64.html
Also have a look at below for OO alv grid:
http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b5533cd30911d2b467006094192fe3/frameset.htm
-->
ABAP List Viewer
The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
This helps us to implement all the features mentioned very effectively.
Using ALV, We can have three types of reports:
1. Simple Report
2. Block Report
3. Hierarchical Sequential Report
There are some function modules which will enable to produce the above reports without much effort.
All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
1. SIMPLE REPORT.
The important function modules are
a. Reuse_alv_list_display
b. Reuse_alv_fieldcatalog_merge
c. Reuse_alv_events_get
d. Reuse_alv_commentary_write
e. Reuse_alv_grid_display
A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
The important parameters are :
I. Export :
i. I_callback_program : report id
ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status iii. I_callback_user_command : routine where the function codes are handled iv. I_structure name : name of the dictionary table v. Is_layout : structure to set the layout of the report vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
II. Tables :
i. t_outtab : internal table with the data to be output
B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
The Important Parameters are :
I. Export :
i. I_program_name : report id
ii. I_internal_tabname : the internal output table iii. I_inclname : include or the report name where all the dynamic forms are handled.
II Changing
ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is declared in the type pool SLIS.
C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
Parameters :
I. Import :
Et_Events : The event table is returned with all possible CALLBACK events for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
II. Export :
I_List_type :
0 = simple list REUSE_ALV_LIST_DISPLAY
1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
3 = hierarchical-sequential block list
REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
Parameters :
I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
This internal table has three fields :
Typ : H header, S selection , A - action Key : only when typ is S.
Info : the text to be printed
E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
Parameters : same as reuse_alv_list_display
This is an example for simple list.
2. BLOCK REPORT
This is used to have multiple lists continuously.
The important functions used in this report are:
A. REUSE_ALV_BLOCK_LIST_INIT
B. REUSE_ALV_BLOCK_LIST_APPEND
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_BLOCK_LIST_DISPLAY
A. REUSE_ALV_BLOCK_LIST_INIT
Parameters:
I. I_CALLBACK_PROGRAM
II. I_CALLBACK_PF_STATUS_SET
III. I_CALLBACK_USER_COMMAND
This function module is used to set the default gui status etc.
B. REUSE_ALV_BLOCK_LIST_APPEND
Parameters :
Export :
I. is_layout : layout settings for block II. it_fieldcat : field catalog III. i_tabname : internal table name with output data IV. it_events : internal table with all possible events
Tables :
i. t_outtab : internal table with output data.
This function module adds the data to the block.
Repeat this function for all the different blocks to be displayed one after the other.
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
This function module is used for hierarchical sequential blocks.
D. REUSE_ALV_BLOCK_LIST_DISPLAY
Parameters : All the parameters are optional.
This function module display the list with data appended by the above function.
Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
3. Hierarchical reports :
Hierarchical sequential list output.
The function module is
A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
Parameters:
I. Export:
i. I_CALLBACK_PROGRAM
ii. I_CALLBACK_PF_STATUS_SET
iii. I_CALLBACK_USER_COMMAND
iv. IS_LAYOUT
v. IT_FIELDCAT
vi. IT_EVENTS
vii. i_tabname_header : Name of the internal table in the program containing the output data of the highest hierarchy level.
viii. i_tabname_item : Name of the internal table in the program containing the output data of the lowest hierarchy level.
ix. is_keyinfo : This structure contains the header and item table field names which link the two tables (shared key).
II. Tables
i. t_outtab_header : Header table with data to be output ii. t_outtab_item : Name of the internal table in the program containing the output data of the lowest hierarchy level.
slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using REUSE_ALV_FIELDCATALOG_MERGE.
Important Attributes :
A. col_pos : position of the column
B. fieldname : internal fieldname
C. tabname : internal table name
D. ref_fieldname : fieldname (dictionary) E. ref_tabname : table (dictionary) F. key(1) : column with key-color G. icon(1) : icon H. symbol(1) : symbol I. checkbox(1) : checkbox J. just(1) : (R)ight (L)eft (C)ent.
K. do_sum(1) : sum up
L. no_out(1) : (O)blig.(X)no out
M. outputlen : output length
N. seltext_l : long key word
O. seltext_m : middle key word
P. seltext_s : short key word
Q. reptext_ddic : heading (ddic)
R. ddictxt(1) : (S)hort (M)iddle (L)ong
S. datatype : datatype
T. hotspot(1) : hotspot
Simple ALV report
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
Go thru these programs they may help u to try on some hands on
ALV Demo program
BCALV_DEMO_HTML
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode BCALV_GRID_DEMO Simple ALV Control Call Demo Program BCALV_TREE_DEMO Demo for ALV tree control BCALV_TREE_SIMPLE_DEMO BC_ALV_DEMO_HTML_D0100
Reward If useful -
Increase the field width in ALV grid display
hi
My problem is that when i am trying to print data through REUSE_ALV_GRID_DISPLAY, a particular field which contain message is being truncated, i used ls_layout-colwidth_optimiser as 'X' and also t_fieldcat-outputlen = 1000, but still i am having this prblm, but i checked in the internal table that is passed in ALV, the entire data is stored there, but while printing its getting truncated for a particular field, please suggest me a solution to my problem.
Regards
SwarnaliHey Neelam
this is a very old thread, so I don t remember the exact solution which I implemented,
however can you use the i_tab name in the field TABNAME of the field catalog.
Regarding breaking the message, you can use a STRLEN if you are aware at the no. of chars where it should break always or split at space the string in 4 strings.
Inside the field catalog you have to take an internal table with 4 different fields and show it.
Hopefully it should resolve your problem.
Regards
SB -
Fields missing in ALV grid display output
Hello Friends,
I have done customer enhancement to VF04 tcode and i have added 2 new additional fields to the existing output.The program is working fine and its displaying the 2 new additional fields in the output display in development server.
But when i transported the program to Q server and i have observed that the 2 new additonal fields are not displayed in the output display but when I am selecting 'choose detail' push button on application tool bar it's showing the 2 new additional fields.In development server in the output 40 fields are displayed but in Q server only 9 fields are displayed.
Could you please help me regarding this.
Thanks in advance,
Arvind.register the enhancementy to the project in Q server .. might be it is not transferred
-
How to append a line in alv grid display
Hi experts!
I have to append a new line into my existing alv and then save it in the database.
can you help me out with that.
thanksHi,
Check these links for more details -
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
ashish -
Dump when summing up CURR field in ALV GRID display
Hi All,
I am getting dump when I try to sum the CURR field in my ALV Grid Display. The field is of CURR 23. I am using classes and methods to display alv grid.
I tried passing <fs_fieldcat>-do_sum = 'X'. When I did this, it is dumping without even displaying the alv grid.
Here is the part it is throwing dump:
ls_lvc_data-value = space.
clear ls_lvc_data-style.
loop at it_fcat_local assigning <ls_fcat>
where tech ne 'X' and no_out ne 'X'.
if l_invisible eq 'X'.
clear l_invisible.
if <ls_fcat>-do_sum is initial.
continue.
else.
clear ls_lvc_data-col_pos.
endif.
endif.
add 1 to ls_lvc_data-col_pos.
assign component <ls_fcat>-fieldname
of structure <ls_data> to <l_field_value>.
_if sy-subrc ne 0.
message x000(0k).
endif._
Regards,
GuruThomas,
Here is the dump:
Runtime Errors MESSAGE_TYPE_X
Date and Time 10/22/2010 23:30:53
Short text
The current application triggered a termination with a short dump.
What happened?
The current application program detected a situation which really
should not occur. Therefore, a termination with a short dump was
triggered on purpose by the key word MESSAGE (type X).
Error analysis
Short text of error message:
Long text of error message:
Technical information about the message:
Message class....... "0K"
Number.............. 000
Variable 1.......... " "
Variable 2.......... " "
Variable 3.......... " "
Variable 4.......... " "
How to correct the error
Probably the only way to eliminate the error is to correct the program.
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"MESSAGE_TYPE_X" " "
"SAPLSLVC" or "LSLVCF36"
"FILL_DATA_TABLE"
If you cannot solve the problem yourself and want to send an error
notification to SAP, include the following information:
1. The description of the current problem (short dump)
To save the description, choose "System->List->Save->Local File
(Unconverted)".
2. Corresponding system log
Display the system log by calling transaction SM21.
Restrict the time interval to 10 minutes before and five minutes
after the short dump. Then choose "System->List->Save->Local File
(Unconverted)".
3. If the problem occurs in a problem of your own or a modified SAP
program: The source code of the program
In the editor, choose "Utilities->More
Utilities->Upload/Download->Download".
4. Details about the conditions under which the error occurred or which
actions and input led to the error.
Source Code Extract
Line
SourceCde
2708
is_subtottxt_info = ls_subtot_info
2709
ip_subtot_line = lr_data
2710
changing
2711
c_subtottxt = l_subtottxt.
2712
ls_lvc_data-value = l_subtottxt.
2713
2714
append ls_lvc_data to ct_lvc_data.
2715
endif.
2716
2717
2718
Column per Fieldcat Entry
2719
2720
ls_lvc_data-value = space.
2721
clear ls_lvc_data-style.
2722
loop at it_fcat_local assigning <ls_fcat>
2723
where tech ne 'X' and no_out ne 'X'.
2724
if l_invisible eq 'X'.
2725
clear l_invisible.
2726
if <ls_fcat>-do_sum is initial.
2727
continue.
2728
else.
2729
clear ls_lvc_data-col_pos.
2730
endif.
2731
endif.
2732
2733
add 1 to ls_lvc_data-col_pos.
2734
2735
assign component <ls_fcat>-fieldname
2736
of structure <ls_data> to <l_field_value>.
2737
if sy-subrc ne 0.
>>>>>
message x000(0k).
2739
endif.
2740
2741
*... work on average
2742
if <ls_fcat>-do_sum eq 'C'.
2743
Initialize average result and entries
2744
<l_field_value> = 0.
2745
clear l_entries.
2746
2747
retrive unit from fieldcatalog
2748
assign space to <l_unit>.
2749
if not <ls_fcat>-cfieldname is initial.
2750
assign component <ls_fcat>-cfieldname
2751
of structure <ls_data> to <l_unit>.
2752
endif.
2753
if not <ls_fcat>-qfieldname is initial.
2754
assign component <ls_fcat>-qfieldname
2755
of structure <ls_data> to <l_unit>.
2756
endif.
2757 -
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 change sub total value in ALV Grid.
Hi All,
Can u please explain how to change SUBTOTAL Value in ALV Grid display based on another field value.
EX; F1 subtotal is initial then we have to modify the F2 sub total to 9999.9.
Thanks
Radha.Hi Radha,
I doubt if that can be changed....because the event that i was referring to in my previous post works with ALV List display...But in any case you can try that.....
There is an event in SLIS....(As i told you, i dont remember the name and currently i dont have access to SAP system, so i am not able to verify and let you know that event name).....
Other thatn TOP and END of PAGE events, there is an event for sub-total text......i think it would start with "SUBTOTAL"...
you need to use that event in your events table and pass it to ALV Grid display.
Then create a sub-routine with that name (As you do for TOP-OF-PAGE event)....and in this event you can change the values in runtime (PROVIDED, this event gets triggered for ALV GRID).....
If this does not work, i think calculating sub-totals while you build the internal table would be a better option....(If you have time constraint....else you can do some more research on the same)........
Best Regards,
Ram. -
How to change a color for a row in ALV grid display
Hi,
how to change a color for a row in ALV grid display based on a condition.Any sample code plzHello Ramya,
Did you check in [SCN|How to color a row of alv grid]
Thanks! -
How to make a field manadatory within ALV Grid using methods and classes
Hi,
I am using ALV Grid using set_table_for_first_display
inside my dialog programming. I have a field called project number inside my grid which has to be made as mandatory field.
I have defined a method called catch_data_changed inside my class lcl_event_receiver. This method captures the changes made to one of the fields inside my ALV grid and displays all the default values of the other fields from the grid.
Now, i have to make project number which is one of my fields inside my ALV grid as mandatory. At the field catalog level i did not find any such option for making a field as required field.
Is there any other way, i can accomplish this within the ALV grid?from my understanding from ur question, i understood that u want the editable field inside alvgrid to be mandatory.
i dont know anthing in fieldcat, but u can try the following logic.
FORM DATA_CHANGED USING P_ER_DATA_CHANGED TYPE REF TO
CL_ALV_CHANGED_DATA_PROTOCOL .
DATA: L_VALUE TYPE LVC_VALUE,
ls_mod_cell type lvc_s_modi.
READ TABLE P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
if sy-subrc = 0.
CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
EXPORTING
I_ROW_ID = LS_MOD_CELL-row_id
I_FIELDNAME = LS_MOD_CELL-fieldname
IMPORTING
E_VALUE = L_VALUE.
IF LS_MOD_CELL-FIELDNAME <> 'fieldname what u want'
MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
ENDIF.
ELSE.
MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
ENDIF. -
How to display field of 250 character length using ALV Grid display
Hello Experts,
Currently I'm using 4.6 version.
I got to insert a new field of length 250 characters into an existing ALV grid display.
I passed a value of length 250 chars into the field and assigned it to the itab passing to the fn module
'REUSE_ALV_GRID_DISPLAY'.
But in the ALV display I am able to view only 132 chars only. I increased the line-size of the report also accordingly. But I'm unable to view all the 250 chars.
Kindly help me out in fixing this issue.you just can't do that
I suggest that you put the first characters in cell and allow user to double-click on cell in order to view the full value in a popup window
Maybe you are looking for
-
How can I access data in different panels?
Hi, I'm a beginner in Swing and have a simple(?) question. Unfortunately I didn't find the answer by oneself so I hope you can help me. I have three classes. In the GUI.java class I build the JFrame and it's components. All components are added to th
-
For All Entries in i_tab
Hi Abapers, I am facing a problem while fetching the data from the database through 'FOR ALL ENTRIES IN '. Problem is actually there are 207 records in my database table But when I use 'FOR ALL ENTRIES IN I_TAB' I am getting only 179 records. Can any
-
I just paid for and downloaded the wrong version of Adobe Acrobat X Pro. I downloaded the Microsoft version and I have a Mac running OX Yosemite. How do I get a credit for what I ordered and then reorder the correct Mac version of Adobe Acrobat X Pro
-
I'm trying to print an Avery saved project (business card) and can't I was told my Adobe Reader is not configured correctly. My OS is Windows 7. What do I need to do? Chef Roberto
-
Why does Maverick's Apple Maps Require WiFi for Location?
I'm connected via ethernet to my cable router. Why do I need WiFi enabled on my iMac for Apple Maps to work? This makes no sense at all and it seems that the OS perfers to use the 54Mbps WiFi connection over my direct 1Gb cable connection. Surely thi