I want to create a traffic light sequence in labview

Hi,
I'm very new to Labview(first post here) and am learning by trying some simple things.
I'm trying to create a continuous running traffic light system, RED, THEN RED AND AMBER, THEN JUST GREEN, THEN JUST AMBER, THEN JUST RED, and repeat the sequence.
I've got 3 LED's of the 3 colours and at the moment they run, RED, THEN RED AND AMBER, THEN RED AND AMBER AND GREEN, THEN ALL OFF, and the sequence then repeats.
I've used a case structure within a while loop.  Set a state for each colour and the reset(all off).  Straight forward I think.
Does anyone have any tips on how i might add to what I've got to create the aforementioned traffic light sequence? 
Many thanks for your time.
PJ.
Solved!
Go to Solution.

You have passed the test, so I will attach the VI this time (LV9, let me know if you need an earlier version).  You'd be surprised how many people will complain about not being provided code, glad to see you are a good sport.
The cluster array constant was created by right-clicking the control and choosing Create Constant.  It simply let me show in a screenshot the contents of the Sequence Array.
I added the delay as a little hint to always be thinking one move ahead.  Eventually you will be thinking many more moves ahead, but start out by considering the next thing you'll want to do and try to keep your code flexible enough to handle it.
Attachments:
SimpleTrafficLight.vi ‏11 KB

Similar Messages

  • I wish to create a traffic light system.

    I want to create a 'traffic light system' in a spread sheet.  I want to enter a date (in the future) in cell that will show green, six months before that date is reached the cell turns amber and then when the date is reached the cell turns red.  Any ideas on a function or formula please?

    Hi Rj,
    This can be handled by conditional formatting of the cell containing the date.
    You have three conditions:
    The date is more than six months from today.
    The date is less than six months from today.
    The date is today or before today.
    1 can be set as the default condition. It does not need to be tested. Set the default fill colour to green.
    3 will be the last condition to become true, so use it as the first condition to be evaluated.
    2 will become true before 3 does, so test it after testing 3.
    Regards,
    Barry

  • Problem when creating multiple traffic lights column in SALV...

    Hello Experts,
    I am using ALV display using the SALV(factory) method. My problem is,
    only the last excception column shows. I making 3 exception columns. Below is my code:
    gt_output[] = im_output[].
        TRY.
            cl_salv_table=>factory(
              EXPORTING
                list_display = ''
              IMPORTING
                r_salv_table = lcl_table
              CHANGING
                t_table      = gt_output ).
          CATCH cx_salv_msg.                                "#EC NO_HANDLER
        ENDTRY.
        lcl_functions = lcl_table->get_functions( ).
    *   Set all standard ALV functions
        lcl_functions->set_all( abap_true ).
        lcl_columns = lcl_table->get_columns( ).
        lcl_columns->set_optimize( '' ).
    *   Set display to striped pattern
        lcl_display = lcl_table->get_display_settings( ).
        lcl_display->set_striped_pattern( cl_salv_display_settings=>true ).
    */Sort columns
        TRY.
            lcl_sorts = lcl_table->get_sorts( ).
          CATCH cx_salv_not_found.                          "#EC NO_HANDLER
        ENDTRY.
        lcl_sorts->set_group_active( ).
        TRY.
            lcl_sorts->add_sort(
              columnname = 'EBELN'
              subtotal   = '' ).
          CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER
        ENDTRY.
        TRY.
            lcl_sorts->add_sort(
              columnname = 'EBELP'
              subtotal   = '' ).
          CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER
        ENDTRY.
    */Set column names
        TRY.
            lcl_columns->set_exception_column( 'EXCEPTION1' ).
            lcl_columns->set_exception_column( 'EXCEPTION2' ).
            lcl_columns->set_exception_column( 'EXCEPTION3' ).
          CATCH cx_salv_data_error.                         "#EC NO_HANDLER
        ENDTRY.
        TRY.
            lcl_column ?= lcl_columns->get_column( 'EXCEPTION1' ).
            lcl_column->set_short_text( text-h01 ).
            lcl_column->set_medium_text( text-h01 ).
            lcl_column->set_long_text( text-h01 ).
            lcl_column->set_output_length( '9' ).
          CATCH cx_salv_not_found.                          "#EC NO_HANDLER
        ENDTRY.
    *    TRY.
    *        lcl_columns->set_exception_column( 'EXCEPTION2' ).
    *      CATCH cx_salv_data_error.                         "#EC NO_HANDLER
    *    ENDTRY.
        TRY.
            lcl_column ?= lcl_columns->get_column( 'EXCEPTION2' ).
    *        lcl_column->set_short_text( text-h07 ).
            lcl_column->set_medium_text( text-h07 ).
            lcl_column->set_long_text( text-h07 ).
            lcl_column->set_output_length( '15' ).
          CATCH cx_salv_not_found.                          "#EC NO_HANDLER
        ENDTRY.
    *    TRY.
    *        lcl_columns->set_exception_column( 'EXCEPTION3' ).
    *      CATCH cx_salv_data_error.                         "#EC NO_HANDLER
    *    ENDTRY.
        TRY.
            lcl_column ?= lcl_columns->get_column( 'EXCEPTION3' ).
    *        lcl_column->set_short_text( text-h08 ).
    *        lcl_column->set_medium_text( text-h08 ).
            lcl_column->set_long_text( text-h08 ).
            lcl_column->set_output_length( '23' ).
          CATCH cx_salv_not_found.                          "#EC NO_HANDLER
        ENDTRY.
    Hope you can help me guys. Thank you and take care!
    Edited by: Viraylab on Feb 15, 2008 3:50 PM

    you can only define one exception per alv table. it's a limitation.
    if you require more than one traffic light, use icons instead

  • How to ... Traffic Lights from Exceptions or CellValue in WAD

    Hi all,
    I need to create traffic lights in the WAD. They should occur either depending on exceptions of a certain query/view or on a special cell value (which I suppose to be quite complex ... table interface(?)).
    I tried the alert monitor element, but that doesnt suite the "traffic light" expectations as it seems.
    Does anybody of you have a manual for creating fancy traffic lights in the WAD? Is there a way without hardcoding this table interface? (I am unexperienced with stuff like that / ABAP coding - if you could guide me through to having a suitable interface I could use with JavaScript then, I would be delighted)
    Best regards and thanks very much in advance for some answers,
    Michael

    Michael,
    I am not sure if you can have icons outside the query that can be controlled by the query values. You could do one thing ...
    1. have a query with an extra Key figure.
    2. Have your validation formulae on this key figure and have an exception on the same
    3. Now your exception column would have three colors.
    4. Now execute the report in IE and go to view source.
    5. Look for the stylesheet classes for the exceptions , they would be something like SAPBexGood1... etc
    6. Go to the table interface ( I assume that you would have figured out how to inherit the class and modify the same from the how to paper...)
    7. Go to c_cell_data
    8. if cell_style="SAPBeXGood1" then replace c_cell_content with <img src="/sap/bw/mime/icons/icon1.gif" /img>
    9. Go to the css and find out your stylesheet class.
    10. Remove the background color attribute from the required style.
    for checking through JavaScript.
    1. The query should have a separate stylesheet class attached to it.
    2. It should have one cell only
    3. You can replace the value by using style.innerHTML=whatever you want.
    Hope this helps...
    Arun
    Assign points if found helpful
    Message was edited by: Arun Varadarajan

  • Traffic light in work orders

    Hi!
    I am searching for an traffic light overview for workorders. For example if some of them are overdue, Partially confirmed,.. I am interested in the system status and I want to assign the traffic lights accordingly to the system status. I use transactions "iw38 or iw39"
    In our SAP System it isn't possible to activate the "monitor". Is this depended on the customizing?
    THX for your help.
    br patrick

    Do anybody know something about such Traffic lights? br patrick

  • Traffic light  repaint not working via button

    I created a traffic light, a button is pressed and the colors should cycle yellow>green>yellow>red etc.. as a normal traffic light would
    when i press the start button, the repaint(); doesnt work, system.output shows me the number which corresponds to the light changes but somehow the graphics/paint is not updated.
    what am i doing wrong?
    package test2;<br />
    <br />
    import java.awt.event.ActionEvent;<br />
    import java.awt.event.ActionListener;<br />
    import javax.swing.JButton;<br />
    import javax.swing.JOptionPane;<br />
    import javax.swing.JPanel;<br />
    <br />
    public class Traffic_Lights extends JPanel implements ActionListener {<br />
    <br />
    private Light_Controller LightController;<br />
    private JButton jStart, jStop;<br />
    <br />
    public Traffic_Lights() {<br />
    jStart = new JButton("START");<br />
    jStop = new JButton("EXIT");<br />
    <br />
    // Register Listeners with buttons<br />
    jStart.addActionListener(this);<br />
    jStop.addActionListener(this);<br />
    LightController = new Light_Controller();<br />
    this.add(jStart);<br />
    this.add(jStop);<br />
    }<br />
    // Adding the traffic light<br />
    <br />
    <br />
    /**<br />
    * This method traps the button click events<br />
    */<br />
    public void actionPerformed(ActionEvent e) {<br />
    // Rotate button is clicked<br />
    if (e.getSource() == jStart) {<br />
    // Change the color displayed<br />
    LightController.changeColor();<br />
    package test2;<br />
    import java.awt.*;<br />
    import java.awt.geom.Rectangle2D;<br />
    import javax.swing.JComponent;<br />
    import javax.swing.JPanel;<br />
    <br />
    <br />
    public class Light_Controller extends JPanel {<br />
    <br />
    private int lightState = 1;<br />
    <br />
    <br />
    public void changeColor() {<br />
    lightState++;<br />
    System.out.println(lightState);<br />
    if (lightState > 5) {<br />
    lightState = 2;<br />
    <br />
    }<br />
    <br />
    this.repaint();<br />
    <br />
    }<br />
    <br />
    /**<br />
    * This method draws the traffic light on the screen<br />
    */<br />
    public void paintComponent(Graphics g) {<br />
    super.paintComponent(g);<br />
    <br />
    Graphics2D g1 = (Graphics2D) g;<br />
    // Draws the traffic light<br />
    // Draw out white frame<br />
    g.setColor(new Color(255,255,255));<br />
    g.fillRoundRect(35,15,120,225,30,30);<br />
    <br />
    // Draw inner black frame<br />
    g.setColor(new Color(0,0,0));<br />
    g.fillRoundRect(50,30,90,195,30,30);<br />
    g.drawRoundRect(35,15,120,225,30,30);<br />
    <br />
    // RED dim<br />
    g.setColor(new Color(100,0,0));<br />
    g.fillOval(70,40,50,50);<br />
    <br />
    // YELLOW dim<br />
    g.setColor(new Color(100,100,0));<br />
    g.fillOval(70,100,50,50);<br />
    <br />
    // GREEN dim<br />
    g.setColor(new Color(0,100,0));<br />
    g.fillOval(70,160,50,50);<br />
    <br />
    // Draw traffic light stand<br />
    g.setColor(new Color(50,50,50));<br />
    g.fillRect(80,240,30,30);<br />
    <br />
    switch(lightState) {<br />
    case 1:<br />
    // red glows<br />
    g.setColor(new Color(255, 0, 0));<br />
    g.fillOval(70, 40, 50, 50);<br />
    g1.fill(new Rectangle2D.Double(440, 450, 60, 5));<br />
    g1.fill(new Rectangle2D.Double(350, 240, 60, 5));<br />
    g1.fill(new Rectangle2D.Double(345, 360, 5, 80));<br />
    g1.fill(new Rectangle2D.Double(500, 250, 5, 90));<br />
    break;<br />
    <br />
    case 2:<br />
    // yellow glows<br />
    g.setColor(new Color(255, 255, 0));<br />
    g.fillOval(70, 100, 50, 50);<br />
    g1.fill(new Rectangle2D.Double(440, 450, 60, 5));<br />
    g1.fill(new Rectangle2D.Double(350, 240, 60, 5));<br />
    g1.fill(new Rectangle2D.Double(345, 360, 5, 80));<br />
    g1.fill(new Rectangle2D.Double(500, 250, 5, 90));<br />
    break;<br />
    <br />
    case 3:<br />
    // green glows<br />
    g.setColor(new Color(0, 255, 0));<br />
    g.fillOval(70, 160, 50, 50);<br />
    g1.fill(new Rectangle2D.Double(440, 450, 60, 5));<br />
    g1.fill(new Rectangle2D.Double(350, 240, 60, 5));<br />
    g1.fill(new Rectangle2D.Double(345, 360, 5, 80));<br />
    g1.fill(new Rectangle2D.Double(500, 250, 5, 90));<br />
    break;<br />
    <br />
    case 4:<br />
    // back to yellow glows<br />
    g.setColor(new Color(255, 255, 0));<br />
    g.fillOval(70, 100, 50, 50);<br />
    g1.fill(new Rectangle2D.Double(440, 450, 60, 5));<br />
    g1.fill(new Rectangle2D.Double(350, 240, 60, 5));<br />
    g1.fill(new Rectangle2D.Double(345, 360, 5, 80));<br />
    g1.fill(new Rectangle2D.Double(500, 250, 5, 90));<br />
    break;<br />
    <br />
    case 5:<br />
    // back to red glows<br />
    g.setColor(new Color(255, 0, 0));<br />
    g.fillOval(70, 40, 50, 50);<br />
    g1.fill(new Rectangle2D.Double(440, 450, 60, 5));<br />
    g1.fill(new Rectangle2D.Double(350, 240, 60, 5));<br />
    g1.fill(new Rectangle2D.Double(345, 360, 5, 80));<br />
    g1.fill(new Rectangle2D.Double(500, 250, 5, 90));<br />
    break;<br />
    }<br />
    }<br />
    } <br />

    Code continued...
    class Light_Controller extends JPanel {
        private int lightState = 1;
        public void changeColor() {
            lightState++;
            System.out.println(lightState);
            if (lightState > 5) {
                lightState = 2;
            this.repaint();
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g1 = (Graphics2D) g;
            g.setColor(new Color(255, 255, 255));
            g.fillRoundRect(35, 15, 120, 225, 30, 30);
            g.setColor(new Color(0, 0, 0));
            g.fillRoundRect(50, 30, 90, 195, 30, 30);
            g.drawRoundRect(35, 15, 120, 225, 30, 30);
            g.setColor(new Color(100, 0, 0));
            g.fillOval(70, 40, 50, 50);
            g.setColor(new Color(100, 100, 0));
            g.fillOval(70, 100, 50, 50);
            g.setColor(new Color(0, 100, 0));
            g.fillOval(70, 160, 50, 50);
            g.setColor(new Color(50, 50, 50));
            g.fillRect(80, 240, 30, 30);
            switch (lightState) {
                case 1:
                    g.setColor(new Color(255, 0, 0));
                    g.fillOval(70, 40, 50, 50);
                    g1.fill(new Rectangle2D.Double(440, 450, 60, 5));
                    g1.fill(new Rectangle2D.Double(350, 240, 60, 5));
                    g1.fill(new Rectangle2D.Double(345, 360, 5, 80));
                    g1.fill(new Rectangle2D.Double(500, 250, 5, 90));
                    break;
                case 2:
                    g.setColor(new Color(255, 255, 0));
                    g.fillOval(70, 100, 50, 50);
                    g1.fill(new Rectangle2D.Double(440, 450, 60, 5));
                    g1.fill(new Rectangle2D.Double(350, 240, 60, 5));
                    g1.fill(new Rectangle2D.Double(345, 360, 5, 80));
                    g1.fill(new Rectangle2D.Double(500, 250, 5, 90));
                    break;
                case 3:
                    g.setColor(new Color(0, 255, 0));
                    g.fillOval(70, 160, 50, 50);
                    g1.fill(new Rectangle2D.Double(440, 450, 60, 5));
                    g1.fill(new Rectangle2D.Double(350, 240, 60, 5));
                    g1.fill(new Rectangle2D.Double(345, 360, 5, 80));
                    g1.fill(new Rectangle2D.Double(500, 250, 5, 90));
                    break;
                case 4:
                    g.setColor(new Color(255, 255, 0));
                    g.fillOval(70, 100, 50, 50);
                    g1.fill(new Rectangle2D.Double(440, 450, 60, 5));
                    g1.fill(new Rectangle2D.Double(350, 240, 60, 5));
                    g1.fill(new Rectangle2D.Double(345, 360, 5, 80));
                    g1.fill(new Rectangle2D.Double(500, 250, 5, 90));
                    break;
                case 5:
                    g.setColor(new Color(255, 0, 0));
                    g.fillOval(70, 40, 50, 50);
                    g1.fill(new Rectangle2D.Double(440, 450, 60, 5));
                    g1.fill(new Rectangle2D.Double(350, 240, 60, 5));
                    g1.fill(new Rectangle2D.Double(345, 360, 5, 80));
                    g1.fill(new Rectangle2D.Double(500, 250, 5, 90));
                    break;
    }

  • How to add Traffic Lights to a Report?

    Hi,
    How do U create a Traffic Light? and how to you change the Light? That's all I need.
    Thanks,
    Kishan

    hi dude,
    This is the way u add lights to ur alv report.
    I'm following this method and i'm getting lights. This will work for sure.
    In data declaration along with your alv display structure as a field named lights(any name).
    DATA : BEGIN OF wa_srr,
    vbeln LIKE vbak-vbeln, "Sales Order number
    posnr LIKE vbap-posnr, "Item nunmber
    matnr LIKE makt-matnr, "Material number Desc
    maktx LIKE makt-maktx, "Material Description
    gbstk LIKE vbuk-gbstk, "Completion status
    bukrs LIKE knb1-bukrs, "Company Code
    butxt LIKE t001-butxt, "Company Code description
    vkorg LIKE vbak-vkorg, "Sales organization
    vtext LIKE tvkot-vtext, "Sales Org description
    vtweg LIKE vbak-vtweg, "Distribution Channel
    dtext LIKE tvtwt-vtext, "Dist Channel description
    spart LIKE vbak-spart, "Division
    dvtxt LIKE tspat-vtext, "Division Description
    kunnr LIKE vbak-kunnr, "Customer Number
    name1 LIKE kna1-name1, "Customer Name
    land1 LIKE kna1-land1, "Country
    regio LIKE kna1-regio, "State
    ort01 LIKE kna1-ort01, "City
    erdat LIKE vbak-erdat, "Creation Date
    vdatu LIKE vbak-vdatu, "Due date
    kwmeng LIKE vbap-kwmeng, "Material Quantity
    netpr LIKE vbap-netpr, "unit net price
    netwr LIKE vbap-netwr, "Price
    wavwr LIKE vbap-wavwr, "Cost price
    bzirk LIKE vbkd-bzirk, "Sales District
    bztxt LIKE t171t-bztxt, "Sales District Discription
    lights, "Diplaying Status
    END OF wa_srr.
    While you are building the field cat do as follows
    FORM build_layout CHANGING l_wa_layout TYPE slis_layout_alv.
    l_wa_layout-zebra = cb_zebr. "Set alterante colored line
    l_wa_layout-colwidth_optimize = cb_colop. "Optimize column width
    l_wa_layout-no_vline = cb_novli. "No vertical line
    l_wa_layout-no_colhead = cb_nocol. "no column Header
    l_wa_layout-lights_fieldname = 'LIGHTS'. "Set light field
    (assigning the field u have added in ur structure here as light field in alv report)
    ENDFORM. " BUILD_LAYOUT
    Then as per the logic, u make green, yellow or red light
    Example,
    FORM build_light .
    LOOP AT it_srr INTO wa_srr. "for all entries in the table
    IF wa_srr-gbstk = 'C'. "If status is 'completed',
    wa_srr-lights = '3'. "Show green signal light
    ELSEIF wa_srr-gbstk = 'B'. "If status is 'Partial'
    wa_srr-lights = '2'. "Show yellow signal light
    ELSE. "If status is 'incomplete'
    wa_srr-lights = '1'. "Show red signal light
    ENDIF.
    MODIFY it_srr FROM wa_srr. "Update to table
    ENDLOOP.
    ENDFORM. " build_light
    after building ur layout, Pass it to ur alv function module like this.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    i_callback_top_of_page = 'TOP_OF_PAGE'
    i_background_id = 'ALV_BACKGROUND'
    i_grid_title = text-011
    pass ur layout structure here********
    is_layout = wa_layout
    it_fieldcat = it_fcat
    it_sort = it_sort
    i_save = v_save
    is_variant = wa_variant
    is_print = wa_print
    TABLES
    t_outtab = it_srr
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE i001. "List cannot be displayed
    ENDIF.
    wat all i did to add light is,
    1) adding an extra field in the main structure.
    2)create internal table with this structure as data table for alv report
    3) add 'field name' field in layout
    4) I have passed values(3, 2, 1) for green, yellow and red light resp, to the field(LIGHTS) in the internal table that is passed to alv function module.(Based on some condition)
    5) pass the layout structure layout to alv function module
    Thats it. If u do all this teps, u r done with it.
    Lemme know u solved it by giving points.
    with regards,
    praveen.

  • Traffic light system

    When selecting a number from a drop down menu is it possible to make a colour appear depending on what number is chosen. Like a traffic light system, you choose 1 and it comes up red, you choose 3 and it comes up green?
    Thank you for taking a look
    S

    Well, you can use a slightly modified version of the script above. Something like this should do:
    var risk = Number(this.getField("Risk").value);
    if (risk>=1 && risk<=7) {
         event.value = "Low Risk";
         event.target.fillColor = color.green;    
    } else if (risk>=8 && risk<=15) {
         event.value = "Medium Risk";
         event.target.fillColor = color.yellow;
    } else if (risk>=16) {
         event.value = "High Risk";
         event.target.fillColor = color.red;    
    } else {
        event.value = "";
        event.target.fillColor = color.white;    
    This code should be used as the custom calculation script of the field where you want to display the "traffic light", and it assumes there's a field called "Risk" that contains the risk value (this field could be hidden).
    Edit: fixed code

  • IPhoto is changing the sequence of the photos I have in my file for the book I want to create. Help?

    iPhoto is changing the sequence of the photos I have in my file for the book I want to create. Help?

    The problem has been solved. As it turns out, I was highlighting the photos in the album I wished to create. And then generating the request for a book. This caused the photo images when loaded into the book format to revert to the sequence used when I originally loaded them into the album. Not the edited sequence. Turns out that I did not need to highlight the photos. By eliminating this step, they remained in the edited sequence.
    Thank you for responding. Warmly, Janice huseby

  • Want to create sequence at class level  row_number , DENSE_RANK() , rank(),

    Dear All,
    I want to create serial no at class level please check my query , i have already try , row_number , DENSE_RANK() , rank(), it shows 1
    Please guie .
    Regards
    SELECT
    distinct
    cla.R_Description,
    cla.N_Description,
    period.period_name,
    cla.BRANCH,
    cla.CLASS_NAME,
    cla.CLASS_NAME CLASS_NAME_SEQ,
    DENSE_RANK() OVER (partition by cla.R_Description order by cla.CLASS_NAME) CLASS_NAME_desk,
    RANK() OVER (partition by cla.CLASS_NAME order by cla.CLASS_NAME) CLASS_NAME_rank,
    st.ACCOUNT_NUMBER,
    st.PARTY_NAME,
    decode(ASCII(substr(site.attribute13,length(site.attribute13),length(site.attribute13)-1)),13,
    substr(site.attribute13,1,length(site.attribute13)-1),site.attribute13) FATHER,
    pay.amount_due_original,
    trx.trx_number challan_no,
    ST.SECTION,
    pay.amount_due_remaining,
    TO_NUMBER(trx.attribute3) Concession,
    ARREAR.DUE_AMOUNT
    FROM
    RA_CUSTOMER_TRX_ALL TRX,
    student_city_school_all st,
    class_v_table cla,
    bill_period period,
    ar_payment_schedules_all pay,
    HZ_CUST_SITE_USES_ALL SITE_USE,
    HZ_CUST_ACCT_SITES_ALL SITE,
    --branch_network_region_link br,
    ( SELECT BILL_TO_CUSTOMER_ID,SUM(DUE_AMOUNT) DUE_AMOUNT FROM ARREARS_STUDENT WHERE PERIOD_START_DATE < nvl(:P_START_DATE,PERIOD_START_DATE)
    --AND
    -- ORG_ID=NVL( :P_ORG_ID , ORG_ID )
    GROUP BY BILL_TO_CUSTOMER_ID
    ) ARREAR
    WHERE TRX.ATTRIBUTE_CATEGORY='Periodic Billing'
    AND trx.attribute2=cla.Fee_Structure_Id
    AND trx.bill_to_customer_id=st.CUST_ACCOUNT_ID
    AND TRX.BILL_TO_SITE_USE_ID=SITE_USE.SITE_USE_ID
    AND SITE_USE.CUST_ACCT_SITE_ID=SITE.CUST_ACCT_SITE_ID
    AND TRX.BILL_TO_CUSTOMER_ID=ARREAR.BILL_TO_CUSTOMER_ID(+)
    AND trx.org_id=nvl(:p_org_id,trx.org_id)
    AND trx.attribute1=period.period_id
    -- AND period.period_id=:P_PERIOD_ID
    AND trx.customer_trx_id=pay.customer_trx_id
    -- AND cla.branch=nvl(:P_BRANCH,cla.branch)
    -- AND CLA.CLASS_NAME=NVL(:P_CLASS,CLA.CLASS_NAME)
    -- AND cla.N_Description LIKE '%KAPCO%'
    -- and (cla.CLASS_NAME like '%kapco%' or cla.CLASS_NAME like '%kapco%' )
    --&P_WHERE
    ORDER BY CLA.CLASS_NAME, ST.SECTION,
    ST.ACCOUNT_NUMBER

    Please have the decency to format your code and put it in between delimiters.
    Also provide create table statements and some test data along with some output that your expecting to see.
    Finally you have had 18 posts and 15 are unresolved. Could you please take the time to mark those as answered
    or we will assume that it is a waste of time helping you as our answers aren't helpful to you.
    All the above is explained clearly in the FAQ
    SQL and PL/SQL FAQ
    Edited by: Paul Horth on 05-Mar-2012 23:55                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Displaying traffic lights in alv grid report?

    Hi everyone,
    I have an alv grid report.I m using the FM reuse_alv_grod_display to display my alv report.I am passing the fieldcatalogue automatically.I m getting the output perfectly.Now i have to add traffic lights to that alv report.
    Since i m passing the fieldcatalogue automatically i m confused to display the traffic lights?
    any suggestions please?
    Thank you.

    hi dp,
    look at the program i made... se the bold part you will be able to impelment lights easily,
    DECLARING TYPES POOL *
    All the definitions of internal tables, structures and constants
    are declared in a type-pool called SLIS.
    type-pools: slis.
    TABLES *
    tables: vbak,vbap,kna1.
    TYPES *
    *&--defining types for TABLE VBAK
    types: begin of t_vbak,
    vbeln type vbeln_va, "sales document
    kunnr type kunag,
    erdat type erdat,
    auart type auart,
    netwr type netwr_ak,
    waerk type waerk,
    vkorg type vkorg,
    vtweg type vtweg,
    spart type spart,
    name1 type name1_gp,
    stras type stras_gp,
    ort01 type ort01_gp,
    pstlz type pstlz,
    regio type regio,
    land1 type land1_gp,
    telf1 type telf1,
    end of t_vbak.
    *&--Defining types for TABLE VBAP
    types: begin of t_vbap,
    vbeln type vbeln_va,
    posnr type posnr_va,
    matnr type matnr,
    maktx type maktx,
    end of t_vbap.
    *&--MERGED FINAL SALES TABLE
    types: begin of t_sales_final,
    vbeln type vbeln_va,
    kunnr type kunag,
    posnr type posnr_va,
    erdat type erdat, "date of creation
    auart type auart,
    netwr type netwr_ak,
    waerk type waerk,
    vkorg type vkorg,
    vtweg type vtweg,
    spart type spart,
    name1 type name1_gp,
    v_lights type c,
    stras type stras_gp,
    ort01 type ort01_gp,
    pstlz type pstlz,
    regio type regio,
    land1 type land1_gp,
    telf1 type telf1,
    matnr type matnr,
    maktx type maktx,
    end of t_sales_final.
    defining wrokarea and IT.
    WORK AREA DECLARATION *
    *&---work area for Internal Tables
    data: wa_vbak type t_vbak.
    data: wa_vbap type t_vbap.
    data: wa_sales_final type t_sales_final.
    *&--work area for layout
    data: wa_layout type slis_layout_alv.
    INTERNAL TABLES DECLARATION *
    *&---Internal tables without Header Line.
    data : i_vbak type standard table of t_vbak,
    i_vbap type standard table of t_vbap,
    i_sales_final type standard table of t_sales_final.
    *&---Internal table for field catalog
    data : i_fieldcat type slis_t_fieldcat_alv,
    *&---Internal table for the sorting sequence.
    i_sortinfo type slis_t_sortinfo_alv,
    *&---Internal table for the event catalog.
    i_eventcat type slis_t_event,
    *&---Internal table for the top of page event
    i_listheader type slis_t_listheader.
    VARIABLE DECLARATION *
    data : v_progname like sy-repid, "Program name(system defined)
    v_gridtitle type lvc_title. "Grid Title
    INITIALIZATION EVENT *
    initialization.
    v_progname = sy-repid.
    refresh:i_vbak,
    i_vbap,
    i_sales_final,
    i_fieldcat,
    i_sortinfo,
    i_eventcat,
    i_listheader.
    clear: wa_vbak,
    wa_vbap,
    wa_sales_final,
    wa_layout.
    SELECTION SCREEN *
    SCREEN FOR ENTERING INFORMATION
    selection-screen begin of block b1 with frame title text-001.
    select-options: r_vbeln for wa_vbak-vbeln obligatory.
    select-options: r_erdat for wa_vbak-erdat obligatory.
    selection-screen end of block b1 .
    AT SELECTION SCREEN *
    at selection-screen.
    perform zf_validate_sales_doc_no.
    perform zf_validate_date.
    START OF SELECTION EVENT
    start-of-selection.
    perform zf_populate_header.
    perform zf_populate_detail.
    perform zf_append_sales_final.
    END OF SELECTION EVENT
    end-of-selection.
    *If Internal Table Is Populated Then Only Display Alv Report.
    if i_sales_final is not initial.
    Prepare fieldcatalog .
    perform zf_build_fieldcat using i_fieldcat.
    MODIFY the records IN the internal TABLE for the traffic lights.
    perform zf_modify_final.
    build event catalogue
    perform zf_eventcat using i_eventcat.
    build sorting
    perform zf_sorting using i_sortinfo.
    &---Build Listheader for TOP OF PAGE EVENT.
    perform zf_build_listheader using i_listheader.
    &---Build layout.
    perform zf_layout.
    &---Initializating Grid Title
    perform zf_build_grid_title.
    &---Display alv grid.
    perform zf_display_alv_grid.
    else.
    *If Table is not Populated ie Records Does not exist
    message 'Record Does Not Exist' type 'S'.
    endif.
    *& Form zf_validate_sales_doc_no
    text
    --> p1 text
    <-- p2 text
    form zf_validate_sales_doc_no .
    select single vbeln into wa_vbak-vbeln from vbak where vbeln in r_vbeln .
    if sy-subrc <> 0.
    message i101.
    endif.
    endform. " zf_validate_sales_doc_no
    *& Form zf_validate_date
    text
    --> p1 text
    <-- p2 text
    form zf_validate_date .
    if date is future
    if r_erdat-low >= sy-datum.
    message e102.
    elseif r_erdat-high >= sy-datum.
    message e103.
    endif.
    endform. " zf_validate_date
    *& Form zf_populate_header
    text
    --> p1 text
    <-- p2 text
    form zf_populate_header .
    select vbeln
    kunnr
    erdat
    auart
    netwr
    waerk
    vkorg
    vtweg
    spart
    into table i_vbak from vbak where vbeln in r_vbeln.
    if sy-subrc <> 0.
    message 'RECORD DOES NOT EXIST' type 'E'.
    endif.
    sort i_vbak by vbeln.
    *&--LOGIC TO GET FIELDS FROM TABLE KNA1 INTO INTERNAL TABLE I_VBAK
    loop at i_vbak into wa_vbak.
    select single name1 stras ort01 pstlz regio land1 telf1 into (wa_vbak-name1,
    wa_vbak-stras,
    wa_vbak-ort01,
    wa_vbak-pstlz,
    wa_vbak-regio,
    wa_vbak-land1,
    wa_vbak-telf1)
    from kna1
    where kunnr = wa_vbak-kunnr.
    modifying it_header.
    modify i_vbak from wa_vbak.
    clear wa_vbak.
    endloop.
    endform. " zf_populate_header
    *& Form zf_populate_detail
    text
    --> p1 text
    <-- p2 text
    form zf_populate_detail .
    if i_vbak[] is not initial.
    select vbeln
    posnr
    matnr
    into table i_vbap from vbap
    for all entries in i_vbak where vbeln = i_vbak-vbeln.
    endif.
    sort i_vbap by vbeln.
    sort i_vbap by posnr.
    *&--LOGIC TO GET FIELDS FROM TABLE MAKT INTO INTERNAL TABLE I_VBAP
    loop at i_vbap into wa_vbap.
    select single maktx into (wa_vbap-maktx)
    from makt where matnr = wa_vbap-matnr and spras = sy-langu.
    modifying it_header.
    modify i_vbap from wa_vbap.
    clear wa_vbap.
    endloop.
    endform. " zf_populate_detail
    *& Form zf_append_sales_final
    text
    --> p1 text
    <-- p2 text
    form zf_append_sales_final .
    sort i_vbak by vbeln.
    sort i_vbap by vbeln posnr.
    loop at i_vbak into wa_vbak.
    move-corresponding wa_vbak to wa_sales_final.
    read table i_vbap with key vbeln = wa_vbak-vbeln
    binary search transporting no fields.
    loop at i_vbap into wa_vbap from sy-tabix.
    if wa_vbap-vbeln <> wa_vbak-vbeln.
    exit.
    endif.
    move-corresponding wa_vbap to wa_sales_final.
    append wa_sales_final to i_sales_final.
    endloop.
    endloop.
    endform. " zf_append_sales_final
    *& Form zf_build_fieldcat
    text
    -->P_I_FIELDCAT text
    form zf_build_fieldcat using p_i_fieldcat type slis_t_fieldcat_alv.
    data: l_fieldcat type slis_fieldcat_alv. "local Workarea used
    clear l_fieldcat.
    FOR LIGHT IN COLUMN
    clear l_fieldcat.
    l_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.
    l_fieldcat-fieldname = 'V_LIGHTS'.
    " FIELD FOR WHICH CATALOG ID FILLED.
    *We are passing final internal table 'I_FINAL' to l_fieldcat(local
    *variable
    l_fieldcat-tabname = 'I_SALES_FINAL'.
    " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
    l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
    l_fieldcat-outputlen = 20.
    " TO DEFINE OUTPUT LENGTH OF THE COLUMN.
    append l_fieldcat to p_i_fieldcat.
    FIRST COLUMN ********************************
    l_fieldcat-col_pos = '2'. " POSITION OF THE COLUMN
    l_fieldcat-fieldname = 'VBELN'. " FIELD FOR WHICH CATALOG ID FILLED
    l_fieldcat-tabname = 'I_SALES_FINAL'. " INTERNAL TABLE BELONGS TO
    l_fieldcat-key = 'X'. " SO THAT this field is not scrollable hiddable.
    l_fieldcat-just = 'L'. " FOR JUSTIFICATION
    *l_fieldcat-hotspot = 'X'. " MARK THIS field as hotsopt
    l_fieldcat-lzero = 'X'. " OUTPUT WITH leading zeros.
    l_fieldcat-seltext_l = 'Sales Document'. " long text for header.
    l_fieldcat-seltext_m = 'Sales Doc'. " medium text for header.
    l_fieldcat-seltext_s = 'Sales Doc'. " sort text for header.
    l_fieldcat-outputlen = 20. " SET THE output length.
    l_fieldcat-ref_tabname = 'VBAK'. " FOR F1 & F4 help as
    append l_fieldcat to p_i_fieldcat.
    clear l_fieldcat.
    **************************SECOND COLUMN ********************************
    *l_fieldcat-col_pos = '3'. " POSITION OF THE COLUMN
    l_fieldcat-row_pos = '2'. " POSITION OF THE COLUMN
    l_fieldcat-fieldname = 'POSNR'. " FIELD FOR WHICH CATALOG ID FILLED
    l_fieldcat-tabname = 'I_SALES_FINAL'. " INTERNAL TABLE BELONGS TO
    l_fieldcat-key = 'X'. " SO THAT this field is not scrollable hiddable.
    l_fieldcat-just = 'L'. " FOR JUSTIFICATION
    l_fieldcat-hotspot = 'X'. " MARK THIS field as hotsopt
    l_fieldcat-lzero = 'x'. " OUTPUT WITH leading zeros.
    l_fieldcat-seltext_l = 'Sales Document Item'. " long text for header.
    l_fieldcat-seltext_m = 'Sales Document Item'. " medium text for header.
    l_fieldcat-seltext_s = 'Sales Document Item'. " sort text for header.
    l_fieldcat-outputlen = 20. " SET THE output length.
    l_fieldcat-ref_tabname = 'VBAP'. " FOR F1 & F4 help as
    append l_fieldcat to p_i_fieldcat.
    clear l_fieldcat.
    endform. " zf_build_fieldcat
    *& Form zf_eventcat
    text
    -->P_I_EVENTCAT text
    form zf_eventcat using p_i_eventcat type slis_t_event.
    data: l_eventcat type slis_alv_event.
    clear l_eventcat.
    call function 'REUSE_ALV_EVENTS_GET'
    exporting
    i_list_type = 0
    importing
    et_events = p_i_eventcat
    exceptions
    list_type_wrong = 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.
    TOP OF PAGE FORM
    clear l_eventcat.
    read table p_i_eventcat into l_eventcat with key
    name = slis_ev_top_of_page.
    "(COMPONENT "NAME"of structure)
    if sy-subrc = 0. "if success
    move 'ZF_TOP_OF_PAGE' to l_eventcat-form.
    "matches name and moves form to workarea and modifies table
    modify p_i_eventcat from l_eventcat index sy-tabix
    transporting form.
    endif.
    PF_STATUS_SET FORM
    clear l_eventcat.
    read table p_i_eventcat into l_eventcat with key
    name = slis_ev_pf_status_set.
    if sy-subrc = 0.
    move 'ZF_PF_STATUS_SET' to l_eventcat-form.
    modify p_i_eventcat from l_eventcat index sy-tabix
    transporting form.
    endif.
    USER_COMMAND FORM
    clear l_eventcat.
    read table p_i_eventcat into l_eventcat with key
    name = slis_ev_user_command.
    if sy-subrc = 0.
    move 'ZF_USER_COMMAND' to l_eventcat-form.
    modify p_i_eventcat from l_eventcat index sy-tabix
    transporting form.
    endif.
    endform. " zf_eventcat
    *& Form zf_sorting
    text
    -->P_I_SORTINFO text
    form zf_sorting using p_i_sortinfo.
    endform. " zf_sorting
    *& Form zf_build_listheader
    text
    -->P_I_LISTHEADER text
    form zf_build_listheader using p_i_listheader type slis_t_listheader.
    data: l_listheader type slis_listheader.
    refresh p_i_listheader.
    clear l_listheader.
    HEADER
    l_listheader-typ = 'H'.
    l_listheader-info = 'FUJITSU CONSULTING INDIA LTD.'.
    append l_listheader to p_i_listheader.
    SELECTION
    l_listheader-typ = 'S'.
    l_listheader-key = 'Date:'.
    l_listheader-info = sy-datum.
    append l_listheader to p_i_listheader.
    ACTION
    l_listheader-typ = 'A'.
    *l_listheader-key =
    l_listheader-info = 'SALES ORDER ALV REPORT By Rohan Malik'.
    append l_listheader to p_i_listheader.
    endform. " zf_build_listheader
    *& Form zf_build_grid_title
    text
    --> p1 text
    <-- p2 text
    form zf_build_grid_title .
    v_gridtitle = 'List of Purchase Order'.
    endform. " zf_build_grid_title
    *& Form zf_display_alv_grid
    text
    --> p1 text
    <-- p2 text
    form zf_display_alv_grid .
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    i_callback_program = v_progname
    i_grid_title = v_gridtitle
    is_layout = wa_layout
    it_fieldcat = i_fieldcat
    it_sort = i_sortinfo
    it_events = i_eventcat
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    tables
    t_outtab = i_sales_final
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform. " zf_display_alv_grid
    *& Form zf_top_of_page
    text
    --> p1 text
    <-- p2 text
    form zf_top_of_page .
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = i_listheader
    i_logo = 'ENJOYSAP_LOGO'
    I_END_OF_LIST_GRID =
    endform. " zf_top_of_page
    *& Form zf_user_command
    text
    --> p1 text
    <-- p2 text
    form zf_user_command using r_ucomm like sy-ucomm
    rs_selfield type slis_selfield .
    case r_ucomm. "FCODE
    when 'VA03'.
    read table i_sales_final into wa_sales_final index rs_selfield-tabindex.
    set parameter id 'AUN' field rs_selfield-value.
    call transaction 'VA03' and skip first screen .
    message i102 with rs_selfield-value .
    when '&IC1'. "for hotspot with VBELN, POSNR, MATNR, KUNNR.
    if rs_selfield-fieldname = 'MATNR'.
    set parameter id 'MAT' field rs_selfield-value.
    call transaction 'MM03' and skip first screen.
    return.
    message i103 with rs_selfield-value .
    endif.
    if rs_selfield-fieldname = 'VBELN'.
    set parameter id 'AUN' field rs_selfield-value.
    call transaction 'VA03' and skip first screen.
    return.
    message i104 with rs_selfield-value .
    endif.
    endcase.
    endform. " zf_user_command
    *& Form ZF_PF_STATUS_SET
    text
    --> p1 text
    <-- p2 text
    form zf_pf_status_set using rt_extab type slis_t_extab.
    set pf-status 'Z11_RM_ALV_SO'.
    endform. " ZF_PF_STATUS_SET
    *& Form zf_layout
    text
    --> p1 text
    <-- p2 text
    form zf_layout .
    wa_layout-zebra = 'X'.
    wa_layout-lights_fieldname = 'V_LIGHTS'.
    wa_layout-lights_tabname = 'I_SALES_FINAL'.
    " 1, 2 or 3 for red, yellow and green respectively.
    endform. " zf_layout
    *& Form zf_modify_final
    text
    --> p1 text
    <-- p2 text
    form zf_modify_final .
    CODE TO EXECUTE LIGHTS
    *start of loop
    loop at i_sales_final into wa_sales_final.
    *giving conditions and modifying as we want to change many rows
    if wa_sales_final-netwr <= 10000.
    wa_sales_final-v_lights = '1'.
    modify i_sales_final from wa_sales_final transporting v_lights.
    elseif wa_sales_final-netwr > 10000 and wa_sales_final-netwr <= 100000.
    wa_sales_final-v_lights = '2'. " Exception.
    modify i_sales_final from wa_sales_final transporting v_lights.
    else.
    wa_sales_final-v_lights = '3'. " Exception.
    modify i_sales_final from wa_sales_final transporting v_lights.
    endif.
    endloop.
    reward point s if helpful
    rohan malik

  • How to insert Traffic light icon in Table UI column

    Hi Expert,
    I am not able to put traffic light icon to table UI's column.
    Can any one help me.
    Thanks and Regards,
    Anil

    Hi,
    For that column of the TABLE, while create BInding option, give the UI element as Image type.
    In the Layout tab of the view, for that column, cell editor give the Image source as the
    ICON......
    Clarify this -
    Do you want to show this icon on any condition basis or ?
    Out of 6 oclumns for which column you want the traffic light icon...
    Hope you got this.
    Regards,
    Lekha.

  • Traffic Light in MD07 MD06 ...

    Hello Gurus,
    I have quick question. When i run the Md07 as collective access my traffic light shows up on the extreme right hand, but i want to show up in the extreme left hand. I have looked around but couldn't find the setting.
    I know i can just drag and drop in left hand side but i have to do it every time i access collective.
    please help !!!
    Thanks!
    Khan

    Khan,
    This uses the standard table view controls.  You can create your own configuration for any of these table displays that have the Configuration button in the top right corner of the table (the icon is a tiny spreadsheet with a blue stripe across the top).
    First, drag all the columns so as to appear the way you want.  Then, click on the table configuration Icon.  In the Maintain Variant block create a name for your customized table display.  Optionally check Use as standard setting.   Clik on Create.  The name you have chosen should  be copied to the top.  Now, Save.
    http://help.sap.com/erp2005_ehp_04/helpdata/EN/7d/f63a19015111d396480000e82de14a/frameset.htm
    http://help.sap.com/erp2005_ehp_04/helpdata/EN/42/c1361415311d64e10000000a1553f6/frameset.htm
    Rgds,
    DB49
    Edited by: Dogboy49 on Jan 18, 2010 12:18 PM

  • CLD Traffic light

    Hi all,
    I have a timing question on the sample CLD traffic light exam (see attachment).  I am seeing a possible discrepency between the spec and the solution. 
    On the spec, it says that the duration for each type of light is as follow:
    Red: 4sec
    Yellow: 2sec
    Green: 4sec
    However, if you look at the sample solution provided, you will see that the red light will light for 6 second.  Doesn't that exceed the spec?  Anybody has a better (more accurate) solution than provided?
    Thanks!
    Yik
    Kudos and Accepted as Solution are welcome!
    Attachments:
    2419.zip ‏426 KB

    Hello Yik,
    If you look at the specification, the sequence is listed as Green, Yellow, Red, Red.  This second Red is necessary to prevent all lanes of traffic from proceeding at once.
    If you only keep the Red light on for 4 seconds, the East and West bound traffic will recieve a Green light while the North and South bound lights have just changed from Green to Yellow, resulting a traffic light which does not operate correctly.
    The "8" seconds of Red light on will also create a time period where all lights are Red, allowing any slow cars to exit the intersection.

  • Display Exception as Traffic Lights

    Dear All,
    is there any possibility to display exceptions per default as traffic lights in a BI 7.0 Web Application? We want to use the same functionality a local status exception is offering. Setting EXCEPTION_RENDERING to Symbol offers the arrow as symbol.  Also the command set_exception in the is using the trend exception symbol as default.
    Thanks for any input
    jens

    Hi ,
    You can display the traffic light symbols for exceptions in BI 7.0.
    You need to create a Status Exception at WAD level by using List of Exceptions Web Item.
    Then you save the executed result as Queryview.
    Use this Queryview as the DataProvider for the Analysis Web Item.
    Hope this helps.

Maybe you are looking for