Disabling all fields in VA02 on a particular Order status

Hi Gurus,
We have a requirement to grey out all the fields of the sales order in VA02 if the current order header status is
set to a particular value , lets say '10' (E0010).
I have tried below code in MV45AFZZ  (userexit_field_modification) :
IF sy-tcode = 'VA02' AND vbak-auart = 'ZTIL'.
    CALL FUNCTION 'STATUS_READ'
      EXPORTING
        client           = sy-mandt
        objnr            = vbak-objnr
        only_active      = 'X'
      TABLES
        status           = lt_stat
      EXCEPTIONS
        object_not_found = 1
        OTHERS           = 2.
    DELETE lt_stat WHERE stat CP 'I*'.
    READ TABLE lt_stat INTO lw_stat WITH KEY stat = 'E0010'.
    IF sy-subrc EQ 0.
      LOOP AT SCREEN.
        screen-input = 0.
        MODIFY SCREEN.
      ENDLOOP.
    ENDIF.
ENDIF.
But, the issue is here the program goes for a long endless loop
and eventually we have to stop the transaction.
(since we did not want to choose any particular field, but grey out entire order)
Could anyone of you please suggest what needs to be done here.
Thanks in advance.
Regards,
Nitin

Hi Nitin,
You didn't mention that you want that two fields to be open.
What you have done is correct in the form routine but you should not use Loop at screen. Because the Form routine is itself called for each field.
The following code logic change inside the userexit_field_modification will solve your problem.
Write like;
IF sy-tcode = 'VA02' AND vbak-auart = 'ZTIL'.
CALL FUNCTION 'STATUS_READ'
EXPORTING
client = sy-mandt
objnr = vbak-objnr
only_active = 'X'
TABLES
status = lt_stat
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
DELETE lt_stat WHERE stat CP 'I*'.
READ TABLE lt_stat INTO lw_stat WITH KEY stat = 'E0010'.
IF sy-subrc EQ 0.
IF SCREEN-NAME NE 'FIELDNAME1' AND SCREEN-NAME NE 'FIELDNAME2'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDIF.
There is no need for trasaction variant and all if this works.
Regards,
Karthik D
Edited by: Karthik D on Feb 3, 2011 4:05 PM - Corrected code

Similar Messages

  • Disabling the field 'Bill-to party' in sales order screen

    Hi friends,
    I need to disable following fields in the partner functions tab of sales order ,while creating/changing a sales order,since they will be automatically populated and user should not be able to modify.
    1.Bill-to party.
    2.Payer.
    I have tried with user exit MV45AFZZ,but program control is not coming there regarding PARTNERS tab,for diabling the screen.
    Can you give me some hints like,any other EXIT or BADI exists for writing the code for this?
    Thanks & Regards
    Seshagiri.

    Hi,
    Your requirement is to identify the bill to based on ship to. if so do the following.
    maintain the partner tab in ship to master record, here you assign the bill to party to whom you have to send the bill.
    Now in partner determination procedure maintain the bill to source as ship to. In partner determination procedure you have all the options from where system has to look for the other partner functions.
    In this processes system first checks with Sold to, finds out a ship to, now from ship to partner tab it automatically finds out the bill to in to the sales order.
    Hope you understood, if not let me know.
    Reward if it helps you.
    Venkat Cheedalla

  • How to disable all fields of a page on button click

    Hello, I am using JDeveloper 11.1.2.3.0
    I have a page with several fields on it. I want to have all the page fields disabled when I click a certain Button. How can I achieve this?
    If what I am asking is too difficult to achieve can you help me with an idea on how to achieve something similar?
    Thank you

    This can be achieved by using JavaScript Client API get the id's all the fields while clicking the button  and disable your Components,
    Calling Backing bean method or binded component involves server side round-trip, you can easily achieve this using simple java script in
    Client Side..
    Call this method in your Client Listener ..
    function disableFields(actionEvent) {
            var field1= AdfPage.PAGE.findComponent("field1id");
            var field2 = AdfPage.PAGE.findComponent("field2id");
            field1.setDisabled(true);
            fileld2.setDisabled(true);

  • PURCHASE ORDER STATUS :When Deleting ALL ITEMS.

    Hi experts,
    I need  to make purchase order status stay  " Release Compleated " when deleting all items.
    Anyone Know How to do it?
    Or anyone Know how to use BAPI_PO_CHANGE in BAdI : ME_PROCESS_PO_CUST 
    In my project , I use Release Strategy of purchase orders, and there is a case of deleting all items.
    In this situation, purchase order status returns to "Active " and release strategy tab disappears.
    This is our problem.
    I need to make purchase order status stay  " Release Compleated " and prevent  release strategy tab disappearing.
    I tried to update the fields EREKZ(final invoice) and ELIKZ(delivery completed) in
    BAdI : ME_PROCESS_PO_CUST  Method : PROCESS_ITEM using BAPI_PO_CHANGE according to SAP Note 456691.
    But BAPI_PO_CHANGE couldn't update EREKZ because of our customize , and I couldn't find how to use
    BAPI_PO_CHANGE in the BAdI.
    Anyone know solutions to solve this problem?
    Thanks a lot.
    Regards,
    TKD

    Hi,
    please review the following information in SAP Note No. 456691 as
    copied below:
    18. Question:
    When are the header conditions updated if a purchase order item is
    deleted?
    Answer:
    If a purchase order item is deleted, the item is marked as 'statistical'
    (field EKPO-STAPO = X) and the change is reflected in the header
    conditions.
    However, if for the item the final invoice indicator(EKPO-EREKZ) or the
    inward delivery completed indicator (EKPO-ELIKZ) is set, the item is not
    marked as 'statistical' (EKPO-STAPO is not set) and thus the header
    conditions are not updated.
    I hope this helps you
    BR
    Nadia Orlandi

  • In the component overview screen of CO01 I want  to disable all  the field in  screen of table control.I want to make it as output screen only.

    Hi all
      In the component overview screen of CO01 I want  to disable all  the field in  screen of table control.I want to make it as output screen only.
    Thanks & Regards,
    Rajib.

    Isn't that just exactly what transaction CO02 does? CO01 is for creating production orders so what sense does it make to have it display mode only?
    Maybe your goal is to stop then end user changing the component assignment that is automatically  detected by the system. If so, personally I think a better starting point would be PP configuration or user authorizations rather than looking to change the screen by whatever method. As we don't know what you are trying to achieve it's hard to offer much more advice maybe all you need is to change transaction to CO02

  • All fields should be in Display mode except Plant field in Va02 and VA32

    Respected Guru's,
    I want all the fields in VA02 and VA32( Change t-codes)  to be in display mode, further user should be able to change the Plant value alone in sales tab.
    Is it possible to restrict it with the help of Authorization or does it requires customization.
    Please Help me in this regard.
    Thank tou,
    Daya

    Thanks for your information
    What is the transaction code for that
    ME29N - DISPLAY SCREEN SETTING ALREADY I HAVE DONE
    account assignment category is working only at item overview level, input - k iS IN DISPLAY MODE
    NOT account assignment tab fields
    please give the transaction code information so that it will be helpful for me

  • How to make a page READ ONLY / all fields are DISABLED ?

    Hi all,
    I am using ONE page to do ADD/EDIT/DISPLAY data. When users are in DISPLAY mode, I want all fields on the page to be read only / disabled.
    How is the best approach to do that ?
    (other than going to every fields and set the ReadOnly/Disabled property)
    Thank you for your help,
    xtanto

    Hi Xtanto,
    My business logic is somewhat different - I don't do this for new/editted rows, but based upon other security. You could certainly set something in your backing bean based upon a user clicking "new" or "edit"
    John

  • Disabling certain fields on the selection screen.

    Hi all,
              I want to disable certain fields on selection screen of my program, also i want to display certain fields on selection screen only if a particular field on the selection screen is checked or selected. Please guide me how this can be achieved via coding in a program.
    Thanks & regards,
    Chetan.

    Hi Chetan,
    try this.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: pa_file TYPE rlgrap-filename MODIF ID abc,
    pa_lifnr TYPE lfa1-lifnr MODIF ID abc,
    pa_vkorg TYPE vbak-vkorg MODIF ID abc.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    PARAMETERS: pa_kunnr TYPE vbak-kunnr MODIF ID def.
    SELECT-OPTIONS: s_lifnr FOR gs_lfa1-lifnr MODIF ID def,
    s_date FOR gs_lfa1-erdat MODIF ID def,
    s_augru FOR gs_vbak-augru MODIF ID def,
    s_vbeln FOR gs_vbak-vbeln MODIF ID def.
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: pa_upd RADIOBUTTON GROUP g1 USER-COMMAND uc01 DEFAULT 'X'."#EC *
    SELECTION-SCREEN COMMENT 3(60) text-004 FOR FIELD pa_upd.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: pa_rep RADIOBUTTON GROUP g1 ."#EC *
    SELECTION-SCREEN COMMENT 3(60) text-005 FOR FIELD pa_rep.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK b3.
    IF pa_rep EQ gc_x.
    LOOP AT SCREEN.
    IF screen-group1 = gc_abc.
    screen-input = gc_zero_num.
    ELSEIF screen-group1 = gc_def.
    screen-active = gc_one_num.
    ENDIF.
    MODIFY SCREEN.
    ENDLOOP.
    ELSEIF pa_upd EQ gc_x.
    *For Reprocessing
    LOOP AT SCREEN.
    IF screen-group1 = gc_def.
    screen-input = gc_zero_num.
    ELSEIF screen-group1 = gc_abc.
    screen-active = gc_one_num.
    ENDIF.
    MODIFY SCREEN.
    CLEAR pa_upd.
    ENDLOOP.
    ENDIF.
    REPORT zrich_001.
    PARAMETERS: p_rad1 RADIOBUTTON GROUP grp1 DEFAULT 'X'
    user-command chk,
    p_rad2 RADIOBUTTON GROUP grp1.
    SELECT-OPTIONS: s_datum1 FOR sy-datum MODIF ID d1,
    s_datum2 FOR sy-datum MODIF ID d2.
    AT SELECTION-SCREEN OUTPUT.
    LOOP AT SCREEN.
    IF p_rad1 = 'X'
    AND screen-group1 = 'D2'.
    screen-active = '0'.
    ENDIF.
    IF p_rad2 = 'X'
    AND screen-group1 = 'D1'.
    screen-active = '0'.
    ENDIF.
    MODIFY SCREEN.
    ENDLOOP.
    reward if useful.
    regards,
    sravanthi.

  • How to disable individual field of a search view

    Hi All,
    Is there a way to disable individual search field of an advance search view ?
    The reason for this is that for a particular search field I am defaulting the value and do not want the user to be able to change this default value, in effect filtering out their search.
    I have tried get_i method but the advance search (thtmlb:advancedSearch) does not seem to trigger the get i method, disabled just disable every fields likewise the global edit/viewgroup context.
    Thanks in advance for your assistance.
    Edited by: ANDREW NGUYEN on May 12, 2010 10:45 AM

    Hi,
    I checked it now and found that the GET_I_FIELD is not getting triggered. Sorry for my wrong solution.
    You can use the rt_result parameter in GET_POSSIBLE_FIELDS method in IMPL class.
    It returns the search fields visible in the view.
    Regards,
    Arun Kumar
    Edited by: Arun Kumar on May 12, 2010 11:35 AM
    Edited by: Arun Kumar on May 12, 2010 11:38 AM

  • Customizing Calendar to disable all dates After Sysdate (Current Date)

    Hi All,
    I have a Requirement In OAF to Disable All Dates in the Calendar After the Sysdate
    Ex: In Air Ticket Booking We can't Enter  Previous Dates in the Calendar Like that I need to make the
    my calendar dates after Sysdate Non Entarable
    Please let me know if you have any sample code or We can fire any action before selecting a date to disable a particular set of Dates
    Thanks,
    Krishna

    Hi ,
    As per my opinion ,u shud put a check in PFR method at select event fire of date field ,capture the selected date anc check it shud be <= sysdate else throw a message using
    throw new OAException ("this date should not exceed current date", OAException.ERROR);
    Thanks
    Pratap

  • How to disable a field on the basis radio button value selected.

    hello to all,
    i am facing one problem.I have declared two selection screen blocks.
    In one i hvae declared two radio button r1 -Fiscal year and r2--Datewise.
    And in another selection screen block all i/p fields. like plant. date.year etc.
    Now if user select r1-Fiscal year  then i/p field - date of second block should be disable.
    And if user select r2-Datewise  then i/p field - year of second block should be disable.
    SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME
              TITLE TEXT-002.
           PARAMETERS: R1 RADIOBUTTON GROUP RA1 user-command ucomm,
                       R2 RADIOBUTTON GROUP RA1 DEFAULT 'X'.
       SELECTION-SCREEN END OF BLOCK  BLK.
    selection-screen begin of block b1 with
      frame title text-001.
    parameters : gjahr like ZSA_DETAIL-gjahr  MODIF ID YAR,
                 aedat like ZSA_DETAIL-aedat  MODIF ID DAT,
                 werks like ZSA_DETAIL-werks .
    selection-screen end of block b1.
    AT SELECTION-SCREEN on RADIOBUTTON GROUP RA1.
       BREAK-POINT.
        IF R1 = 'X'. "fiscal
         LOOP AT SCREEN.
            IF screen-group1 = 'DAT'.
             screen-active = 0.
             screen-invisible = 1.
             MODIFY SCREEN.
             ENDIF.
            endloop.
       ELSEIF R2 = 'X'.
         LOOP AT SCREEN.
         IF screen-group1 = 'YAR'.
           screen-active = 0.
          MODIFY SCREEN.
         ENDIF.
         ENDLOOP.
        ENDIF.

    Hi Shikha,
    Regarding your query, when you select a particular radio-button then the fields pertaining to that radio-button should get activated or get displayed, otherwise it should be hidden.
    This can be done adding the addition to the Radiobutton 'USER-COMMAND' this will automatically enable-up
    the functionality of the fields related to that radiobutton, while disabling the others.
    If USER-COMMAND isn't given, then ENTER key serves the purpose.
    DATA:
    w_carrid LIKE sflight-carrid,
    w_connid LIKE sflight-connid.
    PARAMETERS:
    p_carrid RADIOBUTTON GROUP airl USER-COMMAND airline,
    p_connid RADIOBUTTON GROUP airl.
    SELECT-OPTIONS:
    s_carrid FOR w_carrid,
    s_connid FOR w_connid.
    INITIALIZATION.
    p_carrid = 'X'.
    Now enabling desired fields and disabling the others, can be done by the following snippet.
    AT SELECTION-SCREEN OUTPUT.
    LOOP AT SCREEN.
    IF p_carrid EQ 'X'.
    IF screen-name CS 'S_CONNID'.
    screen-active = 0. " Disable the field S_CONNID
    MODIFY SCREEN.
    ELSEIF screen-name CS 'S_CARRID'.
    screen-active = 1. " Enable the field S_CARRID
    MODIFY SCREEN.
    ENDIF.
    ELSEIF p_connid EQ 'X'.
    IF screen-name CS 'S_CARRID'.
    screen-active = 0.
    MODIFY SCREEN.
    ELSEIF screen-name CS 'S_CONNID'.
    screen-active = 1.
    MODIFY SCREEN.
    ENDIF.
    ENDIF.
    ENDLOOP.
    Hope, this would help you solve your problem.
    Thankyou,
    Zahack.

  • All fields are not displayed in SM30

    Dear All,
    I have created one Z-Table with 5 fields. For that Z-Table I have maintained table maintenance generator. Now in SM30 I am able to see only 3 fields, I have checked all the options but I am not able to find out what is the problem that 2 fields are not getting displayed.
    Please tell me what might be the issue?
    warm regards,
    nishu

    HI,
    While generating the TM there is oneoption which can disable some fields in sm30.
    I think they may be the reason in your case.
    regards,

  • How do I disable all non-essential components in the CS6 installer

    A new question in the spirit of http://forums.adobe.com/thread/548877 and http://forums.adobe.com/message/2778575, where I asked this question for CS4 and CS5 and eventually discovered how to do this (at least for CS4; CS5 was a mess...): How do I disable all the non-essential components in the Photoshop CS6 installer?
    I already found the payloads/Media_db.db sqlite 3 database and wiped the DependencyData table. This goes a long way - unlike CS5, which was a maze of hidden xml configs and sqlite databases, for CS6 just wiping this single table will give the user full control over what the installer will put in the computer. With the dependencies wiped, we can now see all the stuff it's actually going to install:
    Bridge (normal and x64) - 187 and 262 MB
    CMaps (normal and x64) - 7.2 and 7.2 MB
    CSXS Extensions - 1.3MB
    CSXS Infrastructure - 6.8MB
    Color - photoshop, EU, JA, NA - 1.5, 2.1, 3.0, 2.5MB
    Video profiles - 4.7KB
    Dynamic Link Media Server - 96MB
    DynamicLink Support - 6.1MB
    ExtendScript Toolkit - 19MB
    Extension Manageer - 16MB
    Fonts recommended (normal and x64) - 110 and 110MB (why are there x86 and x64 versions? more of an open question than one that really needs an answer, but this is not how fonts work. There are no separate x86 and x64 flavoured OpenType fonts)
    Fonts required (normal and x64) - 123 and 123MB
    Hunspell Linguistics Plugin (normal and x64) - 181 and 181MB
    Linguistics (normal and x64) - 46 and 46MB
    Mini Bridge (normal and x64) - 4.0MB
    PDF Library Files (normal and x64) - 75 and 75MB
    Photoshop (normal and x64) - 486 and 563MB
    Photoshop Support - 9.4MB
    Player for Embedding 3.3 (normal and x64) - 21 and 26MB
    Switchboard 2.0 - 1.1MB
    Type Support (normal and x64) - 6 and 6MB
    Winsoft Linguistics Plugin (normal and x64) - 8.2 and 8.5MB
    XMP Panels - 4.9MB
    ColorCommonSetCMYK - 13MB
    ColorCommonSetRGB - 8.6KB
    Camera Profiles Installer - 285MB
    MSVC++2005 redist. (normal and x64) - 11 and 11MB
    MSVC++2008 redist. (normal and x64) - 11 and 11MB
    MSVC++2010 redist. (normal and x64) - 11 and 11MB
    MSVC80_CRT (normal and x64) - 0.0 and 0.0KB
    PDF Settings - 2.4MB
    Camera Raw 7  (normal and x64) - 22 and 24MB
    Suite Shared Configuration - 3.2MB
    Some of these things we really want installed (Photoshop, CMaps, XMP panels, Type Support and required fonts and color profiles are pretty much the minimal set required for a functional Photoshop installation), but some of these things really have no right to be silentedly installed. There's a good gigabyte of nonsense that someone who just wants Photoshop has no need for. Denying them the option to unselect these things during installation is a bit evil (whatever happened to the 'advanced' or 'custom' installation option? That was a good option).
    That said, there's still something funky going on - unselecting all components indicates that the installation will required 0.0KB on disk. However, selecting Photoshop CS6 x64, which indicates its size is 563MB, results in an installation that requires 677MB on disk. Similar things happen for other components; CMaps is 7.2MB, but when you select it, it suddenly requires 121MB on disk.
    Much last last time, I fully appreciate the install team's choices in making sure the installer will always work as long as people don't tamper with it, but I'm not one of those people - I do tamper with it, because I want to control exactly what lands on my disk. So: how do I find out what these secret things are that are not listed after wiping the dependency data so that I can explicitly pick individual components? Which additional steps are required to reveal the hidden dependencies that will apparently still be installed, or aren't factored into the size indication for the various components? And finally, how do I make the installer NOT determine that "this is not a genuine installer, you may have a counterfeit product" =)
    I know it's been altered; I modified it, because I think your install process is trying to force stuff onto my computer that I never asked for, nor will ever use (I know they're quality products, they just have no right to exist on my computers. If I had the choice to say no, I'd acknowledge them as quality products instead).
    - Mike Kamermans
    nihongoresources.com
    NB: if Eric Wilde ends up replying to this post: I still remember your willingness to help figure this out for CS5, two years ago. Thank you again for that.

    I can see why you wouldn't want to release information that lets people set up arbitrary installers, but that's why I mostly wanted those two specific hashes. The installer team can just generate them without ever saying how, and we will only be able to use them to validate the installer for the modification that lets you pick components. This should in no way interfere with the desire to prevent dangerous installers making it into the wild; in fact, it kind of guarantees that's impossible.
    I know you can't guarantee it'll work or test it, and that's fine. Past experience has shown that CS3, CS4 and CS5 work fine with updates (and most updates don't apply to Photoshop, they apply to the additional components that I traditionally don't install), so I'm pretty sure it'll work fine with CS6 too, although of course it could go wrong in which case I can always fall back to a normal install.
    Would you be willing to ask the install team whether they could generate just these two numbers, based on the single SQL command run on Media_db.db from the main payload directory? I can fully understand not wanting to give the "here is how you generate the hashes" information, but generating two specific numbers that don't work for anything but this specific query should be just as safe as the various hashes we can already see for the other Media_db.db files in the various payload directories (so they wouldn't reveal anything not already known about how to reverse engineer the hashing algorithm). It'd help tech-savvy customers quite a bit without playing into the hands of criminally minded jerks (I actually had the pleasure of running into a duped CS3 Extended disc several years ago! I had ordered CS3 for personal use, and mysteriously received a CS3 extended version with a volume licensing key in what looked like an official normal CS3 box. Needless to say, authorities and Adobe were notified).
    <<I think the right answer to this issue is to simply remove from the products those items that are not required to execute the product. That's actually something we're aggressively pursuing this summer so that the product size reduces in future releases, particularly for PS.>>
    It's not possible to take components out of the payloads directory without the installer complaining that errors have occurred. It really wants all those files there when it starts =(
    <<Have you investigated using AAMEE? I don't think that will get rid of all the "extraneous" pieces; but, it does provide some flexibility in creating an install package that can then be pushed out through normal deployment tools (e.g. SCCM).>>
    I did, but unfortunately AAMEE requires the use of a volume license key, which I don't have. We only have individual products keys for the machines that will get Photoshop CS6.
    - Mike

  • How can I disable all the components in a JPanel?

    I want to disable all the components( button, text field ) in a JPanel. I know I can search the panel and disable each of its children component recursively. Is there a better way to do this?

    I want to disable all the components( button, text field ) in a JPanel.You haven't defined what you mean by "disable".
    If you mean you want the component to be repainted in its disabled state, then you would need to set the property of each individual component to disable, which would imply some kind of recursion.
    If you just want to prevent components from receiving key events and mouse events, then you can use a glass pane or maybe a panel with an overlay layout that contains a non-opaque panel that intercepts all events.

  • Disable all the previous dates in a calendar form

    hi guys,
    I am having a calendar form in which it displays all the previous,current,future dates and months.when i click on the particular button on the
    calendar it dispalys the date, month, and year.its working fine.But what i need is, i want to disable all the previous dates in the calendar till the current
    date.But not to disable the previous button.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class CalendarForm extends JFrame
    JButton[] btn = new JButton[49];
    int month = java.util.Calendar.getInstance().get(java.util.Calendar.MONTH);
    int year = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR);
    JLabel lbl = new JLabel("", JLabel.CENTER);
    JTextField tf1=new JTextField();
    public CalendarForm()
    buildGUI();
    setDates();
    public void buildGUI()
    setLocation(200,350);
    setDefaultCloseOperation(HIDE_ON_CLOSE);
    String[] header = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"};
    JPanel midPanel = new JPanel(new GridLayout(7,7));
    midPanel.setPreferredSize(new Dimension(350,250));
    for(int x = 0; x < btn.length; x++)
    final int selection = x;
    btn[x] = new JButton();
    btn[x].setFocusPainted(false);
    if(x>6)
    btn[x].addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent ae){
    displayDatePicked(btn[selection].getActionCommand());}});
    if(x < 7)
    {btn[x].setFont(new Font("Lucida", Font.PLAIN, 8)); btn[x].setText(header[x]);}
    midPanel.add(btn[x]);
    JPanel lowPanel = new JPanel(new GridLayout(1,3));
    JButton prevBtn = new JButton("<< Previous");
    prevBtn.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent ae){
    month--;setDates();}});
    lowPanel.add(prevBtn);
    lowPanel.add(lbl);
    JButton nextBtn = new JButton("Next >>");
    nextBtn.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent ae){
    month++;setDates();}});
    lowPanel.add(nextBtn);
    getContentPane().add(midPanel,BorderLayout.CENTER);
    getContentPane().add(lowPanel,BorderLayout.SOUTH);
    pack();
    public void setDates()
    for(int x = 7; x < btn.length; x++) btn[x].setText("");
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMMM yyyy");
    java.util.Calendar cal = java.util.Calendar.getInstance();
    cal.set(year,month,1);
    int dayOfWeek = cal.get(java.util.Calendar.DAY_OF_WEEK);
    int daysInMonth = cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH);
    for(int x = 6+dayOfWeek,day = 1; day <= daysInMonth; x++,day++) btn[x].setText(""+day);
    lbl.setText(sdf.format(cal.getTime()));
    setTitle("Calendar - "+lbl.getText());
    public void displayDatePicked(String day)
    if(day.equals("") == false)
    // java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("EEEE d MMMM, yyyy");
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd/MM/yyyy");
    java.util.Calendar cal = java.util.Calendar.getInstance();
    cal.set(year,month,Integer.parseInt(day));
    System.out.println(tf1.getText());
    getContentPane().add(tf1,BorderLayout.NORTH);
    // JOptionPane.showMessageDialog(this,"You picked "+sdf.format(cal.getTime()));
    tf1.setText(sdf.format(cal.getTime()));
    System.out.println("from date"+tf1.getText());
    this.setVisible(false);
    public String getFromDate()
    return tf1.getText();
    public static void main(String[] args)
         new CalendarForm().setVisible(true);
    the above  code is to diaplay the calendar form.plzzzzzzzzzzzzzzzz help me. thanks in advance                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    hi michael,i disabled all the previous buttons in a calendar form.this is my code
    import java.awt.*;
    import java.awt.event.*;
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.util.Date;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.*;
    class CalendarForm extends JFrame {
        JButton[] btn = new JButton[49];
        int month = java.util.Calendar.getInstance().get(java.util.Calendar.MONTH);
        int date = java.util.Calendar.getInstance().get(java.util.Calendar.DATE);
        int year = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR);
        JLabel lbl = new JLabel("", JLabel.CENTER);
        JTextField tf1 = new JTextField();
        public CalendarForm() {
            buildGUI();
            setDates();
        private String getMonthAndYearAsString() {
            java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMMM yyyy");
            return sdf.format(new Date(System.currentTimeMillis()));
        private Date getCurrentDate() {
            java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd MM yyyy");
            return new Date();
        public void buildGUI() {
            setLocation(450, 350);
            setDefaultCloseOperation(HIDE_ON_CLOSE);
            String[] header = {"Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"};
            JPanel midPanel = new JPanel(new GridLayout(7, 7));
            midPanel.setPreferredSize(new Dimension(350, 250));
            for (int x = 0; x < btn.length; x++) {
                final int selection = x;
                btn[x] = new JButton();
                btn[x].setFocusPainted(false);
                if (x > 6) {
                    btn[x].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent ae) {
                            displayDatePicked(btn[selection].getActionCommand());
                if (x < 7) {
                    btn[x].setFont(new Font("Lucida", Font.PLAIN, 8));
                    btn[x].setText(header[x]);
                midPanel.add(btn[x]);
            JPanel lowPanel = new JPanel(new GridLayout(1, 3));
            JButton prevBtn = new JButton("<< Previous");
            prevBtn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    month--;
                    setDates();
                    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMMM yyyy");
                    java.util.Calendar cal = java.util.Calendar.getInstance();
                    cal.set(year, month, 1);
                    int dayOfWeek = cal.get(java.util.Calendar.DAY_OF_WEEK);
                    int daysInMonth = cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH);
                    String currentMonth = getMonthAndYearAsString();
                    System.out.println("CURRENT MONTH AND YEAR " + currentMonth);
                    String selectedMonth = sdf.format(cal.getTime());
                    System.out.println("SELECTED MONTH AND YEAR " + selectedMonth);
                    Date currentDate = getCurrentDate();
                    Date selectedDate = new Date(cal.getTimeInMillis());
                    //Comparing currentDate nad selectedDate
                    int off = currentDate.compareTo(selectedDate);
                    int currentDay = date;
                    if (currentMonth.compareTo(selectedMonth) == 0) {
                        for (int x = 7 + dayOfWeek,  day = 1; day <= btn.length; x++, day++) {
                            btn[x].setEnabled(true);
                            if (day < currentDay) {
                                int k = x - 1;
                                for (int j = 7; j <= k; j++) {
                                    btn[j].setEnabled(false);
                    } else if (off == 1) {
                        for (int x = 6 + dayOfWeek,  day = 1; day < daysInMonth; x++, day++) {
                            for (int i = 6 + dayOfWeek; day < currentDay; i++) {
                                btn.setEnabled(false);
    } else if (off == -1) {
    for (int x = 7, day = 1; day < btn.length; x++, day++) {
    btn[x].setEnabled(true);
    lowPanel.add(prevBtn);
    lowPanel.add(lbl);
    JButton nextBtn = new JButton("Next >>");
    nextBtn.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    month++;
    setDates();
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMMM yyyy");
    java.util.Calendar cal = java.util.Calendar.getInstance();
    cal.set(year, month, 1);
    int dayOfWeek = cal.get(java.util.Calendar.DAY_OF_WEEK);
    int daysInMonth = cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH);
    String currentMonth = getMonthAndYearAsString();
    System.out.println("CURRENT MONTH AND YEAR " + currentMonth);
    String selectedMonth = sdf.format(cal.getTime());
    System.out.println("SELECTED MONTH AND YEAR " + selectedMonth);
    Date currentDate = getCurrentDate();
    Date selectedDate = new Date(cal.getTimeInMillis());
    //Comparing currentDate and selectedDate
    int off = currentDate.compareTo(selectedDate);
    int currentDay = date;
    if (currentMonth.compareTo(selectedMonth) == 0) {
    for (int x = 7 + dayOfWeek, day = 1; day <= btn.length; x++, day++) {
    btn[x].setEnabled(true);
    if (day < currentDay) {
    int k = x - 1;
    for (int j = 7; j <= k; j++) {
    btn[j].setEnabled(false);
    if (off == -1) {
    for (int x = 7, day = 1; day < btn.length; x++, day++) {
    btn[x].setEnabled(true);
    } else if (off == 1) {
    for (int x = 6 + dayOfWeek, day = 1; day < daysInMonth; x++, day++) {
    for (int i = 6 + dayOfWeek; day < currentDay; i++) {
    btn[i].setEnabled(false);
    lowPanel.add(nextBtn);
    getContentPane().add(midPanel, BorderLayout.CENTER);
    getContentPane().add(lowPanel, BorderLayout.SOUTH);
    pack();
    public void setDates() {
    for (int x = 7; x < btn.length; x++) {
    btn[x].setText("");
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMMM yyyy");
    java.util.Calendar cal = java.util.Calendar.getInstance();
    cal.set(year, month, 1);
    int dayOfWeek = cal.get(java.util.Calendar.DAY_OF_WEEK);
    int daysInMonth = cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH);
    lbl.setText(sdf.format(cal.getTime()));
    setTitle("Calendar - " + lbl.getText());
    int currentDay = date;
    for (int x = 6 + dayOfWeek, day = 1; day <= daysInMonth; x++, day++) {
    btn[x].setText("" + day);
    if (day < currentDay) {
    for (int j = 7; j <= x; j++) {
    btn[j].setEnabled(false);
    public void displayDatePicked(String day) {
    if (day.equals("") == false) {
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd/MM/yyyy");
    java.util.Calendar cal = java.util.Calendar.getInstance();
    cal.set(year, month, Integer.parseInt(day));
    System.out.println(month);
    System.out.println(tf1.getText());
    tf1.setText(sdf.format(cal.getTime()));
    System.out.println("from date" + tf1.getText());
    // VStudentAttendanceForm class ....
    if (VStudentAttendanceForm.jcalFlag == 1) {
    VStudentAttendanceForm.jtfFromDate.setText(tf1.getText());
    if (VStudentAttendanceForm.jcalFlag == 2) {
    VStudentAttendanceForm.jtfToDate.setText(tf1.getText());
    if (ManageStudents.cal == 1) {
    ManageStudents.jTextField22.setText(tf1.getText());
    ManageStudents.FromjTextField10.setText(tf1.getText());
    if (ManageStudents.cal == 2) {
    ManageStudents.jTextField23.setText(tf1.getText());
    ManageStudents.TojTextField11.setText(tf1.getText());
    if (vAuditTrail.cal == 1) {
    vAuditTrail.jTextField3.setText(tf1.getText());
    if (vAuditTrail.cal == 2) {
    vAuditTrail.jTextField4.setText(tf1.getText());
    if (Attendance.cal == 1) {
    Attendance.jTextField7.setText(tf1.getText());
    if (Attendance.cal == 2) {
    Attendance.jTextField8.setText(tf1.getText());
    this.setVisible(false);
    public String getFromDate() {
    return tf1.getText();
    public static void main(String[] args) {
    new CalendarForm().setVisible(true);

Maybe you are looking for

  • Change SOAP Address Location in the WSDL

    When deploying a BPEL service the SOAP Address location is automatically generated to have the http://{SERVER}:{PORT} of the SOA server where you are deploying the service but i need to have a different address location. I basically needs this becaus

  • Can I loadOSX TO A MACBOOK 13?

    My mum wants to use iplayer on her Macbook 13. She was told to increase the RAM by 2Gb. She did that and I have an installation disc for OSX from my imac. When I load the install DVD or the Application install DVD it says that Snow Leopard cannot be

  • How do you migrate BB email to a new device?

    The backup didnt work on my desktop so I am trying to reactivate my BB email onto my phone. Any suggestions please?

  • Display image thumbnail in open menu

    jpgs show, pdfs show but the thumbnail for psd are blank

  • New computer, trouble transferring CS4 Design Premium

    I had CS4 Design Premium (educational) on my 2006 MacBook Pro. The computer crashed, I bought a 2013 MacBook Pro, and I'm trying to transfer the license/product onto the new computer. I don't have the original discs, but I'd backed the software up in