Need to check whether first  two characters of a string is Alphabets or not

Hi,
Need to check whether first two characters of a string is alphabet or not.
Lets say for Ex,
String as 'DE123456' i need to check whether first  character is non-numeric and then second character as non numeric.
kindly help me on this.
                IF length(trim(p_parserec(31))) = 22 AND p_parserec(31) LIKE 'DE%'  THEN
                    AUFTRAGGEBERKONTONR := trim(p_parserec(31)) ;
                 ELSIF  (length(trim(p_parserec(31))) > 22 AND length(trim(p_parserec(31))) < 35)  AND p_parserec(31) NOT LIKE 'DE%'  THEN
                   AUFTRAGGEBERKONTONR := lpad(trim(p_parserec(31)), 34, 0) ;
                 ELSIF length(trim(p_parserec(31))) > 10 AND ascii(substr(p_parserec(31), 1, 2)) between 48 and 57 THEN
                   AUFTRAGGEBERKONTONR := lpad(trim(p_parserec(31)), 10, 0) ;
                 ELSE
                    p_errorcd   := sqlcode ;
                    p_errordata := sqlerrm ;
               END IF ;
Note : In the third else if condition the character should be greater than 10 and first 2 characters should not be alphabets.

Siva.V wrote:
Need to check whether first two characters of a string is alphabet or not.
To this requirement only regexp_like will work too! No need of some other string function!
Like:-
        -- in regexp_like last parameter shows to ignore case (optional).
SQL> with t as
  2  (select 'AB123456' as key from dual union all
  3  select 'CD234567' from dual union all
  4  select 'A1234567' from dual union all
  5  select 'A52H4341' from dual union all
  6  select 'Dk274341' from dual union all
  7  select 'DE234556' from dual)
  8  select key
  9  from t
10  where regexp_like(key,'^[A-Z]{2}','i') -- even '^[[:alpha:]]{2}' or '^\D{2}' pattern can be replaced for same result..
  11  /
KEY
AB123456
CD234567
Dk274341
DE234556
Thanks!

Similar Messages

  • I am trying to install windows 7 to my Macbook pro with bootcamp but every time I open bootcamp I am only able to check the first two boxes but not the third one saying "install or remove Windows 7", any solutions ?

    Hi, I am trying to install Windows on my MacBook Pro with bootcamp. Every time I open bootcamp I am only able to check the first two boxes but not the third one saying "install or remove Windows 7". I did this before using the same computer and the same hard drive so I am not sure why this is happening now but did´t happen then. Any solutions ?

    Was your Bootcamp info.plist manipulated to change any options?

  • We need to check whether the order is locked or not?

    I need to check whether the order is locked or not?
    I tried to use this RFC KAUF_ORDER_READ and passed Order no.
    I manually locked the order( using Tcode -IW32) but still Function module is not returning 'X' in FIELDS flg_locked and FLG_ENQUE of the structure E_KAUF.
    the FM should return 'X' in these fields.
    Please help.
    Coudl anybody suggest me how I can check using RFC/ Table fields etc that whether the order is locked or not?

    Hi Rohit,
    Try this code. Check the flag.
    Note : Order number should have left padding of Zero
    DATA : order_tab TYPE TABLE OF ord_pre,
           wa        TYPE ord_pre,
           flag      TYPE rc27x-flg_sel.
    wa-aufnr = '000004006789'. "Order number should have left padding of Zero
    APPEND wa TO order_tab.
    CALL FUNCTION 'CO_ZF_ORDER_READ'
    EXPORTING
       flg_dialog               = ' '
    *   FLG_ENQUEUE              = 'X'
    *   OBJECTS_IMP              = ' '
    *   EXPLODE_IMP              = ' '
    *   FLG_PROT_IMP             = ' '
    *   FLG_NO_EXTERNAL          = ' '
    *   FLG_NO_BANF              =
    *   FLG_CHECK_SIM            =
    *   IMPORT_MESSAGE_ID        =
    *   CHECK_STATUS_READ        = ' '
    *   FLG_NO_GOS               = ' '
    *   FLG_CALLED_TO_COPY       = ' '
    IMPORTING
       flg_enqueue_ok           = flag
    *   FLG_ESCAPE               =
      TABLES
    *   AUFNR_DEL_EXP            =
        aufnr_tab_imp            = order_tab
    EXCEPTIONS
       ORDER_NOT_FOUND          = 1
       RELEASE_NO_CHANGE        = 2
       OTHERS                   = 3
    IF sy-subrc = 0.
      WRITE flag. "If Flag is X order is not locked
    ENDIF.
    Regards
    Rajvansh
    Edited by: Rajvansh Ravi on Nov 27, 2008 12:33 PM

  • I need to add check whether 21 fields of a internal table are empty or not.

    Hello,
    I need to add check whether 21 fields of a internal table are empty or not.How can we write a code for the same wand what would be the correct syntax for it.
    I tried entering all the fields in the IF loop with AND condition but its giving syntax error.Perhaps this is because the lenght of the IF condition would be more than the allowed one.

    Hi,
    After the select quiery.
    If not itab is initial.
    Message 'Table is not empty'    type 'I'.
    Endif.
    Regards,
    Jagadish.

  • How can I pull info into a report using just the first two characters of that field?

    I am trying to pull a total cost based upon locations in a particular area(s). Can I get the formula to just do this based on the first two characters of that field?
    Here is what I have so far:
    if {PACKED.LOCATIONS.NEXT OPERATION} = ["xx"] THEN {Job.Total_Price}
    Packed locations is a table I'm pulling from and the column I want just the first two digits is the the Next operation. Once this meets the "xx" (whatever location) then give me the total price from the Job table.
    This works for one or two orders, but then blows up when I do 10 or so.

    Hi Steve, assuming that Next Operation is a string field...
    Create a new formula and place it in the field where you see the {Job.Total_Price} field (Detail or Group depending on your report) with the formula:
    whileprintingrecords;
    global numbervar TotalValue;
    if len({? Replace me}) <= len({PACKED.LOCATIONS.NEXT OPERATION}) then(
    if left(ucase({PACKED.LOCATIONS.NEXT OPERATION}),len({? Replace me})) = ucase({? Replace me}) then
    TotalValue := TotalValue + {Job.Total_Price}
    TotalValue;
    You can go ahead and suppress that field.
    Create a new formula to place where you want to view the summary using the formula:
    whileprintingrecords;
    global numbervar TotalValue;
    This method allows for a higher degree of flexibility and you can search for the first x characters of that field instead of only the first 2 characters

  • First two characters erversed! (see what I mean?...)

    On my MacBook Pro listed below I get this funny behavior: I go into a text field, or type in TextEdit (it makes no difference what) and sometimes, the first two characters I type get inverted, i.e. I want to type the word 'word' and, sure enough, I hit the keys in the right order: w-o-r-d, but when I look at my screen, I've managed to type 'owrd'. 'w' and 'o' have been entered into the buffer in the opposite order to what I typed.
    And yes, I've been observing this over a number of days prior to my posting. I touch type, and I'm very accurate. The problem doesn't manifest itself with other machines.
    Anyone else has observed something like it?
    Many thanks, as always.

    Hi Carolyn, thanks for the reply.
    I mustn't have put it clearly in the original post: it makes no difference if I'm editing text in TextEdit or another app. I've had the issue with pretty much every text-capable app in OS X.
    Unless, of course, I'm losing it, and I'm actually entering the characters in the wrong order. But I don't think so.
    Still, it's a peculiar issue to pin down, as it's definitely very hard to replicate. I mean, how do you 'replicate' potentially making a mistake?
    Here's a funny instance of it, from just earlier tonight (it's nearly midnight here in Greece):
    I was in Finder and wanted to quickly open a new Finder window to see how much free space I've got on the hard disk (at the bottom of the Finder window) and CMD-Tab to Safari and look at a page I had loaded. So the key sequence was: CMD-N, CMD-Tab. What I got was the opposite: OS X first switched over to Safari, and duly opened a new, blank Safari window instead.
    I had definitely pressed CMD-N before pressing CMD-N.

  • Is there a function to check a list of characters in a string?

    is there a function to check a list of characters in a string?

    You need to create a vi. Find attached a vi that you can use. In the vi, if the number of match occurrence is zero, that indicates no match otherwise it will return the number of matches in the supply string. The vi is a modified version of Search String and Replace - General
    Attachments:
    Search_String_and_Count_Match.vi ‏17 KB

  • Trim last two characters of a String

    Hi,
    I have a task to trim the last two characters of a string in a column and get the rest as output for comparison purpose.
    the length of column value is not fixed.
    For example
    I/p O/p
    India_1 India
    America_2 America
    I achieved the result using the below query:
    SELECT SUBSTR (TRIM ('India_1'), 1, LENGTH (TRIM ('India_1')) - 2) FROM DUAL;
    I have used the trim function to remove the leading and trailing spaces in the column value.
    Could somebody please let me know if there is a better way to get the result .. like in one shot query.
    Thanks,
    Pratik

    I have a task to trim the last two characters of a string in a column
    SQL> with t as (
    select 'India_1' str from dual union all
    select 'America_2' from dual
    select regexp_replace(str, '..$') str1 from t
    STR1        
    India       
    America     
    2 rows selected.

  • Need to Check whether the program is Active or not

    Is there any statement where i can check  whether the report program is Active or not.
    Using below statement i am  copying the entire Code in internal table it_source.Before copying in the source code in the  internal table  it_source.I need to check that program is Active or not if it is not active and i need to give a pop message and forceliy i need to Active it.
    read report wa_trdir-name into it_source.

    Hi Srini,
    i just checked the table REPOSRC for a program which was not activated, i got two entries for the program one as active and one as inactive ,as soon as i activated the program there was a single entry.
    so is it that we should check if we have any inactive entry in the table for the program?.
    Regards,
    gunjan

  • Reversing first two characters of a new line

    Hello all
    I have just been using Pages for the first time in a while and noticed a really odd behaviour. I thought I was making loads of typos but when observing closer, Pages was auto "correcting" for me.
    When typing on a new line, I I failed to capitalize, It would capitalise the first letter and reverse the first 2 character.
    So when trying to type "when", it became "hWen"
    If I remember to capitalise the first letter, I leaves it alone. When it does its thing, the "edit' menubar flashes blue to show it has done something and it does that immediately after i have typed the second character (eg the h in the above example)
    I thought it might be an autocorrection thing, but fix capitalisation and symbol and text substitution are both off.
    Never done this before and never had problems
    I was just about to write "Its confined to Pages (thought it might be a systemwide text expansion thing)" but now I note Keynote is doing it too!
    Any help or suggestions gratefully received.
    OS X 10.8.5, Pages 4.3, Keynote 5.3
    Cheers
    Rob

    Since nobody else has any ideas, I thought I'd at least comment, so that you don't feel totally ignored.
    I wouldn't be too quick to rule out "a systemwide text expansion thing" because I suspect that the iWork text handling is sufficiently different from other apps that it might react differently from other applications. Particularly if you have any third party "text expansion things."

  • To check whether there is any size mismatch between columns of two tables

    Hi,
    Here i got two tables T and M where i am going to migrate data from T to M. But before migrating i need to check whether all the data in source table fits into destination table columns. The datatypes of all columns in source table T is of Varchar2 only as it is a temp table.
    Ex :- Table 'T' (Source table) with columns
    T_Lat Varchar2(50);
    T_Amt Varchar2(50);
    T_Cat Varchar2(50);
    T_Vat Varchar2(50);
    Now I have another table 'M'(Destination Table) with columns
    M_Lat Varchar2(50);
    M_Amt varchar2(25);
    M_Cat date;
    M_Vat number;
    Now my task is I have to do a prevalidation of the data in 'T' that whether all the data in those columns will suit for the destination table columns respectively (to check whether there is any size mismatch). This check should be done dynamically.
    For suppose, in T_Amt(source column of T table) if text is abt 50 characters, it cant fit M_Amt(destination column of M table). In this case it should throw an error indicating that destination column size is less for the source column.
    Note:- There is no unique mapping column for these two tables and there are about 400 columns in the source table to be validate
    I think it can be done using arrays or plsql tables.
    Can any one help in this regard.

    >
    Now my task is I have to do a prevalidation of the data in 'T' that whether all the data in those columns will suit for the destination table columns respectively (to check whether there is any size mismatch). This check should be done dynamically.
    >
    Just because the source table T_Amt column is defined as 50 doesn't mean any of the data is really that long. So the data itself needs to be checked. That is just what a simple query can do.
    See my answer in this thread Posted: Jul 25, 2012 1:14 PM
    Re: Help in Execute Immediate - Invalid relational Operator
    Here is the modified sample query and results for a query of a clone of the EMP table with some modified data
    select count(*) cnt,
           -- job column
           sum(case when job is null then 1 else 0 end) job_nul,
           sum(case when job = 'SALESMAN' then 1 else 0 end) job_salesman,
           min(length(job)) job_minlength, max(length(job)) job_maxlength,
           min(job) job_min, max(job) job_max,
           -- hiredate colulmn
           sum(case when hiredate is null then 1 else 0 end) hiredate_nul,
           min(hiredate) hiredate_min,
           max(hiredate) hiredate_max
            from emp1
    CNT JOB_NUL JOB_SALESMAN JOB_MINLENGTH JOB_MAXLENGTH JOB_MIN JOB_MAX  HIREDATE_NUL HIREDATE_MIN HIREDATE_MAX
    14    2       4            5             9             ANALYST SALESMAN 0            9/28/0001    12/3/9999With one query and ONE pass thru the table I was able to get the COUNTs, the MIN and MAX values for each column and the MIN and MAX lengths of the VARCHAR2 columns.
    There are 14 total records, 2 where JOB is null, 4 where the JOB is SALESMAN. The MIN length of the JOB data is 5 and the MAX is 9.
    Look at the date values. The results tell me I have some problem data.
    The length data tells me if I try to put the JOB data into another table I need to define the length as at least 9 or it won't fit.
    For your use case you might find that all of the data in the T_Lat column is shorter than 26 and will actually fit into the M_Lat target table column.

  • Equipment Category - Need two characters

    Hi All,
    I have a requirement where in equipments variety is huge. If I use standard equipment categories then I can create only 26+10=36 equipment categories.
    I have requirement for equipment categories that might go beyond 36 numbers. And hence I need equipment category should have two characters.
    Please let me know if we can increase the equipment category length from 1 to 2.
    Sundar

    Hi Carlos/Pete,
    I know its odd requirement. As I told you this requirement is for multiple locations and different indstry and different products and our client is only one.
    Also I can use object types, etc. for it  and I may not require equipment categories more than 36 nos, but this was just thought if in case I require two characters category then wherther anyone came across such requirement or not?
    But it seems nobody had such huge requirement.....anyways thanks for your inputs.
    Sundar

  • How to check whether a user session is null or not

    Hi
    I am using Jdeveloper 11.1.2.2
    I have a use case of running some Junit test case, this is the problem I have :
    There are some Junit tests which are written for some VO's. While testing insert and update operation in Junit there is two mandatory columns Created by and Updated by to be entered for committing into the database.
    These values are taken from the UserName of the current UserSession .
    So for getting the these values for each user I thought of displaying a JPanel before the test is run, where the user enters the Username and password which is validated and the user is verified.
    First, I need to check whether there is a session present or not. For checking this, I wrote a createUserSession() and did like this inside it :
    if(fixture.getApplicationModule().getSession().getUserData().isEmpty())If so to show the Jpanel and get the user details and verify the user.
    But while running the test itself I found that the session is already present, now I just have to input the values based on who is the user.
    But Junit doesn't run the tests in the order in which the test are written. So I have to call this in all the test cases.
    The Question is :
    How can I check whether the session is already present or not, so that I don't have to ask the user every time while every test is running to enter the Username and Password ?
    Thanks,
    Nigel.
    Edited by: Nigel Thomas on Jul 30, 2012 10:26 AM

    Hi,
    wondering why don't you create test users and then automatically log them in as Jan Vervecken did on the threads I pointed you to. This way your test cases run without user interaction. To test if a session exists for a user, I would put a custom property into user data. If this property exists, the user session is an existing one. However, make sure the information you save into the user data survives passivation as otherwise the information you get out of this is not accurate. See: http://tompeez.wordpress.com/2011/07/08/jdev-always-test-your-app-with-applicationmodule-pooling-turned-off/
    Frank

  • How to remove first two headerlines while appending files

    Hi,
    Currently the requirement is client only needs the file name without any time stamp or counter. They do not want to overwrite the records.
    They need the csv file structure as:
    Customer
    Custnum,Custname
    123,ABC
    While I am using append, it is also appending the first two header lines.
    Can you please suggest how to append without headers.

    Hi Swapna
    One option is of course to have the flag in the source structure so that you can identify whether it is first run or not. But if there is no such flag in source structure then the only possible solution will be done
    based on a look up.
    You can perform the same in java mapping using a hash table which will be updated with the file name in its first run and in the next run you will check whether the file name exists in the has table or not.Depending on that you have to pass the header value.
    Next solution can be maintaining a table in ABAP and perform a RFC look up in message mapping.
    When the file arrives, its will check whether the name is already there in the table or not. If the file not exists, then it will insert the file name in the table and return true. Based on this you will pass the header names.
    When the next file will arrive with the same name , The look up will find that file has already present in the table so it will return false and no header information will be sent. Only data will be sent.

  • How to check whether the user has a certificate or not?

    Hi everyone.
    We're currently finishing a web project and the last step is to check whether users accessing the application have a valid certificate or not.
    Users with a valid certificate can access all the data. Users without any certificate installed on their browsers may still proceed, but they won't be able to see all data. Please note that the lack of a certificate doesn't mean an error - it's just another use case.
    Is there any way to check whether users have a certificate installed on their browsers?
    Thanks in advance.
    Edit: sorry, I forgot to post some tech details. We're using Struts 1.2 on a Tomcat 5 app server.
    Message was edited by:
    advaca

    I am not sure how Tomcat handles this, but you need to use two-way (mutual authentication) request but not enforce SSL between Tomcat and the client browser. This will make the browser prompt the user for the cert they want to send. Then you'll need to tackle the other part of your problem, getting the correct content displayed depending on whether the user sent a cert or not. I'm even less help there than I was on the first part of your question.
    So, yeah - good luck with that
    Lee

Maybe you are looking for