之前需求要把银行支付回单的PDF文件放到SAP的服务器上,并能使用FB03查询附件,所以做了上传附件的功能,并在FB03中可直接查询附件,如图。后来为了文档的统一管理,需要把文件放到统一的文档服务器上,而FB03通过URL来显示第三文文件。
发送URL地址时应该也是可以使用发送文件的各方法的,只是没找到URL的地址应该填写那个字段,所以只能用了另外的方法来处理。
1.一、文件保存到SAP服务器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
*&********************************************************************* *& PROGRAM NAME : Z15405_003 *& Module Name : *& Apply Author : *& Author : *& Started on : 2020-07-01 *& Transaction : Z15405_003 *& Program type : Report *& Program ID : Z15405_003 *& Program Description : 功能描述。。。。。。 *&*&******************************************************************* *& REVISION LOG * *& * *& LOG# DATE AUTHOR DESCRIPTION * *& ---- ---- ------ ----------- * *& 0001 2020-07-01 XXX Initial Creation *&********************************************************************* REPORT z15405_003. DATA: lv_fm_name TYPE rs38l_fnam. DATA: lv_devtype TYPE rspoptype. DATA: ls_control_parameters TYPE ssfctrlop, ls_output_options TYPE ssfcompop, ls_job_output_info TYPE ssfcrescl. DATA: lt_pdf_line TYPE STANDARD TABLE OF tline, lv_bin_filesize TYPE i, lv_bin_file TYPE xstring. DATA: lv_filename TYPE string. *Call Function module to get function name by passing form name CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = 'ZSTR_TEST001' variant = ' ' direct_call = ' ' IMPORTING fm_name = lv_fm_name EXCEPTIONS no_form = 1 no_function_module = 2 OTHERS = 3. IF sy-subrc <> 0. RETURN. ENDIF. CALL FUNCTION 'SSF_GET_DEVICE_TYPE' EXPORTING i_language = '*' IMPORTING e_devtype = lv_devtype EXCEPTIONS no_language = 1 language_not_installed = 2 no_devtype_found = 3 system_error = 4 OTHERS = 5. IF lv_devtype IS INITIAL. CALL FUNCTION 'SSF_GET_DEVICE_TYPE' EXPORTING i_language = sy-langu IMPORTING e_devtype = lv_devtype EXCEPTIONS no_language = 1 language_not_installed = 2 no_devtype_found = 3 system_error = 4 OTHERS = 5. IF sy-subrc <> 0. RETURN. ENDIF. ENDIF. *Call Function module passing input tables to form interface ls_control_parameters-getotf = 'X'. ls_control_parameters-no_dialog = 'X'. ls_control_parameters-langu = sy-langu. ls_control_parameters-preview = ' '. ls_output_options-tdprinter = lv_devtype. CALL FUNCTION lv_fm_name EXPORTING control_parameters = ls_control_parameters output_options = ls_output_options user_settings = 'X' IMPORTING job_output_info = ls_job_output_info EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 OTHERS = 5. IF sy-subrc <> 0. ENDIF. *Get PDF content CALL FUNCTION 'CONVERT_OTF' EXPORTING format = 'PDF' max_linewidth = 132 IMPORTING bin_filesize = lv_bin_filesize bin_file = lv_bin_file TABLES otf = ls_job_output_info-otfdata[] lines = lt_pdf_line EXCEPTIONS err_max_linewidth = 1 err_format = 2 err_conv_not_possible = 3 err_bad_otf = 4 OTHERS = 5. IF sy-subrc <> 0. ENDIF. DATA: gt_bin TYPE solix OCCURS 0, g_attsize TYPE int4. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING buffer = lv_bin_file * APPEND_TO_TABLE = ' ' IMPORTING output_length = g_attsize TABLES binary_tab = gt_bin. INCLUDE <cntn01>. TYPE-POOLS: slis, abap, truxs. DATA:l_obj TYPE swc_object, g_filename TYPE string, gs_objb TYPE borident, gs_obja TYPE borident, gs_binrel TYPE gbinrel, gt_binatt TYPE STANDARD TABLE OF brelattr. g_filename = 'TEST'. DATA: l_seq TYPE i. swc_container l_cont. swc_create_object l_obj 'MESSAGE' ''. swc_set_element l_cont 'NO_DIALOG' 'X'. swc_set_element l_cont 'DOCUMENTTITLE' g_filename. swc_set_table l_cont 'Content_Hex' gt_bin. swc_set_element l_cont 'DOCUMENTTYPE' 'PDF'. swc_set_element l_cont 'DOCUMENTSIZE' g_attsize. swc_refresh_object l_obj. swc_call_method l_obj 'CREATE' l_cont. swc_get_object_key l_obj gs_objb-objkey. gs_objb-objtype = 'MESSAGE'. "type of attach document gs_obja-objtype = 'BKPF'. "BO of SAP Document. CONCATENATE '6018' "company code '0200000055' "FI Document '2020' "fiscal year INTO gs_obja-objkey. CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT' EXPORTING obj_rolea = gs_obja obj_roleb = gs_objb relationtype = 'ATTA' IMPORTING binrel = gs_binrel TABLES binrel_attrib = gt_binatt EXCEPTIONS no_model = 1 internal_error = 2 unknown = 3 OTHERS = 4. IF sy-subrc EQ 0. MESSAGE s043(sgos_msg). ENDIF. *swc_container l_cont. *swc_create_object l_obj 'MESSAGE' ''. *swc_set_element l_cont 'NO_DIALOG' 'X'. *swc_set_element l_cont 'DOCUMENTTITLE' g_filename. **swc_set_table l_cont 'Content_Hex' gt_bin. *swc_set_element l_cont 'DOCUMENTTYPE' 'URL'. *swc_set_element l_cont 'KEY' 'HTTPS://ARCHIVE.SAP.COM/AAA.PDF'. **swc_set_element l_cont 'DOCUMENTSIZE' g_attsize. *swc_refresh_object l_obj. *swc_call_method l_obj 'CREATE' l_cont. *swc_get_object_key l_obj gs_objb-objkey. * *gs_objb-objtype = 'MESSAGE'." 'URLRUNTIME' ."'MESSAGE'. "type of attach document *gs_obja-objtype = 'BKPF'. "BO of SAP Document. *CONCATENATE '6018' "company code * '0200000055' "FI Document * '2020' "fiscal year * INTO * gs_obja-objkey. * * *CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT' * EXPORTING * obj_rolea = gs_obja * obj_roleb = gs_objb * relationtype = 'URL' "'ATTA' * IMPORTING * binrel = gs_binrel * TABLES * binrel_attrib = gt_binatt * EXCEPTIONS * no_model = 1 * internal_error = 2 * unknown = 3 * OTHERS = 4. *IF sy-subrc EQ 0. * MESSAGE s043(sgos_msg). *ENDIF. |
二、上载为URL地址到FB03
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
*&********************************************************************* *& PROGRAM NAME : ZYG_TESTFB03 *& Module Name : *& Apply Author : *& Author : *& Started on : 2020-07-01 *& Transaction : ZYG_TESTFB03 *& Program type : Report *& Program ID : ZYG_TESTFB03 *& Program Description : 功能描述。。。。。。 *&*&******************************************************************* *& REVISION LOG * *& * *& LOG# DATE AUTHOR DESCRIPTION * *& ---- ---- ------ ----------- * *& 0001 2020-07-01 XXX Initial Creation *&********************************************************************* REPORT zyg_testfb03. TYPES : BEGIN OF tp_out , bukrs LIKE bkpf-bukrs, gjahr LIKE bkpf-gjahr, belnr LIKE bkpf-belnr, title TYPE so_obj_des, content TYPE char255, END OF tp_out . DATA : gt_out TYPE TABLE OF tp_out, gs_out TYPE tp_out. DATA : l_excel_tab TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE . FIELD-SYMBOLS : <fs> . SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001 . PARAMETERS : url TYPE string, dtitle TYPE string, bukrs TYPE bkpf-bukrs DEFAULT '6018', belnr TYPE bkpf-belnr DEFAULT '0200000055', gjahr TYPE bkpf-gjahr DEFAULT '2020'. "inpath TYPE rlgrap-filename . SELECTION-SCREEN END OF BLOCK b1 . * *AT SELECTION-SCREEN ON VALUE-REQUEST FOR inpath . * PERFORM get_pc_filename USING inpath . START-OF-SELECTION . PERFORM frm_upload_data . PERFORM frm_process_data . *&---------------------------------------------------------------------* *& Form FRM_UPLOAD_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_upload_data . * CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE' * EXPORTING * filename = inpath * i_begin_col = 1 * i_begin_row = 2 * i_end_col = 5 * i_end_row = 65535 * TABLES * intern = l_excel_tab * EXCEPTIONS * inconsistent_parameters = 1 * upload_ole = 2 * OTHERS = 3. * IF sy-subrc <> 0 . * MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno * WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 . * ENDIF . * * SORT l_excel_tab BY row col . * LOOP AT l_excel_tab . * ASSIGN COMPONENT l_excel_tab-col OF STRUCTURE gs_out TO <fs> . * MOVE l_excel_tab-value TO <fs> . * AT END OF row . * APPEND gs_out TO gt_out . * CLEAR gs_out . * ENDAT . * ENDLOOP . * IF gt_out IS INITIAL . * MESSAGE 'No data found' TYPE 'I' . * STOP . * ENDIF . ENDFORM . " FRM_UPLOAD_DATA *&---------------------------------------------------------------------* *& Form GET_PC_FILENAME *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_INPATH text *----------------------------------------------------------------------* FORM get_pc_filename USING p_inpath . ENDFORM . " GET_PC_FILENAME *&---------------------------------------------------------------------* *& Form FRM_PROCESS_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_process_data . DATA msg TYPE string . DATA answer . DATA lines TYPE string . DATA folder_id TYPE sofdk . DATA lt_objhead TYPE STANDARD TABLE OF soli . DATA lt_objcont TYPE STANDARD TABLE OF soli WITH HEADER LINE . DATA l_obj_id TYPE soodk . DATA l_obj_data TYPE sood1 . DATA document_id TYPE sofmk . DATA rel_doc TYPE borident . DATA is_object TYPE borident . DATA l_index TYPE sy-index . CLEAR :msg ,answer , lines ,folder_id ,lt_objhead ,lt_objcont ,lt_objcont[] ,l_obj_id ,l_obj_data ,document_id ,is_object ,rel_doc ,l_index . * * lines = lines( gt_out ) . * CONCATENATE lines 'lines of FI Document Note will be updated' INTO msg SEPARATED BY space . * * CALL FUNCTION 'POPUP_TO_CONFIRM' * EXPORTING * text_question = msg * IMPORTING * answer = answer. * * IF sy-subrc <> 0 . * ENDIF . * * IF answer NE '1' . * STOP . * ENDIF . SELECT SINGLE * INTO CORRESPONDING FIELDS OF gs_out FROM bkpf WHERE bukrs = bukrs AND gjahr = gjahr AND belnr = belnr. CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET' EXPORTING region = 'B' IMPORTING folder_id = folder_id EXCEPTIONS OTHERS = 1. * LOOP AT gt_out INTO gs_out . * l_index = sy-tabix . * IF gs_out-title IS INITIAL . * WRITE :/ 'Line ' , l_index , 'title is blank, skip' . * CLEAR gs_out . * CONTINUE . * ENDIF . * IF gs_out-content IS INITIAL . * WRITE :/ 'Line ' , l_index , 'content is blank, skip' . * CLEAR gs_out . * CONTINUE . * ENDIF . * DATA lt_objhead TYPE STANDARD TABLE OF soli. * DATA lt_objcont TYPE STANDARD TABLE OF soli. DATA ls_objcont TYPE soli. DATA lt_urltab TYPE STANDARD TABLE OF sood-objdes. DATA l_tab_size TYPE i. DATA l_url_id TYPE so_url. " DATA l_obj_id TYPE soodk. " DATA l_obj_data TYPE sood1. * l_url_id = url. "note 509858 l_url_id = url. CONCATENATE '&KEY&' 'WWW.BAIDU.COM'INTO ls_objcont. l_obj_data-objdes = dtitle. WHILE NOT l_url_id IS INITIAL. CONCATENATE '&KEY&' l_url_id(250) INTO ls_objcont. l_obj_data-objdes = dtitle. APPEND ls_objcont TO lt_objcont. SHIFT l_url_id LEFT BY 250 PLACES. ENDWHILE. l_obj_data-objsns = 'O'. l_obj_data-objla = sy-langu. IF dtitle IS INITIAL. SPLIT url AT '/' INTO TABLE lt_urltab. DESCRIBE TABLE lt_urltab LINES l_tab_size. READ TABLE lt_urltab INDEX l_tab_size INTO dtitle. ENDIF. CALL FUNCTION 'SO_OBJECT_INSERT' EXPORTING folder_id = folder_id object_type = 'URL' object_hd_change = l_obj_data IMPORTING object_id = l_obj_id TABLES objhead = lt_objhead objcont = lt_objcont EXCEPTIONS active_user_not_exist = 35 folder_not_exist = 6 object_type_not_exist = 17 owner_not_exist = 22 parameter_error = 23 OTHERS = 1000. IF sy-subrc = 0. document_id-foltp = folder_id-foltp. document_id-folyr = folder_id-folyr. document_id-folno = folder_id-folno. document_id-doctp = l_obj_id-objtp. document_id-docyr = l_obj_id-objyr. document_id-docno = l_obj_id-objno. CLEAR rel_doc . rel_doc-objkey = document_id . rel_doc-objtype = 'MESSAGE' . CONCATENATE gs_out-bukrs gs_out-belnr gs_out-gjahr INTO is_object-objkey . is_object-objtype = 'BKPF' . CALL FUNCTION 'BINARY_RELATION_CREATE' EXPORTING obj_rolea = is_object obj_roleb = rel_doc relationtype = 'URL' "'NOTE' EXCEPTIONS OTHERS = 1. IF sy-subrc = 0 . WRITE :/ 'Line ' , l_index , 'updated FI Document Note successfully' . COMMIT WORK . ELSE . WRITE :/ 'Line ' , l_index , 'updated FI Document Note successfully' . ENDIF . CLEAR :lt_objhead ,lt_objcont ,lt_objcont[] ,l_obj_id ,l_obj_data ,document_id ,is_object ,rel_doc ,l_index . CLEAR gs_out . ENDIF. ENDFORM . " FRM_PROCESS_DATA |