#ifndef _GLOBALS_H #define _GLOBALS_H
//--------------------------------------------------------------------// Include Files#include "lrun.h"#include "web_api.h"#include "lrw_custom_body.h"#include "orafuncs.h"//--------------------------------------------------------------------// Global Variables#endif // _GLOBALS_H
//**************************************************************************************//// Script Name -- LoginTemplate// Author -- Julian Wilton// Purpose -- To act as a template script to perform logon to the application// -- It is designed to act with all business processes that require NCA logon// // Date Created -- 10th Oct 2008////Amendments //11 Oct 2008 -- Changed to take full URL as opposed to multiple correlation//13 Oct 2008 -- Added replace code to deal with &//17 Oct 2008 -- Added error handling routines into init section//18 Oct 2008 -- Expanded text check section in login routine////27 Oct 2008 -- Sunil Girdhar - a) Fixed errorhandling() and cleaned up code.// b) Added call to errorhandling() in exception handler close().////06 Nov 2008 -- Sunil Girdhar - Updated generic transaction names in Login() to have// Generic_Logon prefix////06 Nov 2008 -- Sunil Girdhar - Added Logout() to template//**************************************************************************************
Login(){web_cleanup_cookies();
web_reg_find("Text=Login", "SaveCount=Home_Count", LAST);
web_set_max_html_param_len("1024");
lr_start_transaction("Generic_Logon_10_Oracle_Home_Page");
web_url("AppsLocalLogin.jsp",
"URL=http://{ServerInstance}.bc.jsplc.net:8070/OA_HTML/AppsLocalLogin.jsp","Resource=0","RecContentType=text/html","Referer=","Snapshot=t1.inf","Mode=HTML",EXTRARES,"URL=cabo/images/cache/cghec.gif", ENDITEM,LAST);
if (atoi(lr_eval_string("{Home_Count}")) > 0){ lr_end_transaction("Generic_Logon_10_Oracle_Home_Page",
LR_PASS); //lr_output_message("Welcome successful."); }
else{ lr_end_transaction("Generic_Logon_10_Oracle_Home_Page",
LR_FAIL);lr_error_message("Generic_Logon_10_Oracle_Home_Page
failed."); lr_think_time(60); lr_exit(LR_EXIT_MAIN_ITERATION_AND_CONTINUE,
LR_FAIL); return(0);
}
lr_think_time(3);
web_reg_find("Text={Responsibility}", "SaveCount=Login_Count",
LAST);
lr_start_transaction("Generic_Logon_20_Login");
web_submit_form("fndvald.jsp_2","Snapshot=t4.inf",ITEMDATA,"Name=username", "Value={UserName}", ENDITEM,"Name=password", "Value={Password}", ENDITEM,LAST);
if (atoi(lr_eval_string("{Login_Count}")) > 0){ lr_end_transaction("Generic_Logon_20_Login", LR_PASS);
//lr_output_message("Welcome successful."); } else{
lr_end_transaction("Generic_Logon_20_Login", LR_FAIL); lr_error_message("Generic_Logon_20_Login failed with User %s Password %s",
lr_eval_string("{UserName}"),lr_eval_string("{Password}"));
lr_think_time(10); lr_exit(LR_EXIT_MAIN_ITERATION_AND_CONTINUE,
LR_FAIL); return(0);
}
lr_think_time(10);
web_reg_save_param("FullURL","LB=href=\"javascript:launchForm('","RB=')\" class=\"xd\">{StartScreen}","ORD=1",LAST);
web_reg_find("Text={StartScreen}", "SaveCount=StartScreen_Count", LAST);
lr_start_transaction("Generic_Logon_30_Select_Responsibility");
web_link("{Responsibility}",
"Text={Responsibility}","Snapshot=t5.inf",LAST);
if (atoi(lr_eval_string("{StartScreen_Count}")) > 0){ lr_end_transaction("Generic_Logon_30_Select_Responsibility",
LR_PASS); //lr_output_message("Welcome successful."); }
else{ lr_end_transaction("Generic_Logon_30_Select_Responsibility",
LR_FAIL);lr_error_message("Generic_Logon_30_Select_Responsibility
failed with User %s Responsibility %s",
lr_eval_string("{UserName}"),lr_eval_string("{Responsibility}")); lr_think_time(10); lr_exit(LR_EXIT_MAIN_ITERATION_AND_CONTINUE,
LR_FAIL); return(0);
}
//// Remove the & from the trapped url ({FullURL}) and replace with &replace();
//// secgrp_key=1secg web_reg_save_param("secgrp_key",
"LB/IC=secgrp_key=", "RB/IC=&", "Ord=1", "Search=Body", "RelFrameId=1", LAST);
web_reg_save_param("Resp_app", "LB/IC=var xgv2 = \"", "RB/IC=\"", "Ord=1", "Search=Body", "RelFrameId=1", LAST);
//var xgv3 = "SAINS_UKHR_IRC_RECRUITER_SCM"web_reg_save_param("Resp",
"LB/IC=var xgv3 = \"", "RB/IC=\"", "Ord=1", "Search=Body", "RelFrameId=1", LAST);
web_reg_save_param("Start_func", "LB/IC=var xgv5 = \"", "RB/IC=\"", "Ord=1", "Search=Body", "RelFrameId=1", LAST);
web_reg_save_param("ServerInst_db", "LB/IC=var xgv13 = \"", "RB/IC=\"", "Ord=1", "Search=Body", "RelFrameId=1", LAST);
//http://stevux1096f.bc.jsplc.net:8070/pls/jsd11i04/fnd_icx_launch.launch?ICX_TICKET=&resp_app=SQLGL&resp_key=GENERAL_LEDGER_SUPER_USER&secgrp_key=STANDARD&start_func=RGXGRRSTweb_reg_save_param("SecondUrl",
"LB=ICX_TICKET=&resp_app=","RB=&other_params=","ORD=1",LAST);
lr_start_transaction("Generic_Logon_40_Start_Oracle_Forms");
web_url("RF.jsp","URL={FullURL}&formsLink=yes","Resource=0","RecContentType=text/html","Referer=http://{ServerInstance}.bc.jsplc.net:8070/OA_HTML/OA.jsp?
OAFunc=OAHOMEPAGE&akRegionApplicationId=0&navRespId=50966&navRespAppId=800&navSecGrpId=1&transactionid={transactionid}&oapc=2&oas={OasId}",
"Snapshot=t6.inf",
"Mode=HTML",LAST);
//icx_ticket='.JTZLSdXN4khdwepl2ihmDw..'
web_reg_save_param("icx_ticket","LB=icx_ticket='","RB='","ORD=1",LAST);
//secgrp='1' start_func=
web_reg_save_param("secgrp","LB=secgrp='","RB=' start_func=","ORD=1",LAST);
//http://stevux1096f.bc.jsplc.net:8070/pls/jsd11i04/fnd_icx_launch.runforms?ICX_TICKET=&resp_app=PER&resp_key=SAINS_UKHR_IRC_RECRUITER_SCM&secgrp_key=1&start_func=XXJSINTVSLOT_FN&other_params="
web_reg_find("Text=Oracle Applications 11i", "SaveCount=Launch_Count", LAST);
web_url("fnd_icx_launch.runforms","URL=http://{ServerInstance}.bc.jsplc.net:8070/pls/{dbInformation}/
fnd_icx_launch.runforms?ICX_TICKET=&resp_app={SecondUrl}&other_params=","Resource=0","RecContentType=text/html","Referer=","Snapshot=t7.inf","Mode=HTML",LAST);
//************************************************
if (atoi(lr_eval_string("{Launch_Count}")) > 0){ //lr_end_transaction("Generic_Logon_30_Select_Responsibility",
LR_PASS); //lr_output_message("Welcome successful."); //Transaction time is ended later so nothing to pass here }
else{
lr_end_transaction("Generic_Logon_40_Start_Oracle_Forms", LR_FAIL);
lr_error_message("Generic_Logon_40_Start_Oracle_Forms failed with User %s Responsibility %s",
lr_eval_string("{UserName}"),lr_eval_string("{Responsibility}"));
lr_think_time(10); lr_exit(LR_EXIT_MAIN_ITERATION_AND_CONTINUE,
LR_FAIL); return(0);
} //**************************************************************
web_url("Registry.dat",
"URL=http://{ServerInstance}.bc.jsplc.net:8070/OA_JAVA/oracle/forms/registry/Registry.dat",
"Resource=0","RecContentType=text/plain","Referer=","Snapshot=t8.inf","Mode=HTML",LAST);
web_url("OracleApplications.dat","URL=http://{ServerInstance}.bc.jsplc.net:8070/OA_JAVA/oracle/apps/
fnd/formsClient/OracleApplications.dat","Resource=0","RecContentType=text/plain","Referer=","Snapshot=t9.inf","Mode=HTML",EXTRARES,"URL=../jar/fndutil.jar", ENDITEM,"URL=../jar/fndjewtall.jar", ENDITEM,LAST);
if (strcmp(".-1", lr_eval_string("{icx_ticket}")) == 0) {
//report errorlr_error_message("{ScriptName} Failed to logon with user: %s",
lr_eval_string("{UserName}"));lr_exit (LR_EXIT_MAIN_ITERATION_AND_CONTINUE,LR_PASS);
}
nca_set_connect_opt(SCALE_INFO, 8, 20);
nca_connect_server("{dbServer}", "{Port}", "module=/application/app/{dbInformation}/product/11.5.3/fnd/11.5.0/forms/US/FNDSCSGN fndnam=APPS record=names config='{ServerInst_db}' icx_ticket='{icx_ticket}' resp='{Resp_app}/{Resp}' secgrp='{secgrp}' start_func='{Start_func}'::NLS_LANG='AMERICAN_AMERICA.UTF8' FORMS60_USER_DATE_FORMAT='DD-MON-RRRR' FORMS60_USER_DATETIME_FORMAT='DD-MON-RRRR HH24:MI:SS' NLS_DATE_LANGUAGE='AMERICAN' NLS_SORT='BINARY' NLS_NUMERIC_CHARACTERS='.,'");
lr_end_transaction("Generic_Logon_40_Start_Oracle_Forms",LR_AUTO);
nca_set_exception("Error", close);
return 0;}
Logout(){/*
web_url("OALogout.jsp", "URL=http://stevux1022a.bc.jsplc.net:8070/OA_HTML/OALogout.jsp?
menu=Y", "Resource=0", "RecContentType=text/html", "Referer=http://stevux1022a.bc.jsplc.net:8070/OA_HTML/OA.jsp?
OAFunc=OAHOMEPAGE&akRegionApplicationId=0&navRespId=51053&navRespAppId=800&navSecGrpId=1&transactionid=1997616659&oapc=2&oas=mpC-fmRzyT8pVup4XTxszA..",
"Snapshot=t8.inf", "Mode=HTML", LAST);
*/
web_reg_find("Text=Login", "SaveCount=SearchStr1_Count", LAST);
lr_start_transaction("Generic_Logon_50_Oracle_Logout");
web_url("OALogout.jsp",
"URL=http://{ServerInstance}.bc.jsplc.net:8070/OA_HTML/OALogout.jsp?menu=Y",
"Resource=0",
"RecContentType=text/html", "Referer=http://{ServerInstance}.bc.jsplc.net:8070/OA_HTML/OA.jsp?
OAFunc=OAHOMEPAGE&akRegionApplicationId=0&navRespId=20434&navRespAppId=101&navSecGrpId=0&transactionid=1269312078&oapc=2&oas=vmhK9LrNn_k1_wpVo9XPow..",
"Snapshot=t8.inf", "Mode=HTML", LAST);
// Check result
if (atoi(lr_eval_string("{SearchStr1_Count}")) > 0){
lr_output_message("Logout successful."); lr_end_transaction("Generic_Logon_50_Oracle_Logout",LR_PASS);
}
else{
lr_error_message("Logout failed"); lr_end_transaction("Generic_Logon_50_Oracle_Logout",LR_FAIL);
lr_exit(LR_EXIT_MAIN_ITERATION_AND_CONTINUE, LR_FAIL);
return(0);
}
return 0;}
/******
Created By: Sunil Girdhar
Creation Date: 21-Nov-2008Business Process document ref: Coll_Adm\CA_07_TransferContractChange.docBrief description:
Ammend work location of an Employee
Parameterized Data:
a. ColleagueDataType (Leaver.dat) : "NAME" (Full name) or "ID" (Employee number)
b. Colleague (Leaver.dat): Full name or Employee Number of the employee for whom work location is to be ammended.c. RequirementStatus: (RequirementStatus.dat): Currently has 2 values: Ammended Requirement, New Requirementd. NewLocation: (NewLocation.dat): The new location. See note below.
###Note###: If you give an unknown location, all locations are searched and displayed in LOV. This script then
randomly selects 1 location from the first 100 locations returned. So no data may be needed for location.****/
TCC(){/**** Pre-existing template variables definitions block start ****/
char val[100]; // Mainly error handling to get values from text boxeschar topwin[1024]; // Check the topwindow of the displayint result; // Used to handle the string compares etcchar console_text[500]; // Check console messages for successful writes to the
database
/**** Pre-existing template variable definitions block end ****/
/**** Inserted variable definitions block start ****/
int ret_val; // To save return values of functionschar selected_item[256];
/**** Inserted variable declarations block end */
// Check initial window is Find Personnca_get_top_window(topwin);lr_output_message("Starting topwin = %s", topwin);
if (strncmp(topwin, "Find Person", 11) != 0){lr_error_message("Application started without the initial Find Person
dialog");errorhandling();
}
// Enter Employee name or Number in Find Person dialog and searchif (strcmp(lr_eval_string("{ColleagueDataType}"), "NAME") == 0) {
nca_edit_click("CTL_EMP_EMP_NAME_0");nca_edit_set("CTL_EMP_EMP_NAME_0", "{Colleague}");
nca_obj_type("CTL_EMP_EMP_NAME_0", '\t', 0);
nca_get_top_window(topwin);
// If still in Find Person dialog and// Employee Number is not auto-filled, then name is non-existant. Exit
iteration.if (strncmp(topwin, "Find Person", 11) == 0) {
nca_edit_get_text("CTL_EMP_EMPLOYEE_NUMBER_0", val);lr_output_message("Auto-filled employee number = '%s'", val);
if (strcmp(val, "") == 0) {
lr_error_message("Non-existant employee fullname entered");
// Clear Full name field so that errorhandling can close all windows and exit smoothly
nca_edit_set("CTL_EMP_EMP_NAME_0", "");
errorhandling();} //end-if
} //end if
// Else Find People dialog has opened as name is non unique. Exit iteration// If any other window has opened this should take care of that too,
hopefullyelse {
lr_error_message("Non-unique employee fullname entered. Topwin is %s", topwin);
nca_win_close(topwin);
nca_set_window("Find Person");
// Clear Full name field so that errorhandling can close all windows and exit smoothly
nca_edit_set("CTL_EMP_EMP_NAME_0", "");
errorhandling();
} //end-else
} //end-if
else { // {ColleagueDataType} is "ID"
nca_edit_click("CTL_EMP_EMPLOYEE_NUMBER_0");nca_edit_set("CTL_EMP_EMPLOYEE_NUMBER_0", "{Colleague}");
nca_obj_type("CTL_EMP_EMPLOYEE_NUMBER_0", '\t', MODIF_SHIFT); // As last field, tab backwards
nca_get_top_window(topwin);
// If still in Find Person dialog and// Employee Name is not auto-filled, then Employee number is non-
existant. Exit iteration.if (strncmp(topwin, "Find Person", 11) == 0) {
nca_edit_get_text("CTL_EMP_EMP_NAME_0", val);lr_output_message("Auto-filled employee full name = '%s'", val);
if (strcmp(val, "") == 0) {
lr_error_message("Non-existant employee number entered");
// Clear Employee Number field so that errorhandling can close all windows and exit smoothly
nca_edit_set("CTL_EMP_EMPLOYEE_NUMBER_0", "");
errorhandling();
} // end-if
} //end-if
// Else Find People dialog has opened as Employee number is non unique. Exit iteration
// If any other window has opened this should take care of that too, hopefully
else {
lr_error_message("Non-unique Employee Number entered. Topwin is %s", topwin);
nca_win_close(topwin);
nca_set_window("Find Person");
// Clear Employee Number field so that errorhandling can close all windows and exit smoothly
nca_edit_set("CTL_EMP_EMPLOYEE_NUMBER_0", "");
errorhandling();
} //end-else
} //end-else
// Click the Find buttonlr_start_transaction("CA_07_10_Search");
nca_button_press("CTL_EMP_CTL_EMP_FIND_BUTTON_0");
nca_get_top_window(topwin);lr_output_message("After find topwin = %s", topwin);
if (strcmp(topwin, "Transfer or Secondment Details") == 0){
lr_output_message("Transfer or Secondment Details Dates Form Open successful.");
lr_end_transaction("CA_07_10_Search",LR_PASS);
}else {
lr_error_message("Transfer or Secondment Details Dates Form Open failed");
lr_end_transaction("CA_07_10_Search",LR_FAIL);
errorhandling();
}
nca_set_window("Transfer or Secondment Details(Aaaalxe, Mr. Aaazlgy)");
// Open the Transfer or Secondment Details Entry formnca_obj_type("ANALYSES_DATE_FROM_0", '\t', 0);
nca_obj_type("ANALYSES_DATE_TO_0", '\t', 0);
nca_get_top_window(topwin);lr_output_message("After Transfer or Secondment Details Dates Form topwin =
%s", topwin);
if (strcmp(topwin, "Transfer or Secondment Details_1") != 0){
lr_error_message("Transfer or Secondment Details Entry form did not open");
errorhandling();
}
// Enter the RequirementStatus in Transfer or Secondment Details Entry formnca_set_window("Transfer or Secondment Details");
nca_flex_set_cell_data("Transfer or Secondment Details_1", "Requirement Status", "", "{RequirementStatus}");
nca_get_top_window(topwin);lr_output_message("After Requirement Status is entered topwin = %s", topwin);
if (strcmp(topwin, "Transfer or Secondment Details_1") != 0){
lr_error_message("Non-unique or nonexistent Requirement Status (most likely");
errorhandling();
}
/* nca_set_window("Requirement Status");
nca_lov_retrieve_items("Requirement Status", 1, 2);
nca_lov_select_item("Requirement Status", "Amended Requirement");
nca_set_window("Transfer or Secondment Details");*/
// Enter the NewLocation in Transfer or Secondment Details Entry formnca_flex_set_cell_data("Transfer or Secondment Details_1", "New Location", "",
"{NewLocation}");
nca_get_top_window(topwin);
lr_output_message("After New Location is entered topwin = %s", topwin);
if (strcmp(topwin, "New Location") == 0){
lr_output_message("Non-unique or nonexistent New Location entered. Choosing a random location from LOV.");
nca_set_window("New Location");
nca_lov_retrieve_items("New Location", 1, 100);
//nca_lov_select_item("New Location", "London Rd A0811"); nca_lov_select_random_item("New Location", selected_item);
lr_output_message("Randomly selection New Location is '%s'", selected_item);
if (strcmp(selected_item, "") == 0) {
lr_error_message("No item in New Location LOV. Abandoning iteration");
errorhandling();
}
nca_set_window("Transfer or Secondment Details");
}
/* nca_set_window("New Location");
nca_lov_retrieve_items("New Location", 1, 2);
nca_lov_select_item("New Location", "London Rd A0811");*/
nca_get_top_window(topwin);lr_output_message("After New Location has been finalized topwin = %s",
topwin);
if (strcmp(topwin, "Transfer or Secondment Details_1") != 0){
lr_error_message("New Location could not be successfully entered.");errorhandling();
}
// Save the entered new location details to Transfer or Secondment Details dialognca_flex_press_ok("Transfer or Secondment Details_1");
nca_get_top_window(topwin);lr_output_message("After aving the entered new location details topwin = %s",
topwin);
if (strcmp(topwin, "Transfer or Secondment Details") != 0){
lr_error_message("Transfer Details Entry in form failed.");errorhandling();
}
// Save the Changes in DBnca_set_window("Transfer or Secondment Details(Aaaalxe, Mr. Aaazlgy)");
lr_start_transaction("CA_07_20_Transfer");
nca_menu_select_item("Transfer or Secondment Details", "File;Save");
nca_console_get_text(console_text);lr_output_message("Console text after File;Save is '%s'", console_text);if (strcmp(console_text,"FRM-40400: Transaction complete: 1 records applied
and saved.") != 0){
lr_error_message("Saving of record failed.");lr_error_message("Expected console text = '%s'",
"FRM-40400: Transaction complete: 1 records applied and saved.");
lr_end_transaction("CA_07_20_Transfer",LR_FAIL);
errorhandling();}
nca_get_top_window(topwin);lr_output_message("After File;Save topwin = %s", topwin);
if (strcmp(topwin,"Transfer or Secondment Details") == 0){
lr_output_message("Successfully saved record");lr_end_transaction("CA_07_20_Transfer",LR_PASS);
}
else{
lr_error_message("Saving of record failed. Expected topwin = '%s'", topwin);
lr_end_transaction("CA_07_20_Transfer",LR_FAIL);
errorhandling();}
// Close Transfer or Secondment Details windownca_win_close("Transfer or Secondment Details");
nca_get_top_window(topwin);lr_output_message("After Transfer or Secondment Details close topwin = %s",
topwin);
if (strcmp(topwin, "N") != 0){lr_error_message("Transfer or Secondment Details close failed");errorhandling();
}
// Exit Oracle Appnca_set_window("Navigator - {Responsibility}");
nca_menu_select_item("N", "File;Exit Oracle Applications");
nca_get_top_window(topwin);lr_output_message("After File;Exit topwin = %s", topwin);
nca_set_window("Caution");
nca_popup_message_press("Caution", "OK");
ret_val = nca_get_top_window(topwin);
lr_output_message("ret_val = %d, topwin = \"%s\"", ret_val, topwin);lr_output_message("Values are E_OK = %d, E_GENERAL_ERROR = %d,
E_NOT_DISPLAYED = %d", E_OK, E_GENERAL_ERROR, E_NOT_DISPLAYED);
if (ret_val != E_OK || *topwin != '\0') { lr_error_message("Shutdown forms failed"); errorhandling();
}
return 0;}
Vuser init
vuser_init(){
return 0;}
CheckForErrors(){// Checks for error screen where none should existchar topwin[1024]; // topwindow of the oracle formint result; //integer check on string compare
nca_get_top_window(topwin); //lr_error_message("Error -->%s", topwin);result = strcmp( topwin, "Error");
//if ((topwin, "Error")) {if (result==0) { nca_win_close(topwin);
errorhandling();}
//else do nothing all ok}
PrintAllParameters(){
// General template paramterslr_error_message("Parameter ServerInstance = '%s'.",
lr_eval_string("{ServerInstance}"));lr_error_message("Parameter UserName = '%s'.", lr_eval_string("{UserName}"));lr_error_message("Parameter Password = '%s'.", lr_eval_string("{Password}"));
lr_error_message("Parameter Responsibility = '%s'.", lr_eval_string("{Responsibility}"));
lr_error_message("Parameter StartScreen = '%s'.", lr_eval_string("{StartScreen}"));
lr_error_message("Parameter dbInformation = '%s'.", lr_eval_string("{dbInformation}"));
lr_error_message("Parameter dbServer = '%s'.", lr_eval_string("{dbServer}"));lr_error_message("Parameter Port = '%s'.", lr_eval_string("{Port}"));
// Script specific parameters - to be added as created for the scriptlr_error_message("Parameter ColleagueDataType = '%s'.",
lr_eval_string("{ColleagueDataType}"));lr_error_message("Parameter Colleague = '%s'.", lr_eval_string("{Colleague}"));lr_error_message("Parameter RequirementStatus = '%s'.",
lr_eval_string("{RequirementStatus}"));lr_error_message("Parameter NewLocation = '%s'.",
lr_eval_string("{NewLocation}"));
return 0;
}
errorhandling(){
//Error handling routine to exit from anywhere in the script.char topwin[1024]; // topwindow of the oracle formint counter = 0; // Max of 20 screens to close before we assume infinite loop
lr_error_message("Entered Error handling with the following parameters");PrintAllParameters();
lr_think_time(5);
// Get the current top window nca_get_top_window(topwin);
lr_error_message("Exiting from topwin -->%s", topwin);
//Are we at the logoff point already// strcmp( topwin, "Navigator - {Responsibility}") may not be necessary - keeping
as was in the original codeif (strcmp( topwin, "N") == 0 || strcmp( topwin, "Navigator - {Responsibility}")
== 0) {
nca_menu_select_item("N", "File;Exit Oracle Applications"); nca_set_window("Caution"); nca_popup_message_press("Caution", "OK");
lr_think_time(60);lr_exit(LR_EXIT_MAIN_ITERATION_AND_CONTINUE, LR_FAIL);
return(0);}
//We are not at the logoff point (otherwise, we wouldn't have come here) //Loop until we are out of the application, Loop max 20 times and then forcefully exit. while (1) {
// Close the current top window nca_win_close(topwin);
// After closing the top window, find which is the new top window nca_get_top_window(topwin); lr_error_message("Now top window is -->%s", topwin);
if (strcmp(topwin, "Decision") ==0) { nca_popup_message_press("Decision", "Discard"); } else if (strcmp(topwin, "Error") == 0) {
nca_win_close(topwin); } else if (strcmp( topwin, "N") == 0 || strcmp(topwin, "Navigator - {Responsibility}") == 0) {
// strcmp( topwin, "Navigator - {Responsibility}") may not be necessary - keeping as was in the original code nca_set_window("Navigator - {Responsibility}"); // nca_win_close("N"); nca_menu_select_item("N", "File;Exit Oracle Applications"); nca_set_window("Caution"); nca_popup_message_press("Caution", "OK"); lr_think_time(60); lr_exit(LR_EXIT_MAIN_ITERATION_AND_CONTINUE, LR_FAIL);
return(0); }
//If 20 iterations of loop are done, forcefully exit counter ++;
if (counter > 20) { nca_set_window("Navigator - {Responsibility}");
//nca_win_close("N"); nca_menu_select_item("N", "File;Exit Oracle Applications");
nca_set_window("Caution");nca_popup_message_press("Caution", "OK");lr_think_time(60);
lr_exit(LR_EXIT_MAIN_ITERATION_AND_CONTINUE, LR_FAIL); nca_get_top_window(topwin); lr_error_message("Exiting from topwin -->%s", topwin);
return(0);}
} // While loop
// Should never come here lr_think_time(60); nca_get_top_window(topwin); lr_error_message("Exiting from topwin -->%s", topwin);
return(0);}
// Exception handler set using nca_set_exception in the Login()int close() {
//nca_popup_message_press("Error", "OK"); - errorhandling() takes care of this by closing the popup message
errorhandling(); // lr_think_time(60);
}
//// Replace function is a string search and replace function// It is needed to remove the & from the correlated URL// It replaces & with & thereby providing a proper usable URL for the login script//// It takes the FullRUL in the form of a parameter, and saves it back into the// same parameter
replace() { char *string = lr_eval_string("{FullURL}");char *oldpiece = "&";
char *newpiece = "&"; int str_index; int newstr_index; int oldpiece_index; int end; int new_len; int old_len; int cpy_len; char *c; static char newstring[500];
if ((c = (char *) strstr(string, oldpiece)) == NULL) lr_error_message("oops no URL returned");
//return string;
new_len = strlen(newpiece); old_len = strlen(oldpiece); end = strlen(string) - old_len; oldpiece_index = c - string;
newstr_index = 0; str_index = 0; while(str_index <= end && c != NULL) {
/* Copy characters from the left of matched pattern occurence */ cpy_len = oldpiece_index-str_index; strncpy(newstring+newstr_index, string+str_index, cpy_len); newstr_index += cpy_len; str_index += cpy_len;
/* Copy replacement characters instead of matched pattern */ strcpy(newstring+newstr_index, newpiece); newstr_index += new_len; str_index += old_len;
/* Check for another pattern match */ if((c = (char *) strstr(string+str_index, oldpiece)) != NULL) oldpiece_index = c - string;//lr_output_message("It is --> %s", newstring); }
// lr_output_message("It is --> %s", newstring);
/* Copy remaining characters from the right of last matched pattern */ strcpy(newstring+newstr_index, string+str_index);
// lr_output_message("It is --> %s", newstring);
lr_save_string(newstring, "FullURL");//lr_error_message("FullURL --> %s", lr_eval_string("{FullURL}"));
return 0; }
Vuiser endvuser_end(){
return 0;}
Identify Previous Sunday and next Sunday
lr_save_datetime("%a", DATE_NOW, "WeekDayName");
//iWeekDay = atoi(lr_eval_string("{WeekDay}");
while (strcmp(lr_eval_string("{WeekDayName}"), "Sun") != 0) {
iDay--;
lr_save_datetime("%a", DATE_NOW-(ONE_DAY*iDay), "WeekDayName");
//lr_error_message("iday value = %d", iDay);
}
if (strcmp(lr_eval_string("{WeekDayName}"), "Sun") == 0) {
lr_save_datetime("%d-%b-%Y", DATE_NOW-(ONE_DAY*iDay), "EndDate");
iDay = iDay + 7;
lr_save_datetime("%d-%b-%Y", DATE_NOW-(ONE_DAY*iDay), "StartDate");
}
lr_error_message(lr_eval_string("{EndDate}"));lr_error_message(lr_eval_string("{StartDate}"));
Sample
lr_think_time(15);
nca_get_top_window(topwindow1);
if (strncmp(topwindow1,"Submit a New", 12) == 0){
nca_set_window("Submit a New Request");
nca_button_press("WHAT_TYPE_OK_0");
}else
{lr_error_message("Submit a request page NOT found");errorhandling();
}
lr_output_message("The value is %s",(lr_eval_string(topwindow1)));
lr_think_time(13);
nca_get_top_window(topwindow2);
if (strncmp(topwindow1,"Submit Request", 12) == 0){
nca_set_window("Submit Request");
nca_edit_press("WORK_ORDER_USER_CONCURRENT_PROGRAM_NAME_0");}
else {
lr_error_message("Submit Request NOT found");errorhandling();
}
lr_output_message("The value is %s",(lr_eval_string(topwindow2)));
lr_think_time(8);
nca_get_top_window(topwindow3);
if (strncmp(topwindow3,"Reports", 12) == 0){
nca_set_window("Reports");
nca_lov_retrieve_items("Reports", 1, 469);}
else {
lr_error_message("Reports page NOT found");errorhandling();
}
nca_lov_select_item("Reports", "XXJS New Starters and Transfers Report|Sainsburys HR Application");
lr_think_time(7);
nca_set_window("Parameters");
nca_flex_set_cell_data("Parameters", "Start Date", "", "30-NOV-2008");
lr_think_time(11);
nca_flex_set_cell_data("Parameters", "End Date", "", "07-DEC-2008");
lr_think_time(12);
nca_flex_press_lov("Parameters", "Group Name", "");
lr_think_time(7);
nca_set_window("Group Name");
nca_lov_retrieve_items("Group Name", 1, 18);
nca_lov_select_item("Group Name", "Retail Stores");
lr_think_time(7);
nca_set_window("Parameters");
nca_flex_press_lov("Parameters", "Organization", "");
lr_think_time(6);
nca_set_window("Organization");
nca_lov_retrieve_items("Organization", 1, 18);
nca_lov_select_item("Organization", "A0002 - Stratford");
nca_set_window("Parameters");
nca_flex_press_ok("Parameters");
nca_set_window("Submit Request");
nca_button_press("WORK_ORDER_SUBMIT_0");
lr_think_time(6);
nca_set_window("Requests");
nca_obj_type("JOBS_REQUEST_ID_0", '\t', 0);
nca_obj_type("JOBS_PARENT_0", '\t', 0);
nca_obj_type("JOBS_PHASE_0", '\t', 0);
nca_obj_type("JOBS_STATUS_0", '\t', 0);
nca_obj_type("JOBS_ARGUMENTS_0", '\t', 0);
nca_obj_type("JOBS_HOLD_0", '\t', 0);
nca_obj_type("JOBS_JOB_DETAIL_0", '\t', 0);
Refresh=nca_obj_status("JOBS_VIEW_REPORT_0");
lr_error_message("%d",Refresh);
while (nca_obj_status("JOBS_VIEW_REPORT_0")==-24997)//while (Refresh == -24997) {
nca_button_press("JOBS_REFRESH_0");
lr_think_time(10);//lr_error_message("Refrsh %s", Refresh);
}
lr_think_time(5);nca_button_press("JOBS_VIEW_REPORT_0");
nca_menu_select_item("Requests", "File;Close Form");
nca_set_window("Navigator - SSL HR Shared Service - Colleague Admin");
nca_menu_select_item("N", "File;Exit Oracle Applications");
nca_set_window("Caution");
nca_popup_message_press("Caution", "OK");
return 0;