Classes to split ALV in OO
Hi All,
I am using OO to display my ALV, what is needed to have a split on the ALV and display some data in the top half.
Here is my code:
TRY.
cl_salv_table=>factory(
IMPORTING r_salv_table = gr_alv
CHANGING t_table = gt_rpt_details ).
PERFORM f_set_header.
PERFORM f_display_settings.
gr_alv->set_screen_status(
pfstatus = 'ZSTANDARD'
report = sy-repid
set_functions = gr_alv->c_functions_all ). "set all basic ALV funtions
gr_events = gr_alv->get_event( ).
"create layout object
CREATE OBJECT gr_layout.
lr_columns = gr_alv->get_columns( ).
lr_columns->set_optimize( 'X' ).
lr_columns->set_headers_visible( 'X' ).
* get layout object
lo_layout = gr_alv->get_layout( ).
* set Layout save restriction
* 1. Set Layout Key .. Unique key identifies the Differenet ALVs
ls_key-report = sy-repid.
lo_layout->set_key( ls_key ).
* 2. Remove Save layout the restriction.
lo_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
lo_layout->set_default( abap_true ).
* set initial Layout
"lf_variant = 'Z/ZTEST'.
"lo_layout->set_initial_layout( lf_variant ).
CREATE OBJECT event_handler.
SET HANDLER event_handler->on_user_command FOR gr_events.
gr_functions = gr_alv->get_functions( ).
gr_functions->set_all('X').
gr_functions->set_group_filter( value = if_salv_c_bool_sap=>false ).
* Set print preview
gr_functions->set_print_preview( ).
gr_alv->get_display_settings( ).
gr_alv->display( ).
CATCH cx_salv_msg.
MESSAGE 'ALV Display Not possible'(w02) TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
In order to split the ALV you can use the below code for your reference
data : lr_custom_container type ref to cl_gui_custom_container,
lr_event_receiver type ref to lcl_event_receiver,
lr_splitter type ref to cl_gui_splitter_container,
lr_parent_top type ref to cl_gui_container,
lr_parent_grid type ref to cl_gui_container,
lr_dyndoc_id type ref to cl_dd_document,
lr_display type ref to cl_gui_alv_grid.
if lr_custom_container is initial.
v_container_name = " Container name which you defined in Screen
create object lr_custom_container
exporting
container_name = v_container_name
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc <> 0.
message i081 display like c_e.
"Unknown Error Occured While Displaying
leave to screen 0.
endif.
*Split the container into two parts
create object lr_splitter
exporting
parent = lr_custom_container
rows = 2
columns = 1
exceptions
cntl_error = 1
cntl_system_error = 2
others = 3.
if sy-subrc <> 0.
message i081 display like c_e.
"Unknown Error Occured While Displaying
leave to screen 0.
endif.
*Get the upper part of the container into V_PARENT_TOP
call method lr_splitter->get_container
exporting
row = 1
column = 1
receiving
container = lr_parent_top.
*Get the lower part of the container into V_PARENT_GRID
call method lr_splitter->get_container
exporting
row = 2
column = 1
receiving
container = lr_parent_grid.
*Set the height of the top part of the container
call method lr_splitter->set_row_height
exporting
id = 1
height = 28
exceptions
cntl_error = 1
cntl_system_error = 2
others = 3.
if sy-subrc <> 0.
message i081 display like c_e.
"Unknown Error Occured While Displaying
leave to screen 0.
endif.
*Create a instance of cl_gui_alv_grid
create object lr_display
exporting
i_parent = lr_parent_grid
exceptions
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5.
if sy-subrc <> 0.
message i081 display like c_e.
"Unknown Error Occured While Displaying
leave to screen 0.
endif.
Similar Messages
-
How to identify which ALV triggered event in split ALV
Hi all,
I'm using a split ALV like this:
CREATE OBJECT ob_custom
EXPORTING
container_name = 'CONTAINER'.
CREATE OBJECT ob_split1
EXPORTING
parent = ob_custom
orientation = cl_gui_easy_splitter_container=>orientation_vertical.
CREATE OBJECT ob_grid1
EXPORTING
i_parent = ob_split1->top_left_container.
CREATE OBJECT ob_grid2
EXPORTING
i_parent = ob_split1->bottom_right_container.
I want to trigger double_click event:
CREATE OBJECT ob_event.
SET HANDLER ob_event->handle_double_click FOR ob_grid1.
SET HANDLER ob_event->handle_double_click FOR ob_grid2.
The problem is I don't know how to identify in which ALV the user double_clicked.
Is there solution?
Thanks in advanceThe trick is (just to help others):
CLASS lcl_event_receiver1 DEFINITION.
ENDCLASS. "lcl_event_receiver DEFINITION
CLASS lcl_event_receiver1 IMPLEMENTATION.
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver2 DEFINITION.
ENDCLASS. "lcl_event_receiver DEFINITION
CLASS lcl_event_receiver2 IMPLEMENTATION.
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
and for data declaration:
DATA: ob_event1 TYPE REF TO lcl_event_receiver1,
ob_event2 TYPE REF TO lcl_event_receiver2.
and then:
CREATE OBJECT ob_event1.
SET HANDLER ob_event1->handle_double_click FOR ob_grid1.
CREATE OBJECT ob_event2.
SET HANDLER ob_event1->handle_double_click FOR ob_grid2.
Thanks a lot kiran kumar!
Edited by: orgasmics on May 11, 2010 1:56 PM -
Split ALV interms of a field.
Hi ..
How can I split ALV into many fields , according to the a field which can be change dynamically .If necessay to define clearly , my purpose is to show other columns according to different bukrs . For example in selection screen bukrs is selected 1000 but also true datas have for 1100 , I want to open a split for 1100 or what ever else .
Thanks in advance.Hi Yusuf
Use two different intenal tables,
1) for Bukrs
SELECT * FROM bsid INTO TABLE wt_bsid
WHERE bukrs EQ p_bukrs
AND kunnr IN s_kunnr
AND budat IN s_budat
AND bldat IN s_bldat
AND umskz EQ ' '
AND blart IN s_blart
AND waers IN s_waers.
<b>The below query will give you the rest of the data</b>
2) data other than p_bukrs
SELECT * FROM bsid INTO TABLE wt_bsid_others
WHERE bukrs NE p_bukrs
AND kunnr IN s_kunnr
AND budat IN s_budat
AND bldat IN s_bldat
AND umskz EQ ' '
AND blart IN s_blart
AND waers IN s_waers.
What you could do is use a splitter screen display two ALV grid.
Refer this for the code
Two ALV grid in same report output
Regards
Kathirvel
Message was edited by:
Kathirvel Balakrishnan -
Adding header in split alv using SALV
Hello Champs,
I have a requirement to display 6 diff reports in a screen. I have achieved it by using SALV(Split Container). Now I need to add header to each ALV report. The normal way of adding header in SALV doesnt work in the split ALV.
Can someone help me with this.
Thanks,
GregHi, im experiencing the same situation right now, have you solved the problem? any inputs would be appreciated. thanks!
-
Hi,
is it possible to split a Line in REUSE_ALV_LIST_DISPLAY?
Example Normal:
Line 1: MATNR MAKTX ZEINR ...
I want to have:
Line 1: MATNR MAKTX
Line 2: ZEINR
I don't want to use a Hierachie
thanks for help
Regards, DieterHi,
you can try with the Hierarchial alv list using the Fm <b>REUSE_ALV_HIERSEQ_LIST_DISPLAY</b>, also try to have a look in the Demo program <b>BALVHD01</b>.
Regards
vijay -
Hi all.
I have a screen splited to 2.
I would like to split it to 3 - top, middle & bottom.
My code is:
* Creating Custom Container
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_custom_container_name.
ENDIF.
* Creating Split Object
IF g_split IS INITIAL.
CREATE OBJECT g_split
EXPORTING parent = g_custom_container
orientation =
cl_gui_easy_splitter_container=>orientation_vertical
sash_position = 30
with_border = 1.
ENDIF.
* Creating ALV instances
IF grid1 IS INITIAL.
CREATE OBJECT grid1
EXPORTING
i_parent = g_split->top_left_container.
* Exclude functions
PERFORM exclude_tb_functions CHANGING lt_exclude.
* Creating and Registering Handler Object
CREATE OBJECT g_event_handler.
SET HANDLER g_event_handler->handle_toolbar FOR grid1.
SET HANDLER g_event_handler->handle_double_click FOR grid1.
SET HANDLER g_event_handler->handle_user_command FOR grid1.
* Fill Field-Catalogs
PERFORM field_catalog01.
* Set Layout
PERFORM layout1.
SORT gt_order BY aufnr.
* Display
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_layout = gs_layout1
i_save = 'A'
i_default = 'X'
is_variant = g_variant
it_toolbar_excluding = lt_exclude
CHANGING
it_outtab = gt_order[]
it_fieldcatalog = gt_fc1[].
ELSE.
CALL METHOD grid1->refresh_table_display.
ENDIF.
After a double-click I'm activating the following:
IF grid2 IS INITIAL.
CREATE OBJECT grid2
EXPORTING
i_parent = g_split->bottom_right_container.
* Fill Field-Catalog
PERFORM field_catalog02.
* Set Layout
PERFORM layout2.
* SORT gt_res BY rsnum rspos.
IF rb_comp EQ gc_true.
CALL METHOD grid2->set_table_for_first_display
EXPORTING
is_layout = gs_layout2
i_save = 'A'
CHANGING
it_outtab = gt_res[]
it_fieldcatalog = gt_fc2[].
ELSE.
CALL METHOD grid2->set_table_for_first_display
EXPORTING
is_layout = gs_layout2
i_save = 'A'
CHANGING
it_outtab = gt_res_conf[]
it_fieldcatalog = gt_fc2[].
ENDIF.
ELSE.
CALL METHOD grid2->refresh_table_display.
ENDIF.
How can I add the third part ???
When I added it it's being displayed on the second, which means that the problem is with my container's & split's definition.
Thanks in advance,
Rebeka
Code Formatted by: Alvaro Tejada Galindo on Dec 26, 2008 11:19 AMHello Rebeka
If you want to have top/middle/bottom control then create a single splitter container having a single column with three rows. Using the method GET_CONTAINER you retrieve the container instances for each control.
For a sample report have a look at ZUS_SDN_TWO_ALV_GRIDS in thread
alv
Regards
Uwe -
Split ALV Column heading into two
Hello All,
I have a ALV Column Header - ALV LIST - SAP 46C.
Material | Info Type | Quantity | Price etc..
Due to space contraints and other reason client needs to split the Info type column into two.
Material | Info | Quantity | Price etc..
| Type |
The data records should not have any additional blank lines.
How to achieve this?
Thanks,You have to assign X to layout property no_colhead.
Then write your heading using write statements.
Here is the exact example you are looking for [Create Multiple Lines Header In ALV List Report|http://www.freesaptutorial.com/create-multiple-lines-header-in-alv-list-report/] -
String.class without split(String regex)
hello,
This is my problem:
I am using eclipse with j2sdk1.4.2 which
implement
the clase String.class with
method replaceAll(String regex, String replacement) and
method split(String regex)
PAth: home_j2sdk1.4.2/jre/lib/rt.jar 25.762kb
In this way:
String columns[] = line.split("\t");
for (int i=0; i<columns.length; i++)
ws.addCell(new Label(i,row,columns.replaceAll("\"","")));
I move the code above to websphere Application Developer 5.1.2
which use Home_Websphere/eclipse/jre/lib/rt.jar 8.827 kb
this jar in yours String.class not contains the
method replaceAll(String regex, String replacement) and
method split(String regex)
I need to find the use my code above with that methods,
what i need to do ???
possible,i need to find the source to String.java of j2sdk1.4.2
which implement the methods, but where ???
or there is another way to do it ???
Any help is greatly appreciated.If websphere is supposedly 1.4 compatible, arethey
"allowed" to leave out methods from the JFC? Not sure what the JFC is, but no, they would not be
allowed to leave out any methods.
JFC - Java Foundation Classes. I think they started calling what might be considered the Java Core the JFC when they first added Swing to the distribution. Maybe the term is no longer used.
RRD-R
� {� -
Problems loading nib files after class is split into a static library.
I've recently split a project so that the common re-usable controls are in their own class library. My original application project now references these using a cross project reference.
However, since I have split the projects up, my original project crashes when it loads main.xib because it cannot find one of the custom classes which is defined in the library project.
When I first split up the projects, I noticed that there were problems with the nib files not being able to find the IB outlets of the custom classes, but I managed to get around these by going importing the relevant library class files manually (File > Read Class Files…).
I have made sure that all of the nib files compile without warning, so as far as I can tell, Interface Builder is able to read the necessary class headers, but when I try to run the app, it crashes saying that there is an unknown class in the Interface Builder file and that the class is not coding compliant.
Are there any steps I've missed or advice on how to troubleshoot this?I did a bit of digging. The reason why this wasn't working is because the class in question was referenced by the nib files, but not in code. Therefore, while the code compiled and there were no warnings with the nib files, the linker was not linking the classes because no code used them directly.
This can be fixed by going to the Project Settings, and on the Build tab, underneath the Linking heading, adding -ObjC to the Other Linker Flags section. -
How to change column name heading thru Class method in ALV report
When I Select LayOut on Selection screen then Display ALV Output columnname display Quantity but I want change this name to Carats.
I set Short, Medium and Long text is Carats.DATA: lt_fcat type lvc_t_fcat,
lv_fname type fieldname value '<Your FName>'.
FIELD-SYMBOLS: <fcat> type lvc_s_fcat.
CALL METHOD alv_grid->get_frontend_fieldcatalog
IMPORTING
et_fieldcatalog = lt_fcat.
read table lt_fcat assigning <fcat> with key fieldname = lv_fname.
if sy-subrc is initial.
<fcat>-COLTEXT = <fcat>-SCRTEXT_L = <fcat>-SCRTEXT_M = <fcat>-SCRTEXT_S = <fcat>-SELTEXT = '<Your new Description>'.
endif.
CALL METHOD alv_grid->set_frontend_fieldcatalog
EXPORTING
it_fieldcatalog = lt_fcat.
call method alv_grid->REFRESH_TABLE_DISPLAY. -
How to call a Screens modules inside class methods in ALV of OOABAP.
I have a urgent reruirement to call a screen's PBO and PAI module inside a class method. I really dont want to create a function module and call the the screen inside that. Please revert if anyone have a solution as it is really urgent!!
Moderator message - "Urgency" is not catered to in the forums.
Message was edited by: Suhas SahaHi Shehzad,
SAPHELP on Advantages of ABAP Objects - Using ABAP - SAP Library says -
There are only two purposes for which procedural ABAP is essential:
· Encapsulation of classic screens in function modules.
· When you want to make functions available to other systems, but are not able to make class methods available externally using XI server proxies. In this case, you have to use function modules.
Regards,
DPM
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/56/14934259a5c66ae10000000a155106/content.htm -
For all classes used in the alv reports.
we need the list of required classes used in alv reports this urgent .
please help me.Hi Navid,
Check <b>SLIS Package/Dev.Class for node Classes</b>,
here u will find all required <b>classes for ALV including ALV Hierarchical,AVL Tree, ALV HTML.</b>
Classes.
CL_ALVHT_HTMLINPUT-> ALV: HTML Input (Control Proxy)
CL_ALVHT_HTML_PAGE-> ALV HTML Page
CL_ALVHT_HTML_TEMPLATE-> ALV: HTML Templates
CL_ALVHT_TAGSTREAM-> ALV
CL_ALVHT_UI_ELEMENT-> ALV: HTML User Input Element
CL_ALV_BDS-> BDS Access and Data Retention
CL_ALV_CHANGED_DATA_PROTOCOL-> Message Log for Data Entry
CL_ALV_DD_DOUBLE_LISTBOX-> Management Class for two D&D List Boxes
CL_ALV_DD_LISTBOX-> D&D List Box
CL_ALV_EVENT_DATA-> Changing Data Container for Events
CL_ALV_EVENT_TOOLBAR_SET-> ALV Context Menu
CL_ALV_GRAPHICS-> ALV Graphic (Integration with GFW)
CL_ALV_GRAPHICS_CU-> Customizing of ALV Graphics
CL_ALV_LISTBOX_DRAGOBJ->
CL_ALV_OI BDS-> Access and Data Retention
CL_ALV_TABLE_CREATE-> Dynamic Creation of ALV Data Table
CL_ALV_TREE_BASE-> Basis Class ALV Tree Control
CL_ALV_VARIANT-> ALV Variant Management
CL_GUI_ALV_GRID-> ALV List Viewer
CL_GUI_ALV_GRID_BASE-> Basis Class for ALV Grid
CL_GUI_ALV_TREE-> ALV Tree Control
Regards,
Raghav
Message was edited by:
Raghavendra L -
Difference between using FM and class in alv
does anyone know what's the main difference between using FM to create alv and using class to create alv?
in what condition we usually use FM or class?using FM we can create Classical and Interactive ALV Reports.
The classes are used to create the ALV Reports with OOPS concept.
Check this for basic concepts of OOPS
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b6cae890-0201-0010-ef8b-f970a9c41d47
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1591ec90-0201-0010-3ba8-cdcd500b17cf
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/alv%20grid/abap%20code%20sample%20to%20display%20data%20in%20alv%20grid%20using%20object%20oriented%20programming.doc
Tabstrip
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/022ba607-0301-0010-e382-fdedca553f5f
Editable ALV
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ec31e990-0201-0010-f4b6-c02d876ce033
Tree
http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_usrint.htm
General Tutorial for OOPS
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
Reward Points if useful -
Logo & TOP_OF_PAGE in OO ALV
Hi everybody,
I have been struggling on putting Logo and write few things on TOP_OF_PAGE in ALV using OOPS.
I search through forum and found few materials, but still looking precise help. Any suggestions???
Regards,
Deva.Deva,
This is what you will have to do.
Split the initial container into two. display the list in the bottom one.
Now in the top one create a object with reference to CL_DD_DOCUMENT. Use the method vertical_split of this class to split the top container again into two pieces. These split areas will refer to CL_DD_AREA.
Once that is done, use one of the areas to display your logo as shown below.
call method document->vertical_split
exporting split_area = document
split_width = '70%'
importing right_area = a_logo.
call method a_logo->add_picture exporting picture_id = logo.
Regards,
Ravi
Note : Please reward the posts that help you. -
ALV Report to have two different Reports
Hi All,
I have a need to display two different reports for the same set of data selections, (Successful data and Error Data) in a Single ALV Layout using a Application tool bar Button. Does anyone have a sample code for this kind of requirement. Preferably using Objects.
Also, how can we check if an object is already created? In other words, how to check for a null reference?
Thanks in advance.
Jr.Sample code for split alv using OOABAP.
this would help you in ur requirement.
go through this program where the screen is divided in two for two alv in different containers.
DATA: save_ok LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'CC1',
g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
g_max TYPE i VALUE 100.
declarations for top of page event
Data: gv_c_split type ref to cl_gui_splitter_container,
gv_c_ptv type ref to cl_gui_container,
gv_alv_ptv type ref to cl_gui_alv_grid,
o_dd_doc TYPE REF TO cl_dd_document,
text TYPE sdydo_text_element,
o_split type ref to cl_gui_easy_splitter_container,
o_top type ref to cl_gui_container,
o_bot type ref to cl_gui_container,
gv_c_vp type ref to cl_gui_container.
end of declaration for top of page.
CLASS lcl_event_receiver DEFINITION DEFERRED.
*class lcl_application_dc definition deferred.
DATA: o_event_receiver TYPE REF TO lcl_event_receiver.
g_dc type ref to lcl_application_dc.
DATA: gt_outtab TYPE TABLE OF sbook.
CLASS lcl_event_receiver DEFINITION
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS: handle_f4 FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING e_fieldname
es_row_no
er_event_data
et_bad_cells
e_display,
handle_top_of_page FOR EVENT top_of_page OF cl_gui_alv_grid
IMPORTING e_dyndoc_id.
METHODS: reset.
METHODS: show_f4.
PRIVATE SECTION.
attributes for creating an own F4-Help
(using a second ALV Grid Control
DATA: f4_grid TYPE REF TO cl_gui_alv_grid,
f4_custom_container TYPE REF TO cl_gui_custom_container.
TYPES: BEGIN OF ty_f4.
TYPES: value TYPE s_class.
TYPES: descr(20) TYPE c.
TYPES: END OF ty_f4.
DATA: f4_itab TYPE TABLE OF ty_f4.
DATA: f4_fieldcatalog TYPE lvc_t_fcat.
attributes to store event parameters
(after the CALL SCREEN command, the event parameters
are not accessible)
TYPES: BEGIN OF onf4_event_parameters_type.
TYPES: c_fieldname TYPE lvc_fname.
TYPES: cs_row_no TYPE lvc_s_roid.
TYPES: cr_event_data TYPE REF TO cl_alv_event_data.
TYPES: ct_bad_cells TYPE lvc_t_modi.
TYPES: c_display TYPE char01.
TYPES: END OF onf4_event_parameters_type.
DATA: f4_params TYPE onf4_event_parameters_type.
Methods to create own F4-Help
(This is done using a second ALV Grid Control)
METHODS: init_f4.
METHODS: build_fieldcatalog.
METHODS: fill_f4_itab .
METHODS: on_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING es_row_no.
ENDCLASS. "lcl_application_f4 DEFINITION
CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
*§2. Implement an event handler method for event ONF4.
METHOD handle_f4.
Save event parameter as global attributes of this class
(maybe solved differently if you use a function module!)
f4_params-c_fieldname = e_fieldname.
f4_params-cs_row_no = es_row_no.
f4_params-cr_event_data = er_event_data.
f4_params-ct_bad_cells = et_bad_cells.
f4_params-c_display = e_display.
*§3. Call your own f4 help. To customize your popup check
first if the cell is ready for input (event parameter E_DISPLAY).
(parameter E_DISPLAY is checked later in method on_double_click)
(Probably, you would call a function module at this point,
pass the needed event parameter and call the popup screen
within that function module. This is not done in this example
to avoid scattering its code).
CALL SCREEN 101 STARTING AT 10 10.
*§7. Inform the ALV Grid Control that an own f4 help has been processed
to suppress the standard f4 help.
er_event_data->m_event_handled = 'X'.
ENDMETHOD. "on_f4
METHOD show_f4.
DATA: ls_outtab TYPE sbook.
initialize own f4 help if needed
IF f4_custom_container IS INITIAL.
CALL METHOD init_f4.
ENDIF.
CALL METHOD fill_f4_itab.
refresh list of values in f4 help and show it
CALL METHOD f4_grid->refresh_table_display.
CAUTION: Do not use method REFRESH_TABLE_DISPLAY for
your editable ALV Grid instances while handling events
DATA_CHANGED or ONf4. You would overwrite intermediate
values of your output table on frontend.
'f4_grid' is a non-editable ALV Grid Control for the
application specific F4-Help. Therefore, calling
REFRESH_TABLE_DISPLAY for this instance has no
negative effect.
CALL METHOD cl_gui_cfw=>flush.
ENDMETHOD. "show_f4
METHOD init_f4.
DATA: ls_f4_layout TYPE lvc_s_layo.
build fieldcatalog entries for f4
CALL METHOD build_fieldcatalog.
create controls
CREATE OBJECT f4_custom_container
EXPORTING container_name = 'CC_ONF4'.
CREATE OBJECT f4_grid
EXPORTING i_parent = f4_custom_container.
hide toolbar
ls_f4_layout-no_toolbar = 'X'.
CALL METHOD f4_grid->set_table_for_first_display
EXPORTING
is_layout = ls_f4_layout
CHANGING
it_fieldcatalog = f4_fieldcatalog
it_outtab = f4_itab.
register event double click on backend
SET HANDLER me->on_double_click FOR f4_grid.
flush since 'ls_layout' is local!
CALL METHOD cl_gui_cfw=>flush.
ENDMETHOD. "init_f4
METHOD fill_f4_itab.
DATA ls_f4_itab TYPE ty_f4.
Delete all entries in f4_itab to determine
offered values dynamically
CLEAR f4_itab[].
ls_f4_itab-value = 'C'.
ls_f4_itab-descr = text-t03. "Business Class
APPEND ls_f4_itab TO f4_itab.
ls_f4_itab-value = 'Y'.
ls_f4_itab-descr = text-t04. "Economie Class
APPEND ls_f4_itab TO f4_itab.
ls_f4_itab-value = 'F'.
ls_f4_itab-descr = text-t05. "First Class
APPEND ls_f4_itab TO f4_itab.
ENDMETHOD. "fill_f4_itab
METHOD build_fieldcatalog.
DATA: ls_fcat TYPE lvc_s_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'VALUE'.
ls_fcat-coltext = text-t02.
ls_fcat-inttype = 'S_CLASS'.
ls_fcat-outputlen = 5.
APPEND ls_fcat TO f4_fieldcatalog.
CLEAR ls_fcat.
ls_fcat-fieldname = 'DESCR'.
ls_fcat-coltext = text-t01.
ls_fcat-inttype = 'C'.
ls_fcat-outputlen = 20.
APPEND ls_fcat TO f4_fieldcatalog.
ENDMETHOD. "build_fieldcatalog
METHOD on_double_click.
*§5. If not already caught by your own f4 help, check whether
the triggered cell was ready for input by using E_DISPLAY
and if not, exit.
IF f4_params-c_display EQ 'X'.
LEAVE SCREEN.
ENDIF.
*§6. After the user selected a value, pass it to the ALV Grid Control:
*§ 6a. Define a field symbol of type: LVC_T_MODI and a structure of
type LVC_S_MODI to pass the value later on.
FIELD-SYMBOLS TYPE lvc_t_modi.
DATA: ls_modi TYPE lvc_s_modi,
ls_f4_itab TYPE ty_f4.
*§ 6b. Dereference attribute M_DATA into your field symbol and add
the selected value to the table to which this symbol points to.
ASSIGN f4_params-cr_event_data->m_data->* TO .
LEAVE TO SCREEN 0.
ENDMETHOD. "on_double_click
METHOD reset.
FIELD-SYMBOLS display_document
EXPORTING parent = o_top.
ENDMETHOD. "handle_top_of_page
ENDCLASS. "lcl_application_f4 IMPLEMENTATION
END-OF-SELECTION.
CALL SCREEN 100.
MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF g_custom_container IS INITIAL.
PERFORM create_and_init_alv CHANGING gt_outtab[]
gt_fieldcat.
ENDIF.
ENDMODULE. "pbo OUTPUT
MODULE PAI INPUT *
MODULE pai INPUT.
save_ok = sy-ucomm.
CLEAR sy-ucomm.
CASE save_ok.
WHEN 'EXIT' OR 'BACK' OR 'CANCEL'.
PERFORM exit_program.
WHEN 'SWITCH'.
PERFORM switch_edit_mode.
WHEN OTHERS.
do nothing
ENDCASE.
ENDMODULE. "pai INPUT
FORM EXIT_PROGRAM *
FORM exit_program.
LEAVE PROGRAM.
ENDFORM. "exit_program
*& Form build_fieldcat
text
-->PT_FIELDCAT text
FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SBOOK'
CHANGING
ct_fieldcat = pt_fieldcat.
LOOP AT pt_fieldcat INTO ls_fcat.
Exchange smoker field with invoice field - just to
make the dependance between SMOKER and CLASS more transparent
(Smoking is only allowed in the first class).
IF ls_fcat-fieldname EQ 'SMOKER'.
ls_fcat-col_pos = 11.
ls_fcat-outputlen = 10.
ls_fcat-edit = 'X'.
Field 'checktable' is set to avoid shortdumps that are caused
by inconsistend data in check tables. You may comment this out
when the test data of the flight model is consistent in your system.
ls_fcat-checktable = '!'. "do not check foreign keys
MODIFY pt_fieldcat FROM ls_fcat.
ELSEIF ls_fcat-fieldname EQ 'INVOICE'.
ls_fcat-col_pos = 7.
MODIFY pt_fieldcat FROM ls_fcat.
ELSEIF ls_fcat-fieldname EQ 'CLASS'.
ls_fcat-edit = 'X'.
ls_fcat-outputlen = 5.
ls_fcat-checktable = '!'. "do not check foreign keys
MODIFY pt_fieldcat FROM ls_fcat.
ENDIF.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form create_and_init_alv
text
-->PT_OUTTAB text
-->PT_FIELDCAT text
FORM create_and_init_alv CHANGING pt_outtab TYPE STANDARD TABLE
pt_fieldcat TYPE lvc_t_fcat.
DATA: lt_exclude TYPE ui_functions,
ls_layout TYPE lvc_s_layo.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT g_grid
EXPORTING i_parent = g_custom_container.
CREATE OBJECT gv_c_split
EXPORTING
link_dynnr = lv_dynnr
link_repid = lv_repid
parent = g_custom_container
rows = 2
columns = 1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
others = 3 .
CALL METHOD gv_c_split->set_border
EXPORTING
border = space.
CALL METHOD gv_c_split->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = gv_c_ptv.
CALL METHOD gv_c_split->set_row_height
EXPORTING
id = 1
height = 20
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 6 .
CALL METHOD gv_c_split->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = gv_c_vp .
CALL METHOD gv_c_split->set_row_height
EXPORTING
id = 2
height = 10
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3 .
CREATE OBJECT o_split
EXPORTING
parent = gv_c_ptv
with_border = 1
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.
o_top = o_split->top_left_container.
o_bot = o_split->bottom_right_container.
CREATE OBJECT gv_alv_ptv
EXPORTING
i_parent = o_bot
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5 .
CREATE OBJECT g_grid
EXPORTING
i_parent = gv_c_vp
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5 .
PERFORM build_fieldcat CHANGING pt_fieldcat.
Optionally restrict generic functions to 'change only'.
(The user shall not be able to add new lines).
PERFORM exclude_tb_functions CHANGING lt_exclude.
PERFORM build_data CHANGING pt_outtab.
ls_layout-grid_title = 'F4 help implemented for field CLASS'.
CREATE OBJECT o_event_receiver.
SET HANDLER o_event_receiver->handle_top_of_page FOR gv_alv_ptv.
SET HANDLER o_event_receiver->handle_top_of_page FOR g_grid.
CREATE OBJECT o_dd_doc EXPORTING style = 'ALV_GRID'
no_margins = 'X'.
CALL METHOD gv_alv_ptv->set_table_for_first_display
EXPORTING
is_layout = ls_layout
CHANGING
it_outtab = pt_outtab[]
it_fieldcatalog = pt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
it_toolbar_excluding = lt_exclude
is_layout = ls_layout
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = pt_outtab[].
CALL METHOD gv_alv_ptv->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = o_dd_doc.
register f4 for field CLASS
PERFORM register_events.
Set editable cells to ready for input initially
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ENDFORM. "CREATE_AND_INIT_ALV
*& Form exclude_tb_functions
text
-->PT_EXCLUDE text
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
Only allow to change data not to create new entries (exclude
generic functions).
DATA ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
APPEND ls_exclude TO pt_exclude.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*& Form build_data
text
--> p1 text
<-- p2 text
FORM build_data CHANGING pt_outtab TYPE STANDARD TABLE.
DATA: ls_sbook TYPE sbook,
l_index TYPE i.
SELECT * FROM sbook INTO TABLE gt_outtab UP TO g_max ROWS.
IF sy-subrc NE 0.
PERFORM generate_entries CHANGING pt_outtab.
ENDIF.
LOOP AT pt_outtab INTO ls_sbook.
l_index = sy-tabix.
CLEAR ls_sbook-class.
Alternate between smoker and non smoker to make
it more obvious what this example is about
l_index = l_index MOD 2.
IF l_index EQ 1.
ls_sbook-smoker = 'X'.
ELSE.
ls_sbook-smoker = ' '.
ENDIF.
MODIFY pt_outtab FROM ls_sbook.
ENDLOOP.
ENDFORM. " build_data
*& Form generate_entries
text
-->PT_SBOOK text
FORM generate_entries CHANGING pt_sbook TYPE STANDARD TABLE.
DATA: ls_sbook TYPE sbook,
l_month(2) TYPE c,
l_day(2) TYPE c,
l_date(8) TYPE c,
l_prebookid TYPE i.
ls_sbook-carrid = 'LH'.
ls_sbook-connid = '0400'.
ls_sbook-forcurkey = 'DEM'.
ls_sbook-loccurkey = 'USD'.
ls_sbook-custtype = 'B'.
DO 110 TIMES.
l_prebookid = sy-index.
ls_sbook-forcuram = sy-index * 10.
ls_sbook-loccuram = ls_sbook-loccuram * 2.
ls_sbook-customid = sy-index.
ls_sbook-counter = 18.
ls_sbook-agencynum = 11.
l_month = sy-index / 10 + 1.
DO 2 TIMES.
l_day = 3 + l_month + sy-index * 2.
l_date+0(4) = '2000'.
l_date+4(2) = l_month.
l_date+6(2) = l_day.
ls_sbook-fldate = l_date.
SUBTRACT 3 FROM l_day.
ls_sbook-order_date+0(6) = l_date+0(6).
ls_sbook-order_date+6(2) = l_day.
ls_sbook-bookid = l_prebookid * 2 + sy-index.
IF sy-index EQ 1.
ls_sbook-smoker = 'X'.
ELSE.
ls_sbook-smoker = space.
ENDIF.
ls_sbook-luggweight = l_prebookid * 10.
IF ls_sbook-luggweight GE 1000.
ls_sbook-wunit = 'G'.
ls_sbook-class = 'C'.
ELSE.
ls_sbook-wunit = 'KG'.
ls_sbook-class = 'Y'.
ENDIF.
IF ls_sbook-bookid > 40 AND ls_sbook-wunit EQ 'KG'.
ls_sbook-invoice = 'X'.
ENDIF.
IF ls_sbook-bookid EQ 2.
ls_sbook-cancelled = 'X'.
ls_sbook-class = 'F'.
ENDIF.
APPEND ls_sbook TO pt_sbook.
ENDDO.
ENDDO.
ENDFORM. " generate_entries
*& Form register_events
text
FORM register_events.
*§1. Register event ONF4 at frontend using method
register_f4_for_fields. For this purpose, you pass a table
with all fields, for which you want to implement your own
f4 help.
remark: If you want to use an own f4 help for fields where
no standard f4 help exists set field F4AVAILABL for
this field in the fieldcatalog.
DATA: lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.
CLEAR lt_f4.
lt_f4-fieldname = 'CLASS'.
If you would like to deregister the field again,
pass value SPACE with field 'register'.
lt_f4-register = 'X'.
*§ 1b. If the value range in your f4 help depends on other
values of cells that are input enabled, set the
GETBEFORE parameter.
The consequence is that the ALV Grid Control raises
event DATA_CHANGED before the f4 help is called to
check values that the f4 help depends on.
lt_f4-getbefore = 'X'.
The next parameter is used to change values after onf4 has
been processed. The ALV Grid Control will raise
event DATA_CHANGED afterwards, if you set it.
lt_f4-chngeafter = space.
INSERT TABLE lt_f4.
CALL METHOD g_grid->register_f4_for_fields
EXPORTING
it_f4 = lt_f4[].
register events for abap objects (backend)
SET HANDLER o_event_receiver->handle_f4 FOR g_grid.
ENDFORM. " register_events
MODULE status_0101 OUTPUT
MODULE status_0101 OUTPUT.
SET PF-STATUS 'POPUP'.
SET TITLEBAR 'POPUP'.
CALL METHOD o_event_receiver->show_f4.
ENDMODULE. " STATUS_0101 OUTPUT
*& Module USER_COMMAND_0101 INPUT
text
MODULE user_command_0101 INPUT.
PERFORM user_command.
ENDMODULE. " USER_COMMAND_0101 INPUT
*& Form user_command
text
FORM user_command.
DATA: save_ok TYPE sy-ucomm.
save_ok = sy-ucomm.
CLEAR sy-ucomm.
CASE save_ok.
WHEN 'CANCEL'.
CALL METHOD o_event_receiver->reset.
LEAVE TO SCREEN 0.
ENDCASE.
ENDFORM. "user_command
*& Form switch_edit_mode
text
FORM switch_edit_mode.
IF g_grid->is_ready_for_input( ) EQ 0.
set edit enabled cells ready for input
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ELSE.
lock edit enabled cells against input
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
ENDIF.
ENDFORM. "switch_edit_mode
Maybe you are looking for
-
Calendar - "This event no longer exists" Cannot see event details
When I tap an event to see the details, the details view opens and a message that says "This event no longer exists" is shown. After I click on OK, the calendar returns to day view. My calendar syncs with Google Calendar. To reproduce this: 1)
-
Safari 4.0.4 Displays All PDF's as Black Pages
When using *Safari 4.0.4* all PDF's are displayed as a dark black page. I have loaded dozens of pages from different sites with the exact same results. If I use Firefox or Camino the PDFs load and display correctly. I spent over an hour on the phone
-
Panasonic HVX200 / DVCPRO HD and 32fps issues
Hi all, I'm having some problems shooting and working with 32fps footage in FCP. The footage was shot at 720P/25PN in Film Mode with a frame rate of 32fps. However all the footage we've imported into final cut via P2 is coming up as 50fps - and the f
-
Fcpx 10.1.4 crashes when iPhone 4s is connected to iMac
When I connect my iPhone 4S running the latest iOS 8.3 is connected to my 2014 iMac 27 running Yosemite 10.10.2 Final Cut Pro X 10.1.4 crashes. If I do successfully connect the phone, FCPX crashes when I attempt to import video from the iPhone. I hav
-
PP crashes on startup.... Font Capture?
PremierePro cs4 crashes right after it loads everything in the splash screen. I get no error message at all. The only tip I have is when I go to restart or logoff I get a message about the adobe Font Capture and how I need to End Now. I sometimes als