Remove last 3 char ..

Hi ,
     I need to remove last 3 char from my varible which is char 30.
For example : WERKS = 1000 and .
I need to remove last 3 char (and) from the above varibale .Kindly guide this
Regards,
VC

Hi veerachamy,
Just copy this code..it will work fine even if the field changes dynamically..
I took w_char as 30 char..u can give ur field name there...
data:
w_char(30) type c value 'asdfghjklpoiu',
w_tmp(30) type c,
w_tmp1 type i.
w_tmp1 = strlen( w_char ).
w_tmp1 = w_tmp1 - 3.
w_tmp = w_char+0(w_tmp1).
write: w_tmp.
Hope it resolves the issue...
Regards
Kiran

Similar Messages

  • JTextField: delete last entered char

    how can i delete the last entered char in a JTextField.
    In my textfield a Person can only enter 5 Chars. If you enter mor than 5 chars, the chars behind the 5th position must be deletet an the caret must stay behind the 5th char.
    How can i do this in java??
    Java let always stay the last typed char behind my string, i cant remove it.
    2.Question: with the method .getText() i get a String, but the last pressed key is not in that string
    how can i make it right??

    First Construct this method
         public static void setLenText(java.awt.event.KeyEvent event,int len){
         if (event.isConsumed())
    return;
    char c = event.getKeyChar();
    JTextComponent source = (JTextComponent )event.getSource();
    if (source.getText().length() >= len &&
    event.getKeyChar() != event.VK_BACK_SPACE &&
    source.getSelectionStart() == source.getSelectionEnd())
    source.getToolkit().beep();
    event.consume();
    then in the KeyTyped event of the textfield:
    void JTextField_keyTyped(java.awt.event.KeyEvent event)
              GlobalMgr.setLenText(event,5);
    By

  • How can I select the last 2 chars of a string

    Hello all,
    I am trying to select the last 2 characters of a string to match them to another string. This is for a Poem generator that contains 20 or so words and I have to pick 2 words at random, them look at the last 2 characters to see if they match in each string. Say "Plain" and "Rain" would match because they both have "in" at the end. The length of each word could vary. I don't want this doing for me just what Method should I be looking at.
    Thanks.

    hi,
    try this:
    public class StringTest {
         public static void main(String args[]) {
              StringTest obj = new StringTest();
              obj.same();
         void same() {
              String rain = new String("Rain");
              String plain = new String("Plain");
              int rainLength = rain.length();
              int plainLength = plain.length();
              if(rain.substring(rainLength-2).equals(plain.substring(plainLength-2))) {
                   System.out.println("same");
              else {
                   System.out.println("different");
    }you can use the length method to get the length of a string and then use the substring method, passing it length-2, so get the last 2 chars.

  • Best way to remove last line-feed in text file

    What is the best way to remove last line-feed in text file? (so that the last line of text is the last line, not a line-feed). The best I can come up with is: echo -n "$(cat file.txt)" > newfile.txt
    (as echo -n will remove all trailing newline characters)

    What is the best way to remove last line-feed in text file? (so that the last line of text is the last line, not a line-feed). The best I can come up with is: echo -n "$(cat file.txt)" > newfile.txt
    (as echo -n will remove all trailing newline characters)
    According to my experiments, you have removed all line terminators from the file, and replaced those between lines with a space.
    That is to say, you have turned a multi-line file into one long line with no line terminator.
    If that is what you want, and your files are not very big, then your echo statement might be all you need.
    If you need to deal with larger files, you could try using the 'tr' command, and something like
    tr '
    ' ' ' <file.txt >newfile.txt
    The only problem with this is, it will most likely give you a trailing space, as the last newline is going to be converted to a space. If that is not acceptable, then something else will have to be arranged.
    However, if you really want to maintain a multi-line file, but remove just the very last line terminator, that gets a bit more complicated. This might work for you:
    perl -ne '
    chomp;
    print "
    " if $n++ != 0;
    print;
    ' file.txt >newfile.txt
    You can use cat -e to see which lines have newlines, and you should see that the last line does not have a newline, but all the others still do.
    I guess if you really did mean to remove all newline characters and replace them with a space, except for the last line, then a modification of the above perl script would do that:
    perl -ne '
    chomp;
    print " " if $n++ != 0;
    print;
    ' file.txt >newfile.txt
    Am I even close to understanding what you are asking for?

  • Pick last 2 char of a field using rule file

    Hi
    I may be missing out anything but i need some help on this.
    I have column with city and state : city<space>State
    the state is 2 character while city name is of varied length starting from two to ten characters.
    Now i need to pick up last two characters of state using rule file.
    example of data:
    Glendale WI
    NA NJ
    New York NY

    Check this i guess this is answered by one the Oracle Guru
    Pick last 2 char of a field using rule file
    Thanks,
    KKT

  • How do i get the last 4 chars

    String FileE = myFile.getName();
    This gives me a file name but how do I a reverse trim and get the last 4 chars??

    Hi
    What are you trying to achieve here, why are you pulling a file into a String Buffer ?
    fileName.getName() will output a string, you can use the following statement to get the last four characters of the filename
    Here is an example
    String fileName = "testfile";
    String lastFourChars = fileName.substring(fileName.length()-4);
    This will give you the last four characters of the filename.
    But if you are trying to get the extension of the file
    Do this
    String extension = fileName.substring(fileName.lastIndexOf("."));
    Thanks
    Swaraj
    Thanks
    Swaraj

  • Remove last selection for parameters

    Hello expert,
    I have a webi report with multiple parameter inherited from store procedure on which universe is built up. how can I remove last select variant for all parameters ? I mean for every running, I want to select parameters from scratch. but currently in my report, parameters display last selection.
    Many Thanks,

    Hello,
    I believe if you go into the universe and right click on the stored procedure, it should give you an edit option. Then you should be able to select the parameter and change it to "Prompt for a value" or something like that. There are probably some other posts regarding how to do this. I am not sure I have it all correct since I don't have BO up right now, but pretty sure I have done it before.
    Thanks

  • Remove Last part

    i have this data
    ELECT  [item_id]  ,[f2] from [Regions]
    1. ُEgypt
    1.1. Cairo
    1.1.21. New Cairo
    i want to remove last part 
    like in Egypt remove 1.
    and on Cairo remove  last 1.
    and on New Cairo last 21.

    Try:
    DECLARE @City TABLE ( CityName varchar(100));
    INSERT @City VALUES
    ('1. Egypt'),
    ('1.1. Cairo'),
    ('1.1.21. New Cairo'),
    ('1.1.21.5. Alexandria')
    -- SELECT STUFF('abcdef', 2, 3, 'ijklmn');
    SELECT
    CityName, RenumberedCityName=
    LTRIM(STUFF(REVERSE(SUBSTRING(SUBSTRING(REVERSE(CityName), CHARINDEX('.', REVERSE(CityName),1)+1,LEN(CityName))+'.',
    CHARINDEX('.',SUBSTRING(REVERSE(CityName), CHARINDEX('.', REVERSE(CityName),1)+1,LEN(CityName))+'.'),len(CityName))),1,1,'')+SPACE(1)+
    REVERSE(LTRIM(RTRIM(LEFT (REVERSE(CityName), CHARINDEX('.', REVERSE(CityName),1)-1)))))
    FROM @City WHERE CHARINDEX('.',CityName) > 0;
    CityName RenumberedCityName
    1. Egypt Egypt
    1.1. Cairo 1. Cairo
    1.1.21. New Cairo 1.1. New Cairo
    1.1.21.5. Alexandria 1.1.21. Alexandria
    -- USING hierarchyid method
    SELECT
    CityName, RenumberedCityName=
    LTRIM(REPLACE(STUFF(CONVERT(hierarchyid,'/'+REPLACE(LEFT(CityName, CHARINDEX(' ', CityName)-1),'.','/')).GetAncestor(1).ToString(),1,1,''),'/','.')
    +SPACE(1)+REVERSE(LTRIM(RTRIM(LEFT (REVERSE(CityName), CHARINDEX('.', REVERSE(CityName),1)-1)))))
    FROM @City WHERE CHARINDEX('.',CityName) > 0;
    CityName RenumberedCityName
    1. Egypt Egypt
    1.1. Cairo 1. Cairo
    1.1.21. New Cairo 1.1. New Cairo
    1.1.21.5. Alexandria 1.1.21. Alexandria
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Remove last 4 digits

    Hi all,
    I want to remove last 4 digits from my numerical no. how can i do this?
    Plz help me.

    hi
    good
    w_level_03 = strlen( W_STRING ).
    lv_offset = w_level_03 - 4.
    w_string2 = w_string +(lv_offset).
    or
    w_string2 = w_string +0(lv_offset).
    Eg:-
    str = "testing1234".
    int offset = strlen( str ) - 4.
    str = str+0(offset).
    thanks
    mrutyun^

  • How to take last 5 char from a string

    Hi All
    I have a requirement,
    base on some comp i have to populate another field.
    in this case i have compare last 3 char of a string 
    example if total string say asasdffrx i have to take last three char here it is frx.
    always i have to last 3 char.
    i can use +6(3) but it wont work every time because string lenght is not fix for all vaue.
    thanks

    Hi,
    A.H.P sample is ok but insert additional check for strigs shorter than 3 (to avoid negative offset):
    data : n TYPE I.
    n = STRLEN( zfield ) - 3.
    if n >= 0.
    result = zfield+n(3).
    else.
    result = zfield.
    endif.
    Krzys

  • How to remove last char in a string by space

    I have to implement backspace application(remove a last char in a string , when we pressed a button).
    for ex: I enter the no
    1234
    instead of 1236
    So when i press a button on the JWindow... it should display
    123
    so that i can enter 6 now.
    I tried to display the string "123 " instead over "1234" but it is not working when the no background is specified. but works fine when a background color is specified.
    The string is displayed as
    Graphics2D g = (Graphics2D)window.getGraphics();
    AttributedString as = new AttributedString(string, map);
    g.drawString(as.getIterator(),x,y);
    In the map, the background is set to NO_BACKGROUND.
    Thanks and regards

    Deja vu. I saw this kind of post before, and I'm sure
    it was today.http://forum.java.sun.com/thread.jspa?threadID=588110&tstart=0
    Here it is.

  • Remove last char of string

    Hi Guys
    How can I remove the last char of a String ?

    With [the substring method|http://java.sun.com/javase/6/docs/api/java/lang/String.html#substring(int,%20int)] .

  • Remove last char

    Ok i am trying to make just a simple calculator program for a class. I am trying to get the backspace button to work. How would i delete the last char in the string.

    use a substring, the last char. will be:
    myString.length
    that will give you the length and from that you know what the last char. is

  • Remove First/Last N chars from file names?

    I have many files in one folder where the actual name of the file is preceeded by a few characters, and other files in another folder where the actual name of the file is followed by a few characters.  In Windows I could create a batch file in the directory, then when I run the file all other files in its directory are shortened by N characters from either the beginning or the end of the name, depending on what I wrote.
    Is it possible to do such a thing in AppleScript?  If so, would someone please point me to a resource or give me an example?  Thank you very much in advance.

    Hi,
    Avai wrote:
    Is it possible to do such a thing in AppleScript?  If so, would someone please point me to a resource or give me an example?
    Yes, it's possible.
    Here a example
    set nCharacters to 4
    set theFolder to choose folder
    display dialog "remove characters in name :" buttons {"Cancel", "End", "Beginning"} cancel button "Cancel"
    set btn to button returned of the result
    tell application "Finder"
      repeat with thisFile in (get document files in theFolder)
      try
      tell thisFile to set name to my cutChars(name, btn, nCharacters)
      end try
      end repeat
    end tell
    on cutChars(t, b, n)
      if b is "End" then
      return text 1 thru -(n + 1) of t
      else
      return text (n + 1) thru -1 of t
      end if
    end cutChars

  • How to replace or remove last 500 bytes of a file without rewriting all the file?

    Hi everyone,
    Usually I only ask for help when I can't find a solution for several days or weeks... And guess what? That just happen!
    So, this is what i am trying to do:
    I have a program to ZIP folder and protect them with password, then it encrypts the zip file.
    That it's working fine, until the user forgets his password.
    So, what I want to do is give the user a Recovery Password option for each ZIP file created. I can't use the Windows Registry because the idea is to be able to recover the password in any computer.So i came up with an idea...
    In simple terms, this will work like this:
    0 - Choose folder to ZIP
    1 - Ask user for recover details (date of birth, email etc)
    2 - ZIP folder with password
    3 - Encrypt ZIP file
    4 - Encrypt recover details and convert it to HEX
    5 - Add recover details (in HEX) to the end of the ZIP file (last bytes)
    6 - Add "5265636F76657244657461696C73" which is the text "RecoverDetails" in HEX
    7 - Add "504B0506000000000000000000000000000000000000" this is the final bytes of a ZIP file and will make the Operating System think that is a ZIP file (i know that will give an error when we try to open it.. the ideia is to change the
    extension later and use my software to do all the work to access this ZIP/folder again)
    So, explaining what it's here, I want to say that I managed how to do all of this so far. The point number 6 will help us to determine where the recover details are in the file, or if they actually exist because user can choose not to use them.
    In order to unlock this ZIP and extract it's contents, I need to reverse what I've done. That means, that  need to read only the last 500 bytes (or less if the file is smaller) of the ZIP and remove those extra bytes I added so the program can check
    if the user is inputing a correct password, and if so decrypt contents and extract them.
    But, if the user insert a wrong password I need to re-add those bytes with the recover details again to the ZIP file.
    The second thing is, if the user forgets his password and asks to recover it, a form will be shown asking to insert the recover detail (date of birth, email etc), so we need to reed the last 500 bytes of the ZIP, find the bytes in number 6 and remove the
    bytes before number 6, remove bytes in number 6 and number 7, and we will have the recover details to match against the user details input.
    I have all done so far with the locking process. But i need help with the unlocking.
    I am not sure if it's possible, but this what i am looking for:
    Read last 500 bytes of a file, remove the bytes with recover details and save the file. Without reading the whole file, because if we have a 1GB file that will take a very long time. Also, i don't want to "waste" hard drive space creating a new
    clone file with 1GB and then delete the original.
    And then add them back "in case user fails the password" which should be exactly the same.
    This sounds a bit confusing I know, even to me, I am writing and trying to explain this the better I can.. Also my English is not the best..
    Here it goes some code to better understanding:
    'READ LAST 500 BYTES OF ZIP FILE TO CHECK IF IT CONTAINS RECOVER DETAILS
    Dim oFileStream As New FileStream(TextBox_ZIP_to_Protect.Text & ".zip", FileMode.Open, FileAccess.Read)
    Dim oBinaryReader As New BinaryReader(oFileStream)
    Dim lBytes As Long = oFileStream.Length
    oBinaryReader.BaseStream.Position = lBytes - 500
    Dim fileData As Byte() = oBinaryReader.ReadBytes(500)
    oBinaryReader.Close()
    oFileStream.Close()
    Dim txtTemp As New System.Text.StringBuilder()
    For Each myByte As Byte In fileData
    txtTemp.Append(myByte.ToString("X2"))
    Next
    Dim RecoveryDetailsPass_Holder = txtTemp.ToString()
    'Dim Temp_2 = txtTemp.ToString()
    'RichTextBox1.Text = txtTemp.ToString()
    If txtTemp.ToString.Contains("505245434F47414653") Then
    'we have password recovery details(the numbers mean RecoverDetails in HEX)
    'next we will get rid of everything before and after of string "cut_at"
    Dim mystr As String = RecoveryDetailsPass_Holder 'RichTextBox1.Text
    Dim cut_at As String = "505245434F47414653"
    Dim x As Integer = InStr(mystr, cut_at)
    ' Dim string_before As String = mystr.Substring(0, x - 1)
    Dim string_after As String = mystr.Substring(x + cut_at.Length - 1)
    RecoveryDetailsPass_Holder = RecoveryDetailsPass_Holder.Replace(string_after.ToString, "")
    RecoveryDetailsPass_Holder = RecoveryDetailsPass_Holder.Replace("505245434F47414653", "") ' this is RecoverDetails in HEX
    RecoveryDetailsPass_Holder = RecoveryDetailsPass_Holder.Replace("504B0506000000000000000000000000000000000000", "") ' this is the bytes of an empty zip file
    'AT THIS POINT WE HAVE ONLY THE RECOVER PASSWORD DETAILS (date of birth, email etc) IN THE VARIABLE "RecoveryDetailsPass_Holder"
    '////////////////////////////////////////////////////// TO DEBUG
    'MsgBox(string_after.ToString & "505245434F47414653")
    'InputBox("", "", string_after.ToString)
    '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ TO DEBUG
    'Temp_2 = Temp_2.Replace(RecoveryDetailsPass_Holder.ToString, "")
    Now that we have the recover details, we need to remove them from ZIP in order to the software try to unzip it with the password provided by the user on the GUI.
    If the user needs to recover the password we have the details already in RecoveryDetailsPass_Holder variable and just need to match them against user input details.
    If the user fails, we need to put the RecoveryDetailsPass_Holder back on the file.
    Any question just ask, it's a bit trick to explain i think, but please ask.
    Anyone know how to do this?
    Many thanks in advanced.
    Nothing is impossible!
    @ Portugal
    Vote if it's helpfull :)

    @ ALL
    Thank you very much for you help. I know that if I'm "playing" with bytes you should assume that I know a lot of VB.net, but I don't know that much unfortunately. I am not a beginner but I am still very fresh and I probably do stuff that work but
    probably not in the best way...
    Anyway, I will explain the idea of this little software I'm making. Once I wanted to create a program to protect folders with password, and I came up with something to change folder permissions to lock access to them, and that actually worked fine and quickly.
    However, I managed how to "crack" the protection by going to folder properties, security tab and then give permissions back to my username. So that, to me, wasn't a safer system to protect folders, also I want the ability to use passwords. So I search
    and search online for a way to do it, and someone replied (to someone with the same question as me) that the best option would be to create a zip with all contents of the folder, with password and then change the extension from .zip to .whatever and register
    the new extension .whatever on the Windows Registry, so that file will have an icon and open with my software.
    So I did...The program zips everything, change the extension and I added the encryption to avoid people changing the extension to ZIP or trying to open with 7-Zip or similar and be able to see the protected files names in the .zip/.whatever
    Answering to all of you now:
    @Armi
    "System.IO.FileStream.SetLength"
    I know I tried that but I erased the code because it didn't work for some reason, I don't remember why sorry, was long time before I created this post.
    The last code I was trying to use was this:
    ' Set the stream position to the desired location of the stream.
    Dim fileStream As IO.FileStream = _
    New IO.FileStream(TextBox_ZIP_to_Protect.Text & ".zip", IO.FileMode.Append)
    Try
    ' Set the stream (OFFSET) position to the desired location of the stream.
    fileStream.Seek(210, IO.SeekOrigin.Current)
    Dim Bytes_do_ZE As Byte() = HexStringToByteArray(Temp_2.ToString)
    'Write Characters ASCII
    For Each Byte_Do_Zeca As Byte In Bytes_do_ZE
    fileStream.WriteByte(Byte_Do_Zeca)
    Next
    Finally
    fileStream.Close()
    End Try
    and we need this:
    Private Shared Function HexStringToByteArray(ByRef strInput As String) As Byte()
    Dim length As Integer
    Dim bOutput As Byte()
    Dim c(1) As Integer
    length = strInput.Length / 2
    ReDim bOutput(length - 1)
    For i As Integer = 0 To (length - 1)
    For j As Integer = 0 To 1
    c(j) = Asc(strInput.Chars(i * 2 + j))
    If ((c(j) >= Asc("0")) And (c(j) <= Asc("9"))) Then
    c(j) = c(j) - Asc("0")
    ElseIf ((c(j) >= Asc("A")) And (c(j) <= Asc("F"))) Then
    c(j) = c(j) - Asc("A") + &HA
    ElseIf ((c(j) >= Asc("a")) And (c(j) <= Asc("f"))) Then
    c(j) = c(j) - Asc("a") + &HA
    End If
    Next j
    bOutput(i) = (c(0) * &H10 + c(1))
    Next i
    Return (bOutput)
    End Function
    That code, as I understand, is to search for the OFFSET of the bytes in the file and start to write from there... That OFFSET should be the beginning of the 500 bytes read on the code before. I got the OFFSET position "210" reading the file with
    the HEX editor "HxD - Hexeditor v1.7.7.0" but using the OFFSET won't work because every file, password, recover details and so on, are different and so the file size, changing the OFFSET I
    think.
    @Reed Kimble
    Does that sound like something which might work for you?
    Thanks for your help. That might be some solution, however it seams a bit of the same problem where we need to read the bytes again to get the recover details. But, as I said in this post, because this is meant to password protect folders, do you think that
    will apply as well?
    @Crazypennie
    Thanks for your reply.
    All this appears really weak. The user has your application since he need it to open the file .... and the code in the application contain the code to read the file without knowing the password. Therefore anyone can read your code and retrieve the
    data without the password ... if he knows VB.
    The application can only open the file if the user didn't use a password to protect the file. Because the file is encrypted and needs to be unencrypted first.
    When the application tries to open/read the file, will need to decrypt it first and then check for a password and do the validation. Also the application is with the code masked/protected which i think it might not be easy for reverse engineering.
    - You need to use a web server and a symmetric key encryption
    This a good idea, besides I don't know how to implement it. However the idea is to be able to:
    1 - Protect a folder anywhere in any Windows computer (portable app)
    2 - Recover password details (security question) in any computer, online and offline
    And I think we need a computer always connected to the Internet to use that method, right?
    @ Mr. Monkeyboy
    Thank you very much for your effort.
    I just wanted to let you know that the zip method you are using is no longer supported.
    I didn't actually knew that. Thanks for letting me know.
    Do you require the compressed encrypted files to actually be Zip files or could they just be compressed files that have nothing to do with Zip?
    No, it doesn't need to be a .zip extension. I am actually using my own extension. It starts as a Zip but then I changed to my own extension which I have registered on the Windows Registry.
    @ ALL
    Thanks again to all for trying and spending time helping me.
    By the way, I might not be able to answer or try any code during the weekend... It's easter break and family is around. Have a nice easter everyone. :)
    Nothing is impossible! Imagination is the limit!

Maybe you are looking for

  • IPod Touch is not recognized by Windows Computer or iTunes

    All the USB ports are fine and the cable work perfectly. When I plug in my Ipod it shows that its charging but the computers dont do anything. I checked devices and even fiddled with some third party softwares that might be blocking it but nothing is

  • Can't send PIX to my AOL address

    Hello!  I have texting and internet on my cell phone.  I can't seem to send Pix to my AOL account.  The phone indicates the message/pic was successfully sent, but it never reaches it's destination.  Any ideas or suggestions?   Thank you!  Amber

  • JPA and embedded objects

    I am try to figure out the best way to reuse the same @Embeddable class in multiple Entity Beans (EJB 3). I am mapping some legacy data where an address is used in multiple tables. The problem is that the address is not composed of a standard set of

  • HT4864 how do i get folders i have created on my mac to sync through iCloud onto an iPad?

    how do i get folders i have created on my mac to sync through iCloud onto an iPad?

  • Zoom q2hd

    Hi everybody! I just bought an audio/video recorder, Zoom Q2HD. I'm using it as an external USB mic, but there is always a lot of noise, and I don't know why. Anyone can help me? I work with a MacBook 13'' from 2012. Thanks!