Lr Template

Download Lr Template

Post on 15-Nov-2014

120 views

Category:

Documents

7 download

Embed Size (px)

TRANSCRIPT

<p>#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 &amp; //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();</p> <p>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/AppsLocalL ogin.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}")) &gt; 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");</p> <p>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}")) &gt; 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\"&gt;{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);</p> <p>if (atoi(lr_eval_string("{StartScreen_Count}")) &gt; 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); }</p> <p>// // Remove the &amp; from the trapped url ({FullURL}) and replace with &amp; replace(); // // secgrp_key=1secg web_reg_save_param("secgrp_key", "LB/IC=secgrp_key=", "RB/IC=&amp;", "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 = \"",</p> <p>"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 =&amp;resp_app=SQLGL&amp;resp_key=GENERAL_LEDGER_SUPER_USER&amp;secgrp_key=S TANDARD&amp;start_func=RGXGRRST web_reg_save_param("SecondUrl", "LB=ICX_TICKET=&amp;resp_app=", "RB=&amp;other_params=", "ORD=1", LAST); lr_start_transaction("Generic_Logon_40_Start_Oracle_Forms"); web_url("RF.jsp", "URL={FullURL}&amp;formsLink=yes", "Resource=0", "RecContentType=text/html", "Referer=http://{ServerInstance}.bc.jsplc.net:8070/OA_HTML/OA.jsp?O AFunc=OAHOMEPAGE&amp;akRegionApplicationId=0&amp;navRespId=50966&amp;navRespAppI d=800&amp;navSecGrpId=1&amp;transactionid={transactionid}&amp;oapc=2&amp;oas={OasId}", "Snapshot=t6.inf", "Mode=HTML", LAST);</p> <p>//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_TICK ET=&amp;resp_app=PER&amp;resp_key=SAINS_UKHR_IRC_RECRUITER_SCM&amp;secgrp_key =1&amp;start_func=XXJSINTVSLOT_FN&amp;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=&amp;resp_app={SecondUrl}&amp;other_params=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t7.inf", "Mode=HTML", LAST); //************************************************</p> <p>if (atoi(lr_eval_string("{Launch_Count}")) &gt; 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);</p> <p>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/r egistry/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/fn d/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 error lr_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/FNDSC</p> <p>SGN 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?m enu=Y", "Resource=0", "RecContentType=text/html", "Referer=http://stevux1022a.bc.jsplc.net:8070/OA_HTML/OA.jsp?OAFu nc=OAHOMEPAGE&amp;akRegionApplicationId=0&amp;navRespId=51053&amp;navRespAppId=8 00&amp;navSecGrpId=1&amp;transactionid=1997616659&amp;oapc=2&amp;oas=mpCfmRzyT8pVup4XTxszA..", "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.js p?menu=Y", "Resource=0", "RecContentType=text/html", "Referer=http://{ServerInstance}.bc.jsplc.net:8070/OA_HTML/OA.jsp?O AFunc=OAHOMEPAGE&amp;akRegionApplicationId=0&amp;navRespId=20434&amp;navRespAppI</p> <p>d=101&amp;navSecGrpId=0&amp;transactionid=1269312078&amp;oapc=2&amp;oas=vmhK9LrNn_k1_wp Vo9XPow..", "Snapshot=t8.inf", "Mode=HTML", LAST); // Check result if (atoi(lr_eval_string("{SearchStr1_Count}")) &gt; 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-2008 Business Process document ref: Coll_Adm\CA_07_TransferContractChange.doc Brief 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 Requirement</p> <p>d. 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 boxes char topwin[1024]; // Check the topwindow of the display int result; // Used to handle the string compares etc char 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 functions char selected_item[256]; /**** Inserted variable declarations block end */ // Check initial window is Find Person nca_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 search if (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);</p> <p>// 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, hopefully else { 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"</p> <p>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 nonexistant. 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");</p> <p>// 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 button lr_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 form nca_obj_type("ANALYSES_DATE_FROM_0", '\t', 0); nca_obj_type("ANALYSES_DATE_TO_0", '\t', 0); nca_get_top_window(topwin);</p> <p>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 form nca_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_mes...</p>