Document toolboxDocument toolbox

Function Module for RFC connection

If you want to use the RFC connection you have to install the function module. All properties you need to generate it are described below. Instead of that you can install the Function Module /BLTG/RFC_GET_STRING via Transport Request (download )

If you already use Performer Suite you should have that function module in your system and can re-use it.

No Function Module needed since version v1.4.0 of the Metadata API and with SAP BASIS releases >=

  • 7.40 SP27 in that case you cannot use the transport above have to insert the function module as described in the documentation below

  • 7.50 SP23 in that case you cannot use the transport above have to insert the function module as described in the documentation below

  • 7.51 SP13

  • 7.52 SP09

  • 7.53 SP07

  • 7.54 SP05

  • 7.55 SP03

  • 7.56 SP01

General Information

Function Module Name

<your selected prefix>RFC_GET_STRING

Function Pool

<your function pool>

Remote-Enabled Module

Yes

Import Parameters

Parameter

 

Associated Type

Default

Opt.

Pass

Short text

I_TABLE

TYPE

DD02L-TABNAME

 

 

X

 

I_FIELD

TYPE

FELD_NAME

 

X

X

 

I_RAWSTRING

TYPE

SONV-FLAG

 

X

X

 

I_SCAN_STRING

TYPE

CHAR80

 

X

X

 

I_SCAN_FIELD

TYPE

FELD_NAME

 

X

X

 

I_ROWCOUNT

TYPE

SOID-ACCNT

0

X

X

 

I_DECRYPTION

TYPE

SONV-FLAG

'X'

X

X

 

I_DATABUFFERDECOMPRESS

TYPE

SONV-FLAG

''

X

X

 

I_LIMIT

TYPE

INT4

-1

X

X

 

I_OFFSET

TYPE

INT4

-1

X

X

 

Export Parameters

Parameter

 

Associated Type

Pass

Short text

E_STRING

TYPE

STRING

X

 

E_STRINGTAB

TYPE

STRINGTAB

X

 

E_RC

TYPE

INT4

X

 

E_MSG

TYPE

STRING

X

 

Tables

Parameter

 

Associated Type

Opt.

Short text

T_FIELDS

LIKE

RFC_DB_FLD

 

 

T_OPTIONS

LIKE

RTXTLDAT

 

 

Exceptions

Exception

Short text

RELEASE_1_7

 

NOT_AUTHORIZED

 

TABLE_NOT_AVAILABLE

 

Source Code

FUNCTION <your selected prefix>RFC_GET_STRING. *"---------------------------------------------------------------------- *"*"Lokale Schnittstelle: *" IMPORTING *" VALUE(I_TABLE) TYPE DD02L-TABNAME *" VALUE(I_FIELD) TYPE FELD_NAME OPTIONAL *" VALUE(I_RAWSTRING) TYPE SONV-FLAG OPTIONAL *" VALUE(I_SCAN_STRING) TYPE CHAR80 OPTIONAL *" VALUE(I_SCAN_FIELD) TYPE FELD_NAME OPTIONAL *" VALUE(I_ROWCOUNT) TYPE SOID-ACCNT DEFAULT 0 *" VALUE(I_DECRYPTION) TYPE SONV-FLAG DEFAULT 'X' *" VALUE(I_DATABUFFERDECOMPRESS) TYPE SONV-FLAG DEFAULT '' *" EXPORTING *" VALUE(E_STRING) TYPE STRING *" VALUE(E_STRINGTAB) TYPE STRINGTAB *" VALUE(E_RC) TYPE INT4 *" VALUE(E_MSG) TYPE STRING *" TABLES *" T_FIELDS STRUCTURE RFC_DB_FLD *" T_OPTIONS STRUCTURE RTXTLDAT *" EXCEPTIONS *" RELEASE_1_7 *" NOT_AUTHORIZED *" TABLE_NOT_AVAILABLE *"---------------------------------------------------------------------- "Check Auth. CALL FUNCTION 'VIEW_AUTHORITY_CHECK' EXPORTING view_action = 'S' view_name = i_table EXCEPTIONS no_authority = 2 no_clientindependent_authority = 2 no_linedependent_authority = 2 OTHERS = 1. IF sy-subrc = 2. RAISE not_authorized. ELSEIF sy-subrc = 1. RAISE table_not_available. ENDIF. DATA: lr_error TYPE REF TO cx_root, lr_dataref TYPE REF TO data, lv_rawstring TYPE rswr_data_xstring, lv_zip TYPE c LENGTH 1. * Variables DATA: lv_string TYPE string, lv_decrypt TYPE string, lv_temp TYPE string, ls_dfies TYPE dfies, lt_dfields TYPE ddfields, lt_alldfields TYPE ddfields, lt_stringtab TYPE stringtab, "temp. result table lv_skip TYPE c LENGTH 1. "Flag for skipping dataset insert FIELD-SYMBOLS: <lt_tab> TYPE ANY TABLE, <ls_line> TYPE any, <lv_any> TYPE any. IF i_field IS INITIAL. *catch any exception and pass message along to caller TRY. *Get meta data for table CALL FUNCTION 'DDIF_NAMETAB_GET' EXPORTING tabname = i_table TABLES dfies_tab = lt_alldfields EXCEPTIONS OTHERS = 2. IF sy-subrc <> 0. e_rc = 4. e_msg = 'TABLE NOT FOUND, PLEASE TRY AGAIN.'. RETURN. ENDIF. IF t_fields[] IS INITIAL. *No restrictions provided; use all fields lt_dfields = lt_alldfields. ELSE. *Verify that all fieldnames specified exist in table LOOP AT t_fields ASSIGNING <lv_any>. READ TABLE lt_alldfields INTO ls_dfies WITH KEY fieldname = <lv_any>. IF sy-subrc <> 0. *Specified field not found in table e_rc = 4. CONCATENATE 'FIELD' <lv_any> 'NOT FOUND IN TABLE' i_table INTO e_msg SEPARATED BY space. RETURN. ENDIF. *Fieldname found; insert line into working dfies table INSERT ls_dfies INTO TABLE lt_dfields. ENDLOOP. ENDIF. CREATE DATA lr_dataref TYPE STANDARD TABLE OF (i_table). ASSIGN lr_dataref->* TO <lt_tab>. SELECT * FROM (i_table) INTO TABLE <lt_tab> WHERE (t_options). *************New ADÜ_20180209 IF i_databufferdecompress = 'X' AND i_table = 'RSBKCMD'. DATA: lt_rsbkcmd TYPE TABLE OF rsbkcmd, ls_rsbkcmd TYPE rsbkcmd, lt_rsbkcmd2 TYPE TABLE OF rsbkcmd. lt_rsbkcmd = <lt_tab>. CLEAR <lt_tab>. LOOP AT lt_rsbkcmd INTO ls_rsbkcmd. IF ls_rsbkcmd-cmd = 'COMPRESS'. IMPORT instances TO lt_rsbkcmd2 FROM DATA BUFFER ls_rsbkcmd-tpl_instance. INSERT LINES OF lt_rsbkcmd2 INTO TABLE <lt_tab>. CLEAR lt_rsbkcmd2. ELSE. INSERT ls_rsbkcmd INTO TABLE <lt_tab>. ENDIF. ENDLOOP. ENDIF. ************End New ADÜ_20180209 LOOP AT <lt_tab> ASSIGNING <ls_line>. FREE lt_stringtab. LOOP AT lt_dfields INTO ls_dfies. CLEAR: lv_string, lv_decrypt. ASSIGN COMPONENT ls_dfies-position OF STRUCTURE <ls_line> TO <lv_any>. lv_temp = <lv_any>. "force the type conversion "Zipped? IF ls_dfies-fieldname = 'COMPRESSION'. lv_zip = lv_temp. ENDIF. "special treatment for RAWSTRING fields IF ls_dfies-datatype = 'RSTR' AND i_decryption = 'X'. lv_rawstring = lv_temp. PERFORM decrypt_rawstring USING lv_zip lv_rawstring CHANGING lv_decrypt. e_string = lv_decrypt. lv_temp = lv_decrypt. ENDIF. lv_string = lv_temp. INSERT lv_string INTO TABLE lt_stringtab. "In case a string scan is done check if found IF i_scan_string IS NOT INITIAL. IF i_scan_field = ls_dfies-fieldname. IF lv_string CP i_scan_string. CLEAR lv_skip. ELSE."string not found lv_skip = 'X'. ENDIF. ENDIF. ENDIF. ENDLOOP. "In case scan had no hit -> no insert in result table IF lv_skip IS INITIAL. APPEND LINES OF lt_stringtab TO e_stringtab. ENDIF. "Exit if a rowcount restriction was set IF i_rowcount > 0 AND sy-tabix GE i_rowcount. EXIT. ENDIF. ENDLOOP. CATCH cx_root INTO lr_error. e_rc = 4. e_msg = lr_error->get_text( ). ENDTRY. ELSE."read single line and field IF i_rawstring = 'X' AND i_decryption = 'X'. SELECT SINGLE (i_field) FROM (i_table) INTO lv_rawstring WHERE (t_options). CLEAR lv_zip. PERFORM decrypt_rawstring USING lv_zip lv_rawstring CHANGING lv_decrypt. e_string = lv_decrypt. "BEGIN NEW ELSEIF i_rawstring = 'X' AND i_decryption = ''. SELECT SINGLE (i_field) FROM (i_table) INTO lv_rawstring WHERE (t_options). e_string = lv_rawstring. "END NEW ELSE. SELECT SINGLE (i_field) FROM (i_table) INTO e_string WHERE (t_options). ENDIF. ENDIF. ENDFUNCTION. *&--------------------------------------------------------------------* *& Form decrypt_rawstring *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* FORM decrypt_rawstring USING lv_zip lv_rawstring CHANGING lv_decrypt. "Transform rawstring to text DATA: lv_converter TYPE REF TO cl_abap_conv_in_ce. DATA: lv_xstring TYPE xstring. * unzip if compressed IF NOT lv_zip IS INITIAL. TRY. cl_abap_gzip=>decompress_binary( EXPORTING gzip_in = lv_rawstring IMPORTING raw_out = lv_xstring ). CATCH: cx_parameter_invalid_range cx_sy_buffer_overflow. ENDTRY. ELSE. lv_xstring = lv_rawstring. ENDIF. * read lv_converter = cl_abap_conv_in_ce=>create( input = lv_xstring encoding = 'UTF-8' replacement = '?' ignore_cerr = abap_true ). TRY. CALL METHOD lv_converter->read( IMPORTING data = lv_decrypt ). CATCH cx_sy_conversion_codepage. *-- Should ignore errors in code conversions CATCH cx_sy_codepage_converter_init. *-- Should ignore errors in code conversions CATCH cx_parameter_invalid_type. CATCH cx_parameter_invalid_range. ENDTRY. ENDFORM. "decrypt_rawstring

© 2024 bluetelligence GmbH. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of bluetelligence GmbH. The information contained herein may be changed without prior notice. bluetelligence and Performer Suite and their respective logos are trademarks or registered trademarks of bluetelligence GmbH. SAP, ABAP, BAPI, SAP NetWeaver, SAP BI, SAP BW, SAC, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany or an SAP affiliate company. All other product and service names mentioned are the trademarks of their respective companies.
Impressum – Legal Notice: https://bluetelligence.de/en/imprint
Privacy policy: https://bluetelligence.atlassian.net/wiki/spaces/DMA/pages/4188635149/Privacy+Policy
Atlassian privacy policy: https://www.atlassian.com/legal/privacy-policy