SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 9 of 9
  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    QTP Split Function

    xxxxx Communication Systems, Inc.


    ================================================
    ISO converted to Sales Orders
    ================================================
    ISO Number Order Number
    ---------------- --------------------
    46182 : 1 1015746
    46183 : 1 1015747
    ==================================================

    Hi,

    Could you please help me on the above data. I have to fetch Order number associated to each ISO number.

    I have capture the entire data in one variable using getroproperty("innertext").

    I am tried using the split function.
    var1 = Browser("xxxxx").pAGE("XXXXX").Webelement("xxxxx") .GetRoproperty("innertext")
    dat = Split(var1, ": 1")
    dat(0)
    dat(1) =
    Var2 = dat(1)
    var2 = Replace(var2, " " ,"")
    var2 = Left(dat(1), 7)
    Now I got the sales order number(1015746)
    var3 = Replace(dat(2) ,"=", "")

    var3 I have got the sales order number (1015747).


    As of now I have 2 rows of data in the input sheet, but the problem,If i add one more row in the input data sheet one more row will be added.This time I have to amend the code.Could you pls help on this.



    Could you please help the logic in QTP(10.0)

  2. #2
    Member
    Join Date
    Aug 2011
    Location
    Bangalore, India
    Posts
    57
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split Function

    does it come in a table? If yes, you can get the row count loop it. Logic would be same.

  3. #3
    Member
    Join Date
    Feb 2008
    Posts
    83
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split Function

    If the only way to get the data is to use innertext and get everything as a string there are a few ways you could do it

    a) split the text on newline and loop your way the rows with order numbers.
    and then you can split like this
    strText= "46182 : 1 1015746"
    strItem = split(strText," ")(3)
    print strItem

    b) To get all orders you might aswell be able to use a little nested split. But that could of course result in out of bounds

    split(split(split(strAllText,"---------------- --------------------")(1),"===")(0))

  4. #4
    Advanced Member venu.adhikesevan's Avatar
    Join Date
    Jun 2010
    Posts
    517
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0

    Re: QTP Split Function

    [ QUOTE ]
    If i add one more row in the input data sheet one more row will be added

    [/ QUOTE ] Please give more information to help you with the correct solution.

    Count the Lines and store it in variable and call the splited action.
    <font class="small">Code:</font><hr /><pre>
    vcnt = No of Rows
    For Itr = 1 to vcnt
    call SplitAction
    Next
    </pre><hr />
    Venu
    Today is always better than Tomorrow
    My Blog
    My LinkedIn

  5. #5
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split Function

    Hi,
    If Browser("Browser").Page("Page").WebElement("Brocad e Communication").Exist(2)Then
    v_Ordernum = Browser("Browser").Page("Page").WebElement("Brocad e Communication").GetROProperty("innertext")
    Msgbox v_Ordernum
    Arr = split(v_Ordernum,": 1")
    Salesorder1 = Replace(Arr(1)," " ,"")
    Salesorder1 = Left(Salesorder1,7)
    Datatable.SetCurrentRow(1)
    Datatable.Value("SALES_ORDER_NUM","Sheet1") = Trim(SalesOrder1)
    SalesOrder2 = Replace(Arr(2),"=","")
    Datatable.SetCurrentRow(2)
    Datatable.Value("SALES_ORDER_NUM","Sheet1") = Trim(SalesOrder2)
    End If

    Thanks for providing the updates. It would be great if you could advise some more logic using split the text on newline and loop your way the rows with order numbers. I am new to this qtp. Please help me. The above code will work only two rows of data. If I input another two rows in the data sheet. The values are changed.

  6. #6
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split Function

    Hi
    Thanks for the reply.

    The whole data is stored into one string variable

  7. #7
    Member
    Join Date
    Feb 2012
    Posts
    74
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split Function

    This function will fetch you all the order numbers .Note I tried it with a text file and it worked.


    v_Ordernum = Browser("Browser").Page("Page").WebElement("Brocad e Communication").GetROProperty("innertext")

    Set myRegExp = New RegExp
    myRegExp.IgnoreCase = True
    myRegExp.Global = True
    myRegExp.Pattern = ".*\:.*"
    Set myMatches = myRegExp.Execute(v_Ordernum)
    For Each myMatch in myMatches
    sOrderID_UnProcessed = myMatch.Value
    'Here onwards write the logic to split and get each order number.
    'You can either store this ordernumber in a text file or an array and use it !
    Next

    Cheers,
    Pai
    If you do find solution to a problem - have a bud & re-visit !

  8. #8
    Member
    Join Date
    Jan 2008
    Posts
    336
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split Function

    If you are sure that "1" precedes with the OrderNo, use
    str="46182 : 1 1015746"
    arr=split(str," : 1 ")
    msgbox arr(1)


    If it varies, then use below:
    arr=split(str,":")
    str=replace(arr(1)," ","")
    msgbox right(str,len(str)-1)

  9. #9
    Advanced Member venu.adhikesevan's Avatar
    Join Date
    Jun 2010
    Posts
    517
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0

    Re: QTP Split Function

    If Browser("Browser").Page("Page").WebElement("Brocad e Communication").Exist(2)Then
    v_Ordernum = Browser("Browser").Page("Page").WebElement("Brocad e Communication").GetROProperty("innertext")
    Msgbox v_Ordernum
    Arr = split(v_Ordernum,Vbcrlf)
    For I = 1 to Ubound(Arr)
    Datatable.SetCurrentRow(I)
    Datatable.Value("SALES_ORDER_NUM","Sheet1") = Trim(Arr(I-1))
    Next
    End If

    'Please update the split function as per your requirement.
    You can find all the simple function at FAQ Section in 1st Page.
    Venu
    Today is always better than Tomorrow
    My Blog
    My LinkedIn

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 8.82%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 10:49 PM.

Copyright BetaSoft Inc.