Tuesday, March 9, 2010

Descriptive Programming in QTP

Introduction:
This document demonstrates the usage of Descriptive programming in QTP 8.20. It also discusses situations where Descriptive programming can be used. Using Descriptive Programming automation scripts can be created even if the application has not been developed.
Descriptive Programming:
Whenever QTP records any action on any object of an application, it adds some description on how to recognize that object to a repository of objects called object repository. QTP cannot take action on an object until unless its object description is in the Object Repository. But descriptive programming provides a way to perform action on objects which are not in Object repository

Object Identification:

To identify an object during the play back of the scripts QTP stores some properties which helps QTP to uniquely identify the object on a page. Below screen shots shows an example Object repository:
When and Why to use Descriptive programming?

Below are some of the situations when Descriptive Programming can be considered useful:
1. The objects in the application are dynamic in nature and need special handling to identify the object. The best example would be of clicking a link which changes according to the user of the application, Ex. “Logout <>”.
2. When object repository is getting huge due to the no. of objects being added. If the size of Object repository increases too much then it decreases the performance of QTP while recognizing a object.
3. When you don’t want to use object repository at all. Well the first question would be why not Object repository? Consider the following scenario which would help understand why not Object repository

Scenario 1: Suppose we have a web application that has not been developed yet. Now QTP for recording the script and adding the objects to repository needs the application to be up, that would mean waiting for the application to be deployed before we can start of with making QTP scripts. But if we know the descriptions of the objects that will be created then we can still start off with the script writing for testing

Scenario 2: Suppose an application has 3 navigation buttons on each and every page. Let the buttons be “Cancel”, “Back” and “Next”. Now recording action on these buttons would add 3 objects per page in the repository. For a 10 page flow this would mean 30 objects which could have been represented just by using 3 objects. So instead of adding these 30 objects to the repository we can just write 3 descriptions for the object and use it on any page.

4. Modification to a test case is needed but the Object repository for the same is Read only or in shared mode i.e. changes may affect other scripts as well.
5. When you want to take action on similar type of object i.e. suppose we have 20 textboxes on the page and there names are in the form txt_1, txt_2, txt_3 and so on. Now adding all 20 the Object repository would not be a good programming approach.

Code Optimisation Techeniques

VBScript – Code optimization Techniques


1. Use select case instead of If else if

2. StrComp vs 'String1=String2' [5/2/2001]


StrComp() is 100+% faster than using Ucase, for capital unsensitive strings. I actually never knew that strComp() existed. But I think I'm going to try to implent it now where possible. This test was based on the standard method: 500.000 iterations, 5 times.

Used Code:
Public Sub TestOne()
Dim strTest1 As String, strTest2 As String
strTest1 = UCase$("all j00r b453 r b3l0nG 70 U5")
strTest2 = UCase$("ALL J00r base R Bel0NG 70 U5")
If strTest1 = strTest2 Then
End If
End Sub

Public Sub TestTwo()>BR? Dim strTest1 As String, strTest2 As String
strTest1 = "all j00r b453 r b3l0nG 70 U5"
strTest2 = "ALL J00r base R Bel0NG 70 U5"
If StrComp(strTest1$, strTest2$, vbTextCompare) = 0 Then
End If
End Sub

3.
So much effect for so little change of code. These are only the statistics of the "Left" function, but I've also done some tests using "Ucase", "Lcase" and "Trim". All these functions are much faster using the "$" sign after the function. This happens for a simple reason: The functions return a variant without the $ sign. And variants are very slow, you should never use them.
Code Used:
Public Sub TestOne()
Dim strReturn As String
strReturn = Left("This is a test", 4)
End Sub
Public Sub TestTwo()
Dim strReturn As String
strReturn = Left$("This is a test", 4)
End Sub
4

Math

Use "X \ 1" instead of "Cint(x)" [5/2/2001]
"X \ 1" is a lot faster, and the end result is the same. The speed increase is actually more than I would have expected. But as with many other optimizations, this test has been done with 500.000 iterations. So for small loops you might not notice it.
Code used:
Public Sub TestOne()
Dim lngReturn As Long
lngReturn = CInt(100.543253)
End Sub
Public Sub TestTwo()
Dim lngReturn As Long
lngReturn = 100.543253 \ 1
End Sub


5

Always use "\" instead of "/" [5/1/2001]
Major performance gain here! For integer calculations you should always use "\" instead of "/" Using "\" is faster because f you divide by "/" the values will first be converted to singles. So for Sin/Cos/Tan operation you should still use "/" if you want to have precision. code used:
Public Sub TestOne()
Dim intResult As Integer
intResult = 100 / 50
End Sub
Public Sub TestTwo()
Dim intResult As Integer
intResult = 100 \ 50
End Sub
6

Use "x * x" instead of "x ^ 2" [4/30/2001]
You can use "x * x" instead of "x ^ 2". The end result will be the same. Well, I think the statistics prove themself, it's definetly worth to change your code to the optimized method! But As you can see the time for the calculations is very low anyways. Not even a second for 500.000 iterations Maybe with very large iterations you might notice it. Still I recommend to change the code since we want to have our programs running at the maximal speed possible, don't we? I'm not sure but maybe for larger quadratic calculations the routine might become faster. For example "x ^ 5" can also be done using "x * x * x * x * x"
Public Sub TestOne()
Dim dblResult As Double
dblResult = 4 ^ 2
End Sub
Public Sub TestTwo()
Dim dblResult As Double
dblResult = 4 * 4
End Sub
7
Arrays: Temporary variables [5/2/2001]
Well no doubt about it. Temporary variables are going to speed up your program. I have to say that I had to wait longer than expect to complete this routine. Anyway, if you're often pointing to an array, you've definetly got to use temporary values. Check the source code for an example. Note that I've done the test 5 times, but there was only 1 main iteration, cause the For...Next loops where long enough. Also note that in the first test without the temporary variable, I didn't declare the "lngTemp" variable. We didn't use it there, so no extra variable declaration.
Used code: Public Sub TestOne()
Dim I As Long, J As Long
Dim myArray(1 To 50000) As Long
For I = 1 To 50000
For J = I + 1 To 50000
If myArray(I) = myArray(J) Then
End If
Next
Next
Erase myArray
End Sub
Public Sub TestTwo()
Dim I As Long, J As Long
Dim myArray(1 To 50000) As Long
Dim lngTmp As Long
For I = 1 To 50000
lngTmp = myArray(I)
For J = I + 1 To 50000
If lngTmp = myArray(J) Then
End If
Next
Next
Erase myArray
End Sub
8
For…Each vs. For...Next [5/2/2001]
Using For...Next in arrays is a lot faster than For...Each. I'm not sure why this is caused, but probably also because you've got to use a variant as loop index for the "For...Each". And any serious programmer doesn't use a variant in his/her applications. I've used Lbound() and Ubound() in the For...Next loop, cause we do not have to worry about those two values, like in For...Each. No 500.000 iterations this time. I've done 1 iteration, the array was large enough to be precise enough. The test has been done 5 times though.
Used Code:
Public Sub TestOne()
Dim MyArray(1 To 100000)
Dim I As Variant
For Each I In MyArray
Next
End Sub
Public Sub TestTwo()
Dim MyArray(1 To 100000)
Dim I As Long
For I = LBound(MyArray) To UBound(MyArray)
Next
End Sub
9
For…Next: Always use longs [5/2/2001]
Never use anything else than longs in loops. Longs are the fastest variable type in Visual Basic. It's easy to explain why: They are 32bit, your processor is 32 bit, and every other type that isn't 32 bit needs to be converted to 32 bit (which takes time). Okay, now I could have used integers for this test. Integers are slower than longs, but just running an test between a long and integer, without anything between For...Next, will not really matter. But in larger loops, you'll always see that the Long variable type will win in performance.
So that's why I decided to use a single. And you can see the difference between it, definetly. I might add that I haven't used the normal test system for this test: 1 iteration, done 5 times. But the long and single test both contained 100000 iterations, so it should be all right.
Code used:
Public Sub TestOne()
Dim I As Single
For I = 0 To 100000
Next I
End Sub
Public Sub TestTwo()
Dim I As Long
For I = 0 To 100000
Next I
End Sub
11
'With' vs.' No With' [5/2/2001]
The results of this test are very irregular. Sometimes "With" wins and some "No with" wins. I've done this test 10 times, but everytime the same results... I'm not sure why this happens. I always thought that "With" would be (much) faster anyway. It could be the form I've used for this test, but it's highly unlikely. For this test I've done 5000 iterations, and done the test 5 times. Changing properties take so much time in VB. I have limitted the form calls to properties that are not graphical depending on something.
Used code:
Public Sub TestOne()
frmTest.Caption = "test"
frmTest.Enabled = True
frmTest.CurrentX = 10
frmTest.ScaleMode = vbPixels
frmTest.Tag = "test"
frmTest.Tag = "test1"
frmTest.Tag = "test2"
frmTest.Tag = "test3"
frmTest.Tag = "test4"
End Sub
Public Sub TestTwo()
With frmTest
.Caption = "test"
.Enabled = True
.CurrentX = 10
.ScaleMode = vbPixels
.Tag = "test"
.Tag = "test1"
.Tag = "test2"
.Tag = "test3"
.Tag = "test4"
End With
End Sub
12
Memory

Static vs. Public variables [5/3/2001]
Sometimes I use Static variables, but I think I'm going for public now. Not that it really matters that much, but any performance increase is welcome for me. I've used the standard method for this test: 500.000 iterations, 5 times.
Used Code:
Declaration section: Private Var1 As Long
Public Sub TestOne()
Static Var2 As Long
Var2 = Var2 + 1
End Sub
Public Sub TestTwo()
Var1 = Var1 + 1
End Sub
13
Methods

Use Byref or Byval? [5/2/2001]
ByRef arguments are 1/3 faster than Byval. If you do not explcitly declare arguments as Byval or Byref, VB will use ByRef as default. So if you never specify ByVal, there won't be any speed gain for you here. Except that you can specify ByRef explicit (see other VB Fibre article)
Code used:
Public Sub TestOne(ByVal lngValue1 As Long, ByVal strString1 As String, ByVal bByte1 As Byte)
'empty
End Sub
Public Sub TestTwo(ByRef ngValue1 As Long, ByRef strString1 As String, ByRef bByte1 As Byte)
'empty
End Sub
14
Specify ByRef explictly [5/2/2001]
A very little speed increase. I expected a larger increase... Anyway, it's always better to declare arguments byval or byref explicitly. You can then see how values are passed, and see if it returns anything directly. I'm not sure if it's worthy to change all your subs and functions to Byref, because the speed increase ain't that much.
Code used:
Public Sub TestOne(lngValue1 As Long, strString1 As String, bByte1 As Byte)
'empty
End Sub
Public Sub TestTwo(ByRef ngValue1 As Long, ByRef strString1 As String, ByRef bByte1 As Byte)
'empty
End Sub
15
To call or not to call? [5/1/2001]
The difference between call or no call is very small. The funny thing is that there's a difference if you call a sub or a function. That's why I'm probably going to add another test to check if "no call" is faster for subs. The results of this test are based on a function, the function returns a string.
Public Function TestOne() As String
TestOne = "empty"
End Function
This was function was called 500.000 times using "Call Testone" and "Testone", and done 5 times

Browser Compatibility of QTP 9.2

QuickTest supports recording tests only on Microsoft Internet Explorer. It supports running tests on the following Web browsers:
➤ Microsoft Internet Explorer
➤ Netscape Browser
➤ Mozilla Firefox
➤ Applications with embedded Microsoft Internet Explorer Web browser controls

Keep the following in mind when using Microsoft Internet Explorer as your Web browser:
➤ QuickTest Professional Web support behaves as a browser extension in Microsoft Internet Explorer. Therefore, you cannot use the Web Add-in on Microsoft Internet Explorer without enabling the Enable third-party browser extensions option. To set the option, in Microsoft Internet Explorer choose Tools > Internet Options > Advanced and select the Enable thirdparty
browser extensions option.
➤ QuickTest Professional does not support tabbed browsing. Therefore, before using the Web Add-in, you must disable tabbed browsing on Internet Explorer. To disable the option, in Microsoft Internet Explorer choose Tools > Internet Options > Advanced and clear the Enable Tabbed Browsing option. After clearing this option, you must restart your browser before using the QuickTest Professional Web Add-in.

Keep the following in mind when using Netscape Browser or Mozilla Firefox:
➤ You must be logged-in with Administrator privileges (or have write permissions to the browser’s installation folder) on the QuickTest computer when launching Mozilla Firefox with QuickTest for the first time, since adding QuickTest support for Mozilla Firefox requires a file to be created in the browser's installation folder.
➤ You can record tests on Microsoft Internet Explorer and run them on Netscape Browser or Mozilla Firefox. You cannot record tests on Netscape Browser or Mozilla Firefox. There are two ways to create tests to run on Netscape Browser or Mozilla Firefox:
1) Record the test on Microsoft Internet Explorer.
2) Use the keyword-driven methodology: create an object repository for your application using the Object Repository window (local object repository) or Object Repository Manager (shared object repository), and then add steps using the Keyword View or Step Generator. When you use the keyword-driven methodology, you can add objects using Mozilla Firefox or Netscape if you want; you do not have to use Microsoft Internet Explorer.

Wednesday, March 3, 2010

REVIEW CHECKLIST for Automation Script

REVIEW CHECKLIST
Script Name:

Planning/Action Step Review Compliance
Maintainability "Do You understand the Script You are reviewing
(Are the names used meaningful and logical)"
Does the Script implements the desired functionality as per the Scenario of Test Case document?
Are the Error/Confirmation messages or input values hard coded?
Are there proper comments for wait () statements, mentioning the reason why sleep has been included?
Are there proper comments include for the modifications done?
Is it using the credit card information from central repository?
If it is a booking script, is it logging the ORL to the central excel sheet?
is the email id used is from central data table?
Is it a GR path? If yes, how is email id generation handled?
Delete cookie is included at the top of the script?
Is proper credit card used as per the module?

Reusability Are the functions that are used defined in the Utility files ?
Is there any repeated code present in the script file?
Is the implementation optimized?
Is this a repeated script/code/functionality?

Coding Standard Are the naming conventions followed for scripts, functions and variables?
Are there necessary Comments that reflect the Scenario or Test Case document?
Are there variables that are declared but never used in the Script?
Is the email id used is proper?
Has the documentation done in the script.
If there are static functions defined, are the properly commented(Remember that a static function should always start with _orb)
"Do the following lines appear at the top of script?
report_msg(""Running against platform: "" & platform);
report_msg(""Using user: "" & test_props[""email""]);"
"Do the following lines appear at the bottom of script?
report_msg(""END OF TEST"");
"
Are the data table statements used properly?
Do all the values such as Script ownership, status..etc are set for the script in QC?


Indentation Are the used variables declared at the top of the Script File and are they properly commented?
Has sufficient care taken on indentation of the script statements, logical loops, messages, etc,?

Execution Has the Test Case executed devoid of any errors and exceptions
Does the script pass through QC?

The Product Quality Measures - Metrics used in the Testing

The following are the Metrics used in the Testing …

1. Customer satisfaction index

This index is surveyed before product delivery and after product delivery (and on-going on a periodic basis, using standard questionnaires).The following are analyzed:

· Number of system enhancement requests per year

· Number of maintenance fix requests per year

· User friendliness: call volume to customer service hotline

· User friendliness: training time per new user

· Number of product recalls or fix releases (software vendors)

· Number of production re-runs (in-house information systems groups)

2. Delivered defect quantities

They are normalized per function point (or per LOC) at product delivery (first 3 months or first year of operation) or Ongoing (per year of operation) by level of severity, by category or cause, e.g.: requirements defect, design defect, code defect, documentation/on-line help defect, defect introduced by fixes, etc.

3. Responsiveness (turnaround time) to users

· Turnaround time for defect fixes, by level of severity

· Time for minor vs. major enhancements; actual vs. planned elapsed time

4. Product volatility

· Ratio of maintenance fixes (to repair the system & bring it into compliance with specifications), vs. enhancement requests (requests by users to enhance or change functionality)

5. Defect ratios

· Defects found after product delivery per function point.

· Defects found after product delivery per LOC

· Pre-delivery defects: annual post-delivery defects

· Defects per function point of the system modifications

6. Defect removal efficiency

· Number of post-release defects (found by clients in field operation), categorized by level of severity

· Ratio of defects found internally prior to release (via inspections and testing), as a percentage of all defects

· All defects include defects found internally plus externally (by customers) in the first year after product delivery

7. Complexity of delivered product

· McCabe's cyclomatic complexity counts across the system

· Halstead’s measure

· Card's design complexity measures

· Predicted defects and maintenance costs, based on complexity measures

8. Test coverage

· Breadth of functional coverage

· Percentage of paths, branches or conditions that were actually tested

· Percentage by criticality level: perceived level of risk of paths

· The ratio of the number of detected faults to the number of predicted faults.

9. Cost of defects

· Business losses per defect that occurs during operation

· Business interruption costs; costs of work-around

· Lost sales and lost goodwill

· Litigation costs resulting from defects

· Annual maintenance cost (per function point)

· Annual operating cost (per function point)

· Measurable damage to your boss's career

10. Costs of quality activities

· Costs of reviews, inspections and preventive measures

· Costs of test planning and preparation

· Costs of test execution, defect tracking, version and change control

· Costs of diagnostics, debugging and fixing

· Costs of tools and tool support

· Costs of test case library maintenance

· Costs of testing & QA education associated with the product

· Costs of monitoring and oversight by the QA organization (if separate from the development and test organizations)

11. Re-work

· Re-work effort (hours, as a percentage of the original coding hours)

· Re-worked LOC (source lines of code, as a percentage of the total delivered LOC)

· Re-worked software components (as a percentage of the total delivered components)

12. Reliability

· Availability (percentage of time a system is available, versus the time the system is needed to be available)

· Mean time between failure (MTBF).

· Man time to repair (MTTR)

· Reliability ratio (MTBF / MTTR)

· Number of product recalls or fix releases

· Number of production re-runs as a ratio of production runs


Metrics for Evaluating Application System Testing:

Metric = Formula

Test Coverage = Number of units (KLOC/FP) tested / total size of the system. (LOC represents Lines of Code)

Number of tests per unit size = Number of test cases per KLOC/FP (LOC represents Lines of Code).

Acceptance criteria tested = Acceptance criteria tested / total acceptance criteria

Defects per size = Defects detected / system size

Test cost (in %) = Cost of testing / total cost *100

Cost to locate defect = Cost of testing / the number of defects located

Achieving Budget = Actual cost of testing / Budgeted cost of testing

Defects detected in testing = Defects detected in testing / total system defects

Defects detected in production = Defects detected in production/system size

Quality of Testing = No of defects found during Testing/ (No of defects found during testing + No of acceptance defects found after delivery) *100

Effectiveness of testing to business = Loss due to problems / total resources processed by the system.

System complaints = Number of third party complaints / number of transactions processed

Scale of Ten = Assessment of testing by giving rating in scale of 1 to 10

Source Code Analysis = Number of source code statements changed / total number of tests.

Effort Productivity = Test Planning Productivity = No of Test cases designed / Actual Effort for Design and Documentation

Test Execution Productivity = No of Test cycles executed / Actual Effort for testing

Excel Function

' FUNCTION NAME: fnCreateExcel()
' PURPOSE:This function will return a new Excel Object with a default new Workbook
' INPUTS: None
' OUTPUTS: Newly created excel sheet

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public Function fnCreateExcel()
On error resume next

Dim excelSheet 'Excel.worksheet

Set objExcelApp = CreateObject("Excel.Application") 'Create a new excel Object
objExcelApp.Workbooks.Add
objExcelApp.Visible = True
Set CreateExcel = objExcelApp

If err.number<>0 Then
strFuncProcName=" fnCreateExcel"
Call prErrorHandler(environment.Value("TestName"),strFuncProcName,err.number,err.description,err.Source,environment.Value("LocalHostName"))
err.clear
End If
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' FUNCTION NAME: prCloseExcel(objExcelApp)
' PURPOSE:This procedure will close the given Excel Object
' INPUTS: 1' Instance of Excel application.
' OUTPUTS: None

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

public Sub prCloseExcel(ExcelApp)
On error resume next

Set excelSheet = ExcelApp.ActiveSheet
Set excelBook = ExcelApp.ActiveWorkbook
Set objExcel= CreateObject("Scripting.FileSystemObject")

objExcel.CreateFolder strDataFilePath&"Temp"
objExcel.DeleteFile strDataFilePath&"ExcelExamples.xls"
excelBook.SaveAs strDataFilePath&"ExcelExamples.xls"
ExcelApp.Quit
Set ExcelApp = Nothing
Set objExcel = Nothing

If err.number<>0 Then
strFuncProcName="prCloseExcel"
Call prErrorHandler(environment.Value("TestName"),strFuncProcName,err.number,err.description,err.Source,environment.Value("LocalHostName"))
err.clear
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' FUNCTION NAME: fnSaveWorkbook(ExcelApp, workbookIdentifier, path)
' PURPOSE:The function will save a workbook according to the workbookIdentifier
' The function will overwrite the previously saved file under the given path
' Return "OK" on success and "Bad Workbook Identifier" on failure
' workbookIdentifier - The name or number of the requested workbook
' INPUTS:3'
' ExcelApp The excel object
' workbookIdentifier: the workbook/sheet name or Id
' path: The path to whihc the file has to be saved.
' OUTPUTS: The function will overwrite the previously saved file under the given path
' Return Ttrue after saving

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function fnSaveWorkbook(ExcelApp, strworkbookIdentifier, path) 'As String
On error resume next

Dim strWorkBook 'Excel.workbook
Set strWorkBook = ExcelApp.strWorkBook(strworkbookIdentifier)

If Not strWorkBook Is Nothing Then
If path = "" Or path =strWorkBook.FullName Or path = strWorkBook.Name Then
strWorkBook.Save
Else
Set objExcel = CreateObject("Scripting.FileSystemObject")

'if the path has no file extension then add the 'xls' extension
If InStr(path, ".") = 0 Then
path = path & ".xls"
End If

objExcel.DeleteFile path
Set objExcel = Nothing

strWorkBook.SaveAs path
End If
SaveWorkbook = True
Else
SaveWorkbook = False
End If
If err.number<>0 Then
strFuncProcName=" fnSaveWorkbook"
Call prErrorHandler(environment.Value("TestName"),strFuncProcName,err.number,err.description,err.Source,environment.Value("LocalHostName"))
err.clear
End If
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' FUNCTION NAME: prSetCellValue(ExcelSheet, intRow, intColumn, strValue)

' PURPOSE:The procedure sets the given 'value' in the cell which is identified by
' its row column and parent Excel sheet
' excelSheet - the excel sheet that is the parent of the requested cell
' row - the cell's row in the excelSheet
' column - the cell's column in the excelSheet
' value - the value to be set in the cell
' INPUTS:4
' ExcelSheet,: The excel sheet to whihc the value needs to be set.
' intRow: The row to whihc the value has to be set
' intColumn : The column to whihc the value has to be set
' strValue: The value that needs to be set.
' OUTPUTS: None

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public Sub prSetCellValue(ExcelSheet, intRow, intColumn, strValue)
On Error Resume Next

ExcelSheet.Cells(intRow, intColumn) = strValue

If err.number<>0 Then
strFuncProcName=" prSetCellValue"
Call prErrorHandler(environment.Value("TestName"),strFuncProcName,err.number,err.description,err.Source,environment.Value("LocalHostName"))
err.clear
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' FUNCTION NAME: fnGetCellValue(ExcelSheet, intRow, intColumn)
' PURPOSE:The function returns the cell's value according to its row column and sheet
' excelSheet - the Excel Sheet in which the cell exists
' row - the cell's row
' column - the cell's column
'' INPUTS:3' ExcelSheet,: The excel sheet / intRow : the row to whihc the value has to be set / intColumn: the column to which the value has to be set.
' OUTPUTS: return 0 if the cell could not be found and the value in the cell , if it can be found.

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function fnGetCellValue(ExcelSheet, intRow, intColumn)


value = 0
Err = 0

inttempValue = ExcelSheet.Cells( intRow, intColumn)
If Err = 0 Then
value = inttempValue
Err = 0
End If
fnGetCellValue = value



End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' FUNCTION NAME: fnGetSheet(ExcelApp, sheetIdentifier)
' PURPOSE:The GetSheet method returns an Excel Sheet according to the sheetIdentifier
' INPUTS:2'
' ExcelApp - the Excel application which is the parent of the requested sheet
' sheetIdentifier - the name or the number of the requested Excel sheet
' OUTPUTS: It will return name or the number of the requested Excel sheet or ' return Nothing on failure

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function fnGetSheet(ExcelApp, sheetIdentifier) 'As Excel.worksheet


Set strGetSheet = ExcelApp.Worksheets.Item(sheetIdentifier)


End Function

Tuesday, March 2, 2010

Material Master FAQS

Material Master FAQS QUESTIONS


Q: How can I extend all material to a new plant?


Q: How can we delete materials permanently from Material master?


Q: SAP only provides moving average value for current, previous period, and previous year.
SAP does not provide transactions/reports that will provide moving average value for a given date.
How can I report moving average price for material number 10000000 at plant 0001 on July 4, 1998 .



Q: We have defined all the variables for the materials. However, when I attempt to use Material Matchcode object MAT1, I get the response "No possible entries found". Why?


Q: The matchcode object selection is defaulted to matctcode ID "B". Iwould like to change to M "Material by Description" What is the solution?




Q: We can make field mandatory. We want to make a default value to a Particular field in the Material
Master. Say, We want that the period indicator in the MRP2 view as "P". What is the best way?


Q: What is the use of configurable material.?









Material Master FAQS ANSWERS


Q: How can I extend all material to a new plant?
A: The SAP program - RMDATIND is
used to create /update material master record.


Q: How can we delete materials permanently from Material master?
A: Use transaction MM70 - Material Master->Other->Reorganization->Material->Choose.
Build variant with selection range of material master records to be selected for deletion and maintain
run parameters.
Execute.
Use transaction MM71 - Material Master-> other-> Reorganizationn-->Material->Reorganization
Build a second variant
Maintain run parameters and execute.
It is also important to remove the records manually from info record, POs, PRs, reservation etc
for successful deletion of the material.
Q: SAP only provides moving average value for current, previous period, and previous year. SAP
does not provide transactions/reports that will provide moving average value for a given date.
How can I report moving average price for material number 10000000 at plant 0001 on July 4,
1998 .
A: Try any of these solutions:
1. Change the updating level of the structure (S031) to "daily". In LIS the total value and the total
stock are available. Divide value by the stock. It is possible to calculate this dynamically when
the analysis is run and to display the result.
2. Create your own structure in LIS and populate it by copying the Moving Average Price from the
material master every time there is a transaction. You will have data on those days when there
was a transaction.
Q: We have defined all the variables for the materials. However, when I attempt to use Material
Matchcode object MAT1, I get the response "No possible entries found". Why?
A: Matchcode i.d. "B", "Material by bill of material" has a selection condition for field STLNR NE ' '.
STLNR is the BOM number associated with a material in table MAST. Hence the message - "no
possible entries..." pops up if there are no bills of materials associated with your material numbers.
You get the matchcodes as long as the material referred by you has BOM number associated with
it.
Q: The matchcode object selection is defaulted to matctcode ID "B". Iwould like to change to M "
Material by Description" What is the solution?
A: Press the pull down arrow on the material number field and matchcode "B" is displayed, press
F5 double-click matchcode i.d. "M", then press F6 . This will set matchcode "M" as the default.
Q: We can make field mandatory. We want to make a default value to a Particular field in the Material
Master. Say, We want that the period indicator in the MRP2 view as "P". What is the best way?
A: Use transaction variant. Transaction SHD0 and then Transaction SE93.


Q: What is the use of configurable material.?
A: Configurable material is useful if you have a large number of combination of parts that go into a
product. It means different permutations and combinations of the parts for same material. If you
maintain a unique material code for each combination , you require a large number of material
numbers. KMAT may be used in such a case where you maintain just one generic product code.
A super BOM is maintained for such a material consisting of all possible alternatives. A routing is
also maintained consisting of all possible operations that could be used. Typically configurable
material is used in Made To Order (MTO) environment. However frequently ordered
configurations may be planned with a material variant which needs to have a material master record.
Thus Material variants may have stock and value. Depending upon characteristic values chosen at
sales order entry Sales Order BOM is created. Routing operations are also chosen depending upon
which BOM components are assigned to them.