zoukankan      html  css  js  c++  java
  • SAP 实例 6 HTML input

    REPORT demo_html_input.
    
    CLASS demo DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS main.
      PRIVATE SECTION.
        CLASS-METHODS handle_sapevent
          FOR EVENT sapevent
                      OF cl_abap_browser
          IMPORTING action
                      query_table.
    ENDCLASS.
    
    CLASS demo IMPLEMENTATION.
      METHOD main.
        DATA error_list TYPE cl_abap_browser=>html_table.
    
        SET HANDLER handle_sapevent.
    
        DATA(html_str) =
           `<html>`
        && `  <head>`
        && `    <meta http-equiv="content-type" `
        && `          content="text/html; `
        && `          charset=utf-8">`
        && `    <script language="JavaScript">`
        && `      function sendInput(form) `
        && `          { fname=form.name;       `
        && `            document[fname].submit();} `
        && `      function InputKeyDown(form) {`
        && `        if(event.keyCode == 13) {`
        && `            fname=form.name;`
        && `            document[fname].submit();} }`
        && `    </script>`
        && `  </head>`
        && `  <body>`
        && `    <form name="INPUT" accept-charset="utf-8" `
        && `          method="post" action="SAPEVENT:INPUT"> `
        && `      <input type="text" id="in1" name="field1" `
        && `             size=30 maxlength=30 title="" value="aaa" `
        && `             onKeyDown="InputKeyDown(this.form);"><br>`
        && `      <input type="text" id="in2" name="field2" `
        && `             size=30 maxlength=30 title="" value="bbb" `
        && `             onKeyDown="InputKeyDown(this.form);"><br>`
        && `      <input type="text" id="in3" name="field3" `
        && `             size=30 maxlength=30 title="" value="ccc" `
        && `             onKeyDown="InputKeyDown(this.form);"><br><br>`
        && `     <button id="enterButton" type="button" `
        && `             title="Enter" onClick="sendInput(INPUT);" `
        && `             onKeypress="if(event.keycode=13) `
        && `             sendInput(INPUT);">`
        && `             Enter</button>`
        && `    </form>`
        && `  </body>`
        && `</html>`.
    
        cl_abap_browser=>show_html(
          EXPORTING
            html_string = html_str
            title       = 'Input Demo'
          IMPORTING
             html_errors = error_list ).
    
        IF error_list IS NOT INITIAL.
          MESSAGE 'Error in HTML' TYPE 'I' DISPLAY LIKE 'E'.
        ENDIF.
      ENDMETHOD.
      METHOD handle_sapevent.
        DATA(out) = cl_demo_output_stream=>open( ).
        SET HANDLER cl_demo_output_html=>handle_output FOR out.
        out->write_data( iv_name = 'ACTION'      ia_value = action ).
        out->write_data( iv_name = 'QUERY_TABLE' ia_value = query_table ).
        out->close( ).
      ENDMETHOD.
    ENDCLASS.
    
    START-OF-SELECTION.
      demo=>main( ).

    Description

    This example creates a HTML file containing multiple input fields, a pushbutton, and JavaScript functions for handling the input. The form INPUT uses method="post" to send the input data. The HTML control in CFW uses the parameter QUERY_TABLE of the event SAPEVENT to pass this data to its handler. The class CL_ABAP_BROWSER (a wrapper for the class CL_GUI_HTML_VIEWER also passes this parameter and the user input can be used in the ABAP program.

    Also see the corresponding example for ICF

  • 相关阅读:
    SAP Cloud for Customer的Account Team里的role如何配置
    SAP标准培训课程C4C10学习笔记(二)第二单元
    SAP标准培训课程C4C10学习笔记(一)第一单元
    如何找到SAP Cloud for Customer标准培训和认证方面的信息
    我用ABAP做过的那些无聊的事情
    有道云笔记不需要通过开通会员的方式来去除广告显示
    微软OneDrive使用体验
    自己开发的在线视频下载工具,基于Java多线程
    CloudFoundry命令行和Kubernetes命令行的Restful API消费方式
    利用装饰器计算函数运行的时间
  • 原文地址:https://www.cnblogs.com/JackeyLove/p/13489488.html
Copyright © 2011-2022 走看看