Creating multiple lines under a header - SAP - Fredodo - 12-14-2012
Sorry for the duplication - was originally created in General area:
Dear all,
i will like an assistance on how to get around this problem:
1. I created a new Characteristic "QTWTEST2"
2. I added a Char value "QTW002"(can add more than one value) under the header
3. Some characteristis have more that one Char value in my data table
4. How can i let qtp recognise the single/multiple Char. values from the data table.
I am attaching the composition of my data table and qtp codes
I will be glad of any input.
Code: SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiEdit("Characteristic").Set "QTWTEST2"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiButton("Create").Click
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiEdit("Description").Set "QTP characteristics test2"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiComboBox("Data Type").SetFocus
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiComboBox("Data Type").Select "Character Format"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiEdit("Number of Chars").Set "6"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTabStrip("TABSTRIP1").Select "Descriptions"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTabStrip("TABSTRIP1").Select "Values"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTable("Allowed Values").SetCellData 1,"Char. Value","QTW002"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTable("Allowed Values").SetCellData 1,"Description","TEST2"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTable("Allowed Values").SelectCell 1,"Description"
Character name Char. Value Description
1 QTPXTEST1 QTX001 TEST1
2 QTWTEST2 QTW002 TEST2
3 QTWTEST2 QTW003 TEST3
4 QTPBRUN1 QTB001 RUN1
5 QTPBRUN1 QTB002 RUN2
6 QTPBRUN1 QTB003 RUN3
Line 1 - 1 char. value
Line 2/3 - 2 char value
Line 4,5,6 - 3 char value
RE: Creating multiple lines under a header - SAP - Fredodo - 12-18-2012
Does anyone have an idea on how to solve this problem? I guess I can insert a "IF, THEN, ELSE". But where and on what reference?
RE: Creating multiple lines under a header - SAP - Ankesh - 12-18-2012
pass mulitple values in datatable separated by comma(,) and then split it in your code. Insert those values in the SAPGUiTable.
RE: Creating multiple lines under a header - SAP - Fredodo - 12-18-2012
Thank you Ankesh,
I am new to this but willing to learn. Please give me some guidiance....an example i can build on. Sorry for taking up some of your valuable time.
RE: Creating multiple lines under a header - SAP - Ankesh - 12-19-2012
Please correct me if i have misunderstood your requirement.
All you want to do is pass multiple values in one column and then use it in your script.
Say, datatable has a column named "InputCharacters" which has values as QTW002,QTW003,QTW004
Please note i have separated the values by comma.
Now the code goes as
Code: strCharacters=Datatable("InputCharacters",dtGlobalSheet)'get the datatable values
'Now you need to split the values
arrCharacters=Split(strCharacters,".")'i am splitting on comma as the values were separated by comma
arrCharacters will have all the values now.
to get the values, you can use the index. Let us consider our example
arrCharacters(0) will give QTW002
arrCharacters(1) will give QTW003
arrCharacters(2) will give QTW004
you can use these values to set in the table as
Code: For i=0 to Ubound(arrCharacters)
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTable("Allowed Values").SetCellData i+1,"Char. Value",arrCharacters(i)
Next
Note: You can always modify the code to fit in ur requirement.
Regards,
Ankesh
RE: Creating multiple lines under a header - SAP - Fredodo - 12-19-2012
Ankesh,
big thanks to you and the web......exactly what i was trying to do. According to your instructions, I made the following and will like to hear from you if it is ok.
Please see also the attached file:
‘my final code might look like this (2 coloms where multiple values may exist - Char. Value and Description)
Code: strCharacters=Datatable("InputCharacters",dtGlobalSheet)'get the datatable values
strDescription=Datatable("InputDescription",dtGlobalSheet)'get the datatable values
arrCharacters=Split(strCharacters,".")
arrDescription=Split(strDescription,".")
For i=0 to Ubound(arrCharacters)
For i=0 to Ubound(arrDescription)
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiEdit("Characteristic").Set "QTWTEST2"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiButton("Create").Click
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiEdit("Description").Set "QTP characteristics test2"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiComboBox("Data Type").SetFocus
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiComboBox("Data Type").Select "Character Format"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiEdit("Number of Chars").Set "6"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTabStrip("TABSTRIP1").Select "Descriptions"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTabStrip("TABSTRIP1").Select "Values"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTable("Allowed Values").SetCellData i+1,"Char. Value",arrCharacters(i)
next
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTable("Allowed Values").SetCellData i+1,"Description","arrDescription(i)"
next
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTable("Allowed Values").SelectCell 1,"Description"
Is this correct?
RE: Creating multiple lines under a header - SAP - Fredodo - 12-28-2012
Hello Ankesh,
still need a help on this. I ran this script below and the result is halfway, please see the attachment.
Please help review my script:
Code: strCharacters=Datatable("Characters",dtGlobalSheet)'get the datatable values
strDescription=Datatable("Description",dtGlobalSheet)'get the datatable values
arrCharacters=Split(strCharacters,",")
arrDescription=Split(strDescription,",")
For i=0 to Ubound(arrCharacters)
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiEdit("Characteristic").Set "QTWTEST2"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiButton("Create").Click
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiEdit("Description").Set "QTP characteristics test2"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiComboBox("Data Type").SetFocus
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiComboBox("Data Type").Select "Character Format"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiEdit("Number of Chars").Set "6"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTabStrip("TABSTRIP1").Select "Descriptions"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTabStrip("TABSTRIP1").Select "Values"
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTable("Allowed Values").SetCellData i+2, "Char. Value",arrCharacters(i)
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTable("Allowed Values").SetCellData i+2, "Description",arrDescription(i)
next
RE: Creating multiple lines under a header - SAP - Saleel Prabhu - 01-02-2013
Use For loop only for the last last 2 statements rather than entire code.
Code: SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTabStrip("TABSTRIP1").Select "Values"
For i=0 to UBound(arrCharacters)
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTable("Allowed Values").SetCellData i+2, "Char. Value",arrCharacters(i)
SAPGuiSession("Session").SAPGuiWindow("Characteristics").SAPGuiTable("Allowed Values").SetCellData i+2, "Description",arrDescription(i)
Next
Regards,
Saleel
|