主页 > 云服务器 > > 正文

专属服务器_236企业邮箱登录入口_免费领

来源:胜利云 发布时间:2021-09-27 01:34 标签:服务器企业邮箱免费登录入口专属
浏览:

Usually, when talking about attachments, we are thinking of someone who have to choose the file he want to attach,

and for this there are numerous posts.

I want to talk about a scenario where I know where the file is and I want to attach it to the object without user input.

Specific, the scenario I was facing was like this:

Basically, I used 3 FMs:

*"———————————————————————-

*"*"Local Interface:

*"  IMPORTING

*"     VALUE(IV_BELNR) TYPE  RE_BELNR

*"     VALUE(IV_GJAHR) TYPE  GJAHR

*"     REFERENCE(IV_OBJTYPE) TYPE  SWO_OBJTYP

*"———————————————————————-

DATA: lv_full_file_path   TYPE draw–filep.

PERFORM scan_to_file

USING    iv_belnr

CHANGING lv_full_file_path.

CHECK lv_full_file_path IS NOT INITIAL.

PERFORM check_file_exist

CHANGING lv_full_file_path.

CHECK lv_full_file_path IS NOT INITIAL.

PERFORM attach_file

USING    iv_belnr

iv_gjahr

iv_objtype

lv_full_file_path.

PERFORM delete_folder

USING    lv_full_file_path.

PERFORM initiate_wf_event

USING    iv_belnr

iv_gjahr.

ENDFUNCTION.

*———————————————————————-*

*              Form  Check_File_Exist

*

* This function will if the scanned file exist.

* There is no way to tell if the user canceled the scanning from

* the results of the FMs and Methods under "Scan_File" form,

* so the only way to tell is check if the file exist.

*———————————————————————-*

FORM check_file_exist

CHANGING cv_full_file_path   TYPE draw–filep.

DATA: lv_file   TYPE string,

lv_result  TYPE abap_bool,

lv_subrc  TYPE string.

* Convert to Method type.

lv_file = cv_full_file_path.

CALL METHOD cl_gui_frontend_services=>file_exist

EXPORTING

file                 = lv_file

RECEIVING

result               = lv_result      "X=file exist

EXCEPTIONS

cntl_error           = 1

error_no_gui         = 2

wrong_parameter      = 3

not_supported_by_gui = 4

OTHERS               = 5.

* Error searching file.

IF sy–subrc 0.

CLEAR: cv_full_file_path.     "Indicate error.

lv_subrc = sy–subrc.

CONDENSE lv_subrc.

MESSAGE i002(zmm_invoice_wf) WITH lv_subrc ‘Checking File’(010).   "Error #& when calling "&" – please report.

ENDIF.

* File does not exist.

IF lv_result ‘X’.

CLEAR: cv_full_file_path.

MESSAGE i004(zmm_invoice_wf).   "No documents scanned.

ENDIF.

ENDFORM.                    "Check_File_Exist

*———————————————————————-*

*              Form  Attach_File

*

* This function will attach the scanned Invoice to the Invoice object.

*———————————————————————-*

FORM attach_file

USING iv_belnr            TYPE re_belnr       "Ivoice number

iv_gjahr            TYPE gjahr          "Invoice year

iv_objtype          TYPE swo_objtyp     "Object type (BUS…)

iv_full_file_path   TYPE draw–filep.    "Scanned file full-path

DATA: lt_objcont    TYPE STANDARD TABLE OF soli,

ls_folder_id  TYPE sofdk,

ls_obj_id     TYPE soodk,

ls_object     TYPE borident,

ls_obj_roleb  TYPE borident,

lt_objhead    TYPE soli_tab,

ls_hd_change  TYPE sood1.

DATA: lv_subrc      TYPE string.

* Write UI message.

zcl_messages=>display_message( ‘Attaching Invoice…’ ).  "#EC NOTEXT

PERFORM prepare_before_object_insert

USING    iv_full_file_path

CHANGING ls_folder_id

lt_objcont.

PERFORM call_so_object_upload

USING    ls_folder_id

iv_full_file_path

CHANGING lt_objcont

lt_objhead

ls_hd_change

ls_obj_id.

PERFORM call_so_object_insert

USING    ls_folder_id

lt_objcont

lt_objhead

ls_hd_change

iv_full_file_path

CHANGING ls_obj_id.

ls_obj_roleb–objtype = ‘MESSAGE’.

* Build Object-key.

CONCATENATE ls_folder_id

ls_obj_id–objtp

ls_obj_id–objyr

ls_obj_id–objno

INTO ls_obj_roleb–objkey.

CONCATENATE iv_belnr iv_gjahr INTO ls_object–objkey.

ls_object–objtype = iv_objtype.

CALL FUNCTION ‘BINARY_RELATION_CREATE_COMMIT’

EXPORTING

obj_rolea      = ls_object

obj_roleb      = ls_obj_roleb

relationtype   = ‘ATTA’

EXCEPTIONS

no_model       = 1

internal_error = 2

unknown        = 3

error_message  = 4

OTHERS         = 5.

IF sy–subrc 0.

lv_subrc = sy–subrc.

CONDENSE lv_subrc.

MESSAGE i002(zmm_invoice_wf) WITH lv_subrc ‘Attach Object’(005).   "Error #& when calling "&" – please

ENDIF.

ENDFORM.                    "Attach_File

*———————————————————————-*

*              Form  Delete_Folder

*

* This function will delete the folder that was created for the scanned

* file so to avoid filling up users drive quota.

*———————————————————————-*

FORM delete_folder

USING iv_full_file_path   TYPE draw–filep.    "Scanned file full-path

DATA: lv_from_file  TYPE rlgrap–filename,

lv_drive      TYPE pcfile–drive,

lv_path       TYPE rlgrap–filename,

lv_path_str   TYPE string,

lv_file_str   TYPE string,

lv_cmd_param  TYPE string,

lv_rc          TYPE i,

lv_subrc      TYPE string.

* Convert to FM type.

lv_from_file = iv_full_file_path.

CALL FUNCTION ‘Z_PC_SPLIT_COMPLETE_FILENAME’

EXPORTING

complete_filename       = lv_from_file

path_separator          = ‘\’

IMPORTING

drive                   = lv_drive

path                    = lv_path

EXCEPTIONS

invalid_drive           = 1

invalid_extension       = 2

invalid_name            = 3

invalid_path            = 4

separator_not_specified = 5

OTHERS                  = 6.

IF sy–subrc 0.

lv_subrc = sy–subrc.

CONDENSE lv_subrc.

MESSAGE i002(zmm_invoice_wf) WITH lv_subrc ‘Find Folder’(008).   "Error #& when calling "&" – please report.

RETURN.

ENDIF.

* Create Folder path.

CONCATENATE lv_drive ‘:’ lv_path INTO lv_path_str.

* Create "RMDIR" command string.

CONCATENATE ‘"‘ lv_path_str ‘"‘ INTO lv_path_str.                           "Full path with quotes

CONCATENATE ‘rmdir /q /s’ lv_path_str INTO lv_cmd_param SEPARATED BY ‘ ‘.   "RMDIR command with spaces

CONCATENATE ‘/C’ ‘"‘ lv_cmd_param ‘"‘ INTO lv_cmd_param SEPARATED BY ‘ ‘.

CALL METHOD cl_gui_frontend_services=>execute

EXPORTING

application            = ‘cmd’

parameter              = lv_cmd_param

EXCEPTIONS

cntl_error             = 1

error_no_gui           = 2

bad_parameter          = 3

file_not_found         = 4

path_not_found         = 5

file_extension_unknown = 6

error_execute_failed   = 7

synchronous_failed     = 8

not_supported_by_gui   = 9

OTHERS                 = 10.

IF sy–subrc 0.

lv_subrc = sy–subrc.

CONDENSE lv_subrc.

MESSAGE i002(zmm_invoice_wf) WITH lv_subrc ‘Delete Folder’(011).   "Error #& when calling "&" – please report.

ENDIF.

ENDFORM.                    "Delete_Folder

*———————————————————————-*

*              Form  Initiate_WF_Event

*

* This function will initiate a Work-flow event.

*———————————————————————-*

FORM initiate_wf_event

USING iv_belnr            TYPE re_belnr       "Ivoice number

iv_gjahr            TYPE gjahr.         "Invoice year

DATA: lv_object_key     TYPE swr_struct–object_key,

lv_return_code    TYPE sy–subrc,

lv_subrc          TYPE string.

* Build Object-key.

CONCATENATE iv_belnr iv_gjahr INTO lv_object_key.

CALL FUNCTION ‘SAP_WAPI_CREATE_EVENT’

EXPORTING

object_type = ‘BUS2081’

object_key  = lv_object_key

event       = ‘startapproval’

commit_work = ‘X’

IMPORTING

return_code = lv_return_code.

IF lv_return_code IS NOT INITIAL.

lv_subrc = sy–subrc.

CONDENSE lv_subrc.

MESSAGE i002(zmm_invoice_wf) WITH lv_subrc ‘Initiate WF’(012).   "Error #& when calling "&" – please report.

ENDIF.

ENDFORM.                    "initiate_wf_event

*———————————————————————-*

*              Form  Prepare_Before_Object_Insert

*

* This function will prepare data before calling "SO_OBJECT_INSERT".

*———————————————————————-*

FORM prepare_before_object_insert

USING    iv_full_file_path   TYPE draw–filep     "Scanned file full-path

CHANGING cs_folder_id        TYPE sofdk

ct_objcont          TYPE soli_tab.

DATA: ls_objcont    TYPE soli.

DATA: lv_subrc      TYPE string.

* Get Folder properties.

CALL FUNCTION ‘SO_FOLDER_ROOT_ID_GET’

EXPORTING

region    = ‘B’

IMPORTING

folder_id = cs_folder_id

EXCEPTIONS

OTHERS    = 0.

IF sy–subrc 0.

lv_subrc = sy–subrc.

CONDENSE lv_subrc.

MESSAGE i002(zmm_invoice_wf) WITH lv_subrc ‘Folder ID’(003).   "Error #& when calling "&" – please report.

RETURN.

ENDIF.

CONCATENATE ‘&KEY&’ iv_full_file_path INTO ls_objcont–line.

APPEND ls_objcont TO ct_objcont.

ENDFORM.                    "Prepare_Before_Object_Insert

*———————————————————————-*

*              Form  Call_SO_OBJECT_UPLOAD

*

* This function will call FM "SO_OBJECT_INSERT".

*———————————————————————-*

FORM call_so_object_upload

USING    is_folder_id        TYPE sofdk

iv_full_file_path   TYPE draw–filep     "Scanned file full-path

CHANGING ct_objcont          TYPE soli_tab

ct_objhead          TYPE soli_tab

ls_hd_change        TYPE sood1

cs_obj_id           TYPE soodk.

DATA: ls_objhead           TYPE soli,

lt_objcont           TYPE STANDARD TABLE OF soli.

DATA: lv_type              TYPE rlgrap–filetype,   " VALUE ‘BIN’,

lv_filelength        TYPE soxwd–doc_length,

lv_cancelled         TYPE sonv–flag,

lv_act_filetype      TYPE c,

lv_act_filename      TYPE c,

lv_act_objtype       TYPE soodk–objtp,

lv_file_put_to_kpro  TYPE sonv–flag,

lv_complete_filename TYPE rlgrap–filename,

lv_extension         TYPE rlgrap–filename,

lv_name              TYPE rlgrap–filename,

lv_subrc             TYPE string.

CALL FUNCTION ‘SO_OBJECT_UPLOAD’

EXPORTING

filetype                = lv_type

path_and_file           = iv_full_file_path

no_dialog               = ‘X’

IMPORTING

filelength              = lv_filelength

f_cancelled             = lv_cancelled

act_filetype            = lv_type

act_filename            = lv_act_filename

act_objtype             = lv_act_objtype

file_put_to_kpro        = lv_file_put_to_kpro

TABLES

objcont                 = ct_objcont

EXCEPTIONS

file_read_error         = 1

invalid_type            = 2

x_error                 = 3

object_type_not_allowed = 4

kpro_insert_error       = 5

error_message           = 6

OTHERS                  = 7.

IF sy–subrc 0.

lv_subrc = sy–subrc.

CONDENSE lv_subrc.

MESSAGE i002(zmm_invoice_wf) WITH lv_subrc ‘Object Upload’(006).   "Error #& when calling "&" – please report.

RETURN.

ENDIF.

* Convert to FM compatible.

lv_complete_filename = iv_full_file_path.

CALL FUNCTION ‘Z_PC_SPLIT_COMPLETE_FILENAME’

EXPORTING

complete_filename       = lv_complete_filename

IMPORTING

extension               = lv_extension

name                    = lv_name

EXCEPTIONS

invalid_drive           = 1

invalid_extension       = 2

invalid_name            = 3

invalid_path            = 4

separator_not_specified = 5

OTHERS                  = 6.

IF sy–subrc 0.

lv_subrc = sy–subrc.

CONDENSE lv_subrc.

MESSAGE i002(zmm_invoice_wf) WITH lv_subrc ‘File Details’(007).   "Error #& when calling "&" – please report.

RETURN.

ENDIF.

ls_hd_change–objpri   = ‘5’.      "Priority: 5 out of 10

ls_hd_change–objdes   = lv_name.

ls_hd_change–file_ext = lv_extension.

ls_hd_change–objlen   = lv_filelength.

ls_hd_change–extct    = ‘K’.    "lv_file_put_to_kpro.

CONCATENATE ‘&SO_FILENAME=’ lv_name ‘.’ lv_extension INTO ls_objhead–line. "#EC NOTEXT

APPEND ls_objhead TO ct_objhead.

CLEAR: ls_objhead.

CONCATENATE ‘&SO_FORMAT=’ lv_type INTO ls_objhead–line.   "#EC NOTEXT

APPEND ls_objhead TO ct_objhead.

ENDFORM.                    "Call_SO_OBJECT_UPLOAD

*———————————————————————-*

*              Form  Call_SO_OBJECT_INSERT

*

* This function will call FM "SO_OBJECT_INSERT".

*———————————————————————-*

FORM call_so_object_insert

USING    is_folder_id        TYPE sofdk

it_objcont          TYPE soli_tab

it_objhead          TYPE soli_tab

is_hd_change        TYPE sood1

iv_full_file_path   TYPE draw–filep     "Scanned file full-path

CHANGING cs_obj_id           TYPE soodk.

DATA: lv_type       TYPE rlgrap–filetype,   " VALUE ‘BIN’,

lv_subrc      TYPE string.

CALL FUNCTION ‘SO_OBJECT_INSERT’

EXPORTING

folder_id                  = is_folder_id

object_type                = ‘EXT’

object_hd_change           = is_hd_change

owner                      = sy–uname

IMPORTING

object_id                  = cs_obj_id

TABLES

objcont                    = it_objcont

objhead                    = it_objhead

EXCEPTIONS

active_user_not_exist      = 1

communication_failure      = 2

component_not_available    = 3

dl_name_exist              = 4

folder_not_exist           = 5

folder_no_authorization    = 6

object_type_not_exist      = 7

operation_no_authorization = 8

owner_not_exist            = 9

parameter_error            = 10

substitute_not_active      = 11

substitute_not_defined     = 12

system_failure             = 13

x_error                    = 14

error_message              = 15

OTHERS                     = 16.

IF sy–subrc 0.

lv_subrc = sy–subrc.

CONDENSE lv_subrc.

MESSAGE i002(zmm_invoice_wf) WITH lv_subrc ‘Object Insert’(004).   "Error #& when calling "&" – please report.

RETURN.

ENDIF.

ENDFORM.                    "Call_SO_OBJECT_INSERT

Note:

I hope this will be useful.

Post any question and I’ll do my best to help.

,大数据系统,服务器云,360大数据,云端云服务器,买云服务器
发表评论
验证码: 点击我更换图片

注:网友评论仅供其表达个人看法,并不代表本站立场。

热门文章

  • 云存储_企业邮箱是怎么申请_便宜的
    <strong>云存储_企业邮箱是怎么申请_便宜的</strong>

    云存储_企业邮箱是怎么申请_便宜的

    雪花数据仓库中的端到端加密2016年4月13日作者:马丁·亨切尔彼得·波维尼克云数据安全,工程作者:马丁·亨切尔和彼得·波维尼克。保护客户数据是雪花...

  • 分布式数据库_八度网络云主机_便宜的
    <strong>分布式数据库_八度网络云主机_便宜的</strong>

    分布式数据库_八度网络云主机_便宜的

    在云数据库服务的世界里,对客户来说,没有什么比不间断地访问他们的数据更重要的了。在在线游戏和金融服务等交易率较高的行业,即使是最小的中断...

  • 数据库服务器_服务器带宽_哪家好
    <strong>数据库服务器_服务器带宽_哪家好</strong>

    数据库服务器_服务器带宽_哪家好

    图1。派特法是一家领先的油田服务公司派特法为能源客户锁定价值派特法设计、建造、运营和维护石油、天然气和可再生能源资产。公司致力于数字化转型...

  • MySQL数据库_不能用邮箱注册企业邮箱吗
    <strong>MySQL数据库_不能用邮箱注册企业邮箱吗</strong>

    MySQL数据库_不能用邮箱注册企业邮箱吗

    如今,企业被迫维护两种类型的分析系统:数据仓库和数据湖。数据仓库提供了有关业务健康状况的重要见解。数据湖可以发现客户、产品、员工和流程的...

  • 微软云_服务器售后_年度促销
    <strong>微软云_服务器售后_年度促销</strong>

    微软云_服务器售后_年度促销

    使用Azure的客户管理密钥进行数据加密2019年9月6日|3分钟读取作者:保卢斯雪花新闻,雪花科技2017年,雪花宣布使用AWS密钥管理服务(KMS)支持客户管理密...

云储存

更多 >
  • <strong>微软云_最后的灰姑娘百度云_排行榜</strong>
    微软云_最后的灰姑娘百度云_排行榜

    SAP Lumira的1.25版现在有一个Universe查询面板扩展,您需要安装它。安装后,您将看到熟悉的查询面板。您不需要"发布"到BI平台,而需要对BI平台执行"文件>另...

  • <strong>网站空间_斗破苍穹动漫第二季百度云_哪</strong>
    网站空间_斗破苍穹动漫第二季百度云_哪

    如果你读过我以前的博客,那么你就知道如何创建一个定制报告程序,根据映射表自动分析APO中的CIF后处理记录,并从阻塞的队列/记录中提取错误消息号。...

云储存游戏服务器_滨州网站建设_学生机
云储存网站空间_申报数据库_怎么样
云储存文件存储_rms服务器_免费1年
云储存微软云_哪家企业邮箱好_精选特惠
云储存企业网站_宁波网站建设哪家好_9元