Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Shared Memory, exporting data reference and generic types

bilen_cekic
Explorer
0 Likes
3,156

Hello,

I have a class and a method which has an import parameter like

IT_DATA type standard table.

i am tryingto export this table  to shared memory (my data reference variable) but i always get  error. Is there a way to export dynamic tables to SHMA ?

code is similar to this

DATA: v_area_handle TYPE REF TO zcl_shr_areahandle_area,
v_root        TYPE REF TO zcl_shr_areahandle_root.

FIELD-SYMBOLS <fs_data> TYPE ANY.

TRY.
v_area_handle = zcl_shr_areahandle_area=>attach_for_write( ).

CREATE OBJECT v_root AREA HANDLE v_area_handle.

v_area_handle->set_root( v_root ).

*dref is the attribute created in root class.

CREATE DATA v_root->dref AREA HANDLE v_area_handle TYPE IT_DATA.

ASSIGN v_root->dref->* TO <fs_data>.


<fs_data> = it_data[] .

v_area_handle->detach_commit( ).

gives error on detach_commit.

11 REPLIES 11
Read only

edgar_nagasaki
Contributor
0 Likes
2,399

Hi Bilen,

Check this thread, think it can help: https://scn.sap.com/thread/2065599

Regards,

Edgar

Read only

0 Likes
2,399

no that doesnt fix. i want to use SHMA

myerror is

  The exception 'CX_SHM_EXTERNAL_REFERENCE' was raised, but it was not caught

   anywhere along

  the call hierarchy.

  Since exceptions represent error situations and this error was not

  adequately responded to, the running ABAP program

   'CL_SHM_AREA===================CP' has to be

  terminated.

Read only

former_member186413
Participant
0 Likes
2,399

I don't think that you are using correct procedure and method for passing your table into share area. 

Why don't you create a dynamic type's(RTTS) attribute in your share object class such as

COMP TYPE REF TO CL_ABAP_TABLEDESCR

OR

COMP TYPE REF TO DATA

And several class method to initial the property of this component's type and array of data which are going to contain.

Of Cause, the first important thing is make sure that your class is share memory enable.

Read only

0 Likes
2,399

hello<

you can use data references in your shared memory enabled class without problem.

But if your source table is dynamically created it doesnt work.

i mean here

CREATE DATA v_root->dref AREA HANDLE v_area_handle TYPE IT_DATA

IT_DATA is dynmic or it is RTTS variable, (to access that data you always use datarefernce get structure and assign to field symbol(

it gives error.

even if you unassing fieldsymbols bfore sending to shma.


Read only

0 Likes
2,399

I think, you should try this

CREATE DATA v_area_handle->root->dref AREA HANDLE v_area_handle TYPE IT_DATA.

Read only

0 Likes
2,399

Because you should modified the object in the share memory indirectly via share memory class object itself.  This is what the problem is occurring in your program.  Unless you throw an event to tell the share memory object that your v_root have been bounded to the array of data.

Read only

0 Likes
2,399

SORRY man

first i though that it was working

yes

if you cal like that it works

data:

itab type table of mara.

select * from mara into table itab.

call function z001

export

it_data = itab

and data type of it_data is standad table.

well it works like that but in BADI which a parameter is coming as a standard table

didnt work

  The type \TYPE=%_T00003S00000118O0000016260 cannot currently be created in the

  shared objects memory

Read only

0 Likes
2,399

This message was moderated.

Read only

0 Likes
2,399

THE ONLY WAY to make it work is

our source table which we are sending to memory

should be a global type like structure, table, integer etc,...

it doesnt work if it isdynamically created like RTTI

Read only

0 Likes
2,399

I think you can solve this by the following, I'm not sure it will work but you can try.

First, The dynamic reference variables (including RTTI) will be set as the one of  the BADI implementation class attributes.

Secondly, in your SHMA, you set your constructor class of your share memory area's dynamic properties as the BADI implementation class.

There is some useful reference in here: http://saptechnical.com/Tutorials/Others/SharedMemory/Concept.htm

About how to call SHM dynamically in its constructor class.

Read only

0 Likes
2,399

I am expecting that root is dynamic reference, so

"THE ONLY WAY to make it work is

our source table which we are sending to memory

should be a global type like structure, table, integer etc,...

it doesnt work if it isdynamically created like RTTI." ,

May not be the true.