商务合作:179001057@qq.com

SAP常用系统函数

技术2022-05-11  0


某平台价值19860元的编程课程资料免费领取【点我领取】


在工作中,归纳了如下函数,以后将继续补充。

函数名                       描述 CONVERSION_EXIT_ALPHA_INPUT   料号前面补0 CONVERSION_EXIT_ALPHA_OUTPUT  料号前面减0 CONVERSION_EXIT_MATN1_INPUT   料号前面补0 CONVERSION_EXIT_MATN1_OUTPUT  料号前面减0 LAST_DAY_OF_MONTHS            查询某日期的在当月的最后一天 CO_SF_CAUFVD_GET              根据工单号查询订单抬头和项目 SO_NEW_DOCUMENT_ATT_SEND_API1 外发邮件 VIEW_MAINTENANCE_CALL         调用数据表的维护视图 SO_OBJECT_SEND                外发邮件

函数名 CONVERSION_EXIT_ALPHA_INPUT 功能:料号前面补0, 实例: CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'             "料号前面加0”       EXPORTING         input  = matnr_in       IMPORTING         output = matnr_out.

说明:1)数字料号入Table需要补0,不会自动产生,有字母料号却会自动补0.      2)只能用’字符型’ CONVERSION_EXIT_MATN1_INPUT 功能:料号前面补0 实例:  CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'             "料号前面补0”       EXPORTING         input        = matnr_in       IMPORTING         output       = matnr_out       EXCEPTIONS         length_error = 1         OTHERS       = 2. 说明: 1)数字料号入Table需要补0,不会自动产生,有字母料号却会自动补0.        2)只能用于料号转换       CONVERSION_EXIT_ALPHA_OUTPUT 功能:料号前面去0 实例: CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'            "料号前面去0.          EXPORTING            input  = wa_ysy1-matnr          IMPORTING            output = wa_ysy1-matnr.

说明: CONVERSION_EXIT_MATN1_OUTPUT 功能:料号前面去0 实例:    CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'       EXPORTING         input  = t_afpo-matnr       IMPORTING         output = t_afpo-matnr       EXCEPTIONS         OTHERS = 1. 说明: LAST_DAY_OF_MONTHS 功能:查询某日期的在当月的最后一天 CALL FUNCTION 'LAST_DAY_OF_MONTHS'             EXPORTING               day_in = f_date   "月任意一天 类型必须为D(要完成日期##             IMPORTING              last_day_of_month = p_date           "月最后一天 类型必须为D(完整日期)             EXCEPTIONS              day_in_no_date           = 1              OTHERS                   = 2. 说明: CO_SF_CAUFVD_GET 功能: 根据工单号查询订单抬头和项目 实例: DATA: wa_caufvd TYPE caufvd. CALL FUNCTION 'CO_SF_CAUFVD_GET'"取得订单抬头和项目   EXPORTING      aufnr_imp  = aufnr   IMPORTING      caufvd_exp = wa_caufvd “订单抬头和项目结构   EXCEPTIONS      not_found  = 1      OTHERS     = 2.

说明: SO_NEW_DOCUMENT_ATT_SEND_API1 功能:邮件发送 SAPoffice: Send new document with attachments using RFC 实例: FORM email_itab. “邮件内容“

WRITE: '编号'     TO email_itab-line+0(3), "255个长度的文本字段:文本"          '记帐日期' TO email_itab-line+3(10),         ENDFORM.                    " email_itab FORM reset_objpack .   it_packing_list-transf_bin = space. "标记将以二进制形式传输对象的标志"   it_packing_list-head_start = 0."表头开始行"   it_packing_list-head_num = 1.  "表头行数"   it_packing_list-body_start = 1."内容开始行"   it_packing_list-body_num = it_message_lines. "内容行数"   it_packing_list-doc_type = 'RAW'. "信息类型"   APPEND it_packing_list. ENDFORM.                    " reset_objpack FORM reset_doc_chng .

  DESCRIBE TABLE email_itab LINES it_message_lines.   gd_doc_data-doc_size = it_message_lines * 255 + STRLEN( email_itab ). "SAPoffice 文档的大小 "   gd_doc_data-obj_langu = sy-langu. "创建文档使用的语言"   gd_doc_data-obj_name = 'SAPRPT'.  "文档,文件夹或分配清单的名称"   gd_doc_data-obj_descr = '邮件标题'. "Email标题" gd_doc_data-sensitivty = 'F'. "对象:灵敏度(个人的,功能的,...) F:功能"

ENDFORM.                    " reset_doc_chng FORM reset_reclist .

  SELECT zmaaddr   INTO it_receivers-receiver   FROM ziebtemail.     it_receivers-rec_type = 'U'. "互联网地址     APPEND it_receivers.     CLEAR it_receivers.   ENDSELECT.

ENDFORM.                    " reset_reclist

DATA: gd_doc_data LIKE sodocchgi1,       gd_sent_all(1) TYPE c,       it_message_lines TYPE sy-tabix,       it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,       it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE. DATA: BEGIN OF email_itab OCCURS 10.         INCLUDE STRUCTURE soli. DATA: END OF email_itab.

  PERFORM email_itab. " TABLES OUTPUT_TAB.   PERFORM reset_doc_chng.   PERFORM reset_reclist.   PERFORM reset_objpack.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'   EXPORTING     document_data                    =  gd_doc_data  “新文档的属性”     PUT_IN_OUTBOX                    = 'X' “标志:发送后将文档移到outbox *   COMMIT_WORK                      = ' ' * IMPORTING    SENT_TO_ALL                      = gd_sent_all “Flag: Document sent to all” *   NEW_OBJECT_ID                    = ID of created object (not document!)   tables     packing_list                     = it_packing_list “SAPoffice:输入对象组件描述” *   OBJECT_HEADER                    = *   CONTENTS_BIN                     = *   CONTENTS_TXT                     = *   CONTENTS_HEX                     = *   OBJECT_PARA                      = *   OBJECT_PARB                      =     receivers                        = email_itab”SAPoffice:API 收件人清单的结构” * 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. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.

说明: VIEW_MAINTENANCE_CALL 功能:调用数据表的维护视图 实例:  CALL FUNCTION 'VIEW_MAINTENANCE_CALL'   EXPORTING     action                               =  'U' “活动(显示/维护/传输)” *   CORR_NUMBER                          = '          ' *   GENERATE_MAINT_TOOL_IF_MISSING       = ' ' *   SHOW_SELECTION_POPUP                 = ' '     view_name                            =  'ZIEBTEMAIL' “要处理的视图/表格的名称” *   NO_WARNING_FOR_CLIENTINDEP           = ' ' *   RFC_DESTINATION_FOR_UPGRADE          = ' ' *   CLIENT_FOR_UPGRADE                   = ' ' *   VARIANT_FOR_SELECTION                = ' ' *   COMPLEX_SELCONDS_USED                = ' ' *   CHECK_DDIC_MAINFLAG                  = ' ' *   SUPPRESS_WA_POPUP                    = ' ' * TABLES *   DBA_SELLIST                          = *   EXCL_CUA_FUNCT                       = * EXCEPTIONS *   CLIENT_REFERENCE                     = 1 *   FOREIGN_LOCK                         = 2 *   INVALID_ACTION                       = 3 *   NO_CLIENTINDEPENDENT_AUTH            = 4 *   NO_DATABASE_FUNCTION                 = 5 *   NO_EDITOR_FUNCTION                   = 6 *   NO_SHOW_AUTH                         = 7 *   NO_TVDIR_ENTRY                       = 8 *   NO_UPD_AUTH                          = 9 *   ONLY_SHOW_ALLOWED                    = 10 *   SYSTEM_FAILURE                       = 11 *   UNKNOWN_FIELD_IN_DBA_SELLIST         = 12 *   VIEW_NOT_FOUND                       = 13 *   MAINTENANCE_PROHIBITED               = 14 *   OTHERS                               = 15           . IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.

说明: SO_OBJECT_SEND 功能:外发邮件 实例: REPORT  ztmail02                                                    .

DATA:  BEGIN OF itab OCCURS 0,           pernr LIKE pa0001-pernr,           ename LIKE pa0001-ename,        END OF itab.

DATA:  message_content LIKE soli OCCURS 10 WITH HEADER LINE,        receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,        packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,        listobject LIKE abaplist OCCURS 10,        compressed_attachment LIKE soli occurs 100 WITH HEADER LINE,        w_object_hd_change LIKE sood1 occurs 100 WITH HEADER LINE,        compressed_size LIKE sy-index.

START-OF-SELECTION.   SELECT pernr ename   INTO  CORRESPONDING FIELDS OF TABLE itab   FROM  pa0001   WHERE  pernr < 50.

  LOOP AT itab.     WRITE: /02 sy-vline, itab-pernr, 15 sy-vline, itab-ename, 50           sy-vline.   ENDLOOP.

*receivers   receiver_list-recextnam = 'eric.guh@sina.com' . “直接外部地址作为接收方”   receiver_list-recesc = ‘U’. “收件人类型的说明; U 互联网地址”   receiver_list-sndart = ‘MAIL'. “输出设备; MAIL 邮件”   receiver_list-sndpri = '1'.   “发送:优先级; 1 最高优先权”   APPEND receiver_list.

*general data   w_object_hd_change-objla = sy-langu.        “创建文档使用的语言”   w_object_hd_change-objnam = 'Object name'.  “文档,文件夹或分配清单的名称”   w_object_hd_change-objsns = 'F'.   “对象:灵敏度(个人的,功能的,...)” F: 功能 w_object_hd_change -OBJDES = ‘Message subject’.  “Mail的标题” APPEND w_object_hd_change.

*content   message_content-line = 'Message content'.  “发送的内容”   APPEND message_content.     CALL FUNCTION 'SO_OBJECT_SEND'     EXPORTING       object_hd_change = w_object_hd_change  “通常头数据”       object_type      = 'RAW'               “对象类型”       OUTBOX_FLAG      = 'X'                  “标志:发送后将文档移到outbox       owner            = sy-uname            “负责传送的用户”     TABLES       objcont          = message_content     “发送的内容”       receivers        = receiver_list       “接收对象属性”       att_cont         = compressed_attachment.

说明:


最新回复(0)