Custom control: slider with two needles
I've been using LabVIEW for some years, and I was able to create a lot of custom controls.
I know that CVI is doesn't allow me such a level of customization, but I don't know if there is a simple and effective way to create a slider controls with two needles (based on the Vertical Pointer Slide for example).
I used two different overlapped slides, and they behave more or less as I expected (not fully satisfied, but ...). I need placing a lot of these controls in a panel, so I wonder if I can group the two slides in a custom control, and write some c code to interface with them (if I select Create >>Custom control, I can't select two different controls...)
Is there another way to create a slider control with two needles?
Vix
In claris non fit interpretatio
Using LV 2013 SP1 on Win 7 64bit
Using LV 8.2.1 on WinXP SP3
Using CVI 2012 SP1 on Win 7 64bit, WinXP and WinXP Embedded
Using CVI 6.0 on Win2k, WinXP and WinXP Embedded
Hey Vix -
While I agree it's not quite as straightforward as LabVIEW, you can do exactly what you're talking about with LabWindows/CVI. The basic instructions to do this are here. Another good resource is to check out the installed custom controls in <CVI>\toolslib\custctrl, and copy their format. It sounds like for your particular case, you'd want to create a custom control for a slide control. Then, in the API for your custom control, you could have a convert function that programmatically created the second slide control for your second needle. If you need more detail than this, let me know.
NickB
National Instruments
Similar Messages
-
One controlling area with two company codes assigned with one CoA
Hi,
I am having one controlling area with two company codes assigned , i am using the same gl for two company codes as cost element , when i am positng the miro for vendor purpose it posted the error , to avoid the price difference purpose , i have given one cost center of first company code in OKB9 , and overcome the error , entries posted, when i am posting new entry for MIRO in secod company codes with same cost element , price difference of that account should go to the other cost center which specifically created for second company code, in the OBK9 i have given cost center first company code of the same GL account , now this is another new entry in the second company code with other cost center in the second company code since the price difference account should sit in the other cost center of second company code, how to over come this problem, pls help me
Thanks and regards
MurugesanHi,
First, remove the default cost center in the cost element. Then, for the system to derive the correct cost center for each company codes, define one cost center for each compny codes in OKB9 just like this:
Co Code Cost Element Cost Center
1000 1000000 A
2000 1000000 B
So during MIRO, the system will derive these values you maintain in OKB9.
Regards, -
How can i control graph with two inputs?
Hi,
i would like to ask you about the graph with two inputs
Normally, if i just give one input, they generate the graph with this input(y) vs time(x).
But now i would like to get the graph with my two inputs in x axis and y axis .
i want to control both of two axis. How could i do for it ?
i attached the file that i try to use "Build XY graph" to control both x and y axis with random number .
It can run but i don't know how come the graph show nothing. .
Actually , it have to show something like wavefrom continuously. am i right?
Could you tell me a way to solve it ?
>>>
what i want to get is ..
in Graph,
for x axis , ditance (always increases)
for y axis , vibration (vary)
>>>
Thank you so much for your time . I am looking forward your kindly reply.
With Respect,
Su
Attachments:
using Build XY graph.vi 59 KBHi NI9233,
Mind me to interrupt, I am just helping Mike to explain what he meant to you, refer to the graph:
Picture 1:
Double click on Build XY Graph, uncheck the clear data on each call
Picture 2 and 3:
Change your formula node into +1 Basic Function in Functions Pallette.
Hope that helps!
PS: I am sorry for the size of the image, seems I made a mistakes when I saved the picture.
Sincerely,
Krisna Wisnu
Message Edited by Krisna Wisnu on 11-19-2008 08:19 PM
Sincerely,
Krisna Wisnu
Attachments:
Clear Graph on Each Call.PNG 46 KB
+1.PNG 30 KB
+1_2.PNG 21 KB -
Controlling event with two controls
Here's what I have.
I have two separate Time loops. Inside each timed loop I have an event structure. Each even structure is trigger by pressing a button each. This works just fine.
However, I'd like to add a third button, that executes both event structures. I want to do this without creating additional events in each structure. Is this possible to somehow wire this third button to the other two and trigger the two based off the action of the third? I'm having trouble getting that to work.
Thanks
Message Edited by crazyjay on 02-24-2010 09:15 PM
Solved!
Go to Solution.Quick example
Attachments:
Event with Value Signaling.vi 12 KB -
How can i create a custom control, indicator
This is FredFred,
How can i create a custom control switch with 3 or more options,
OFF
ON
STANDBY
Other than rocker, slide, or toggle switch, are there other switches that we can use, hence, the question of creating a custom switch.
Also, is there a way to create an indicator with two options. Enclosed is a jpeg with an example of what i need
Thanks in Advance
Attachments:
sample switches_displays.bmp 720 KBHello.
Boolean controls can only have 2 possible values, true or false, and there is no way to add more values to them.
If you need more values, then you must use a numeric control (or a string, but I tend to like numerics better, although strings could be just as useful).
There are several types of numeric controls you could use to provide 3 or more options. Attached is a VI which shows a ring, a knob, and a slide each with 3 possible values. In your code, you would then perform different actions depending on the numeric value of your control.
Hope this helps,
Alejandro
Attachments:
NumericsWith3Options.vi 14 KB -
Help me on HSlider with two thumbs
Hi Friends,
I have a problem with HSlider. I am working on a slider with two thumbs. I have a requirement to overlap two thumbs. But the problem with overlapping is i can slide in reverse also. I need to restrict that. Please suggest me solution and save my time.
I will explain with example:
I have a slider to select classes from 1 - 12. For this i am using HSlider with two thumbs.
Now a user can select class range between 1 - 12. i.e., 5-6 or 8-9 or 2-9 etc..
I am giving an option to select 1-1 or 4-4 or 5-5 by overlapping the thumbs.
Now the problem i am facing is : user can select 9-5 or 6-1 or 5-3 etc, because i am giving chance to overlap thumbs.
But i have to restrict that behaviour... The user should not be able to select reverse.
I tried to Override getSnapValue method to restirct that behavior. But it is not working as expected. Please suggest me a solution for this. Please share me if you have any example which is having same or similar behavior.
Thanks,
Venu S.Hi Bhasker,
Thanks for immediate response.
Here is my code:
package
import mx.controls.HSlider;
import mx.controls.sliderClasses.SliderThumb;
import mx.core.mx_internal;
use namespace mx_internal;
public class CustonSlider extends HSlider{
public function CustonSlider (){
override mx_internal function getSnapValue(value:Number, thumb:SliderThumb = null):Number{
if (!isNaN(snapInterval) && snapInterval != 0){
var val:Number = getValueFromX(value);
trace("value min max val "+value+" "+minimum+" "+maximum+" "+val);
//if (thumb && (thumbs.numChildren > 1) && !allowThumbOverlap)
if (thumb && (2 > 1) && !allowThumbOverlap){
var check_bounds:Boolean = true;
var bounds:Object
bounds = getXBounds(thumb.thumbIndex);
var prevThumb:SliderThumb =thumb.thumbIndex > 0 ?
//SliderThumb(thumbs.getChildAt(thumb.thumbIndex- 1)) :
SliderThumb(getThumbAt(thumb.thumbIndex- 1)) :
null;
var nextThumb:SliderThumb =
//thumb.thumbIndex + 1 < thumbs.numChildren ?
thumb.thumbIndex + 1 < 2 ?
//SliderThumb(thumbs.getChildAt(thumb.thumbIndex + 1)) :
SliderThumb(getThumbAt(thumb.thumbIndex + 1)) :
null;
if (prevThumb){
bounds.min -= (prevThumb.width / 2);
trace("bounds.min "+bounds.min);
// check if thumb is at minimum, if not we can ignore the bounds logic
if (val == minimum)
if (getValueFromX((prevThumb.xPosition - prevThumb.width/2)) <= minimum)check_bounds =
false;}
else
if (val >= minimum)check_bounds =
false;}
if (nextThumb){
bounds.max += (nextThumb.width / 2);
trace("bounds.max "+bounds.max);
// check if thumb is at maximum, if not we can ignore the bounds logic
if (val == maximum)
if (getValueFromX((nextThumb.xPosition + nextThumb.width/2)) >= maximum)check_bounds =
false;}
else
if (val <= maximum)check_bounds =
false;}
trace("check_bounds : "+check_bounds);
if (check_bounds)val = Math.min(Math.max(val, getValueFromX(Math.round(bounds.min)) + snapInterval),
getValueFromX(Math.round(bounds.max)) - snapInterval);
return getXFromValue(val);}
return value;}
I am calling the above snippet in my application.
But it is not working as i expected. Let us consider two thumbs as left thumb and right thumb, the left thumb should not move to right and rite thumb should move to right thumb. I can achieve this functionality if i set the boolean property "allowThumbOverlap" to false. But if i did this i cannot select range between 1-1 0r 4-4 or 9-9 etc. I have to give a chance to select range between 1-1 or 4-4 or 9-9 etc
Message was edited by: SVenu_2703 -
UI Design help / Slider with multiple thumbs?
I've got an application which is trying to set multiple bounds
around a single value. For instance, if my value was "temperature",
possible bounds might be cold, temperate, hot.
I want my user to be able to assign all of those ranges.
My first thought was to use a slider with multiple thumbs. I could
have 0 and 100 as min and max, say, with 2 sliders. Everything
to the left of the first slider is "cold", everything between the two
sliders is "temperate", and everything to the right of the second
slider is "hot.
Of course, JSlider does not have support for multiple thumbs.
So, I was hoping someone could either suggest a freeware/LGPL
widget that did *or* could propose a clever redesign to obviate
the need for one.
In reality, my problem is more complex -- multiple values with
varying start values, end values, and number of thresholds. I'm
using multiple sliders right now, and it's functional, but really fugly.
Thanks for any help you might be able to provide!
EricHave found this triple slider from Gene Vishnevsky. Needs some work to adapt to your needs :
* TripleSlider_Test.java
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import javax.swing.*;
public class TripleSlider_Test extends JFrame {
public TripleSlider_Test() {
setTitle("TripleSlider Test");
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setSize(400,300);
setLocationRelativeTo(null);
MyTripleSlider slider = new MyTripleSlider();
add(slider, BorderLayout.NORTH);
public static void main(String args[]) {
new TripleSlider_Test().setVisible(true);
class MyTripleSlider extends TripleSlider{
* This method is called when the "thumb" of the slider is dragged by
* the user. Must be overridden to give the slider some behavior.
public void Motion(){
// TODO add your handling code here:
* TripleSlider
* Description: Slider with two thumbs that divide the bar
* into three parts. Relative size of each part is
* the value of that part, so the three values add up to 1.
* Author: Gene Vishnevsky Oct. 15, 1997
* This class produces a slider with 2 thumbs that has 3 values.
class TripleSlider extends JPanel {
private final static int THUMB_SIZE = 14;
private final static int BUFFER = 2;
private final static int TEXT_HEIGHT = 18;
private final static int TEXT_BUFFER = 3;
private final static int DEFAULT_WIDTH = 300; //200;
private final static int DEFAULT_HEIGHT = 15;
/** Array that holds colors of each of the 3 parts. */
protected Color colors[];
private boolean enabled=true;
private Dimension preferredSize_;
/* this value depends on resizing */
protected int pixMin_, pixMax_, width_;
private int pix1_, pix2_; // pixel position of the thumbs
private double values[]; // the 3 values
/** current font of the labels. */
protected Font font;
* Enables/disables the slider.
public void setEnabled( boolean flag ) {
enabled = flag;
* Constructs and initializes the slider.
public TripleSlider() {
values = new double[3];
colors = new Color[3];
preferredSize_ = new Dimension( DEFAULT_WIDTH,
DEFAULT_HEIGHT + TEXT_HEIGHT + TEXT_BUFFER );
font = new Font("TimesRoman", Font.PLAIN, 12);
pixMax_ = DEFAULT_WIDTH - THUMB_SIZE - 1;
pixMax_ = DEFAULT_WIDTH - THUMB_SIZE - 1;
width_ = DEFAULT_WIDTH;
resize( width_, DEFAULT_HEIGHT + TEXT_HEIGHT /*�+ TEXT_BUFFER*/ );
setValues( 0.33333, 0.33333 );
setColor( 0, Color.blue );
setColor( 1, Color.green );
setColor( 2, Color.red );
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent evt) {
mouseDown(evt);
addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent evt) {
mouseDrag(evt);
* Sets color of a part.
public void setColor( int part, Color color ) {
colors[part] = color;
* Returns color of a part.
* @return current part's color.
public Color getColor( int part ) {
return colors[part];
* This method is called by the runtime when the slider is resized.
public void reshape( int x, int y, int width, int height ) {
// setBounds() is not called.
super.reshape(x, y, width, height);
width_ = width;
pixMin_ = THUMB_SIZE;
pixMax_ = width - THUMB_SIZE - 1;
// recompute new thumbs pixels (for the same values)
setValues( values[0], values[1], values[2] );
repaint();
private void setValues( double a, double b, double c ) {
// we know the values are valid
values[0] = a;
values[1] = b;
values[2] = c;
double total = (double)( width_ - THUMB_SIZE * 4 ); // sum
pix1_ = (int)(a * total) + THUMB_SIZE;
pix2_ = (int)(b * total) + pix1_ + THUMB_SIZE * 2;
* Sets new values of the slider.
* is 1 - a - b.
public void setValues( double a, double b ) {
double sum_ab = a + b;
if( sum_ab > 1. || sum_ab < 0. ) {
/* invalid input: should throw exception */
System.out.println("invalid input");
return;
/* call this private method */
setValues( a, b, 1 - sum_ab );
repaint();
private void updateValues() {
double total = (double)( width_ - THUMB_SIZE * 4 ); // sum
int a = pix1_ - THUMB_SIZE;
int b = pix2_ - pix1_ - THUMB_SIZE * 2;
int c = width_ - (pix2_ + THUMB_SIZE);
values[0] = (double)a / total;
values[1] = (double)b / total;
values[2] = (double)c / total;
* Returns value for a part.
* @return value for the part.
public double getValue( int part ) {
return values[part];
* This method is called when the "thumb" of the slider is dragged by
* the user. Must be overridden to give the slider some behavior.
public void Motion() {
* Paints the whole slider and labels.
public void paint( Graphics g ) {
int width = size().width;
int height = size().height;
g.setColor( Color.lightGray ); // bground
g.fillRect( 0, 0, width, TEXT_HEIGHT );
g.setColor( colors[0] );
g.fillRect( 0, TEXT_HEIGHT,
pix1_ - THUMB_SIZE, height - TEXT_HEIGHT );
g.setColor( colors[1] );
g.fillRect( pix1_ + THUMB_SIZE, TEXT_HEIGHT,
pix2_ - pix1_ - THUMB_SIZE * 2, height - TEXT_HEIGHT );
g.setColor( colors[2] );
g.fillRect( pix2_ + THUMB_SIZE, TEXT_HEIGHT,
width_ - pix2_ - THUMB_SIZE, height - TEXT_HEIGHT );
/* draw two thumbs */
g.setColor( Color.lightGray );
g.fill3DRect( pix1_ - THUMB_SIZE, TEXT_HEIGHT /*+ BUFFER*/,
THUMB_SIZE * 2 + 1, height /*- 2 * BUFFER*/ - TEXT_HEIGHT,
true);
g.fill3DRect( pix2_ - THUMB_SIZE, TEXT_HEIGHT /*+ BUFFER*/,
THUMB_SIZE * 2 + 1, height /*- 2 * BUFFER*/ - TEXT_HEIGHT,
true);
g.setColor( Color.black );
g.drawLine(pix1_, TEXT_HEIGHT + BUFFER + 1,
pix1_, height - 2 * BUFFER);
g.drawLine(pix2_, TEXT_HEIGHT + BUFFER + 1,
pix2_, height - 2 * BUFFER);
g.setFont(font);
// center each value in the middle
String str = render( getValue(0) );
g.drawString(str,
pix1_ / 2 - (int)(getFontMetrics(font).stringWidth(str) / 2),
TEXT_HEIGHT - TEXT_BUFFER);
str = render( getValue(1) );
g.drawString(str,
(pix2_ - pix1_ ) / 2 + pix1_ -
(int)(getFontMetrics(font).stringWidth(str) / 2),
TEXT_HEIGHT - TEXT_BUFFER);
str = render( getValue(2) );
g.drawString(str,
(width_ - pix2_ ) / 2 + pix2_ -
(int)(getFontMetrics(font).stringWidth(str) / 2),
TEXT_HEIGHT - TEXT_BUFFER);
private String render(double value){
DecimalFormat myF = new DecimalFormat("###,###,###.#");
return myF.format(value);
* An internal method used to handle mouse down events.
private void mouseDown(MouseEvent e) {
if( enabled ) {
HandleMouse((int)e.getPoint().getX());
Motion();
* An internal method used to handle mouse drag events.
private void mouseDrag(MouseEvent e) {
if( enabled ) {
HandleMouse((int)e.getPoint().getX());
Motion();
* Does all the recalculations related to user interaction with
* the slider.
protected void HandleMouse(int x) {
boolean leftControl = false;
int left = pix1_, right = pix2_;
int xmin = THUMB_SIZE;
int xmax = width_ - THUMB_SIZE;
// Which thumb is closer?
if( x < (pix1_ + (pix2_ - pix1_) / 2 ) ) {
leftControl = true;
left = x;
} else {
right = x;
/* verify boundaries and reconcile */
if( leftControl ) {
if( left < xmin ) {
left = xmin;
} else if( left > (xmax - THUMB_SIZE*2) ) {
left = xmax - THUMB_SIZE*2;
} else {
if( left > (right - THUMB_SIZE * 2) && right < xmax ) {
// push right
right = left + THUMB_SIZE * 2;
} else {
// right control
if( right > xmax ) {
right = xmax;
} else if( right < (xmin + THUMB_SIZE*2) ) {
right = xmin + THUMB_SIZE*2;
} else {
if( right < (left + THUMB_SIZE * 2) && left > xmin ) {
// push left
left = right - THUMB_SIZE * 2;
pix1_ = left;
pix2_ = right;
updateValues();
repaint();
* Overrides the default update(Graphics) method
* in order not to clear screen to avoid flicker.
public void update( Graphics g ) {
paint( g );
* Overrides the default preferredSize() method.
* @return new Dimension
public Dimension preferredSize() {
return preferredSize_;
* Overrides the default minimumSize() method.
* @return new Dimension
public Dimension minimumSize() {
return preferredSize_;
} -
JSlider with two slider controls
I apologise if this is an obvious question, but my searches have not revealed the answers I was looking for.
I am looking to implement a sort-of JSlider component in an application, which would allow the user to change two controls along the entire length of the slider - i.e. picking a minimum and maximum value. I realise I could do this with two different JSliders, but unless their size changed dynamically, this would be a less intuitive solution.
If anyone has any ideas of how this might be achieved, I would love to hear. Thank you very much.How to do it? Implement your own custom component. You can base it on an assembly of two JSliders if you like, since it would make sense because de facto you have two sliders. It's probably easier than duplicating the innards of a standard JSlider and modifying its renderer.
-
Hello,
Does anyone know how to increase the size of the digital display increment arrows on a slider control? I want to make the arrows bigger but the "custom control" selection under edit is grayed out. I am working with a 30" monitor and would like them to be twice the size.
Thanks,
JohnHi there John,
the procedure seems to be a bit tricky, but you can customize the increment arrows by first switching to the customize mode, then selecting the digital display and only after that it lets you select the Customize control -option. Try it. This works at least in LabVIEW 2009 and 2011.
Cheers,
Cerati -
Problem with custom control and focus
I've a problem with the focus in a custom control that contains a TextField and some custom nodes.
If i create a form with some of these custom controls i'm not able to navigate through these fields by using the TAB key.
I've implemented a KeyEvent listener on the custom control and was able to grab the focus and forward it to the embedded TextField by calling requestFocus() on the TextField but the problem is that the TextField won't get rid of the focus anymore. Means if i press TAB the first embedded TextField will get the focus, after pressing TAB again the embedded TextField in the next custom control will get the focus AND the former focused TextField still got the focus!?
So i'm not able to remove the focus from an embeded TextField.
Any idea how to do this ?Here you go, it contains the control, skin and behavior of the custom control, the css file and a test file that shows the problem...
control:
import javafx.scene.control.Control;
import javafx.scene.control.TextField;
public class TestInput extends Control {
private static final String DEFAULT_STYLE_CLASS = "test-input";
private TextField textField;
private int id;
public TestInput(final int ID) {
super();
id = ID;
textField = new TextField();
init();
private void init() {
getStyleClass().add(DEFAULT_STYLE_CLASS);
public TextField getTextField() {
return textField;
@Override protected String getUserAgentStylesheet() {
return getClass().getResource("testinput.css").toExternalForm();
@Override public String toString() {
return "TestInput" + id + ": " + super.toString();
}skin:
import com.sun.javafx.scene.control.skin.SkinBase;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
public class TestInputSkin extends SkinBase<TestInput, TestInputBehavior> {
private TestInput control;
private TextField textField;
private boolean initialized;
public TestInputSkin(final TestInput CONTROL) {
super(CONTROL, new TestInputBehavior(CONTROL));
control = CONTROL;
textField = control.getTextField();
initialized = false;
init();
private void init() {
initialized = true;
paint();
public final void paint() {
if (!initialized) {
init();
getChildren().clear();
getChildren().addAll(textField);
@Override public final TestInput getSkinnable() {
return control;
@Override public final void dispose() {
control = null;
}behavior:
import com.sun.javafx.scene.control.behavior.BehaviorBase;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
public class TestInputBehavior extends BehaviorBase<TestInput> {
private TestInput control;
public TestInputBehavior(final TestInput CONTROL) {
super(CONTROL);
control = CONTROL;
control.getTextField().addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
@Override public void handle(final KeyEvent EVENT) {
if (KeyEvent.KEY_PRESSED.equals(EVENT.getEventType())) {
keyPressed(EVENT);
control.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override public void changed(ObservableValue<? extends Boolean> ov, Boolean wasFocused, Boolean isFocused) {
if (isFocused) { isFocused(); } else { lostFocus(); }
public void isFocused() {
System.out.println(control.toString() + " got focus");
control.getTextField().requestFocus();
public void lostFocus() {
System.out.println(control.toString() + " lost focus");
public void keyPressed(KeyEvent EVENT) {
if (KeyCode.TAB.equals(EVENT.getCode())) {
control.getScene().getFocusOwner().requestFocus();
}the css file:
.test-input {
-fx-skin: "TestInputSkin";
}and finally the test app:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class Test extends Application {
TestInput input1;
TestInput input2;
TestInput input3;
TextField input4;
TextField input5;
TextField input6;
Scene scene;
@Override public void start(final Stage STAGE) {
setupStage(STAGE, setupScene());
private Scene setupScene() {
input1 = new TestInput(1);
input2 = new TestInput(2);
input3 = new TestInput(3);
input4 = new TextField();
input5 = new TextField();
input6 = new TextField();
GridPane pane = new GridPane();
pane.add(input1, 1, 1);
pane.add(input2, 1, 2);
pane.add(input3, 1, 3);
pane.add(input4, 2, 1);
pane.add(input5, 2, 2);
pane.add(input6, 2, 3);
scene = new Scene(pane);
return scene;
private void setupStage(final Stage STAGE, final Scene SCENE) {
STAGE.setTitle("Test");
STAGE.setScene(SCENE);
STAGE.show();
public static void main(String[] args) {
launch(args);
The test app shows three custom controls on the left column and three standard textfields on the right column. If you press TAB you will see what i mean... -
In custom control , I wnt to save the layout with variant -
Hi,
In custom control , I want to save the layout using variant and i want to choose the layout from the variant
Plz give me the details.
Rerards,
RaniHello Rani
I assume you have an ALV grid displayed within a custom control. For this ALV grid you want to be able to save layouts.
Assuming that you are using class CL_GUI_ALV_GRID you have set the following IMPORTING parameters when calling method go_grid->set_table_for_first_display:
" Fill variant parameter with following values:
gs_variant-report = syst-repid.
gs_variant-handle = 'GRID'. " 4-digit handle; required if you have multiple ALV grids
- I_SAVE = 'A' " allows saving of user-specific and global layouts
- IS_VARIANT = gs_variant
Regards,
Uwe -
How can one use Mission Control with two monitors? Please bring Spaces back
How can one use Mission Control with two monitors. With Spaces I could treat each space as a single desktop.
SyBBI use two monitors at work and have no issue. I have my mail set to use Desktop 1 and iTunes set to the second monitor of Desktop 1. I have browsers set to Desktop 2 and Fusion and RDC set to Desktop 3.
Two things that may help you. In System Preferences > Mission Control, disable the setting "Automatically rearrange spaces...". This screwed with assigning applications to certain spaces. And the other thing is don't use full screen on apps that support it. This just makes your second monitor superfluous. -
TOP of PAGE using ABAP oo with single CUSTOM CONTROL
Can anybody please tell me how to handle TOP_OF_PAGE using ABAP OBJECTS with a SINGLE CUSTOM CONTROL and not with SPLIT CONTAINER(i.e. using single CL_GUI_CUSTOM_CONTAINER and single grid CL_GUI_ALV_GRID ). Is it possible if so Please help me out?
Hi Ravi,
Here is my code. i didn't handle the top_of_page event yet but created a method to handle.
REPORT ZSATEESH_ALV_CONTAINER MESSAGE-ID ZZ
LINE-SIZE 150 NO STANDARD PAGE HEADING.
PROGRAM id : ZSATEESH_ALV_CONTAINER *
Title : Sales document report *
Author : Sateesh *
Date : *
CR# : *
Dev Initiative :
Description :ALV GRID/LIST Report which displays the sales
document header data using ABAP Objects.
Modification Log
Corr. no date programmer description
TYPES Declaration
*--Type for the Header Sales data
TYPES: BEGIN OF TY_VBAK ,
INDICAT LIKE ICON-ID, " Icon
VBELN LIKE VBAK-VBELN, " Sales Document
AUDAT LIKE VBAK-AUDAT, " Document date
VBTYP LIKE VBAK-VBTYP, " SD document category
AUART LIKE VBAK-AUART, " Sales Document Type
AUGRU LIKE VBAK-AUGRU, " Order reason
NETWR LIKE VBAK-NETWR, " Net Value
WAERK LIKE VBAK-WAERK, " SD document currency
END OF TY_VBAK.
DATA Declaration
*--Tableto hold the header sales data
DATA: TB_VBAK TYPE STANDARD TABLE OF TY_VBAK.
*--Table to hold the Icons
DATA: BEGIN OF TB_ICON OCCURS 0,
ID TYPE ICON-ID, " Icon
NAME TYPE ICON-NAME, " Name of an Icon
END OF TB_ICON.
*--Declaration of ALV Grid Tables
DATA: TB_FDCAT TYPE LVC_T_FCAT, " Fieldcatalog
TB_SORT TYPE LVC_T_SORT. " Sorting
DATA: OK_CODE LIKE SY-UCOMM. " sy-ucomm
*--Reference variables for container and grid control.
DATA: CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
" Container reference
OBJ_ALV_GRID TYPE REF TO CL_GUI_ALV_GRID.
" Alv Grid reference
S T R U C T U R E S
DATA: X_FDCAT TYPE LVC_S_FCAT, " Fieldcatalog
X_LAYOUT TYPE LVC_S_LAYO, " layout
X_SORT TYPE LVC_S_SORT, " Sorting
X_VBAK TYPE TY_VBAK, " sales header stucture
X_ICON LIKE TB_ICON. " icons structure
C O N S T A N T S
*--Declaration of Constants
CONSTANTS :
C_GREEN(40) TYPE C VALUE 'ICON_GREEN_LIGHT',
C_RED(40) TYPE C VALUE 'ICON_RED_LIGHT',
C_YELLOW(40) TYPE C VALUE 'ICON_YELLOW_LIGHT',
C_X TYPE C VALUE 'X'. " Flag
SELECTION SCREEN
*--Block 1.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER: P_AUDAT LIKE VBAK-AUDAT
DEFAULT '20050101'(003). " doc date.
SELECTION-SCREEN: END OF BLOCK B1.
*--bLOCK 2.
SELECTION-SCREEN : BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETER :P_ALVDIS AS CHECKBOX. " For List/Grid
SELECTION-SCREEN : END OF BLOCK B2.
Class LC_VBAK definition
CLASS LC_VBAK DEFINITION.
PUBLIC SECTION.
METHODS: VBAK_POPULATE, " sales header population
ICON_POPULATE, " Icons population
FINAL_POPULATE, " Final ALV population
DISPLAY, " Displaying ALV
TOP_OF_PAGE FOR EVENT TOP_OF_PAGE OF CL_GUI_ALV_GRID
IMPORTING E_DYNDOC_ID.
ENDCLASS. "LC_VBAK DEFINITION
Class LC_VBAK IMPLEMENTATION
CLASS LC_VBAK IMPLEMENTATION.
METHOD VBAK_POPULATE.
*-- selecting from VBAK
SELECT VBELN
AUDAT
VBTYP
AUART
AUGRU
NETWR
WAERK
INTO CORRESPONDING FIELDS OF TABLE TB_VBAK
FROM VBAK
WHERE AUDAT > P_AUDAT AND
NETWR > 0.
IF SY-SUBRC <> 0.
SORT TB_VBAK BY AUART VBTYP WAERK .
ENDIF.
ENDMETHOD . "VBAK_POPULATE
METHOD ICON_POPULATE.
*--selecting from ICON table
SELECT ID
NAME
INTO TABLE TB_ICON
FROM ICON.
IF SY-SUBRC = 0.
SORT TB_ICON BY NAME .
ENDIF.
ENDMETHOD . "ICON_POPULATE
METHOD FINAL_POPULATE.
*--looping through VBAK table into the work area
LOOP AT TB_VBAK INTO X_VBAK .
IF X_VBAK-NETWR <= 10.
*--Reading the ICON table into work area comparing field NAME
READ TABLE TB_ICON INTO X_ICON WITH KEY NAME = C_GREEN
BINARY SEARCH.
IF SY-SUBRC = 0.
X_VBAK-INDICAT = X_ICON-ID.
*--modifying the TB_VBAK table
MODIFY TB_VBAK FROM X_VBAK.
ENDIF.
ELSEIF X_VBAK-NETWR > 10 AND X_VBAK-NETWR < 100.
*--Reading the ICON table into work area comparing field NAME
READ TABLE TB_ICON INTO X_ICON WITH KEY NAME = C_YELLOW
BINARY SEARCH.
IF SY-SUBRC = 0.
X_VBAK-INDICAT = X_ICON-ID.
*--modifying the TB_VBAK table
MODIFY TB_VBAK FROM X_VBAK.
ENDIF.
ELSEIF X_VBAK-NETWR >= 100.
*--Reading the ICON table into work area comparing field NAME
READ TABLE TB_ICON INTO X_ICON WITH KEY NAME = C_RED
BINARY SEARCH.
IF SY-SUBRC = 0.
X_VBAK-INDICAT = X_ICON-ID.
*--modifying the TB_VBAK table
MODIFY TB_VBAK FROM X_VBAK.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD. "FINAL_POPULATE
METHOD top_of_page *
METHOD TOP_OF_PAGE.
PERFORM EVENT_TOP_OF_PAGE USING E_DYNDOC_ID.
ENDMETHOD. "top_of_page
METHOD DISPLAY.
*--Building fieldcatalog table
PERFORM FIELDCATLOG.
*--FOr making the Layout settings
PERFORM LAYOUT.
*--For sorting the fields
PERFORM SORTING.
*--perform for displaying the ALV
PERFORM ALV_GRID_DISPLAY.
ENDMETHOD. "DISPLAY
ENDCLASS. "LC_VBAK IMPLEMENTATION
*& Form FIELDCATLOG
Building the FIELDCATALOG
FORM FIELDCATLOG .
CLEAR: X_FDCAT,TB_FDCAT[].
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 1.
X_FDCAT-FIELDNAME = 'INDICAT'(004) .
X_FDCAT-TABNAME = 'TB_VBAK'(005).
X_FDCAT-SCRTEXT_L = 'STATUS_INDICATOR'(006).
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 2.
X_FDCAT-FIELDNAME = 'VBELN'(007) .
X_FDCAT-TABNAME = 'TB_VBAK'(005).
X_FDCAT-SCRTEXT_L = 'SALES DOC'(008).
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 3.
X_FDCAT-FIELDNAME = 'AUDAT'(009) .
X_FDCAT-TABNAME = 'TB_VBAK'.
X_FDCAT-SCRTEXT_L = 'DOC DATE'(010).
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 4.
X_FDCAT-FIELDNAME = 'VBTYP'(011) .
X_FDCAT-TABNAME = 'TB_VBAK'.
X_FDCAT-SCRTEXT_L = 'SALES CATEGORY'(012).
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 5.
X_FDCAT-FIELDNAME = 'AUART'(013) .
X_FDCAT-TABNAME = 'TB_VBAK'.
X_FDCAT-SCRTEXT_L = 'DOC TYPE'(014).
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 6.
X_FDCAT-FIELDNAME = 'AUGRU'(015) .
X_FDCAT-TABNAME = 'TB_VBAK'.
X_FDCAT-SCRTEXT_L = 'REASON'(016).
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 7.
X_FDCAT-FIELDNAME = 'NETWR'(017) .
X_FDCAT-TABNAME = 'TB_VBAK'.
X_FDCAT-SCRTEXT_L = 'NET VALUE'(018).
X_FDCAT-DO_SUM = C_X.
APPEND X_FDCAT TO TB_FDCAT.
X_FDCAT-ROW_POS = 1.
X_FDCAT-COL_POS = 8.
X_FDCAT-FIELDNAME = 'WAERK'(019) .
X_FDCAT-TABNAME = 'TB_VBAK'.
X_FDCAT-SCRTEXT_L = 'UNIT'(020).
APPEND X_FDCAT TO TB_FDCAT.
ENDFORM. " FIELDCATLOG
*& Module STATUS_0007 OUTPUT
module for setting the pf status
MODULE STATUS_0007 OUTPUT.
SET PF-STATUS 'ZSTATUS'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0007 OUTPUT
*& Module USER_COMMAND_0007 INPUT
module for handling the user commands
MODULE USER_COMMAND_0007 INPUT.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0007 INPUT
*& Form LAYOUT
ALV Layout settings
FORM LAYOUT .
CLEAR X_LAYOUT.
*-- making Layout settings
X_LAYOUT-GRID_TITLE = 'Sales Header Document'(021).
X_LAYOUT-ZEBRA = C_X.
IF P_ALVDIS = C_X.
X_LAYOUT-NO_HGRIDLN = C_X.
X_LAYOUT-NO_VGRIDLN = C_X.
ENDIF.
ENDFORM. " LAYOUT
*& Form SORTING
sub routine for sorting criteria
FORM SORTING .
CLEAR X_SORT.
X_SORT-SPOS = '1'(022).
X_SORT-FIELDNAME = 'AUART'.
X_SORT-UP = C_X.
APPEND X_SORT TO TB_SORT.
CLEAR X_SORT.
X_SORT-SPOS = '2'(023).
X_SORT-FIELDNAME = 'VBTYP'.
X_SORT-UP = C_X.
APPEND X_SORT TO TB_SORT.
CLEAR X_SORT.
X_SORT-SPOS = '3'(024).
X_SORT-FIELDNAME = 'WAERK'.
X_SORT-UP = C_X.
X_SORT-SUBTOT = C_X.
APPEND X_SORT TO TB_SORT.
ENDFORM. " SORTING
*& Form CREATE_CONTAINER_OBJECT
subroutine to create object of container
FORM CREATE_CONTAINER_OBJECT .
CREATE OBJECT CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = 'CUST_CONTROL'(025)
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
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.
ENDFORM. " CREATE_CONTAINER_OBJECT
*& Form CREATE_ALV_GRID_OBJECT
subroutine to create object of ALV GRID
FORM CREATE_ALV_GRID_OBJECT .
CREATE OBJECT OBJ_ALV_GRID
EXPORTING
I_PARENT = CUSTOM_CONTAINER
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CREATE_ALV_GRID_OBJECT
*& Form ALV_GRID_DISPLAY
subroutine to call method for displaying the ALV GRID
FORM ALV_GRID_DISPLAY .
CALL METHOD OBJ_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = X_LAYOUT
CHANGING
IT_OUTTAB = TB_VBAK
IT_FIELDCATALOG = TB_FDCAT
IT_SORT = TB_SORT
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
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.
CALL SCREEN 0007.
ENDFORM. " ALV_GRID_DISPLAY
START OF SELECTION
START-OF-SELECTION.
*--Creating a reference variable for the class LC_VBAK
DATA : OBJ1 TYPE REF TO LC_VBAK.
*--Creating a container object
PERFORM CREATE_CONTAINER_OBJECT.
*--Creating a ALV GRID control object
PERFORM CREATE_ALV_GRID_OBJECT.
*--Creating a object of class LC_VBAK
CREATE OBJECT OBJ1.
*--calling vbak population method
CALL METHOD OBJ1->VBAK_POPULATE.
*--calling icon population method
CALL METHOD OBJ1->ICON_POPULATE.
*--calling fianl table population method
CALL METHOD OBJ1->FINAL_POPULATE.
*--calling final method for display
CALL METHOD OBJ1->DISPLAY.
*& Form EVENT_TOP_OF_PAGE
text
-->P_E_DYNDOC_ID text
FORM EVENT_TOP_OF_PAGE USING P_E_DYNDOC_ID TYPE REF TO
CL_DD_DOCUMENT.
ENDFORM. " EVENT_TOP_OF_PAGE -
Populating a table with two columns using a custom bean
hello,
Can someone provide me or give me a link to an example of populating a table (with two columns) with a custom bean?
thank you
fwu1)create a java class
2)have a list as a class variable
3) populate the list in the constructor..
4) map the values in the af:table
//Employee pojo
public class Employee {
public Employee() {
super();
private String empName;
private String empManager;
private String job;
public void setEmpName(String empName) {
this.empName = empName;
public String getEmpName() {
return empName;
public void setEmpManager(String empManager) {
this.empManager = empManager;
public String getEmpManager() {
return empManager;
public void setJob(String job) {
this.job = job;
public String getJob() {
return job;
//maanged bean
public class Bean {
private List<Employee> employee;
public Bean() {
super();
employee = new ArrayList<Employee>();
Employee e1 = new Employee();
e1.setEmpName("xxxxx");
e1.setEmpManager("xxxxxxxx");
e1.setJob("xxxxxxx");
Employee e2 = new Employee();
e2.setEmpName("yyyyyyy");
e2.setEmpManager("yyyyyyy");
e2.setJob("yyyyyyt");
Employee e3 = new Employee();
e3.setEmpName("zzzzzz");
e3.setEmpManager("zzzzzzz");
e3.setJob("zzzzzzzz");
employee.add(e1);
employee.add(e2);
employee.add(e3);
employee.add(e4);
public void setEmployee(List<Employee> employee) {
this.employee = employee;
public List<Employee> getEmployee() {
return employee;
}in the table map like
<af:table value="#{Bean.employee}" var="row" rowBandingInterval="0"
id="t1">
<af:column headerText="Employee Name" id="c1">
<af:inputText value="#{row.empName}" id="it5"/>
</af:column>
<af:column headerText="Employee Manager" id="c2">
<af:inputText value="#{row.empManager}" id="it2"/>
</af:column>
</af:table> -
Consolidating with two controlling areas
Hi
We are looking to implement JVA on our SAP system, and for this there will be requirement for a second controlling area to be created.
We see this as causing us problems regarding consolidation in BCS u2013 We were wondering if anyone knows if it is possible to consolidation in BCS with two controlling areas?
ThanksI'm assuming that you are creating a second Controlling Area for a second year end (since you are looking at JVA)? If some other reason, don't bother with reading the rest of my post.
We are currently using two Controlling Areas due to the fact that we also invest in many joint ventures. Our corporate year-end is January 31, while many of the JVs are December 31.
For BCS, we are defaulting the Fiscal Year Variant to the January 31 value when the data is brought in via Load from Data Stream (we hard-coded the assignment in the mapping). Our requirement is only to consolidate for our corporate year-end, which is why we are able to do this. Since BCS is based on periods (and not calendar date), the data is brought in as follows: December 31 year-ends come in a month ahead (i.e. the month of January data is actually period 12 of the previous year for BCS, even though it is actually that company's fiscal period 1, the month of February is period 1 of the following year for BCS, etc.); meanwhile, our January 31 companies come into BCS in line with our corporate year-end (i.e month of January data is period 12 for both the company itself and BCS).
Hope this makes sense.
Jim Link
Maybe you are looking for
-
My Macbook Pro keeps getting the spinning wheel...
Hello there. This seems to be something thats asked about quite often. I wanted to see if there was something I could do to fix this problem without having to go to Apple. and if not, it is what it is. ....I have a Macbook Pro, bought it in 2011...ha
-
I am seeing an irritating problem with the default mail account, calendar and contacts list on my iPhone 4. Every so often (I think it happens randomly after syncing or even just connecting the iPhone to my iMac without syncing) I notice that some or
-
Which is better?? INDEXING or AGGREGATES or PARTITIONING??
Hello BW Experts, If I need to decide one out of three i.e., INDEXING or AGGREGATES or PARTITIONING for better performance.. ?? whcih one should i go for?? and why?? Plz throw some light on this!! Thanks & Regards, Sapster.
-
Why does home sharing drop from ATV after short time?
I've been having the same trouble with my ATV and itunes homesharing. The connection fails after a short time and I have to restart the homesharing in itunes to get it to work again.
-
Eclipse Enterprise Pack Plugin error for wl 103
I am trying to integrate eclipse plugin for WebLogic 10.3 with Eclipse versions of 3.3 and 3.4 This is the error I got. The documentation says this plugin is good with 10.3 version of Web Logic Server but gives the following error The path "C:\BEA10g