Set MaxLength to Password field

Hi All,
I have developed small login window kind of application. I want to set maximam length for the password field. Narratively, I want to show the message "Password should contain upto 8 characters" if user types more than 8 letters. How to do that?
You can view my code below
import javax.swing.JPasswordField;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.CaretListener;
import javax.swing.event.CaretEvent;
import javax.swing.text.*;
public class PassWord
    private JFrame fr;
    private JPanel panel;
    private JLabel userIDLabel;
    private JLabel passwordLabel;
    private JTextField userID;
    private JPasswordField password;
    int i=0;
    public void createFrame()
        panel = new JPanel();
        panel.setLayout(new GridLayout(2,2));
        userIDLabel = new JLabel("Userid");
        passwordLabel = new JLabel("Password");
        panel.add(userIDLabel);
        userID = new JTextField("Your UserID");
        password = new JPasswordField();
        password.setEchoChar('*');
        password.setColumns(8);
        /*password.addCaretListener(new CaretListener()
            public void caretUpdate(CaretEvent e)
                i++;
                if(i>=8)
                   password.exit(0);
        panel.add(userID);
        panel.add(passwordLabel);
        panel.add(password);
        fr = new JFrame("Authentication");
        fr.getContentPane().add(panel);
        fr.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        fr.setSize(200,200);
        fr.setLocation(300,200);
        fr.setVisible(true);
        fr.pack();
    public static void main(String args[])
        new PassWord().createFrame();
}

Sir,
Remember that behind a swing control lives a Model.
The most appropriate way to provide constraints (such as max length) is to build the constraint in to the Model itself.
Text controls provide a getDocument() method which returns the Document (model) the control is associated with.
You will notice that Document provides a method to add a DocumentListener to it.
A DocumentListener added to a Document is notified of any changes made to the document.
So, suppose your document has a max length of 8.
When you receive notification of a change, you can check to see if this maximum length has been exceeded.
If it has, you can, for example remove the extra characters from the model.
There are probably other ways to do this - but remember that the Swing control is just a View of the underlying Model. The best way to enforce constraints is in the model.

Similar Messages

  • Set limitation in Password Field

    How to set the passwordField so it can read only the numeric and alphabet character???

    Add a key listener to the field:
            m_jPasswordField.addKeyListener(new java.awt.event.KeyAdapter()
                public void keyTyped(KeyEvent e)
                    m_jPasswordField_keyTyped(e);
            });and use it to filter keys:
        void m_jPasswordField_keyTyped(KeyEvent e)
            if(!Character.isLetterOrDigit(e.getKeyChar()))
                if(e.getKeyChar()!=e.VK_BACK_SPACE)
                    e.consume();
                    Toolkit.getDefaultToolkit().beep();
        }

  • Setting password field in JOptionPane

    Is it possible for me to set password field in JOptionPane's input field. If possible please help me. It would be very nice if u could email me at the following address
    [email protected]

    Did you try .setText(password)? Try it.

  • How do I set up a password on my WRT54GS?

    I have been using my wireless router for a couple of years and never bothered to set up a password... When I am away from home and try to use either my lap top or IPod Touch to connect to a wireless network, I notice that I need to enter a password to be allowed to do it... I would like to set up something similar in my wireless router so that anyone in my neighborhood attempting to use my wireless network has to enter a password before being able to do it.  How can I set this up?  I have no idea and would appreciate any help.... Thanks!

    1st it is suggested you do these steps on a hardwired PC.
    Step 1: Access the routers web based utility interface. To do this, open up Internet Explorer or any web browser and then type on the address bar http://192.168.1.1 (username just leave it blank, password as a default is admin).
    Then click on WIRELESS and then WIRELESS SECURITY.
    Step 2:
    Select WPA Personal under the Security Mode drop-down menu.
    Enter your desired WPA Key on the WPA Shared Key field such as “MySecretKey.” This will serve as your network key whenever you connect to your wireless network.
    NOTE: Do not give this key to anyone. This key will secure your wireless network. Leave Group Key Renewal to 3600 seconds.
    Then save the settings and you are good to go from there.

  • How can I prevent Safari/iCloud Keychain from saving data in our password field?

    We have a web-based management system where administrators can set and update passwords for individual users. While I love iCloud keychain personally, the problem we are finding is that if the user, once prompted by Safari to Save the password in iCloud Keychain for Autofill, actually clicks 'Save Password', then our page wants to autofill that same password for any selected user or newly added user (and since we don't allow duplicates, constant errors result).
    So the basic question: is there a way in HTML or Javascript to set form fields - or an entire form or div - to be ignored by iCloud Keychain, even if they are username or password fields.
    We know we could just tell all our Safari users to disable in preferences with a pop-up banner, but that would be unfortunate (and IE-like)
    (If this is the wrong place to find this type of info, any clue appreciated. Naturally we've searched a bunch already)

    Can I remove my iCloud Keychain from Apple's servers?
    Yes. Follow these steps, starting on any one of your iOS devices or Macs that is using iCloud Keychain:
    Devices using iOS 7.0.3 or later:
    Go to Settings > iCloud > Account > Keychain and turn off “Approve with Security Code”.
    Go to each of your other devices that is using iCloud Keychain and turn iCloud Keychain off.
    Macs using OS X Mavericks v10.9 or later:
    Choose Apple () menu > System Preferences. Click iCloud, then click Account details.
    Deselect “Allow approving using security code”.
    Go to each of your other devices that is using iCloud Keychain and turn iCloud Keychain off.
    After you complete these steps, your keychain data will remain locally on your devices, but changes to your keychain information will not push to your other devices or the cloud unless you turn iCloud Keychain back on. If you want keychain data to push to all of your devices, but not to the cloud, turn on iCloud Keychain on each device as described earlier in this document, but skip the step to create an iCloud Security Code.
    iCloud: Frequently asked questions about iCloud Keychain
    http://support.apple.com/kb/HT5813

  • Make a report column display as an editable password field.

    Hi Guys,
    - Apex 3.2
    - Report region, one of the columns represents a password.
    - Made that column editable ==> display as text-item.
    How can I make it display as a password field?
    If I add:
    type="password"to the element attributes (in column attributes), then it still displays as a text field. Show html source reveales it just adds a second type= attribute:
    <input type="text" name="f05" size="15" maxlength="2000" value="test" type="password" id="f05_0001" />Which still makes it display as text, not password...
    Appreciate any help on this.
    Toon

    Dan McGhan wrote:
    There is no "out of the box" solution for this. You'd have to do a bit of work. However, before we go down that road, I'm curious as to why you'd want to put a password field in a tabular form.
    It's a multi row insert/update/delete (tabular) form, and one of the columns represents a password.
    One row represents "an application". The column represents the application password.
    I actually have two of them (columns) + a process that verifies that the same value was entered in both.
    I'm suprised that this is not out-of-the box possible...
    It would be a very easy to just support the 'password field' type in the dropdown list that I have now used to make it a simple text field. No?
    Appreciate any assistance...
    Edited by: Toon Koppelaars on Jul 14, 2010 1:20 PM

  • OIM 11g - Set a default password when a user is created

    Hi everybody,
    I'm trying to set a default password when I create a user manually but I've got some errors.
    I firstly created a pre-process event handler to generate automatically a login and an email for a user who is created and it worked fine. But now I'm trying to generate a default password (like "ChangeIt" for example) that the user will have to change the first time.
    This is the code I wrote :
    public EventResult execute(long processId, long eventId, Orchestration orchestration) {
    String methodName = "EventREsult execute";
    System.out.println("###### " + className + " - method " + methodName + " - STARTED");
    HashMap<String, Serializable> parameters = orchestration.getParameters();
    System.out.println("###### OK1");
    String firstName = (String)parameters.get(UserManagerConstants.AttributeName.FIRSTNAME.getId());
    System.out.println("###### OK2");
    String lastName = (String)parameters.get(UserManagerConstants.AttributeName.LASTNAME.getId());
    System.out.println("###### OK3");
    String userKey = (String)parameters.get(UserManagerConstants.AttributeName.USER_KEY.getId());
    System.out.println("###### OK4");
    String userLogin = firstName + lastName;
    parameters.put(UserManagerConstants.AttributeName.USER_LOGIN.getId(), userLogin);
    System.out.println("###### OK5");
    parameters.put(UserManagerConstants.AttributeName.EMAIL.getId(), firstName + "." + lastName + "@test.test");
    System.out.println("###### OK6");
    parameters.put(UserManagerConstants.AttributeName.PASSWORD.getId(), "ChangeIt");
    System.out.println("###### " + className + " - method " + methodName + " - ENDED");
    return new EventResult();
    And When I try to create a user, I've got the error : "An error occured. Null input buffer"
    This is what I have in the console :
    <10 mai 2012 16 h 44 CEST> <Error> <oracle.iam.identity.usermgmt.impl> <IAM-3050030> <Exception lors de la rÚalisation de l'opÚration.
    java.lang.IllegalArgumentException: Null input buffer
    at javax.crypto.Cipher.doFinal(DashoA13*..)
    at com.thortech.xl.crypto.tcDefaultDBEncryptionImpl.decrypt(tcDefaultDBEncryptionImpl.java:219)
    at com.thortech.xl.crypto.tcCryptoUtil.decrypt(tcCryptoUtil.java:122)
    at com.thortech.xl.crypto.tcCryptoUtil.decrypt(tcCryptoUtil.java:200)
    at oracle.iam.platform.utils.crypto.CryptoUtil.getDecryptedPassword(CryptoUtil.java:136)
    at oracle.iam.transUI.impl.handlers.user.UpdateUsrPwdFields.updateUserPwdFields(UpdateUsrPwd
    Fields.java:124)
    at oracle.iam.transUI.impl.handlers.user.UpdateUsrPwdFields.execute(UpdateUsrPwdFields.java:
    71)
    at oracle.iam.platform.kernel.impl.OrchProcessData.runPreProcessEvents(OrchProcessData.java:
    898)
    <10 mai 2012 16 h 44 CEST> <Error> <oracle.iam.identitytaskflow.logging> <BEA-000000> <IAM-3060023>
    I know this is something due to the password parameter but I don't understand what is expected for this one ...
    If you someone could help me with this it would be really helpful !
    Thanks,
    Thibault

    Hi, Thanks for your quick answer !
    So it solved half of the problem ! Now I've got an other error : decrypt failed
    And this is the beginning of the error in the console :
    <10 mai 2012 18 h 14 CEST> <Error> <XELLERATE.ACCOUNTMANAGEMENT> <BEA-000000> <Class/Method: tcDefau
    ltDBEncryptionImpl/decrypt encounter some problems: Input length must be multiple of 16 when decrypting with padded cipher
    javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with pad
    ded cipher
    at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
    at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
    at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA13*..)
    at javax.crypto.Cipher.doFinal(DashoA13*..)
    at com.thortech.xl.crypto.tcDefaultDBEncryptionImpl.decrypt(tcDefaultDBEncryptionImpl.java:2
    19)
    at com.thortech.xl.crypto.tcCryptoUtil.decrypt(tcCryptoUtil.java:122)
    at com.thortech.xl.crypto.tcCryptoUtil.decrypt(tcCryptoUtil.java:200)
    at oracle.iam.platform.utils.crypto.CryptoUtil.getDecryptedPassword(CryptoUtil.java:136)
    at oracle.iam.transUI.impl.handlers.user.UpdateUsrPwdFields.updateUserPwdFields(UpdateUsrPwd
    Fields.java:124)
    at oracle.iam.transUI.impl.handlers.user.UpdateUsrPwdFields.execute(UpdateUsrPwdFields.java:
    71)
    at oracle.iam.platform.kernel.impl.OrchProcessData.runPreProcessEvents(OrchProcessData.java:
    898)
    What does it means ? My password must be encrypted or something like this ?
    Thanks if you can help me with this !!
    Thibault

  • Masking the password field in webdynpro for java

    Hi,
    I am developing a logon view in webdynpro with username and password input fields.But i want to mask the password field.
    How do i do that
    Points will be rewarded for the useful answers
    Bala

    Hi,
    Set the properties of the Input field
    <b>passwordField     true</b>
    Regards
    Ayyapparaj

  • How to use password fields

    Hi All,
    I have to a create login page with fields user name and password .could you please explain me how to implement the entered password field as invisible in the text fields (that is passward field) where the user is going to enter the password.
    Thanks
    Kumar

    Hi,
    ---There is one property called secret.
    ---set secret :*TRUE*
    Regards
    Meher Irk

  • Mask password field while rendering the page

    Dear All,
    I have made a application wherein I have 2 pages. The 1st page is a tabular diaplay of the data and the 2nd page(which is called from the 1st page after clicking on the link) is for adding/modifying the data. This is based on my user master table which has a "Password" field in it and it is not null field at the database level. I am not showing this password field on the 1st page(report). I am showing this field on the 2nd page while entering/modifying the data. I have set its display type as "Password" so that while adding the data, it is displayed as dot. But when I am trying to edit the same data, it is not showing me the data in the password field. So I am not able to save any changes to the existing data. If I change the display type to some other option then it works fine.
    Please suggest some solution.
    (We are using application express version 3.0.0.00.20)
    Minakshi

    Minakshi,
    We don't retrieve password form items from session state when rendering them. So you should be able to type a new value in and save the form. If you mean that you cannot save the form without entering a value for the password, then that is an expected effect of this same practice. You'll need to allow for a null value using an after-submit computation (which populates the item by selecting from the existing row) or handle it in a trigger on the table.
    Scott

  • ICloud keychain isn't recognizing new password fields

    I'm trying to change a few passwords with iCloud Keychain, and on some sites its worked perfectly. However, on some other sites (facebook, netflix, and a message board I frequent) Safari doesnt seem to be recognizing the password field because the password suggestion popup isnt showing up. Is there a way to manually generate a password in safari? or to get it to recognize a "new password" field and suggest a pw? Thanks for your help

    I have what may be a related issue: For some sites, keychain isn't storing passwords.  Passwords that were there before I set up keychain are there when I check passwords in Safari, but new ones aren't being added.

  • Shadow and gshadow have x in password field

    I tried doing some research to find out what an 'x' in the password field of the shadow and the gshadow files means and couldn't find an answer that I'm sure about. I know an 'x' in the passwd and groups files means that the Shadow Suite is being used and the 'x' acts as a place holder. Why would the shadow files have an 'x' in the password field though? It seems to only be for system accounts, so maybe it means that some other authentication method is being used besides passwords. I can't find any mention of it in the man files. The man files and Google search both indicate that the only thing that should in the password field should be an encrypted password, an '!', an '!!', or an '*'. I tried looking through the source code for the Shadow Suite a little bit too, but couldn't find an answer. Any ideas?

    loafer wrote:
    The x only seems to appear in shadow when the shell is /bin/false in passwd.
    edit: I'm not sure if there's any need to worry about gshadow as groups don't tend to have passwords.
    edit:  They are the ones included in the filesystem package (root isn't there in the examples above because we set a password for root):
    root::14871::::::
    bin:x:14871::::::
    daemon:x:14871::::::
    mail:x:14871::::::
    ftp:x:14871::::::
    http:x:14871::::::
    nobody:x:14871::::::
    I'm pretty sure this isn't a problem.  The field containing x is for the encrypted passwords and since "x" won't match a real password is there a problem here?
    That is a good observation. I didn't catch the pattern with /bin/false. I didn't think anything was broken because I recently ran updates and the gshadow.pacnew file has x's in it too. I was just curious because I like to know why things are the way they are instead of just accepting it for the way it is.
    rowdog wrote:x is not a valid result of crypt.
    That was what lead me down this road. Thanks for all responses!!

  • Switch from List of user to username and password fields?

    I have my Login Window to display a List of Users by default.
    Is there is shortcut key that switches to username & password fields so one can type in the username as well as the password?
    I googled it and I found something like "hold opt+return and click on any username", does not work though...
    I know that I can change it in System Pref. but it would be handy to know the shortcut key as well.
    Thanks.

    The "Option"-"Enter" trick should still work from the keyboard - use the arrow keys or type the first few letters of a listed name to highlight a username, then press "Option-Return":
    http://docs.info.apple.com/article.html?artnum=25686
    As I recall, to do the same thing with keyboard + mouse, the modifiers to be used when clicking did change between 10.3 and 10.4 so some of what you find on the web may be out of date.

  • Password Field not mapped between Request and Provisioning Form

    Hi to all. I'm working with OIM 11g. I've faced a strange issue. I'm not sure I'm working properly, so let me explain you my case. In my installation I've got the SSH connector, which is correctly connected with the physical resources. I've loaded the resource dataset ProvisionResourceSSH User bundled with the connector. Consider now that the user "goofy", with "ALL USERS" role, tries to make a request Provision Resource SSH User (Request Based provisioning). He fills in all the field in the appropriate manner, but when OIM triggers "Create User" provisioning task, after the required approval process, the password field is always blank (although goofy filled it in!!!).
    I've thought: "ok, it seems a role trouble". And effectively, if goofy has got also the role "REQUEST ADMINISTRATORS", the provisioning form shows the password field correctly valued (as goofy stated in his request).
    Note that all the fields are correctly mapped between request dataset and the provisioning form (I'm using the original dataset and the original provisioning form installed by the connector). So all other fields filled by goofy on the request form (request based provisioning) are correctly passed to the provisioning form. All the fields, except for the password.
    Am I wrong in something? How Could I make possible to pass the data filled on the request for the password field to the provisioning form even if the requester has not the role "REQUEST ADMINISTRATORS"?
    Thank you in advance for the help.

    This sure seems goofy! ;-) ... can you try making the ALL Users have all the permissions on the Resource Object and the Process Form and test it out? Also try from the backend at the database and see if the table has NULL for the password field? ... What's the type of password field in the dataset and the process form? Encrypted/Secret at both ends or mis match? Try making them plain text both the places as well.
    -Bikash

  • To set HOTSPOT for a field in ALV-oops and when clecked should call transac

    Hi,
    I need to set HOTSPOT for a field in O/P list using ALV-oops and when clecked should take me to Transaction VA01. Please help....
    Thanks,
    Prabhu

    Hi,
         Please go through this code it may help u.
    REPORT zcls_alv_oops MESSAGE-ID z1.
    TABLES : mara.
    Types Declaration..\
    TYPES :
    BEGIN OF t_mara,
    matnr TYPE matnr,
    mtart TYPE mtart,
    maktx TYPE maktx,
    END OF t_mara,
    BEGIN OF t_marc,
    matnr TYPE matnr,
    werks TYPE werks_d,
    mtart TYPE mtart,
    maktx TYPE maktx,
    END OF t_marc.
    Internal Tables Declaration..\
    DATA :
    i_mara TYPE TABLE OF t_mara,
    i_marc TYPE TABLE OF t_marc,
    i_fcat1 TYPE lvc_t_fcat,
    i_fcat2 TYPE lvc_t_fcat.
    Constants Declaration..\
    CONSTANTS :
    c_cont1 TYPE scrfname VALUE 'CONT1',
    c_cont2 TYPE scrfname VALUE 'CONT2'.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    SELECT-OPTIONS:
    s_matnr FOR mara-matnr NO INTERVALS.
    SELECTION-SCREEN SKIP 1.
    PARAMETERS :
    p_hotspt RADIOBUTTON GROUP r1 DEFAULT 'X',
    p_bttn RADIOBUTTON GROUP r1.
    SELECTION-SCREEN END OF BLOCK b1.
    \* Class forward referncing.
    CLASS lcl_rcvr_class DEFINITION DEFERRED.
    \* Pointers Declaration..
    DATA :
    lp_rcvr TYPE REF TO lcl_rcvr_class,
    lp_cont1 TYPE REF TO cl_gui_custom_container,
    lp_cont2 TYPE REF TO cl_gui_custom_container,
    lp_grid1 TYPE REF TO cl_gui_alv_grid,
    lp_grid2 TYPE REF TO cl_gui_alv_grid.
    \* Local Class Definiton.
    CLASS lcl_rcvr_class DEFINITION.
    PUBLIC SECTION.
    METHODS :
    hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
    IMPORTING e_row_id e_column_id es_row_no,
    handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
    IMPORTING e_row e_column.
    ENDCLASS.
    \* Local Class Implementation.
    CLASS lcl_rcvr_class IMPLEMENTATION.
    METHOD hotspot_click.
    DATA :
    wa_mara TYPE t_mara,
    wa_marc TYPE t_marc.
    DATA :
    l_index TYPE sy-tabix.
    READ TABLE i_mara INTO wa_mara INDEX e_row_id-index.
    IF sy-subrc EQ 0.
    REFRESH i_marc.
    SELECT matnr
    werks
    INTO TABLE i_marc
    FROM marc
    WHERE matnr EQ wa_mara-matnr.
    IF sy-subrc EQ 0.
    LOOP AT i_marc INTO wa_marc.
    l_index = sy-tabix.
    wa_marc-mtart = wa_mara-mtart.
    wa_marc-maktx = wa_mara-maktx.
    MODIFY i_marc FROM wa_marc INDEX l_index
    TRANSPORTING mtart maktx.
    ENDLOOP.
    CALL SCREEN 200.
    ELSE.
    MESSAGE e121 WITH text-005 wa_mara-matnr.
    ENDIF.
    ENDIF.
    ENDMETHOD.
    METHOD handle_double_click.
    DATA :
    wa_mara TYPE t_mara,
    wa_marc TYPE t_marc.
    DATA :
    l_index TYPE sy-tabix.
    READ TABLE i_mara INTO wa_mara INDEX e_row-index.
    IF sy-subrc EQ 0.
    REFRESH i_marc.
    SELECT matnr
    werks
    INTO TABLE i_marc
    FROM marc
    WHERE matnr EQ wa_mara-matnr.
    IF sy-subrc EQ 0.
    LOOP AT i_marc INTO wa_marc.
    l_index = sy-tabix.
    wa_marc-mtart = wa_mara-mtart.
    wa_marc-maktx = wa_mara-maktx.
    MODIFY i_marc FROM wa_marc INDEX l_index
    TRANSPORTING mtart maktx.
    ENDLOOP.
    CALL SCREEN 200.
    ELSE.
    MESSAGE e121 WITH text-005 wa_mara-matnr.
    ENDIF.
    ENDIF.
    ENDMETHOD.
    ENDCLASS.
    \* Start of Selection
    START-OF-SELECTION.
    \* Extract the Material Master data for the Input Material.
    SELECT a~matnr
    a~mtart
    b~maktx
    INTO TABLE i_mara
    FROM mara AS a
    INNER JOIN makt AS b
    ON a~matnr EQ b~matnr
    WHERE a~matnr IN s_matnr
    AND b~spras EQ sy-langu.
    END-OF-SELECTION.
    IF NOT i_mara\[\] IS INITIAL.
    \* Call Screen to display the Material Master data.
    CALL SCREEN 100.
    ELSE.
    MESSAGE s121 WITH text-006.
    ENDIF.
    \*& Module DISP_GRID OUTPUT
    \* text
    MODULE disp_grid OUTPUT.
    \* Build the Field catelog for Material Master data.
    PERFORM build_fcat.
    \* Display the Material Master data using ALV.
    PERFORM disp_alv.
    ENDMODULE. " DISP_GRID OUTPUT
    \*& Module USER_COMMAND_0100 INPUT
    \* text
    MODULE user_command_0100 INPUT.
    \*when exit or cancel is clicked program has to come out
    CASE sy-ucomm.
    WHEN 'EXIT' OR 'CANC'.
    LEAVE PROGRAM.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    \*& Form build_fcat
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM build_fcat.
    DATA : ws_fcat TYPE lvc_s_fcat.
    ws_fcat-fieldname = 'MATNR'.
    ws_fcat-scrtext_m = text-001.
    ws_fcat-tabname = 'I_MARA'.
    IF p_hotspt EQ 'X'.
    ws_fcat-hotspot = 'X'.
    ENDIF.
    APPEND ws_fcat TO i_fcat1.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MTART'.
    ws_fcat-scrtext_m = text-002.
    ws_fcat-tabname = 'I_MARA'.
    APPEND ws_fcat TO i_fcat1.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MAKTX'.
    ws_fcat-scrtext_m = text-003.
    ws_fcat-tabname = 'I_MARA'.
    APPEND ws_fcat TO i_fcat1.
    CLEAR ws_fcat.
    ENDFORM. " build_fcat
    \*& Form disp_alv
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM disp_alv.
    IF lp_cont1 IS INITIAL.
    \* Create the Container Object of Material Master.
    CREATE OBJECT lp_cont1
    EXPORTING
    container_name = c_cont1
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6 .
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Create the Object for Grid of Material Master.
    CREATE OBJECT lp_grid1
    EXPORTING
    i_parent = lp_cont1
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    others = 5.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Dipslay Material Master data by calling method.
    CALL METHOD lp_grid1->set_table_for_first_display
    CHANGING
    it_outtab = i_mara
    it_fieldcatalog = i_fcat1
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Set Handler for the Hot Spot Event.
    CREATE OBJECT lp_rcvr.
    IF p_hotspt EQ 'X'.
    SET HANDLER lp_rcvr->hotspot_click FOR lp_grid1.
    ELSE.
    SET HANDLER lp_rcvr->handle_double_click FOR lp_grid1.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDFORM. " disp_alv
    \*& Module STATUS_0100 OUTPUT
    \* text
    MODULE status_0100 OUTPUT.
    SET PF-STATUS 'MAIN_STAT'.
    SET TITLEBAR 'T_100'.
    ENDMODULE. " STATUS_0100 OUTPUT
    \*& Module STATUS_0200 OUTPUT
    \* text
    MODULE status_0200 OUTPUT.
    SET PF-STATUS 'PLANT_STAT'.
    SET TITLEBAR 'T_200'.
    ENDMODULE. " STATUS_0200 OUTPUT
    \*& Module DISP_GRID_plant OUTPUT
    \* text
    MODULE disp_grid_plant OUTPUT.
    \* Build the Field catelog for Material Plant data.
    PERFORM build_fcat_plant.
    \* Display the Material Master Plant data using ALV.
    PERFORM disp_alv_plant.
    ENDMODULE. " DISP_GRID_plant OUTPUT
    \*& Module USER_COMMAND_0200 INPUT
    \* text
    MODULE user_command_0200 INPUT.
    \*when exit or cancel is clicked program has to come out
    CASE sy-ucomm.
    WHEN 'EXIT' OR 'CANC'.
    LEAVE PROGRAM.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0200 INPUT
    \*& Form build_fcat_plant
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM build_fcat_plant.
    DATA : ws_fcat TYPE lvc_s_fcat.
    ws_fcat-fieldname = 'MATNR'.
    ws_fcat-scrtext_m = text-001.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'WERKS'.
    ws_fcat-scrtext_m = text-004.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MTART'.
    ws_fcat-scrtext_m = text-002.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MAKTX'.
    ws_fcat-scrtext_m = text-003.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ENDFORM. " build_fcat_plant
    \*& Form disp_alv_plant
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM disp_alv_plant.
    IF lp_cont2 IS INITIAL.
    \* Create the Container Object of Material Plant data.
    CREATE OBJECT lp_cont2
    EXPORTING
    container_name = c_cont2
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Create the Object for Grid of Material Plant data.
    CREATE OBJECT lp_grid2
    EXPORTING
    i_parent = lp_cont2
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    others = 5.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Dipslay Material Plant data by calling method.
    CALL METHOD lp_grid2->set_table_for_first_display
    CHANGING
    it_outtab = i_marc
    it_fieldcatalog = i_fcat2
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDIF.
    ENDIF.
    ELSE.
    \* Call method 'REFRESH_TABLE_DISPLAY' to refresh the grid data.
    CALL METHOD lp_grid2->refresh_table_display.
    ENDIF.
    ENDFORM. " disp_alv_plant

Maybe you are looking for

  • HR ABAP creation of PD info.

    Hi,           I am new to HR ABAP.can any body tell how to create custom  PD.custom infotype should be built with the same data structure (the fields in HRP1002 and associated tables) and processing options available for PD infotype 1002.  Thanks in

  • Issue syncing desktop iphoto '09 to iphone/ipad

    Having an issue syncing photos from an event from my desktop iphoto '09 (where I can see all of them just fine) to either my iphone or ipad.  I even created a separate album with just those specific photos but when I update to phone the album is ther

  • 3d graph write mpeg

    Hi is there a general way to convert a 3d graph into a mpeg video? i already have a vi that can convert a polar plot image into a video i was just wondering if it was possible for 3d plots? so in other words: can you convert directly or can you conve

  • Client proxy and XI

    Hi all, When a client proxy is called (in R/3), how do we know which Receiver Determination will be taken in XI ? I mean is there somewhere in the client proxy where it is specified ? Thanks in advance

  • Why do you need o=internet DC suffix?

    Hello all. I know the default is to have an o=internet suffix that you place your dc's under, but is this required? We are an edu site and will ONLY house edu addresses, so is it possible to have a dc=edu as your dc suffix and then create a dc=school