VUGen与SAPGUI协议

时间:2016-11-17 09:01:45

标签: vugen

这是我第一次在VUGen中使用SAPGUI协议。我使用SAPGUI协议在VUGen中记录了一个脚本。我记录的过程是VA01“创建销售订单”。在重放脚本的过程中,我在不打开sap logon的情况下直接得到错误:

  

错误:第2行包含8列而不是6错误:表   'C:\用户\管理员\文件\ VuGen将\脚本\ VA01 \ data_1.dat'   无法打开。错误代码为“-4”。警告:扩展参数   在调用函数ExtPerProcessInitialize时报告错误-4错误:   线程上下文:调用驱动程序的服务失败,原因 - 线程   在这个帖子中没有初始化上下文。

1 个答案:

答案 0 :(得分:0)

我已经尝试记录“VA01 - 创建销售订单”流程,并且能够成功重播。

我正在使用SAP 7.40和VuGen 12.55。

你能发布你录制的剧本吗?

此外,您可以查看我在此录制的脚本:https://pastebin.com/DkFD8W5J

Action()
{

sapgui_open_connection_ex(connection_string1, 
    "", 
    "con[0]");

sapgui_select_active_connection("con[0]");

sapgui_select_active_session("ses[0]");

sapgui_select_active_window("wnd[0]");

sapgui_window_resize("149", 
    "25", 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui104", 
    END_OPTIONAL);

/*Before running script, enter password in place of asterisks in logon function*/

lr_think_time(4);

sapgui_logon("NWBCUSER", 
    "mercury", 
    "800", 
    "EN", 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1012", 
    END_OPTIONAL);

sapgui_tree_set_selected_node("VA01 - Create Sales Order", 
    shell1, 
    "F00003", 
    BEGIN_OPTIONAL, 
        "AdditionalNodeInfo=Favorites;VA01 - Create Sales Order", 
        "AdditionalInfo=sapgui1013", 
    END_OPTIONAL);

sapgui_tree_double_click_node("VA01 - Create Sales Order", 
    shell1, 
    "F00003", 
    BEGIN_OPTIONAL, 
        "AdditionalNodeInfo=Favorites;VA01 - Create Sales Order", 
        "AdditionalInfo=sapgui1014", 
    END_OPTIONAL);

lr_think_time(4);

sapgui_set_text("VBAK-AUART", 
    "12", 
    ctxtVBAK1, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1017", 
    END_OPTIONAL);

sapgui_set_text("Sales Organization", 
    "ss", 
    ctxtVBAK2, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1018", 
    END_OPTIONAL);

sapgui_set_focus(ctxtVBAK2, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1019", 
    END_OPTIONAL);

sapgui_send_vkey(F4, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1021", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[1]");

sapgui_window_scroll_to_row("0", 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1025", 
    END_OPTIONAL);

sapgui_set_focus(lbl1, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1024", 
    END_OPTIONAL);

sapgui_send_vkey(F2, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1028", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[0]");

sapgui_set_focus(ctxtVBAK3, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1031", 
    END_OPTIONAL);

sapgui_send_vkey(F4, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1033", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[1]");

sapgui_window_scroll_to_row("0", 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1037", 
    END_OPTIONAL);

sapgui_set_focus(lbl2, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1036", 
    END_OPTIONAL);

sapgui_send_vkey(F2, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1040", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[0]");

sapgui_set_focus(ctxtVBAK4, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1043", 
    END_OPTIONAL);

sapgui_send_vkey(F4, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1045", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[1]");

sapgui_window_scroll_to_row("0", 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1049", 
    END_OPTIONAL);

sapgui_set_focus(lbl3, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1048", 
    END_OPTIONAL);

sapgui_send_vkey(F2, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1052", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[0]");

sapgui_set_focus(ctxtVBAK5, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1055", 
    END_OPTIONAL);

sapgui_send_vkey(F4, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1057", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[1]");

sapgui_press_button("Continue   (Enter)", 
    btn1, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1060", 
    END_OPTIONAL);

sapgui_press_button("Continue   (Enter)", 
    btn1, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1063", 
    END_OPTIONAL);

sapgui_set_focus(ctxtG_SELFLD_TAB1, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1066", 
    END_OPTIONAL);

sapgui_send_vkey(F2, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1068", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[2]");

sapgui_window_close(
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1071", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[1]");

sapgui_set_focus(txtG_SELFLD_TAB1, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1074", 
    END_OPTIONAL);

sapgui_send_vkey(F2, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1076", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[2]");

sapgui_grid_select_cell("'Sales Office' (2, Description)", 
    shell2, 
    "2", 
    "TEXT", 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1079", 
    END_OPTIONAL);

sapgui_grid_select_rows("'Sales Office', 2", 
    shell2, 
    "2", 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1080", 
    END_OPTIONAL);

sapgui_grid_double_click_current_cell("'Sales Office' (2, Description)", 
    shell2, 
    BEGIN_OPTIONAL, 
        "CurrentRow=2", 
        "CurrentCell=TEXT", 
        "AdditionalInfo=sapgui1081", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[1]");

sapgui_set_focus(txtG_SELFLD_TAB1, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1084", 
    END_OPTIONAL);

sapgui_press_button("Cancel   (F12)", 
    btn2, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1086", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[0]");

sapgui_send_vkey(F4, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1089", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[1]");

sapgui_window_close(
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1092", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[0]");

sapgui_status_bar_get_text("paramStatusBarText", 
    BEGIN_OPTIONAL, 
        "Recorded status bar text: Choose a valid function", 
        "AdditionalInfo=sapgui1097", 
    END_OPTIONAL);

lr_think_time(6);

sapgui_set_text("Sales Office", 
    "1", 
    ctxtVBAK5, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1098", 
    END_OPTIONAL);

sapgui_set_text("Sales Group", 
    "2", 
    ctxtVBAK6, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui1099", 
    END_OPTIONAL);

sapgui_set_focus(ctxtVBAK6, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui10100", 
    END_OPTIONAL);

sapgui_press_button("Back   (F3)", 
    btn3, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui10102", 
    END_OPTIONAL);

sapgui_press_button("Log off   (Shift+F3)", 
    btn4, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui10105", 
    END_OPTIONAL);

sapgui_select_active_window("wnd[1]");

sapgui_press_button("Yes", 
    btnSPOP1, 
    BEGIN_OPTIONAL, 
        "AdditionalInfo=sapgui10108", 
    END_OPTIONAL);

return 0;

}