How to Extract Data with OPEN HUB to a Customer Defined Logical Filename
BUSINESS INFORMATION WAREHOUSE
Applicable Releases: 3.0B, 3.1C January 2004, Version 1
SAP (SAP America, Inc. and SAP AG) assumes no responsibility for errors or omissions in these materials. These materials are provided as is without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages. mySAP BI How-To papers are intended to simplify the product implementation. While specific product features and procedures typically are explained in a practical business context, it is not implied that those features and procedures are the only approach in solving a specific business problem using mySAP BI. Should you wish to receive additional information, clarification or support, please refer to SAP Professional Services (Consulting/Remote Consulting).
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME
1 Business Scenario
With the help of the OPEN HUB and by using user-defined logical filenames, you can save data on the application server. It is assumed that the logical filename has already been created using the FILE transaction.
2 Introduction
This How To paper describes how the open hub functionality can be enhanced with the use of logical filenames with 2 modifications and the creation of an append structure for table RSBFILE.
2004 SAP AMERICA, INC. AND SAP AG
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME The Step By Step Solution
1. Enhancement of Table RSBFILE
1. Start Transaction SE11
Database table: RSBFILE Click: DISPLAY Comment: Please take a look to chapter 3 Upgrade to BW 3.5 Patch 1+
2. Append Structure of table RSBFILE Click: Append Structure
2004 SAP AMERICA, INC. AND SAP AG
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 3. Type in the technical name of the structure-append.
4. Type in the Description: Append for logical filename Add the components and Component types: Component 1: ZZFILEINT Component type 1: FILEINTERN Component 2: ZZDOTNETLS Component type 2: LOGSYS Check and activate the APPEND Ignore the warnings.
2004 SAP AMERICA, INC. AND SAP AG
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME
2. Define CLASS ZCL_RSB_FILE_LOGICAL
Please import the added Transport. The Transport includes the class ZCL_RSB_FILE_LOGICAL. Transport:
K902312.qb8
R902312.qb8
Please check and activate the imported class.
3. Modify Class CL_RSB_DEST
1. Goto Transaction SE24 DISPLAY Object type: CL_RSB_DEST
2. Double click on the Method: GET_OBJECT_REF_INT
2004 SAP AMERICA, INC. AND SAP AG
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME Change line: 19 from:
DATA: l_r_file_applsrv TYPE REF TO cl_rsb_file_applsrv.
to:
DATA: l_r_file_applsrv TYPE REF TO ZCL_RSB_FILE_LOGICAL.
)
DATA: l_r_file_applsrv TYPE REF TO CL_RSB_FILE_LOGICAL. Example for modification: see * nchste Zeile fr Michael Hoerisch gendert METHOD get_object_ref_int . DATA: l_desttype TYPE rsdesttype, l_appserver TYPE rsbappserver. SELECT SINGLE desttype INTO l_desttype FROM rsbohdest WHERE ohdest = n_dest AND objvers = rs_c_objvers-active. IF sy-subrc <> 0. SELECT SINGLE desttype INTO l_desttype FROM rsbohdest WHERE ohdest = n_dest AND objvers = rs_c_objvers-modified. ENDIF. CHECK sy-subrc = 0. CASE l_desttype. WHEN rsbo_c_desttype_int-file_applsrv. * nchste Zeile fr Michael Hoerisch gendert *\ data: l_r_file_applsrv type ref to cl_rsb_file_applsrv. DATA: l_r_file_applsrv TYPE REF TO ZCL_RSB_FILE_LOGICAL. CREATE OBJECT l_r_file_applsrv EXPORTING i_dest = n_dest i_objvers = i_objvers
2004 SAP AMERICA, INC. AND SAP AG
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 3. Double click on the Method: CHANGE_PARMS
Replace line 23: from:
data: l_r_file_applsrv type ref to cl_rsb_file_applsrv. to: data: l_r_file_applsrv type ref to zcl_rsb_file_logical. Example for modification: see * nchste Zeile fr Michael Hoerisch gendert method change_parms . data: l_s_vdest type rsbo_s_vdest. l_s_vdest = i_s_vdest. * l_s_vdest-objvers = rs_c_objvers-new. l_s_vdest-desttype_int = get_desttype( l_s_vdest ). * if not p_r_vers_n is initial. check: re-instantiation necessary ? data: l_s_vdest_old type rsbo_s_vdest. call method p_r_vers_n->get_info importing e_s_vdest = l_s_vdest_old. if l_s_vdest-desttype_int ne l_s_vdest_old-desttype_int. clear p_r_vers_n. clear p_r_vers_m. clear p_r_vers_a. endif. endif.
if p_r_vers_n is initial. case l_s_vdest-desttype_int. when rsbo_c_desttype_int-file_applsrv. * nchste Zeile fr Michael Hoerisch gendert *\ data: l_r_file_applsrv type ref to cl_rsb_file_applsrv. data: l_r_file_applsrv type ref to zcl_rsb_file_logical. create object l_r_file_applsrv exporting i_dest = n_dest
2004 SAP AMERICA, INC. AND SAP AG
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME
i_objvers = rs_c_objvers-new.
4. Save & Activate the class
2004 SAP AMERICA, INC. AND SAP AG
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME
4. Modify Class CL_RSB_SPOK_VIEW
5. Goto Transaction SE24 DISPLAY Object type: CL_RSB_SPOK_VIEW
6. Double click on the Method: SET_SCREEN_2001
Replace line 109-110 from:
e_input = rsboh_c_off. e_active = rsboh_c_on.
to:
if p_s_dynp2001-appserver = 'X'. e_input = rsboh_c_on. e_active = rsboh_c_on. else. e_input = rsboh_c_off. e_active = rsboh_c_on. endif. e.g.see REPLACE! method set_screen_2001 .
2004 SAP AMERICA, INC. AND SAP AG
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME
*==== set screen attributes =========== if p_s_status-mode = rsbo_c_mode-display or p_s_dynp200-deltastatus = rsbo_c_dstatus-active. * Eingabefelder ***** Anzeigemodus ******************************** *------- Kopfeintrge----------------------------case i_group2. when 'HED' or 'KEY' or 'RAD'. e_active = rsboh_c_on. e_input = rsboh_c_off. *------- Pushbuttons-----------------------------when 'PU1'. e_active = rsboh_c_on. when 'PU2'. e_active = rsboh_c_off. *------- Typ-spezifische Eigenschaften ----------when 'TYP'. if p_s_dynp2001-typefile = 'X'. * Anzeigen / File case i_group3. when 'FIL'. e_active = rsboh_c_on. * Anzeigen / File / Gruppe File case i_group4. when 'APP'. * Anzeigen / File / Gruppe File / Laden auf Appl.server if p_s_dynp2001-appserver = 'X'. e_input = rsboh_c_off. e_active = rsboh_c_on. else. e_input = rsboh_c_off. e_active = rsboh_c_off. endif. when others. * Anzeigen / File / Gruppe File / Laden auf lok. server e_input = rsboh_c_off. e_active = rsboh_c_on. endcase. when 'DB'. * Anzeigen / File / Gruppe DB Tabelle e_input = rsboh_c_off. e_active = rsboh_c_off. endcase. else. * Anzeigen / DB Tabelle oder undefiniert case i_group3. when 'FIL'. * Anzeigen / DB Tab / Gruppe File e_input = rsboh_c_off. e_active = rsboh_c_on. when 'DB'. * Anzeigen / DB Tab / Gruppe DB Tabelle e_input = rsboh_c_off. e_active = rsboh_c_on. endcase. endif. endcase. else. "if p_s_status-mode = rsbo_c_status-display. ************* nderungs- / Anlegemodus ********** *------- Kopfeintrge----------------------------case i_group2. when 'HED'.
2004 SAP AMERICA, INC. AND SAP AG
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME
e_active = rsboh_c_on. e_input = rsboh_c_on. when 'KEY'. e_active = rsboh_c_on. e_input = rsboh_c_off. when 'RAD'. if p_s_dynp200-deltastatus ne rsbo_c_dstatus-active. e_active = rsboh_c_on. e_input = rsboh_c_on. else. e_active = rsboh_c_on. e_input = rsboh_c_off. endif. *------- Pushbuttons-----------------------------when 'PU1'. e_active = rsboh_c_on. when 'PU2'. e_active = rsboh_c_on. when 'TYP'. *------- Typ-spezifische Eigenschaften ----------if p_s_dynp2001-typefile = 'X'. * ndern / File case i_group3. when 'FIL'. * ndern / File / Gruppe File case i_group4. when 'APP'. * ndern / File / Gruppe File / Laden auf Appl.server if p_s_dynp2001-appserver = 'X'. e_input = rsboh_c_on. e_active = rsboh_c_on. else. e_input = rsboh_c_off. e_active = rsboh_c_off. endif. when 'LOC'. * ndern / File / Gruppe File / Laden auf lok.server if p_s_dynp2001-appserver = 'X'. e_input = rsboh_c_off. e_active = rsboh_c_on. else. e_input = rsboh_c_on. e_active = rsboh_c_on. endif. when 'NAM'. *{ REPLACE *\ e_input = rsboh_c_off. *\ e_active = rsboh_c_on. if p_s_dynp2001-appserver = 'X'. e_input = rsboh_c_on. e_active = rsboh_c_on. else. e_input = rsboh_c_off. e_active = rsboh_c_on. endif. *} REPLACE when others. * ndern / File / Gruppe File / Laden auf lok. server e_input = rsboh_c_on. e_active = rsboh_c_on. endcase. when 'DB'.
2004 SAP AMERICA, INC. AND SAP AG
10
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME
* ndern / File / Gruppe DB Tabelle e_input = rsboh_c_off. e_active = rsboh_c_on. endcase. else. * ndern / DB Tabelle case i_group3. when 'FIL'. * ndern / DB Tab / Gruppe File e_input = rsboh_c_off. e_active = rsboh_c_on. when 'DB'. * ndern / DB Tab / Gruppe DB Tabelle case i_group4. when 'TAB'. * ndern / DB Tab / Gruppe DB Tabelle / Tabellenname e_input = rsboh_c_off. e_active = rsboh_c_on. when others. * ndern / DB Tab / Gruppe DB Tabelle / Einstellungen e_input = rsboh_c_on. e_active = rsboh_c_on. endcase. endcase. endif. endcase. endif. endmethod. "SET_SCREEN_200
5. Create a logical Filename
1. Goto Transaction FILE
2. Define a Logical File Path click on: Logical File Path Definition
2004 SAP AMERICA, INC. AND SAP AG
11
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME New Entries Logical file path: ZMHHOWTOIS Name: HowTo InfoSpoke with logical Filename Save
3. Click: Assignment Physical Paths of Logical Path New Entries Symtax Group: WINDWOS NT Physical path: <P=DIR_GLOBAL>\<FILENAME> the Parameters (P) are maintainable with Report RSPARAM see. Online
Documentation
click Save 4. Click: Logical Filename Definition, Cross Client New Entries Define a Logical Filename:
Name: HowTo InfoSpoke with logical Filename Physical file: MH<TIME> <TIME> is a predefinded Veriable Data format: ASC Application Area: BW Logical path: ZMHHOWTOIS see 2. SAVE
6. Create a Infospoke with the destination logical Filename
1. Go to transaction RSA1
2004 SAP AMERICA, INC. AND SAP AG
12
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 2. Click Menu: Tools Open Hub Service InfoSpoke Transaction: RSBO Create
3. Define a InfoSpoke Name: MHHOWTOIS Click Create
4. Fill the general fields: Description: HowTo paper Select a Data Source: e.g. InfoCube MHRENO03 Destination: MHHOWTOIS Extraction Mode: Full Lines per Data Package: 10000
2004 SAP AMERICA, INC. AND SAP AG
13
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 5. Fill the Destination Fields Select FILE Select Application Server Filename (logicl Filename!): ZHOWTOFILE
6. Fill InfoObjects Move all to the left page
2004 SAP AMERICA, INC. AND SAP AG
14
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 7. No Selection and to Transformation SAVE and ACTIVATE
8. Start the InfoSoke in Dialog
9. Go to Transaction AL11 Check the existing file in the physical directory of the logical filename File MH142400: exists!
3 Upgrade to BW 3.5 Patch 1+
After upgrade to BW 3.5 Patch X the field FILEINTERN of table RSBFILE will exist. It will be necessary to copy for all entries of table RSBFILE the field ZZFILEINT to FILEINTERN and ZZDOTNETLS to DOTNETLS. Otherwise the FILENAME will be removed from the InfoSpoke definition.
2004 SAP AMERICA, INC. AND SAP AG
15
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME
4 Appendix Coding in attached Transport
CLASS ZCL_RSB_FILE_LOGICAL
1. Start Transaction SE24
create a class: ZCL_RSB_FILE_LOGICAL Description: Open Hub Destination: File
2004 SAP AMERICA, INC. AND SAP AG
16
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 2. maintain Properties Screen: Super class: CL_RSB_FILE_GENERAL Message Class: RSBO Type Group/Object type: RS RSBO RSUDT
3. SAVE
4. Redefine Methods (1) IF_RSB_OPEN_HUB_TARGET~RECEI VE_DATA
2004 SAP AMERICA, INC. AND SAP AG
17
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME Copy and paste the following coding:
method IF_RSB_OPEN_HUB_TARGET~RECEIVE_DATA . data: * l_update_task LIKE sy-subrc, l_line_fix(64000) type c, l_line_csv type string. * Erzeuge typisierte lokale Schnittstellentabelle data: l_r_data type ref to data. field-symbols: <l_t_data> type standard table. create data l_r_data type standard table of (o_tabname). assign l_r_data->* to <l_t_data>. call method i_r_data->get_info importing e_t_data = <l_t_data>. * write data package I_R_DATA to file field-symbols: <l_s_data> type any, <l_fix_line> type any. data: l_r_data2 type ref to data. create data l_r_data2 like line of <l_t_data>. * assign local copy of initial line of i_t_data to <l_s_data>. assign l_r_data2->* to <l_s_data>. * write data to file if o_fieldcount > 0. data l_filename type rsbfilename. loop at <l_t_data> assigning <l_s_data>. if o_s_file-returntpf = rsbo_c_returntp-file. * --- convert to a CSV line call method convert_to_csv exporting i_s_data = <l_s_data> importing e_line_csv = l_line_csv. * --- write CSV line to file transfer l_line_csv to o_filename. endif. endloop. endif. endmethod.
CHECK and SAVE the coding
2004 SAP AMERICA, INC. AND SAP AG
18
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 5. Redefine Methods (2) IF_RSB_OPEN_HUB_TARGET~BEFO RE_EXTRACTION
Copy and paste the following coding:
method IF_RSB_OPEN_HUB_TARGET~BEFORE_EXTRACTION . call method super->if_rsb_open_hub_target~before_extraction exporting i_r_request = i_r_request i_r_log = i_r_log. * open file * data l_x. * while l_x is initial. * endwhile. open dataset o_filename for output in text mode encoding default. check sy-subrc <> 0. message e214 with o_filename into o_dummy_msg. raise_sy_error( ). endmethod. "IF_RSB_OPEN_HUB_TARGET~BEFORE_EXTRACTION
6. Redefine Methods (3) IF_RSB_OPEN_HUB_TARGET~AFTE R_EXTRACTION
Copy and paste the following coding:
method IF_RSB_OPEN_HUB_TARGET~AFTER_EXTRACTION . close dataset o_filename. call method super->if_rsb_open_hub_target~after_extraction importing e_state = e_state. endmethod. "IF_RSB_OPEN_HUB_TARGET~AFTER_EXTRACTION
2004 SAP AMERICA, INC. AND SAP AG
19
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 7. Redefine Methods (4) IF_RSB_OPEN_HUB_TARGET~REQU EST_ROLLBACK
Copy and paste the following coding:
method IF_RSB_OPEN_HUB_TARGET~REQUEST_ROLLBACK . call method super->if_rsb_open_hub_target~request_rollback exporting i_r_log = o_r_log. * ======= clear Data File ============= open dataset o_filename for output in text mode encoding default. close dataset o_filename. * ======= replace Status File ============= data: l_s_data(2048), l_t_data like table of l_s_data. call method generate_control_file_csv exporting i_state = rsbo_c_rqstate-error importing e_t_data_tab = l_t_data. open dataset o_filename_ctrl for output in text mode encoding default. check sy-subrc = 0. loop at l_t_data into l_s_data. transfer l_s_data to o_filename_ctrl. endloop. close dataset o_filename_ctrl. endmethod.
8. Redefine Methods (5) CHANGE_PARMS
2004 SAP AMERICA, INC. AND SAP AG
20
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME Copy and paste the following coding:
method CHANGE_PARMS . data: l_s_file_old type rsbfile. l_s_file_old = o_s_file. move-corresponding i_s_vdest to o_s_file. o_s_file-zzfileint = i_s_vdest-file. ******* Separator *********** if o_s_file-separator is initial. * get separator from RSADMIN call function 'RSCC_RSADM_ACC' exporting fieldname = rs_c_rsadmin-excel_fieldsep action = rs_c_actionadm-sel changing adminvalue = o_s_file-separator. endif. * separator value if o_s_file-separator is initial. o_s_file-separator = ';'. endif. ********* filetype ************ if o_s_file-returntpf is initial. o_s_file-returntpf = rsbo_c_returntp-file. endif. determine_filename( ). ********** check ************** call method check exporting i_repair = rs_c_true. if l_s_file_old <> o_s_file and not l_s_file_old is initial. o_is_saved = rs_c_false. endif. data l_issaved_hdr type rs_bool. call method super->change_parms exporting i_s_vdest = i_s_vdest importing e_issaved = l_issaved_hdr. if l_issaved_hdr = rs_c_false or o_is_saved = rs_c_false. e_issaved = rs_c_false. else. e_issaved = rs_c_true. endif. endmethod. "
2004 SAP AMERICA, INC. AND SAP AG
21
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 9. Redefine Methods (6) CONVERT_INT_TO_EXT
Copy and paste the following coding:
method CONVERT_INT_TO_EXT . call method super->convert_int_to_ext exporting i_s_dest_int = i_s_dest_int i_s_destt = i_s_destt importing e_s_vdest = e_s_vdest. e_s_vdest-desttype = rsbo_c_desttype-file. e_s_vdest-appserver = rs_c_false. endmethod.
10. Redefine Methods (7) GET_INFO
2004 SAP AMERICA, INC. AND SAP AG
22
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME Copy and paste the following coding:
method GET_INFO . call method super->get_info importing e_s_vdest = e_s_vdest. move-corresponding o_s_file to e_s_vdest. if o_is_saved = rs_c_false. e_s_vdest-is_saved = rs_c_false. endif. e_s_vdest-desttype = rsbo_c_desttype-file. e_s_vdest-appserver = rs_c_true. * serialization of incoming data e_s_vdest-dreqser = rsudt_c_dreqser-data_package. e_s_vdest-file = o_s_file-zzfileint. endmethod.
11. Redefine Methods (8) SAVE
Copy and paste the following coding:
method SAVE . call method super->save exporting i_objvers = i_objvers i_detlevel = '3' changing c_subrc = c_subrc. check c_subrc = 0. * DB * save file specific data o_s_file-objvers = rs_c_objvers-modified. modify rsbfile from o_s_file. if sy-subrc <> 0. message e003 with 'RSBFILE' into o_dummy_msg. cl_rso_application_log=>add_message_level( i_detlevel = i_detlevel ) . c_subrc = 4. * Fehler beim Schreiben in die Datenbanktabelle &1 endif. o_is_saved = rs_c_true. endmethod. "
2004 SAP AMERICA, INC. AND SAP AG
23
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 12. Redefine Methods (9) CHECK
Copy and paste the following coding:
method check . data: l_logical type rs_bool. * -------------- check filename ----------------------* assert path is valid if o_s_file-zzfileint is initial. if not i_r_msg is initial. message e109 into o_dummy_msg. i_r_msg->add_msg( ). endif. e_subrc = 4. endif. * check whether this is a logical filename data: l_fileintern type fileintern. data l_filename type rsbfilename. l_fileintern = o_s_file-zzfileint. call function 'FILE_GET_NAME' exporting logical_filename = l_fileintern importing file_name = l_filename exceptions file_not_found = 1 others = 2. if sy-subrc <> 0. if not i_r_msg is initial. message e104 with l_filename into o_dummy_msg. call method i_r_msg->add_msg. e_subrc = 4. endif. endif. * ---- repair file ------------clear l_filename. * ---- repair pathname ------------data l_homedir(128). clear l_homedir. . * repair instantly ? if i_repair = rs_c_true. o_s_file-file = l_filename. o_s_file-path = l_homedir. o_s_file-zzfileint = l_fileintern. e_is_repaired = rs_c_true. endif. endmethod. "
2004 SAP AMERICA, INC. AND SAP AG
24
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 13. Redefine Methods (10) GENERATE_CONTROL_FILE_CSV
Copy and paste the following coding:
method GENERATE_CONTROL_FILE_CSV . call method super->generate_control_file_csv exporting i_state = i_state importing e_t_data_tab = e_t_data_tab. * open file open dataset o_filename_ctrl for output in text mode encoding default. check sy-subrc = 0. data l_s_line(2048). loop at e_t_data_tab into l_s_line. transfer l_s_line to o_filename_ctrl. endloop. close dataset o_filename_ctrl. endmethod.
14. Redefine Methods (11) GENERATE_CONTROL_FILE_ASC
Copy and paste the following coding:
method GENERATE_CONTROL_FILE_ASC . call method super->generate_control_file_asc importing e_t_data_tab = e_t_data_tab. * open file open dataset o_filename_ctrl for output in text mode encoding default. data l_s_line(2048). loop at e_t_data_tab into l_s_line. transfer l_s_line to o_filename_ctrl. endloop. close dataset o_filename_ctrl. endmethod. "GENERATE_CONTROL_FILE
2004 SAP AMERICA, INC. AND SAP AG
25
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 15. Redefine Methods (12) DETERMINE_FILENAME
Copy and paste the following coding:
method determine_filename . data: l_fileextern TYPE filename-fileextern, l_logpath TYPE filename-pathintern. * concatenate o_s_file-path l_slash o_s_file-file into o_filename. * concatenate o_s_file-path l_slash 'S_' o_s_file-file * into o_filename_ctrl. * replace '/' with '[' into i_fileid. * replace '/' with ']' into i_fileid. * Build physical filename call function 'FILE_GET_NAME_AND_LOGICAL_PATH' exporting logical_filename = o_s_file-zzfileint * parameter_1 = i_fileid use_buffer = 'X' operating_system = sy-opsys importing file_name = l_fileextern logical_path = l_logpath exceptions others = 4. data l_file_ctrl type filename-fileextern. concatenate 'S_' l_fileextern into l_file_ctrl. data l_filename type w3filename. call function 'FILE_GET_NAME_USING_PATH' exporting logical_path = l_logpath file_name = l_fileextern importing file_name_with_path = l_filename exceptions others = 3. o_filename = l_filename. call function 'FILE_GET_NAME_USING_PATH' exporting logical_path = l_logpath file_name = l_file_ctrl importing file_name_with_path = l_filename exceptions others = 3. o_filename_ctrl = l_filename. endmethod.
2004 SAP AMERICA, INC. AND SAP AG
26
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME 16. Define Methods F4_FILE (1) Methods: F4_FILE Level: Static Method Visibility: Public
17. Define Methods F4_FILE (2) Parameters
2004 SAP AMERICA, INC. AND SAP AG
27
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME Copy and paste the following coding:
method F4_FILE . data: l_t_files type standard table of ocs_f_info, l_s_files type ocs_f_info, l_mask(100). call function 'OCS_FILENAME_GET' exporting PI_DEF_FILENAME = ' ' PI_DEF_PATH = ' ' pi_mask = 'Alle Dateien'(001) PI_MODE = 'O' PI_TITLE = ' ' tables pt_fileinfo = l_t_files exceptions inv_winsys = 1 no_batch = 2 selection_cancel = 3 selection_error = 4 general_error = 5 others = 6 . check sy-subrc = 0. read table l_t_files into l_s_files index 1. concatenate l_s_files-file_path l_s_files-file_name into c_file. "f4_logsys_2000
* * * *
endmethod.
18. Define Method CONSTRUCTOR (1)
19. Define Method CONSTRUCTOR (2) Maintain Parameters: click on Parameters
I_DEST I_OBJVERS I_S_VDEST I_R_VERS Type RSOHDEST Type RSOBJVERS Type RSBO_S_VDEST Type Ref to CL_RSB_DEST_VERS
2004 SAP AMERICA, INC. AND SAP AG
28
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME
20. Define Method CONSTRUCTOR (3) Click on Exceptions Maintain Exceptions: INPUT_INVALID
21. Define Method CONSTRUCTOR (4) Click Methods
Double click on Method Constructorand insert coding:
2004 SAP AMERICA, INC. AND SAP AG
29
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME Copy and paste the following coding:
method CONSTRUCTOR . if i_dest is initial. message e001 raising input_invalid. endif. call method super->constructor EXPORTING i_dest = i_dest i_objvers = i_objvers i_s_vdest = i_s_vdest i_r_vers = i_r_vers EXCEPTIONS input_invalid = 1. if sy-subrc <> 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 raising input_invalid. endif. 3 different methods to initialize: if not i_s_vdest is initial. 1. create with properties given by caller if i_dest <> i_s_vdest-ohdest. message e010 with i_dest i_s_vdest-ohdest raising input_invalid. Ungltige Eingabe &1 &2 &3 &4 endif. move-corresponding i_s_vdest to o_s_file. o_is_saved = i_s_vdest-is_saved. determine_filename( ). elseif not i_r_vers is initial. 2. create from object reference given by caller (copy) data: l_s_vdest type rsbo_s_vdest. call method i_r_vers->get_info IMPORTING e_s_vdest = l_s_vdest. move-corresponding l_s_vdest to o_s_file. o_is_saved = rs_c_false. determine_filename( ). else. 3. read from DB data: l_s_dest type rsbohdest, l_objvers_read type rsobjvers. l_objvers_read = i_objvers. if l_objvers_read = rs_c_objvers-new. data l_activfl type rsactivfl. select single activfl from rsbohdest into l_activfl where ohdest = i_dest and objvers = rs_c_objvers-active. if sy-subrc <> 0. select single activfl from rsbohdest into l_activfl where ohdest = i_dest and objvers = rs_c_objvers-modified. check sy-subrc = 0. endif. if l_activfl = rs_c_true. l_objvers_read = rs_c_objvers-active. else. l_objvers_read = rs_c_objvers-modified. endif.
* *
2004 SAP AMERICA, INC. AND SAP AG
30
HOW TO EXTRACT DATA VIA OPEN HUB TO A CUSTOMER DEFINED LOGICAL FILENAME
endif. select single * from rsbfile into o_s_file where ohdest = i_dest and objvers = l_objvers_read. o_is_saved = rs_c_true. determine_filename( ). endif. endmethod.
22. Save and activate the Class
2004 SAP AMERICA, INC. AND SAP AG
31