Micro Focus QTP (UFT) Forums
QTP SAPWindows Leading Zeros - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: QTP SAPWindows Leading Zeros (/Thread-QTP-SAPWindows-Leading-Zeros)



QTP SAPWindows Leading Zeros - bodd - 04-17-2008

Using QTP 8.2 to record SAP Windows on WinXP SP2 for creation of testing data:

In creating scripts for SAP-MM, the Purchase Req is created and the number written to the DataTable. Same script then calls up the Purchase Req number from the DataTable to create a Purchase Order. Problem is, the script is writing leading zeros on the PReq number, which when read by the script as a node in the SAP TableTreeControl, is looking for Node 0010015866 instead of 10015866, creating a failure error. I have tried every kind of number formatting both inside the QTP DataTable AND outside QTP modifying the Default using Excel. How can I get QTP to not write/read the leading zeros?

Expert View Writing to DataTable:
Code:
SAPGuiSession("Session").SAPGuiWindow("Create Purchase Requisition").SAPGuiStatusBar("StatusBar").Output CheckPoint("StatusBar")
0010015866 is written

Code:
Reading from DataTable into an SAP input field:
SAPGuiSession("Session").SAPGuiWindow("Purchase requisitions").SAPGuiEdit("Purchase requisition number").Set DataTable("Purch_Req_Num", dtGlobalSheet)
Reads 0010015866, SAP ignores the leading zeros, finds the correct PReq, creates it as the one item in the TableTree as 10015866

Selecting the Node:
Code:
SAPGuiSession("Session").SAPGuiWindow("Create Purchase Order").SAPGuiTree("TableTreeControl").SelectNode DataTable("Purch_Req_Num", dtGlobalSheet)
Looks for 0010015866, cannot find it, Failure error.

(attachment: Keyword view, Working write, QTP error)
Thanks for looking/help. -Bodd


RE: QTP SAPWindows Leading Zeros - niranjan - 04-17-2008

There are two ways I can think of...
1) Instead of using Output Value, try using GetROProperty.

2) Use the following :
' Before selecting the node,
Code:
sNum = DataTable("Purch_Req_Num", dtGlobalSheet)
sNumWithoutZero = Right(sNum, Len(sNum) - 0)
SAPGuiSession("Session").SAPGuiWindow("Create Purchase Order").SAPGuiTree("TableTreeControl").SelectNode sNumWithoutZero

Let me know if it doesnt work out..


RE: QTP SAPWindows Leading Zeros - bodd - 04-18-2008

Thanks Niranjan.
Neither method worked, so I added a column to the DataTable using the =ABS() formula. So now it outputs the Purchase Request number with the leading zeros, and then reads from the next column with the Absolute value of that number -zeros removed- to create the Purchase Order. -Bodd

UPDATE: I found that you can also Hide the output column in the Data Table using Excel, the scripts work fine and the user will then only see the numbers without leading zeros.


RE: QTP SAPWindows Leading Zeros - niranjan - 04-18-2008

Cool.
I am glad your problem is solved.


RE: QTP SAPWindows Leading Zeros - RaghavendraRaichur - 08-20-2008

Hi Guys,
I just joined this community.
I do working on QTP 9.2. on both SAP & .Net applications.

Just for your refernce use CInt(). This will solve your problem.


Regards
Raghu