eCATT script for multiple line item entry (step by step)
It took me a while to figure out how to make my eCATT script, recorded for t-code FB60 (manual invoice entry) work for the case where I wanted it to enter multiple line items. While I found multiple discussions on SDN which gave me some insight and pointed me in the right direction, it still took me some good amount of time to figure this out for myself.
So here’s my “step-by-step guide – eCATT scripts to handle multiple lines – for dummies (including myself)” :
Please note – the steps detailed below are for t-code FB60 recorded using SAPGUI mode of eCATT.
Step 1: Record your script using data for a single line item. Start parameterizing it.
Step 2: When parameterizing, you will need to define the line item level parameters (the ones that will be repeated as part of multiple lines) as a table. To do this, you need to specify a parameter reference, which is an ABAP dictionary object.
So how do I find my parameter reference? Simple. Navigate to the screen you are recording and position your cursor on the first field of the first line item (that you would like to enter multiple times). Press F1 and click on the ‘technical information’ icon. You should see the Table Name here. This then is your parameter reference.
Copy the table name and insert it in the parameter reference field of your eCATT script for all those import parameters that will need to repeat as part of the multiple line entry. Add square brackets  at the end to make this is a table parameter (see screen shot below).
For example, I have G/L Account (parameter IP_GL_ACCT below), Amount in doc. currency (parameter IP_AMT below) and cost center (parameter IP_CST_CNTR below) that I want to enter for every line item in FB60. So these are my import parameters that I will maintain as a table with parameter reference in my eCATT script.
Step 3: Maintaining values for the line item fields: Highlight the row for each parameter in the table (ie, each unique line item field) and click on the blue ‘i’ icon. The table structure will open up in the structure editor section below. Click on the “Append row” icon to add value for this field. Note here – you will need to know the technical name of the field that you wish to maintain value for. This can be found from technical information (see ‘Field Name’ in FIG 3 above).
Step 4: Within the command interface, the parameter would be entered thus in the GuiElement section:
ie, Parameter Name assigned to field[test data record #]-technical name of field
Step 5: Looping your script to enable data entry
In the test script editor, split your command interface so that the repetitive line item entry part is in its own separate SAPGUI command. Add a parameter (of type variable) to maintain the count – this will contain the # of line items you plan to enter. We will call this LINE_ITEM_COUNT. Add another variable, say ROW (of type V) to keep track of the row. Initialize this parameter’s value to 0.
When you’re entering line items in an ALV grid table, the row # starts with 0. See figure below to get an idea:
Via Insert Pattern, add a Do – Enddo around your SAPGUI command which enters the line item details.
SAPGUI command to add line item fields.
ROW = ROW + 1.
Within the command interface of this specific SAPGUI command, make the following changes:
For every GuiElement that will be entered in the loop, replace the test data record # with &LPC.
IP_GL_ACCT-HKONT –> IP_GL_ACCT[&LPC]-HKONT
IP_AMT-WRBTR –> IP_AMT[&LPC]-WRBTR
&LPC is nothing but the current value of the do – enddo loop.
Under every GuiElement is an Id. Double click on this and replace the constant row number with <!ROW!> where the variable ROW carries the row count and will be updated with the do loop.
The angle brackets and exclamation points serve as an escape sequence. During execution of the test script, <!ROW!>will be replaced by the current value of the parameter ROW. You can only do this with the IDs of controls. Reference: http://help.sap.com/saphelp_nw70ehp2/helpdata/EN/91/cb79ce29c0de40b91fc04ddb263f1c/frameset.htm
Changing this ensures that once the script has maintained values for row 0, it moves onto the next row, row 1, to enter the second set of data and so on and so forth.
As is always needed with an eCATT script, make your changes, execute and then tweak your script to meet your needs.
NOTE: I am still a novice in eCATT. If you have a better, easier way to do this – please share! Constructive feedback is also welcome.