SAP 调用OO类发送邮件测试(可发送表格和附件)

news2024/11/18 4:47:55

原文链接:https://blog.csdn.net/sapliumeng/article/details/134152739
在SAP实施中,邮件发送功能在很多项目都会用到,而且往往是把内表以Excel或者CSV的格式发送附件,最好是这个表格也可以显示在正文中,这样的话如果数据行数比较少,就不需要打开附件了。

发送的邮件如下图所示:
在这里插入图片描述
以往这种需要都是每个程序单独写好长的代码,代码的工作量非常大,本文就是把功能都集成到几个子程序和函数中,大大减少了开发工作量。

程序特点:
1、支持发送到多个外部邮箱
2、支持发送到SAP账号(使用事务码SBWP看邮件)
3、可以选择是否紧急邮件
4、支持多个内表发送,表格和附件分别显示
5、附件压缩为ZIP文件
6、邮件表格界面友好美观
7、如果正文表格未显示所有内表行,则最后一行为省略号

示例代码:

*&---------------------------------------------------------------------*
*& Report ZCYCLE064
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zcycle064.
**** RFC 版发送邮件测试 START ********
*DATA: it_document_data  TYPE sodocchgi1,
*      it_content_text   TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE,
*      it_packing_list   TYPE TABLE OF sopcklsti1 WITH HEADER LINE,
*      it_receivers      TYPE STANDARD TABLE OF somlreci1 WITH HEADER LINE,
*      lc_mail_attach    TYPE string,
*      lt_content_hex    TYPE STANDARD TABLE OF solix WITH HEADER LINE,
*      lt_object_header  TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE,
*      lc_mail_xattach   TYPE xstring,
*      lv_send_all       TYPE c,
*      it_makt           LIKE TABLE OF makt WITH HEADER LINE,
*      fir_date          TYPE sy-datum,
*      mimetype          TYPE char64.
*DATA: it_itab           TYPE TABLE OF itab WITH HEADER LINE,
*      wa_itab           TYPE itab.
*
*CONSTANTS:lc_tab  TYPE c VALUE cl_bcs_convert=>gc_tab,       "excel换格符
*          lc_ctrl TYPE c VALUE cl_bcs_convert=>gc_crlf.      "excel换行符
*
*PARAMETER p_flag  TYPE c AS CHECKBOX.
*
*IF p_flag = 'X'.
*  PERFORM send_email.
*ENDIF.
*
**&---------------------------------------------------------------------*
**&      Form  SEND_EMAIL
**&---------------------------------------------------------------------*
**       text
**----------------------------------------------------------------------*
*FORM send_email.
*  DATA sy_vline TYPE i.
*  DATA:mblnr TYPE string,   "物料凭证
*       matnr TYPE string,   "物料
*       mjahr TYPE string,   "年度
*       maktx TYPE string.   "物料描述
*
*  it_document_data-obj_descr = '邮件主题' .    "内容的简短描述
*  it_document_data-priority = '1'.             "优先次序  1~9  1:最高优先权
*  it_document_data-obj_name = 'OFFER'.
*  it_document_data-obj_langu = sy-langu.
*
**  ****邮件正文信息
*  it_content_text = '各位好:'.
*  APPEND it_content_text.
*  it_content_text = '  此邮件为测试邮件!!!!!!!'.
*  APPEND it_content_text.
*
*  DESCRIBE TABLE it_content_text LINES sy_vline.
*  it_document_data-doc_size = 255 * ( sy_vline - 1 ) + strlen( it_content_text ).  "SAPoffice 文档的大小(用于 API1*
*  it_packing_list-transf_bin = space.
*  it_packing_list-head_start = 1.
*  it_packing_list-head_num = 0 .
*  it_packing_list-body_num = sy_vline.
*  it_packing_list-body_start = 1.
*  it_packing_list-doc_type = 'RAW'.
*  APPEND it_packing_list.
*
*
****收件人信息
*  it_receivers-receiver = '1243327997@qq.com'.  "收件人地址
*  it_receivers-rec_type = 'U'.
*  it_receivers-com_type = 'INT'.
*  it_receivers-notif_del =  'X'.
*  it_receivers-notif_ndel = 'X'.
*  APPEND it_receivers.
*
*  CONCATENATE '物料'     lc_tab
*              '物料凭证' lc_tab
*              '物料描述' lc_tab
*              '年度'     lc_ctrl INTO lc_mail_attach.   "lc_ctrl换行符
*
*  CLEAR:mblnr, matnr, mjahr, maktx.
*  mblnr  = '7777777'.
*  matnr  = '7777777'.
*  mjahr  = '7777'.
*  maktx  = 'seven'."物料类型
*
*  CONCATENATE lc_mail_attach
*              matnr  lc_tab
*              mblnr  lc_tab
*              mjahr  lc_tab
*              maktx  lc_ctrl INTO lc_mail_attach.      "lc_ctrl换行符
*
*  CLEAR:mblnr, matnr, mjahr, maktx.
*  mblnr  = '8888888'.
*  matnr  = '8888888'.
*  mjahr  = '8888'.
*  maktx  = 'seven'."物料类型
*
*  CONCATENATE lc_mail_attach
*              matnr  lc_tab
*              mblnr  lc_tab
*              mjahr  lc_tab
*              maktx  lc_ctrl INTO lc_mail_attach.      "lc_ctrl换行符
*
*  mimetype = 'APPLICATION/MSEXCEL;CHARSET=UTF-16LE'.
*  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
*    EXPORTING
*      text       = lc_mail_attach
*      mimetype   = mimetype
**     ENCODING   =
*   IMPORTING
*      buffer     =  lc_mail_xattach
*   EXCEPTIONS
*      failed     = 1
*      others     = 2 .
*
*  IF sy-subrc = 0.
*    CONCATENATE cl_abap_char_utilities=>byte_order_mark_little lc_mail_xattach INTO lc_mail_xattach IN BYTE MODE.
*  ENDIF.
*
*  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
*    EXPORTING
*      buffer          = lc_mail_xattach
**    APPEND_TO_TABLE  = ' '
**  IMPORTING
**    OUTPUT_LENGTH    =
*    TABLES
*      binary_tab      = lt_content_hex.
*
*"不知道干啥用的
*  lt_object_header = 'Seven test'.
*  APPEND lt_object_header.
*
*  DESCRIBE TABLE lt_content_hex LINES sy_vline.
*
*  it_packing_list-transf_bin = 'X'.
*  it_packing_list-head_start = 1 .
*  it_packing_list-head_num =  0 .
*  it_packing_list-body_start = 1.
*  it_packing_list-body_num = sy_vline.
*  it_packing_list-doc_type = 'XLS'.
*  it_packing_list-doc_size = 255 * sy_vline.
*  it_packing_list-obj_name = '附件名'.
*  it_packing_list-obj_descr = it_packing_list-obj_name.
*  APPEND it_packing_list.
*
*
*"方法1  无法指定发送人邮箱
********  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
********    EXPORTING
********      document_data              = it_document_data
********      put_in_outbox              = 'X'
********      commit_work                = 'X'
********    IMPORTING
********      sent_to_all                = lv_send_all
*********       NEW_OBJECT_ID              =
********    TABLES
********      packing_list               = it_packing_list[]
********      object_header              = lt_object_header[]
*********     contents_bin               =
********      contents_txt               = it_content_text[]
********      contents_hex               = lt_content_hex[]
*********     object_para                =
*********     object_parb                =
********      receivers                  = it_receivers[]
********    EXCEPTIONS
********      too_many_receivers         = 1
********      document_not_sent          = 2
********      document_type_not_exist    = 3
********      operation_no_authorization = 4
********      parameter_error            = 5
********      x_error                    = 6
********      enqueue_error              = 7
********      others                     = 8 .
*
*"方法2  可以指定发送人邮箱
*  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
*    EXPORTING
*      document_data                    = it_document_data
*      put_in_outbox                    = 'X'
*      sender_address                   = 'lei.cao@lifotronic.com' "发件人邮箱
*      sender_address_type              = 'INT'
*      commit_work                      = 'X'
**     IP_ENCRYPT                       =
**     IP_SIGN                          =
**     IV_VSI_PROFILE                   =
*    IMPORTING
*      sent_to_all                      = lv_send_all
**     NEW_OBJECT_ID                    =
**     SENDER_ID                        =
*    TABLES
*      packing_list                     = it_packing_list[]
*      object_header                    = lt_object_header[]
**     CONTENTS_BIN                     =
*      contents_txt                     = it_content_text[]
*      contents_hex                     = lt_content_hex[]
**     OBJECT_PARA                      =
**     OBJECT_PARB                      =
*      receivers                        = it_receivers[]
**     ET_VSI_ERROR                     =
*    EXCEPTIONS
*      too_many_receivers               = 1
*      document_not_sent                = 2
*      document_type_not_exist          = 3
*      operation_no_authorization       = 4
*      parameter_error                  = 5
*      x_error                          = 6
*      enqueue_error                    = 7
*      others                           = 8
*            .
*  IF sy-subrc <> 0.
**   Implement suitable error handling here
*  ELSE.
*    SUBMIT RSCONN01 WITH MODE = 'INT'
*                   WITH OUTPUT = 'X'
*                   AND RETURN.
*  ENDIF.
*
*ENDFORM.                    "SEND_EMAIL
**** RFC 版发送邮件测试 END ********

**** OO 版发送邮件测试 START ********************
TABLES adr6.
DATA: BEGIN OF gt_out OCCURS 0,
        bukrs TYPE t001-bukrs,
        butxt TYPE t001-butxt,
        ort01 TYPE t001-ort01,
        land1 TYPE t001-land1,
        waers TYPE t001-waers,
        spras TYPE t001-spras,
      END OF gt_out.


SELECT-OPTIONS s_smtp FOR adr6-smtp_addr NO INTERVALS OBLIGATORY.
PARAMETERS p_subj TYPE so_obj_des DEFAULT '发送邮件测试'.


AT SELECTION-SCREEN OUTPUT.
  %_s_smtp_%_app_%-text = '接收邮箱'.
  %_p_subj_%_app_%-text = '邮件主题'.


START-OF-SELECTION.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_out FROM t001.
  PERFORM sendmail.
  MESSAGE s000(oo) WITH 'Done'.


*&---------------------------------------------------------------------*
*& sendmail
*&---------------------------------------------------------------------*
FORM sendmail.
  DATA lv_string TYPE string.
  DATA lv_csvxstr TYPE xstring.
  DATA lv_binlen  TYPE i.
  DATA lt_html TYPE TABLE OF w3html WITH HEADER LINE.
  DATA lt_smtp TYPE TABLE OF piqapp_email WITH HEADER LINE.
  DATA lt_atta TYPE wlftt_mail_attachment WITH HEADER LINE.


***邮件内容文本
  APPEND 'TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST<br/>' TO lt_html.
  APPEND 'TEST TEST TEST TEST TEST TEST TEST TEST <br/>' TO lt_html.
  APPEND 'TEST TEST TEST TEST <br/><br/>' TO lt_html.


***下面显示表格,如果有多个内表需要发送,重复下面4个步骤即可
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_out FROM t001.
***内表转为CSV文件
  PERFORM itab_to_csv
                     TABLES gt_out
                     USING '公司代码,名称,城市,国家,货币,语言' "CSV文件的标题
                     CHANGING lv_string lv_csvxstr.


***压缩CSV文件
  PERFORM xstr2zipxstr
                       USING 'BUKRS.XLS' lv_csvxstr
                       CHANGING lv_csvxstr.


***压缩文件作为附件
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer        = lv_csvxstr
    IMPORTING
      output_length = lv_binlen
    TABLES
      binary_tab    = lt_atta-binary_content.
  lt_atta-description = 'BUKRS.zip'.
  lt_atta-binary_size = lv_binlen.
  APPEND lt_atta.


***内表的前N条以表格的形式显示在邮件正文中
  PERFORM itab_to_mail_body
                            TABLES gt_out lt_html
                            USING '公司代码列表:' "表格上面文本
                                  '公司代码,名称,城市,国家,货币,语言' "表格标题
                                  'XXXXXX'  "要显示的列,按照顺序,如果显示为X,不显示为空格
                                  '10'.     "显示内表前N行,如果内表大于N行则最后一行显示省略号


***接收邮箱
  LOOP AT s_smtp.
    APPEND s_smtp-low TO lt_smtp.
  ENDLOOP.


***调用发送函数
  CALL FUNCTION 'ZPUB_SEND_MAIL'
    EXPORTING
      subject   = p_subj
      commit    = 'X'
      atta_tab  = lt_atta[]
    TABLES
      mail_body = lt_html
      recv_smtp = lt_smtp.
ENDFORM.

*&---------------------------------------------------------------------*
*& 内表转为CSV文件
*&---------------------------------------------------------------------*
FORM itab_to_csv TABLES t_intab USING pv_header
                 CHANGING cv_str cv_utf8x.
  DATA: lo_csv TYPE REF TO cl_rsda_csv_converter.
  DATA: lv_str TYPE char2048.


  CALL METHOD cl_rsda_csv_converter=>create
    RECEIVING
      r_r_conv = lo_csv.


  IF pv_header IS NOT INITIAL.
    cv_str = pv_header && %_cr_lf.
  ENDIF.


  LOOP AT t_intab.
    CALL METHOD lo_csv->structure_to_csv
      EXPORTING
        i_s_data = t_intab
      IMPORTING
        e_data   = lv_str.
    cv_str = cv_str && lv_str && %_cr_lf.
  ENDLOOP.


  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text     = cv_str
      mimetype = 'UTF8'
    IMPORTING
      buffer   = cv_utf8x
    EXCEPTIONS
      failed   = 1
      OTHERS   = 2.
  IF sy-subrc = 0.
    cv_utf8x = cl_abap_char_utilities=>byte_order_mark_utf8 && cv_utf8x.
  ENDIF.
ENDFORM.


*&---------------------------------------------------------------------*
*& XSTRING压缩为ZIP文件XSTRING
*&---------------------------------------------------------------------*
FORM xstr2zipxstr USING pv_filename pv_xstr CHANGING cv_zipxstr.
  DATA: lo_zip TYPE REF TO cl_abap_zip.
  DATA: lv_str TYPE string.


  lv_str = pv_filename.
  CREATE OBJECT lo_zip.
  CALL METHOD lo_zip->add
    EXPORTING
      name    = lv_str
      content = pv_xstr.
  CALL METHOD lo_zip->save
    RECEIVING
      zip = cv_zipxstr.
ENDFORM.


*&---------------------------------------------------------------------*
*& 内表写到邮件表格
*&---------------------------------------------------------------------*
FORM itab_to_mail_body TABLES t_intab t_contents STRUCTURE solisti1
                       USING pv_text pv_coldesc pv_mask pv_toline.
  DATA: lt_conts TYPE TABLE OF solisti1 WITH HEADER LINE,
        lt_title TYPE TABLE OF char40 WITH HEADER LINE.
  DATA: subrc   TYPE sy-subrc,
        index   TYPE sy-index,
        charc   TYPE char2048,
        charstr TYPE string,
        lmask   TYPE char200,
        omitnum TYPE i,
        ftype .
  FIELD-SYMBOLS <fs_fld> .


  CHECK t_intab[] IS NOT INITIAL.


  SPLIT pv_coldesc AT ',' INTO TABLE lt_title.
  lmask = pv_mask.


  APPEND pv_text TO lt_conts.
  APPEND:
    `<style type="text/css">.solid{BORDER-TOP: 1px solid;` TO lt_conts,
    `BORDER-RIGHT:1px solid;BORDER-BOTTOM: 1px solid;    ` TO lt_conts,
    `BORDER-LEFT: 1px solid}</style><table border=1      ` TO lt_conts,
    `cellpadding=2 style='border-collapse:collapse;font-`  TO lt_conts,
    `size:10.5pt'><tbody><tr style="background:#DDD9C4;">` TO lt_conts.


  LOOP AT lt_title.
    APPEND |<td class="solid">{ lt_title }</td>| TO lt_conts.
  ENDLOOP.
  APPEND `</tr>` TO lt_conts.


  LOOP AT t_intab FROM 0 TO pv_toline.
    APPEND '<tr>' TO lt_conts.
    CLEAR omitnum.
    DO.
      index = sy-index - 1.
      ASSIGN COMPONENT sy-index OF STRUCTURE t_intab TO <fs_fld>.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.


      CHECK lmask+index(1) = 'X' OR lmask = ''.
      omitnum = omitnum + 1.


      DESCRIBE FIELD <fs_fld> TYPE ftype.
      CASE ftype.
        WHEN 'I' OR 'P' OR 'F' OR 'a' OR 'e' OR 'b' OR 's'.
          charc = abs( <fs_fld> ).
          CONDENSE charc NO-GAPS.
          IF <fs_fld> < 0.
            CONCATENATE '-' charc INTO charc.
          ENDIF.
          charstr = charc.
        WHEN 'D' OR 'T'.
          IF <fs_fld> IS INITIAL OR <fs_fld> = ''.
            charc = ''.
          ELSE.
            WRITE <fs_fld> TO charc .
          ENDIF.
          charstr = charc.
        WHEN 'X' OR 'y' OR 'g'.
          charstr = <fs_fld> .
        WHEN OTHERS.
          WRITE <fs_fld> TO charc .
          charstr = charc.
      ENDCASE.
      APPEND |<td class="solid">{ charstr }</td>| TO lt_conts.
    ENDDO.
    APPEND `</tr>` TO lt_conts.
  ENDLOOP.
  IF lines( t_intab ) > pv_toline.
    APPEND '<tr>' TO lt_conts.
    DO omitnum TIMES.
      APPEND |<td class="solid">...</td>| TO lt_conts.
    ENDDO.
    APPEND '</tr>' TO lt_conts.
  ENDIF.
  APPEND '</tbody></table> <br/> ' TO lt_conts.


  APPEND LINES OF lt_conts TO t_contents.
ENDFORM.
**** OO 版发送邮件测试 END ********************

发送函数 ZPUB_SEND_MAIL:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
源代码:

FUNCTION zpub_send_mail.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     REFERENCE(SUBJECT) TYPE  SO_OBJ_DES
*"     REFERENCE(SENDER) TYPE  AD_SMTPADR OPTIONAL
*"     REFERENCE(EXPRESS) TYPE  OS_BOOLEAN OPTIONAL
*"     REFERENCE(COMMIT) TYPE  CHAR1 OPTIONAL
*"     REFERENCE(ATTA_TAB) TYPE  WLFTT_MAIL_ATTACHMENT OPTIONAL
*"  EXPORTING
*"     REFERENCE(RTYPE) TYPE  BAPI_MTYPE
*"     REFERENCE(RTMSG) TYPE  BAPI_MSG
*"  TABLES
*"      MAIL_BODY STRUCTURE  SOLISTI1 OPTIONAL
*"      RECV_USER STRUCTURE  SSCRUSER OPTIONAL
*"      RECV_SMTP STRUCTURE  PIQAPP_EMAIL OPTIONAL
*"----------------------------------------------------------------------
  DATA lr_email  TYPE REF TO cl_bcs.
  DATA lr_body   TYPE REF TO cl_document_bcs.
  DATA lr_sender TYPE REF TO if_sender_bcs.
  DATA lr_recver TYPE REF TO if_recipient_bcs.
  DATA lr_cxbcs  TYPE REF TO cx_bcs.
  DATA ls_atta   TYPE wlfs_mail_attachment.
  DATA lv_result TYPE os_boolean.


  TRY.
      lr_email = cl_bcs=>create_persistent( ).
      lr_body = cl_document_bcs=>create_document( i_type = 'HTM'
                                                  i_text = mail_body[]
                                                  i_subject = subject ).
      LOOP AT atta_tab INTO ls_atta.
        CALL METHOD lr_body->add_attachment
          EXPORTING
            i_attachment_type    = ls_atta-type
            i_attachment_subject = ls_atta-description
            i_attachment_size    = ls_atta-binary_size
            i_att_content_hex    = ls_atta-binary_content.
      ENDLOOP.
      lr_email->set_document( lr_body ).


      IF sender IS INITIAL.
        lr_sender = cl_sapuser_bcs=>create( sy-uname ).
      ELSE.
        CALL METHOD cl_cam_address_bcs=>create_internet_address
          EXPORTING
            i_address_string = sender
            i_address_name   = 'Sender'
          RECEIVING
            result           = lr_sender.
      ENDIF.
      lr_email->set_sender( lr_sender ).


      LOOP AT recv_user.
        lr_recver = cl_sapuser_bcs=>create( recv_user-uname ).
        lr_email->add_recipient( i_recipient = lr_recver i_express = express ).
      ENDLOOP.


      LOOP AT recv_smtp.
        lr_recver = cl_cam_address_bcs=>create_internet_address( recv_smtp-e_mail ).
        lr_email->add_recipient( i_recipient = lr_recver i_express = express ).
      ENDLOOP.


      lr_email->set_send_immediately( 'X' ).
      lv_result = lr_email->send( i_with_error_screen = '' ).
      IF lv_result = 'X'.
        IF commit IS NOT INITIAL.
          COMMIT WORK. "在Update进程或者增强里面,禁止提交
        ENDIF.
      ENDIF.
    CATCH cx_bcs INTO lr_cxbcs. " cx_root INTO lr_cxroot.
      rtype = 'E'.
      rtmsg = lr_cxbcs->get_text( ).
  ENDTRY.





ENDFUNCTION.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1264484.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

利用kibana 快照备份es数据库

环境 主机名ip地址组件ambari-hadoop1192.168.10.101ambari-hadoop2192.168.10.102kibanaambari-hadoop3192.168.10.103es 这里我们利用共享文件系统&#xff0c;存储快照&#xff0c;所以需要利用到nfs&#xff08;NFS&#xff08;Network File System&#xff09;是一种分布…

Dijkstra算法(贪心),Floyd-Warshall算法(动态规划), Bellman-Ford算法——用Python实现

图论中最短路径三剑客 前言一、Dijkstra算法&#xff08;贪心&#xff09;1.1 Dijkstra在生活中的应用举例1.2 设计思路1.3 算法应用实例1.3.1 以交通规划为例1.3.2 Dijkstra算法执行步骤1.3.3 python代码 1.4 时空复杂度 二、Floyd-Warshall算法&#xff08;动态规划&#xff…

八、Lua数组和迭代器

一、Lua数组 数组&#xff0c;就是相同数据类型的元素按一定顺序排列的集合&#xff0c;可以是一维数组和多维数组。 在 Lua 中&#xff0c;数组不是一种特定的数据类型&#xff0c;而是一种用来存储一组值的数据结构。 实际上&#xff0c;Lua 中并没有专门的数组类型&#xf…

Stable Diffusion绘画系列【2】:二次元风美女

《博主简介》 小伙伴们好&#xff0c;我是阿旭。专注于人工智能、AIGC、python、计算机视觉相关分享研究。 ✌更多学习资源&#xff0c;可关注公-仲-hao:【阿旭算法与机器学习】&#xff0c;共同学习交流~ &#x1f44d;感谢小伙伴们点赞、关注&#xff01; 《------往期经典推…

Maven——Maven使用基础

1、安装目录分析 1.1、环境变量MAVEN_HOME 环境变量指向Maven的安装目录&#xff0c;如下图所示&#xff1a; 下面看一下该目录的结构和内容&#xff1a; bin&#xff1a;该目录包含了mvn运行的脚本&#xff0c;这些脚本用来配置Java命令&#xff0c;准备好classpath和相关…

极限学习机

极限学习机&#xff08;ELM, Extreme Learning Machines&#xff09;是一种前馈神经网络&#xff0c;ELM 不需要基于梯度的反向传播来调整权重&#xff0c;而是通过 Moore-Penrose generalized inverse来设置权值。 标准的单隐藏层神经网络结构如下&#xff1a; 单隐藏层神经…

Fabric:搭建自定义网络

Hyperledger Fabric: V2.5.4 写在最前 从本篇博客开始&#xff0c;将陆续介绍使用Fabric搭建自定义网络及部署执行链码的过程。本篇主要介绍如何搭建网络。   由于前文在安装Fabric的时候&#xff0c;已经将目录fabric-samples/bin加入到了环境变量PATH中&#xff0c;所以正文…

Error:SSL peer shut down incorrectly

去年的一个android项目一直没有维护&#xff0c;注册的服务器地址修改了一下&#xff0c;重新编译&#xff0c;发现提示编程所依赖的插件需要更新&#xff0c;但死活更新不到。一直同步失败。。折腾了两天&#xff0c;提示ERROR: SSL peer shut down incorrectly错误。 在网上…

Django大回顾-2 之 Django的基本操作、路由层,MTV和MVC模型

【1】MTV和MVC模型 MVC与MTV模型 --->所有web框架其实都遵循mvc架构 MVC模型 MVC 本来坨在一起的代码&#xff0c;拆到不同的位置 模型(M&#xff1a;数据层)&#xff0c;控制器(C&#xff1a;逻辑判断)和视图(V&#xff1a;用户看到的)三层 他们之间以一种插件式…

知识蒸馏—原理+代码实战(Distillation CNN 和 Progressive Distillation Diffusion)

文章目录 1. Distillation 基本概念2. Distillation MNIST CNN分类代码实战3. Progressive Distillation Diffusion生成代码实战3.1 Progressive Distillation原理3.2 v-parameterization3.2 渐进蒸馏 cifar 代码实战 1. Distillation 基本概念 知识蒸馏被广泛的用于模型压缩和…

测试用例设计全网最强篇(建议收藏)

本篇从多角度带大家从0开始学习怎么写测试用例&#xff0c;七种方法8个案例&#xff08;含用例模板&#xff09;&#xff1b;学习目标&#xff1a;测试用例的基本知识以及黑盒测试用例的设计方法。 前言&#xff1a;总体编写策略&#xff1a; 对于测试用例编写来说&#xff0…

C语言——一个数如果恰好等于它的因子之和,这个数就称为“完全数”。

一个数如果恰好等于它的因子之和,这个数就称为“完全数”。例如,6的因子是 1、2、3,而6123。因此6是一个完全数。编程找出 1000 之内的所有完全数。 #include <stdio.h> int main() {int i, j, sum;for (i 1; i < 1000; i) {sum 0; //这一步很重要&#xff0c;每…

SQL注入 - CTF常见题型

文章目录 题型一 &#xff08; 字符型注入 &#xff09;题型二 &#xff08; 整数型注入 &#xff09;题型三 &#xff08; 信息收集SQL注入&#xff09;题型四 &#xff08; 万能密码登录 &#xff09;题型五 &#xff08; 搜索型注入文件读写 &#xff09;题型六 &#xff08…

Softing VisualODX 助力OEM诊断数据开发

ODX 2.2是由ASAM&#xff08;自动化及测量系统标准协会&#xff09;提出的诊断标准&#xff0c;是一种基于XML语言的开放式诊断数据格式&#xff0c;已在国际上得到广泛使用。目前&#xff0c;ODX诊断标准已被国内各大OEM采用&#xff0c;但在ODX数据开发阶段&#xff0c;ODX诊…

Java高级技术(单元测试)

一&#xff0c;概括 二&#xff0c;junit 三&#xff0c;案例 &#xff08;1&#xff09;&#xff0c;实验类 package com.bilibili;public class Name {public static void main(String name) {if (name null){System.out.println("0");return;}System.out.print…

C#文件流FileStream类

目录 一、文件流类 1.FileStream类的常用属性 2.FileStream类的常用方法 3.使用FileStream类操作文件 二、文本文件的写入与读取 1.StreamWriter类 2.StreamReader类 3.示例及源码 三、二进制文件的写入与读取 1.BinaryWriter类 2.BinaryReader类 3.示例源码 数据流…

锂电涂布机设备健康管理:降低运维成本的关键

随着锂电池行业的快速发展&#xff0c;锂电涂布机设备作为关键生产工艺装备&#xff0c;扮演着至关重要的角色。然而&#xff0c;涂布机设备的故障和维护成本对于企业来说是一个不可忽视的挑战。本文将介绍做好锂电涂布机设备的健康管理&#xff0c;降低运维成本的关键措施。 锂…

JAVA的一些便捷性方法(Object)

在IDEA中&#xff0c;如何查看JDK的源码&#xff1f; CTRL B; 常用方法&#xff1a; 1.equals&#xff08;&#xff09; booleanequals(Object obj) 指示其他某个对象是否与此对象“相等”。 与 的比较&#xff1a; &#xff0c;即可判断基本类型&#xff0c;也…

为什么说橘子酒是像红葡萄酒的白葡萄酒?

酿酒师通常会使用不同的葡萄品种来酿橘子酒&#xff0c;这样的葡萄酒味道就会有很大的不同&#xff0c;因此很难为橘子酒定义一个通用的风味特征。其中一些有干花或香草的香味&#xff0c;又或者是核果风味&#xff0c;如杏、油桃或桃子&#xff0c;再或者你可能感觉到坚果和蜂…

Python分享之字符串格式化 (%操作符)

在许多编程语言中都包含有格式化字符串的功能&#xff0c;比如C和Fortran语言中的格式化输入输出。Python中内置有对字符串进行格式化的操作%。 模板 格式化字符串时&#xff0c;Python使用一个字符串作为模板。模板中有格式符&#xff0c;这些格式符为真实值预留位置&#xff…