Application Development 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: 

How to handle static data in combination with BW parallell processing?

0 Kudos
206

Hi,

I'm primeraly a BW developer, and certainly a rookie at OO so please bare with me if I don't see the obvious here

The scenario is as follows:

When loading economic line items from a DSO (transp. table) to a BW cube we have a lookup in the same DSO to enrich the data with info from other lines than the one currently processed.

The loading from dso to cube is handled by SAP programs cl_rstran*. There are only some openings for inserting custom code and one of them the is the method start_routine which is edited in the BW transformations screen.

The amount of records from the dso that needs to be available in an internal table for lookup is large (~20mi records).

Data between dso and cube is typically processed in packages of 500.000 records and 3 packages in parallell.

Our old code was loading the internal table in the start_routine method, and a 20 mio record table was built to process 500.000 records every time. Not effective.

So my idea was to load the internal table once as static data of a new class zcl_tran_hs and handle lookup in methods of this class.

In order to prevent multiple loads of the itable I made a call in the start_routine

 zcl_tran_hs=>factory(
IMPORTING
ex_hs_instance = ref_hs
). 

zcl_tran_hs:

 method FACTORY.
DO.
 IF data_loading NE 'X'. "loop until loading is complete
  CREATE OBJECT hs_instance.
  EXIT.
 ENDIF.
ENDDO.
endmethod. 

 method CONSTRUCTOR.
IF instance_count = 0.
 data_loading = 'X'.
 load_dso ( ).
 data_loading = ''.
ENDIF.
ADD 1 to instance_count
endmethod. 

data_loading and instance_count are static attributes.

OK, so what's the problem?

BW spawns 3 background jobs to run the transformation in parallell. And when they reach my class all of the three first datapackages gets instance_count = 0 thus causing the table to be filled 3 times. For subsequent packages in the same jobs all is well. What am I missing here, I thought that static attributes in a global class would be able to hold the counter from the class was first called? And what about the internal hashed table it_hs, are there also 3 separate tables with the same name or is it updating the same internal table trice? ( that would be bad since the lookup in the first process starts before the last has completed the select)

I tried using the class_constructor with the same result. The three background jobs seems not to share the static atributes of the class.

Could this be the case, static attributes are not shared between parallell jobs?

Regards,

Ola

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos
155

Hi Ola,

SAP-ABAP is different from other languages: Starting a program/job you create a new logical unit of work (LUW). Each Job creates it's own LUW, so your static classes are also loaded anew with each job.

I think, SHARED MEMORY / SHARED OBJECTS could be a solution. But I think the shared memory area is also restricted by some server parameters.

But this is the only way to share information between independent jobs.

And I don't know why SAP herself makes as good as no use of this concept.

I'd be interested if you can.

Regards,

Clemens

2 REPLIES 2

Clemenss
Active Contributor
0 Kudos
156

Hi Ola,

SAP-ABAP is different from other languages: Starting a program/job you create a new logical unit of work (LUW). Each Job creates it's own LUW, so your static classes are also loaded anew with each job.

I think, SHARED MEMORY / SHARED OBJECTS could be a solution. But I think the shared memory area is also restricted by some server parameters.

But this is the only way to share information between independent jobs.

And I don't know why SAP herself makes as good as no use of this concept.

I'd be interested if you can.

Regards,

Clemens

0 Kudos
155

Thank you, that answers my question and relieves my fear of corrupting data. I'll look into shared objects in time and update this thread - the only time I've come across that is at a course.

Ola