Remove / set focus on ALV using objects
I have a screen with 6 subscreen and 6 customercontainers with each 1 ALV, I have 6 ALV's on the same screen, some of the ALV's are only display, and some are for input, my problem is that each alv have fokus on the first cell I want to remove the fokus in all display alv's, I am using the method "set_current_cell_via_id" to place the fokus in edit cell for the alv's with editable cell's, but how to remove fokus in alv, where only display ?
Best regards Jørgen Jensen INIT A/S
Hello Jørgen
This is one of the rare occasion where I believe that something is NOT possible with SAP.
You may have a look at my sample report
ZUS_SDN_SPLITTER_CONTAINER and play around with various methods yet I doubt you will be successful.
*& Report ZUS_SDN_SPLITTER_CONTAINER
REPORT zus_sdn_splitter_container.
**type-pools: abap.
TYPES: ty_t_knb1 TYPE STANDARD TABLE OF knb1
WITH DEFAULT KEY.
TYPES: BEGIN OF ty_s_control.
TYPES: cell TYPE REF TO cl_gui_container.
TYPES: grid TYPE REF TO cl_gui_alv_grid.
TYPES: data TYPE ty_t_knb1.
TYPES: row TYPE lvc_s_row.
TYPES: layout TYPE lvc_s_layo.
TYPES: variant TYPE disvariant.
TYPES: END OF ty_s_control.
TYPES: ty_t_control TYPE STANDARD TABLE OF ty_s_control
WITH DEFAULT KEY.
DATA:
gs_control TYPE ty_s_control,
gt_controls TYPE ty_t_control.
DATA:
gd_repid TYPE syst-repid,
gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
** go_cell TYPE REF TO cl_gui_container,
** go_grid TYPE REF TO cl_gui_alv_grid,
gs_layout TYPE lvc_s_layo.
DATA:
gd_msg TYPE bapi_msg,
gd_perc TYPE i,
gd_lines TYPE i,
gd_idx TYPE i,
gd_cnt TYPE i,
gt_knb1 TYPE STANDARD TABLE OF knb1.
PARAMETERS:
p_row TYPE i DEFAULT '3',
p_col TYPE i DEFAULT '3'.
START-OF-SELECTION.
PERFORM init_controls.
DESCRIBE TABLE gt_controls.
gd_lines = syst-tfill.
SELECT * FROM knb1 INTO TABLE gt_knb1 UP TO 100 ROWS
WHERE bukrs = '1000'.
LOOP AT gt_controls INTO gs_control.
gd_idx = syst-tabix.
gd_cnt = syst-tabix * 5.
gd_perc = ( syst-tabix * 100 ) / gd_lines.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = gd_perc
* TEXT = ' '
gs_control-data = gt_knb1.
DELETE gt_knb1 INDEX 1.
" Set individual layout and variant
gs_control-layout-cwidth_opt = abap_true.
gs_control-layout-zebra = abap_true.
gs_control-layout-no_toolbar = abap_true.
gs_control-layout-smalltitle = abap_true.
gs_control-row-index = gd_idx.
WRITE gd_idx TO gs_control-layout-grid_title NO-ZERO.
CONDENSE gs_control-layout-grid_title NO-GAPS.
CONCATENATE gs_control-layout-grid_title
'. Customer'
INTO gs_control-layout-grid_title.
CALL METHOD gs_control-grid->set_table_for_first_display
EXPORTING
i_structure_name = 'KNB1'
is_layout = gs_control-layout
i_save = 'A'
is_variant = gs_control-variant
CHANGING
it_outtab = gs_control-data
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF ( gd_idx > 1 ).
CALL METHOD gs_control-grid->set_current_cell_via_id
EXPORTING
is_row_id = gs_control-row.
CALL METHOD gs_control-grid->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
* EXCEPTIONS
* FINISHED = 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.
ENDIF.
MODIFY gt_controls FROM gs_control INDEX gd_idx.
ENDLOOP.
gd_msg = gd_lines.
CONDENSE gd_msg NO-GAPS.
CONCATENATE gd_msg 'grids displayed on single screen.'
INTO gd_msg
SEPARATED BY space.
MESSAGE gd_msg TYPE 'S'.
* Link the docking container to the target dynpro
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
* Flow logic of dynpro (does not contain any dynpro elements):
*PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
*PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form INIT_CONTROLS
* text
* --> p1 text
* <-- p2 text
FORM init_controls .
* define local data
DATA:
ld_column TYPE i,
ls_control TYPE ty_s_control.
REFRESH: gt_controls.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_docking->set_extension( 99999 ).
* Create splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = p_row
columns = p_col
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_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.
DO p_col TIMES.
ld_column = syst-index.
DO p_row TIMES.
* Get cell container
CLEAR: ls_control.
CALL METHOD go_splitter->get_container
EXPORTING
row = syst-index
column = ld_column
RECEIVING
container = ls_control-cell.
* Create ALV grid
CREATE OBJECT ls_control-grid
EXPORTING
i_parent = ls_control-cell
EXCEPTIONS
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.
APPEND ls_control TO gt_controls.
ENDDO. " rows
ENDDO. " columns
ENDFORM. " INIT_CONTROLS
Regards
Uwe
Similar Messages
-
Setting focus in TextArea using AWT
I have looked at all the documentation for the TextArea in the API and cannot work out how to set the focus in a TextArea when a frame is loaded. Should it go in the constructor? the main method? the TextArea? I have tried to use hasFocus() but nothing is happening. Also how could I launch a dialog box when one of the menu items is selected? I'm trying to write a notepad application in Java. Thanks for any help
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class textpad extends Frame implements MouseListener{
TextArea inputarea;
GridBagLayout c;
MenuBar mb;
Menu filem, editm, searchm, helpm;
MenuItem newmenui, openmenui, savemenui, saveasmenui, exitmenui;
MenuItem undomenui, cutmenui, copymenui, pastemenui;
MenuItem findmenui, findnextmenui;
MenuItem helptopmenui, aboutmenui;
public textpad(String title)
super(title);
c=new GridBagLayout();
setLayout(c);
setLayout(null);
setSize(400,300);
setBackground(Color.gray);
//set position frame appears in screen??
TextArea inputarea = new TextArea("Does it work?");
inputarea.setBackground(Color.white);
inputarea.getAccessibleContext();
inputarea.setSize(399,270);
add(inputarea);
//set position within frame??
//add MenuBar
mb = new MenuBar();
setMenuBar(mb);
//Add File Menu to Bar
filem = new Menu("File");
mb.add(filem);
newmenui = new MenuItem("New");
filem.add(newmenui);
openmenui = new MenuItem("Open");
filem.add(openmenui);
savemenui = new MenuItem("Save");
filem.add(savemenui);
saveasmenui = new MenuItem("Save As");
filem.add(saveasmenui);
exitmenui = new MenuItem("Exit");
filem.add(exitmenui);
//Add Edit Menu to Bar
editm = new Menu("Edit");
mb.add(editm);
undomenui = new MenuItem("Undo");
editm.add(undomenui);
cutmenui = new MenuItem("Cut");
editm.add(cutmenui);
copymenui = new MenuItem("Copy");
editm.add(copymenui);
pastemenui = new MenuItem("Paste");
editm.add(pastemenui);
//Add Search Menu to Bar
searchm = new Menu("Search");
mb.add(searchm);
findmenui = new MenuItem("Find");
searchm.add(findmenui);
findnextmenui = new MenuItem("Find Next");
searchm.add(findnextmenui);
//Add Help Menu to Bar
helpm = new Menu("Help");
mb.add(helpm);
helptopmenui = new MenuItem("Help Topics");
helpm.add(helptopmenui);
aboutmenui = new MenuItem("About Notepad");
helpm.add(aboutmenui);
public static void main(String args[])throws IOException
textpad textpad1=new textpad("Untitled - Notepad");
textpad1.show();
public void mouseClicked(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
a very curious thing just happened when I ran it. The
bits of the constructor were being created on the
screen and the test String "Does it work" flashed up
then disappeared as the MenuBar was created. I have
also just changed the layout to null. Do I need to
re-position my TA? What do you think? Thanks for
your help by the wayAs long as you can see the TA, you shouldn't need to re-position it. Try changing the bg color. Something tells me that maybe the chars are being painted on in white, so you can't see them because their color matches that of the bg color. I could be wrong, though.
It is weird to be the one trying to solve somebody else's problem. I was the one getting the answers just a few short months ago...:) -
ALV using Object oriented programming concepts
Hi All,
I am unable to call a transaction after a hotspot click on a field.... I have used CALL METHOD w_grid->get_current_cell to get the cell info.....but this is not happening.... Can anyone plz tell me how to call a transaction on doing a hotspot click on a field?One reason why your code is not working is i think the method you are using is Protected. ie it can't be used outside the class.
Try the following code.
In the method definition define the method as follows.
methods : HOTSPOT_CLICK
FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID
E_COLUMN_ID
ES_ROW_NO.
The E_ROW_ID E_COLUMN_ID ES_ROW_NO are the parameters returnned by the event HOT-SPOT click.
Let us suppose I_MARA is your internal table using which you have displayed your ALV HRID.
Now in the method Implementation part use the following code.
METHOD HOTSPOT_CLICK.
CLEAR : WA_MARA.
READ TABLE I_MARA INDEX E_ROW_ID INTO WA_MARA.
IF SY-SUBRC EQ 0.
IF E_COLUMN_ID-FIELDNAME EQ C_MATNR.
SET PARAMETER ID 'MAT' FIELD WA_MARA-MATNR.
SET PARAMETER ID 'WRK' FIELD C_WERKS.
CALL TRANSACTION 'MD04' AND SKIP FIRST SCREEN.
ELSE.
CALL SCREEN 0130 starting at 35 15.
ENDIF.
ENDIF.
ENDMETHOD.
At the call Transaction point you can call which ever Transaction you want.
And aslo please check if you have registered the event HOTSPOT.
Hope this code works.
Thanks & regards,
Y Gautham -
I AM USING LVC_T_FCAT. BUT I CAN GET THE TOTAL IN ALV REPORT DISPLAY. PLS, SOMEBODY HELP
Hi
while creating fieldcatalog, for which field you want t calculate SUM for that field set
fieldcatalg-DO_SUM = 'X'-----> Totals calculation for column values
check these links
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
Reward all helpfull answers
Regards
Pavan -
Hi Team ,
I have one requirement , where i have to made selected row editable in ALV Webdynpro . There is one Edit button and selected row will become ediatble when we click on this button . This part is done . But whenever iam clicking on Edit button , focus is moving to first row . I want it to remain on selected row .
Regards
Jagjit Singh SainiHi Tashi ,
Thanks Its working now .
I have used
LO_ND_MATERIAL->SET_LEAD_SELECTION_INDEX( index = index ) after binding .
Regards
Jagjit Singh Saini -
How to write Block ALV using Object-oriented methodology?
Hi all,
How to write a Block ALV without using 'Reuse_ALV.....' FMs? I want to use the CL_GUI....' methods. What is the procedure? Any sample block ALV?
Thanks,
Charles.Currently there is not an OO method of implementing the block ALV, it is only available using the REUSE function module.
Regards,
RIch Heilman -
Sum in ALV grid display using objects
Hi Experts,
I have created a Report with ALV using objects and also am able to get SUM for some fields using do_sum = 'X'.
My problem is i want to do some calculation using the total amount which i have got, how can i do that (or can it be done??).
Thanks in Advance...
SantoshHi this may be of some help.
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
with regards,
Hema Sundara.
pls reward if u find it helpful. -
Comparing OO ALV and ALV using Function modules
Hi All,
Please provide me what are the advantages of developing ALV using Objects compared to creation using function modules. What are the disadvantages of creating using the conventional FM way.
I have not worked much on ALV using Function modules, have been developing using standard abap classes. I wanted to have an detailed understanding and differences between the two.
Please provide your views on the same.
I have searched SDN forum, but didnt find much information, so it will be of great help if you provide some inputs.
Thanks & Regards,
Navneeth K.Hi, Navneeth,
With ALV functions, you can everything that you would do otherwise with the OOPS ALV. However , I don't think you can possibily have more controls in case of alv function because it occupies the entire screen and the function only calls 2 screens internally ( screen numbers 500 and 700 (for popup alv)).
But with OOPS on the other hand, you can have many controls on one screen, for example, you can have 2 ALV lists, or a splitter control with one of them having a Tree control and the other alv grid/list, pictures etc.
So the sole motive of the function is if you want to display a list, but when developing a serious application, I would go for OOPs ALV.
regards,
Advait -
Comparing ALV using Function modules and OO ALV
Hi All,
Please provide me what are the advantages of developing ALV using Objects compared to creation using function modules. What are the disadvantages of creating using the conventional FM way.
I have not worked much on ALV using Function modules, have been developing using standard abap classes. I wanted to have an detailed understanding and differences between the two.
Please provide your views on the same.
I have searched SDN forum, but didnt find much information, so it will be of great help if you provide some inputs.
Thanks & Regards,
Navneeth K.Hello,
Check this link
ALV FUNCTION MODULE AND OBJECT ORIENTED ?
Example programs
http://saplab.blogspot.com/2007/10/sample-abap-program-of-alv-grid-control.html
http://www.abapcode.info/2007/06/object-oriented-alv-using-two.html -
Set cursor alv grid (not using objects)
I got a question on ALV GRID (not using objects), please let me know if you have pointers. Thanks.
Output has 2 screens both has different contents. The output is generated using internal table1 and 2 and using FM 'REUSE_ALV_GRID_DISPLAY_LVC' (both screen use same FM).
First screen has multiple pages of output (say 10 pages). User scrolled page 5 and line 10 of first screen and then double clicked it takes to screen #2. After completion of screen #2, the back arrow should get back to page 5 and line 10 of screen #1. Currently the back arrow gets to screen#1 page 1 and line 1. How to remember the cursor position in alv grid and instruct the cursor to go there?
Appreciate the input.
Note: I tried "set cursor line n" with "Scroll" command but no luck. http://help.sap.com/saphelp_nw70/helpdata/EN/9f/dba47e35c111d1829f0000e829fbfe/content.htmThanks for the inputs.
FYI, I got it implemented using method CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->set_current_cell_via_id
The method is called by 'REUSE_ALV_GRID_DISPLAY_LVC' form 'PF_STATUS_SET' when the ALV grid output is presented each time.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_bypassing_buffer = 'X'
i_callback_program = gc_repid
i_callback_pf_status_set = 'PF_STATUS_SET'
i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = lwa_layout
it_fieldcat_lvc = git_fc_lvc
i_default = ' '
TABLES
t_outtab = git_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
FORM alv_event_pf_status_set USING rt_extab
TYPE slis_t_extab.
DATA lo_ref1 TYPE REF TO cl_gui_alv_grid.
*Get the reference to class "lo_ref1" for the ALV report
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lo_ref1.
*set the focus of cursor in ALV
CALL METHOD lo_ref1->set_current_cell_via_id
EXPORTING
is_row_no = gv_row. "row number where you want to focus the cursor
ENDFORM. -
ALV using ABAP Classes and Objects
Hi All,
I am trying to print the values in my internal table using ALV, using ABAP classes and objects. Here the title for columns are picked based on the title specified in the data element. I want to set the title of my columns by my own. how to achieve this ?. Please provide me a sample code if possible.
thanks & regards,
Navneeth.KHello Navneeth
The following sample report shows how to build and modify a fieldcatalog (routine <b>BUILD_FIELDCATALOG_KNB1</b>).
*& Report ZUS_SDN_ALVGRID_EVENTS
REPORT zus_sdn_alvgrid_events.
DATA:
gd_okcode TYPE ui_func,
gt_fcat TYPE lvc_t_fcat,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid1 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
PARAMETERS:
p_bukrs TYPE bukrs DEFAULT '2000' OBLIGATORY.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_hotspot_click.
* define local data
DATA:
ls_knb1 TYPE knb1,
ls_col_id TYPE lvc_s_col.
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CASE e_column_id-fieldname.
WHEN 'KUNNR'.
SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
WHEN 'ERNAM'.
* SET PARAMETER ID 'USR' FIELD ls_knb1-ernam.
* NOTE: no parameter id available, yet simply show the priciple
CALL TRANSACTION 'SU01' AND SKIP FIRST SCREEN.
WHEN OTHERS.
* do nothing
ENDCASE.
* Set active cell to field BUKRS otherwise the focus is still on
* field KUNNR which will always raise event HOTSPOT_CLICK
ls_col_id-fieldname = 'BUKRS'.
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
is_row_id = e_row_id
is_column_id = ls_col_id.
ENDMETHOD. "handle_hotspot_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = p_bukrs.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grid
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_docking
EXCEPTIONS
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.
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_hotspot_click FOR go_grid1.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog_knb1.
* Display data
CALL METHOD go_grid1->set_table_for_first_display
CHANGING
it_outtab = gt_knb1
it_fieldcatalog = gt_fcat
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_FIELDCATALOG_KNB1
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog_knb1 .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'KNB1'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
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.
LOOP AT gt_fcat INTO ls_fcat
WHERE ( fieldname = 'KUNNR' OR
fieldname = 'ERNAM' ).
ls_fcat-hotspot = abap_true.
ls_fcat-scrtext_s = '<short text>'. " short text of column
ls_fcat-scrtext_m = '<medium text>'. " medium text of column
ls_fcat-scrtext_l = '<long text>'. " longtext text of column
ls_fcat-tooltip = '...'. " ALV control: Tool tip for column header
ls_fcat-coltext = '...'. " ALV control: Column heading
MODIFY gt_fcat FROM ls_fcat.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG_KNB1
Regards
Uwe -
Hi,
The requirement is to create ""Document Sets in Bulk" using JSOM. I am using the following posts:-
http://blogs.msdn.com/b/mittals/archive/2013/04/03/how-to-create-a-document-set-in-sharepoint-2013-using-javascript-client-side-object-model-jsom.aspx
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/1904cddb-850c-4425-8205-998bfaad07d7/create-document-set-using-ecma-script
But, when I am executing the code, I am getting error "Cannot read property 'DocumentSet' of undefined "..Please find
below my code. I am using Content editor web part and attached my JS file with that :-
<div>
<label>Enter the DocumentSet Name <input type="text" id="txtGetDocumentSetName" name="DocumentSetname"/> </label> </br>
<input type="button" id="btncreate" name="bcreateDocumentSet" value="Create Document Set" onclick="javascript:CreateDocumentSet()"/>
</div>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"> </script>
<script type="text/javascript">
SP.SOD.executeFunc('sp.js','SP.ClientContext','SP.DocumentSet','SP.DocumentManagement.js',CreateDocumentSet);
// This function is called on click of the “Create Document Set” button.
var ctx;
var parentFolder;
var newDocSetName;
var docsetContentType;
function CreateDocumentSet() {
alert("In ClientContext");
var ctx = SP.ClientContext.get_current();
newDocSetName = $('#txtGetDocumentSetName').val();
var docSetContentTypeID = "0x0120D520";
alert("docSetContentTypeID:=" + docSetContentTypeID);
var web = ctx.get_web();
var list = web.get_lists().getByTitle('Current Documents');
ctx.load(list);
alert("List Loaded !!");
parentFolder = list.get_rootFolder();
ctx.load(parentFolder);
docsetContentType = web.get_contentTypes().getById(docSetContentTypeID);
ctx.load(docsetContentType);
alert("docsetContentType Loaded !!");
ctx.executeQueryAsync(onRequestSuccess, onRequestFail);
function onRequestSuccess() {
alert("In Success");
SP.DocumentSet.DocumentSet.create(ctx, parentFolder, newDocSetName, docsetContentType.get_id());
alert('Document Set creation successful');
// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
alert("Document Set creation failed" + + args.get_message());
Please help !!
Vipul JainHello,
I have already tried your solution, however in that case I get the error - "UncaughtSys.ArgumentNullException: Sys.ArgumentNullException:
Value cannot be null.Parameter name: context"...
Also, I tried removing SP.SOD.executeFunc
from my code, but no success :(
Kindly suggest !!!
Vipul Jain -
Hi Friends,
I am new to Web Dynpro, I have question to you guys.. I dont know is it possible or not..
Ok the Question is..
My Requirement is to enable(Editable) or disable(Not editable) the column in ALV, according to so some conditions...
I have ALV table in my screen and lets assume that i have 20 column..
I know we can do this in method "WDDOMODIFYVIEW" of view . But i dont want to do this because every time when i click on the any element of the ALV on the screen it will go to method "WDDOMODIFYVIEW" and sets the attributes every single time.
Can i create a Context node with attributes of this 20 fields and bind the READ ONLY property of the ALV column to each one in context node. So that i can create a Method in Component controller and call that method every time where i disable or enable columns of ALV using a specific Action Button and change the Context node property.. Rather un nessasarily excecuting the method "WDDOMODIFYVIEW" of view every time for simply on clicking the checkbox of the ALV column or any thing .......
Hope i have made you people understand my Question..
Thanks for help in Advance.
Madhu MV.Hi Lekha.. Thanks so much for the reply..
Please See the Below Code .. Let me know what i am doing wrong...
> The column is NOT changed to Ediatble.... Please Help...
LOOP AT lt_wo_item INTO ls_wo_item.
*--> Append Operation
lv_op_num = ls_wo_item-z_oper_num.
MOVE-CORRESPONDING ls_wo_item TO ls_wo_alv.
IF lv_op_num NE lv_count_op.
CLEAR lv_count_op.
ADD lv_op_num TO lv_count_op.
ls_wo_alv-z_op_count = lv_count_op.
CLEAR lv_count.
ADD lv_count_op TO lv_count.
ls_wo_alv-z_item_count = lv_count.
ls_wo_alv-readonly = abap_true.
APPEND ls_wo_alv TO lt_wo_alv.
ELSE.
ls_wo_alv-z_op_count = lv_count_op.
ADD '0.1' TO lv_count.
ls_wo_alv-z_item_count = lv_count.
ls_wo_alv-readonly = abap_true.
APPEND ls_wo_alv TO lt_wo_alv.
ENDIF.
LOOP AT lt_wo_services INTO ls_wo_services
WHERE z_oper_num = ls_wo_item-z_oper_num
AND z_sub_oper_num = ls_wo_item-z_sub_oper_num.
*--Append Services.
MOVE-CORRESPONDING ls_wo_services TO ls_wo_alv.
ls_wo_alv-z_op_count = lv_count_op.
ADD '0.1' TO lv_count.
ls_wo_alv-z_item_count = lv_count.
ls_wo_alv-readonly = abap_true.
APPEND ls_wo_alv TO lt_wo_alv.
ENDLOOP.
ENDLOOP.
DATA lo_nd_cn_alv TYPE REF TO if_wd_context_node.
DATA lo_el_cn_alv TYPE REF TO if_wd_context_element.
DATA ls_cn_alv TYPE wd_this->element_cn_alv.
navigate from <CONTEXT> to <CN_ALV> via lead selection
lo_nd_cn_alv = wd_context->get_child_node( name = wd_this->wdctx_cn_alv ).
lo_nd_cn_alv->bind_table( lt_wo_alv ).
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_alv_table( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
lo_interfacecontroller = wd_this->wd_cpifc_alv_table( ).
DATA lo_value TYPE REF TO cl_salv_wd_config_table.
lo_value = lo_interfacecontroller->get_model(
DATA: lr_column TYPE REF TO cl_salv_wd_column.
DATA: lr_input TYPE REF TO cl_salv_wd_uie_input_field.
DATA : lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lt_columns TYPE salv_wd_t_column_ref,
ls_column TYPE salv_wd_s_column_ref.
lr_column_settings ?= lo_value.
lt_columns = lr_column_settings->get_columns( ).
LOOP AT lt_columns INTO ls_column.
CASE ls_column-id.
WHEN 'Z_PRODUCT'.
CREATE OBJECT lr_input
EXPORTING
value_fieldname = 'Z_PRODUCT'.
CALL METHOD ls_column-r_column->set_cell_editor
EXPORTING
value = lr_input.
CALL METHOD lr_input->set_read_only_fieldname
EXPORTING
value = 'READ_ONLY'.
ENDCASE.
ENDLOOP. -
How to capture index/row no of row in table using object oriented alv.
i have a table with many fields. i have an alv grid table displayed using object oriented alv. when i double click on a record, i call another screen. there i want to display the record number. eg, if i doubleclick on the third row, i will go to next screen and display 3 there.
please let me know how it is done as it is urgent.
thanks in advance.Hi,
Use the following code to get rowno.
CLASS lcl_grid_events DEFINITION DEFERRED.
DATA:
grid1_events TYPE REF TO lcl_grid_events.
CLASS lcl_grid_events DEFINITION.
PUBLIC SECTION.
METHODS:
dbclk
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no.
ENDCLASS. "lcl_grid_events DEFINITION
CLASS lcl_grid_events IMPLEMENTATION.
METHOD dbclk.
*access e_row variable, which contains the record no.
ENDMETHOD. "dbclk
ENDCLASS. "lcl_grid
write the following code after method call of set_table_for_first_display
CREATE OBJECT grid1_events.
SET HANDLER grid1_events->dbclk
FOR grid1.
reward point if useful. -
Advanced ALV using ABAP objects
Hi All ABAPers,
I have a question in Advanced ALV using ABAP objects.Can we display the output ie., ALV Grid without defining the custom cointainer?ie., just as we do in the classical ALV without defining any screens.Can we do that as a normal executable program ie., without using module pool programming.Please give me a solution.
Thanks & Regards,
Chaitanya.If you want editable grids then the cl_salv_table method won't unfortunately be of use since (currently) there's no editable facility / method.
So if you are using cl_gui_alv_grid here's how to "get round" the problem.
I'm essentially using my own alv class which is a reference to cl_gui_alv_grid but the methodology shown here is quite simple.
What you can do is to create a method which calls a function module for example ZZ_CALL_SCREEN so you only have to code a Screen and a GUI in ONE function module and not in every ALV report.
for example you could create something like this
My version has the option of 2 screens - so when I double click on a cell in one grid I can perform some actions and then display a 2nd grid before returning back to the ist grid.You can easily modify this to suit your applications.
The parameters are fairly self evident from the code. You can just use this as a model for your own applications.
I agree that having to code a separate screen and GUI for OO ALV GRID reports was for some people a "show stopper" in switching from the old SLIS to OO ALV reports.
I Hope if any SAP development guys are reading this PLEASE PROVIDE EDITABLE FUNCTIONALITY IN THE NEW CL_SALV_TABLE class. Thanks in advance.
method display_data.
call function 'ZZ_CALL_SCREEN'
exporting
screen_number = screen_number
program = program
title_text = title_text
i_gridtitle = i_gridtitle
i_zebra = i_zebra
i_edit = i_edit
i_opt = i_opt
i_object = z_object
changing
e_ucomm = e_ucomm
it_fldcat = it_fldcat
gt_outtab = gt_outtab.
e_ucomm = sy-ucomm.
endmethod.
function zz_call_screen .
*"*"Local interface:
*" IMPORTING
*" REFERENCE(SCREEN_NUMBER) TYPE SY-DYNNR
*" REFERENCE(PROGRAM) TYPE SY-REPID
*" REFERENCE(TITLE_TEXT) TYPE CHAR50
*" REFERENCE(I_GRIDTITLE) TYPE LVC_TITLE
*" REFERENCE(I_ZEBRA) TYPE LVC_ZEBRA
*" REFERENCE(I_EDIT) TYPE LVC_EDIT
*" REFERENCE(I_OPT) TYPE LVC_CWO
*" REFERENCE(I_OBJECT) TYPE REF TO ZZHR_ALV_GRID
*" CHANGING
*" REFERENCE(E_UCOMM) TYPE SY-UCOMM
*" REFERENCE(IT_FLDCAT) TYPE LVC_T_FCAT
*" REFERENCE(GT_OUTTAB) TYPE STANDARD TABLE
assign gt_outtab to <dyn_table>.
move title_text to screen_title.
assign i_object to <zogzilla>.
export <dyn_table> to memory id 'dawggs'.
export i_gridtitle to memory id 'i_gridtitle'.
export i_edit to memory id 'i_edit'.
export i_zebra to memory id 'i_zebra'.
export i_opt to memory id 'í_opt'.
export it_fldcat to memory id 'it_fldcat'.
case screen_number.
when '100'.
call screen 100.
when '200'.
call screen 200.
endcase.
endfunction.
process before output.
module status_0100.
process after input.
module user_command_0100.
rocess before output.
module status_0200.
process after input.
module user_command_0200.
* INCLUDE LZHR_MISCO01 *
*& Module STATUS_0100 OUTPUT
* text
module status_0100 output.
import <dyn_table> from memory id 'dawggs'.
import i_gridtitle from memory id 'i_gridtitle'.
import i_edit from memory id 'i_edit'.
import i_opt from memory id 'í_opt'.
import it_fldcat from memory id 'it_fldcat'.
i_object = <zogzilla>.
call method i_object->display_grid
exporting
i_gridtitle = i_gridtitle
i_edit = i_edit
i_zebra = i_zebra
i_opt = i_opt
g_fldcat = it_fldcat
g_outtab = <dyn_table>
changing
it_fldcat = it_fldcat
gt_outtab = <dyn_table>.
set pf-status '001'.
set titlebar '000' with screen_title.
endmodule. " STATUS_0100 OUTPUT
*& Module STATUS_0200 OUTPUT
* text
module status_0200 output.
import <dyn_table> from memory id 'dawggs'.
import i_gridtitle from memory id 'i_gridtitle'.
import i_edit from memory id 'i_edit'.
import i_opt from memory id 'í_opt'.
import it_fldcat from memory id 'it_fldcat'.
i_object = <zogzilla>.
call method i_object->display_grid
exporting
i_gridtitle = i_gridtitle
i_edit = i_edit
i_zebra = i_zebra
i_opt = i_opt
g_fldcat = it_fldcat
g_outtab = <dyn_table>
changing
it_fldcat = it_fldcat
gt_outtab = <dyn_table>.
set pf-status '001'.
set titlebar '000' with screen_title.
endmodule. " STATUS_0200 OUTPUT
* INCLUDE LZHR_MISCI01 *
*& Module USER_COMMAND_0100 INPUT
* text
module user_command_0100 input.
case sy-ucomm.
when 'BACK'.
leave to screen 0.
when 'EXIT'.
leave program.
when 'RETURN'.
leave program.
when others.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
*& Module USER_COMMAND_0200 INPUT
* text
module user_command_0200 input.
case sy-ucomm.
when 'BACK'.
leave to screen 0.
when 'EXIT'.
leave program.
when 'RETURN'.
leave program.
when others.
endcase.
endmodule. " USER_COMMAND_0200 INPUT
Cheers
jimbo
Maybe you are looking for
-
App that can send more than one attachment at a time....
Does anyone know of a app that I can send more than one attachment at a time like resumes + cover letters. Not having any luck with gmail or pages for the Ipad. Please help
-
Bluescreens and Lock-ups with 2.15.0
I downloaded the latest driver version, 2.5.0006 today in an effort to try and fix an issue that was intermittently causing the card to stop working (either Vista would tell me no sound device was detected, or there inexplicably would not be any soun
-
How to find out the projects with status "Invalid"?
I'm new to Oracle Projects -OP. We are on 12.0.4. This' my new job. I have a task of "Remove projects with status 'Invalid' ". Questions: How to access the OP forms to verify the existent of the invalid projects? What are the PA tables having the sta
-
FBL5N open items not appeared for clearing in F-32
Hi all, I was trying to clear 2 open items whcih are getting displayed in FBL5N report with opposite signs and equal amounts. But when I am trying to clear those two transactions in F-32, I am able to see only 1 items instead fo two. Both transactio
-
Can't get any screen display (nano 7th gen)
can't get any screen display (7th gen nano) -- yesterday had low battery and it may have been "a little sweaty" wet, charger all night -- still can't get it to "turn on"