cancel
Showing results for 
Search instead for 
Did you mean: 

Start Routine In Update Rules

Former Member
0 Kudos

Hello,

It is my understanding that a start routine in Update Rules is run once per data package. That is clear.

I have a start routine in which an internal table gets populated from another ODS.

My question is this:

Will I repopulate this internal table for every data package that arrives? Or will this table be recognized as already having been loaded, and thus will not get reloaded again (redundantly). Does the internal table persist between data packages or is it dumped from memory when the new data package arrives (thus requiring a reload of its contents again).

Thanks,

Nick

Message was edited by: Nick Bertz

Accepted Solutions (1)

Accepted Solutions (1)

edwin_harpino
Active Contributor
0 Kudos

hi Nick,

internal table will persist between data packages.

we populate it in global area.

hope this helps.

Answers (4)

Answers (4)

udayabhanupattabhiram_cha
Active Contributor
0 Kudos

Hi Nick:

Try this code and test and see if its getting filled multiple times.

Also, you have no other way to do this piece of Code apart from these two ways, so you might as well stick with one of these two, whichever one is better.

If I find anything else, I will let you guys know.

PROGRAM UPDATE_ROUTINE.

$$ begin of global - insert your declaration only below this line -

  • TABLES: ...

TYPES: BEGIN OF wa_stru,

material LIKE /bic/azcopc_0500-material,

plant LIKE /bic/azcopc_0500-plant,

fiscper LIKE /bic/azcopc_0500-fiscper,

fiscvarnt LIKE /bic/azcopc_0500-fiscvarnt,

zadjvr LIKE /bic/azcopc_0500-/bic/zadjvr,

amountvr LIKE /bic/azcopc_0500-amountvr,

END OF wa_stru.

DATA: wa TYPE TABLE OF wa_stru WITH HEADER LINE.

  • data: wa type hashed table of wa_stru with unique key

  • material plant fiscper fiscvarnt

  • with header line.

select material

plant

fiscper

fiscvarnt

/bic/zadjvr

amountvr

into table wa

from /bic/azcopc_0500.

sort wa by material plant fiscper descending fiscvarnt.

$$ end of global - insert your declaration only before this line -

  • The follow definition is new in the BW3.x

TYPES:

BEGIN OF DATA_PACKAGE_STRUCTURE.

INCLUDE STRUCTURE /BIC/CS1_CO_PA2900010_DS.

TYPES:

RECNO LIKE sy-tabix,

END OF DATA_PACKAGE_STRUCTURE.

DATA:

DATA_PACKAGE TYPE STANDARD TABLE OF DATA_PACKAGE_STRUCTURE

WITH HEADER LINE

WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.

FORM startup

TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring

MONITOR_RECNO STRUCTURE RSMONITORS " monitoring with record n

DATA_PACKAGE STRUCTURE DATA_PACKAGE

USING RECORD_ALL LIKE SY-TABIX

SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS

CHANGING ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update

*

$$ begin of routine - insert your code only below this line -

  • fill the internal tables "MONITOR" and/or "MONITOR_RECNO",

  • to make monitor entries

BREAK-POINT. "Beginning of the Start Routine

BREAK-POINT. "End of the Start Routine

  • if abort is not equal zero, the update process will be canceled

ABORT = 0.

$$ end of routine - insert your code only before this line -

*

ENDFORM.

You are Srini, have a good weekend.

Ram Chamarthy.

udayabhanupattabhiram_cha
Active Contributor
0 Kudos

Hi Srini:

I agree with most of what you wrote. But, this info is different.

The data package is refreshed as soon as it finished the loop. But, global values will not be refreshed for each data package. That is why they you need do declare them before this line in the start routine.

$$ end of global - insert your declaration only before this line -

Ram Chamarthy

Former Member
0 Kudos

Here is the code:

PROGRAM UPDATE_ROUTINE.

$$ begin of global - insert your declaration only below this line -

  • TABLES: ...

TYPES: BEGIN OF wa_stru,

material LIKE /bic/azcopc_0500-material,

plant LIKE /bic/azcopc_0500-plant,

fiscper LIKE /bic/azcopc_0500-fiscper,

fiscvarnt LIKE /bic/azcopc_0500-fiscvarnt,

zadjvr LIKE /bic/azcopc_0500-/bic/zadjvr,

amountvr LIKE /bic/azcopc_0500-amountvr,

END OF wa_stru.

DATA: wa TYPE TABLE OF wa_stru WITH HEADER LINE.

  • data: wa type hashed table of wa_stru with unique key

  • material plant fiscper fiscvarnt

  • with header line.

$$ end of global - insert your declaration only before this line -

  • The follow definition is new in the BW3.x

TYPES:

BEGIN OF DATA_PACKAGE_STRUCTURE.

INCLUDE STRUCTURE /BIC/CS1_CO_PA2900010_DS.

TYPES:

RECNO LIKE sy-tabix,

END OF DATA_PACKAGE_STRUCTURE.

DATA:

DATA_PACKAGE TYPE STANDARD TABLE OF DATA_PACKAGE_STRUCTURE

WITH HEADER LINE

WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.

FORM startup

TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring

MONITOR_RECNO STRUCTURE RSMONITORS " monitoring with record n

DATA_PACKAGE STRUCTURE DATA_PACKAGE

USING RECORD_ALL LIKE SY-TABIX

SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS

CHANGING ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update

*

$$ begin of routine - insert your code only below this line -

  • fill the internal tables "MONITOR" and/or "MONITOR_RECNO",

  • to make monitor entries

BREAK-POINT. "Beginning of the Start Routine

if wa is initial. "load lookup table from /bic/azcopc_0500

select material

plant

fiscper

fiscvarnt

/bic/zadjvr

amountvr

into table wa

from /bic/azcopc_0500.

sort wa by material plant fiscper descending fiscvarnt.

endif.

BREAK-POINT. "End of the Start Routine

  • if abort is not equal zero, the update process will be canceled

ABORT = 0.

$$ end of routine - insert your code only before this line -

*

ENDFORM.

Former Member
0 Kudos

Hi Nick,

You code is fine. It wont add redundant data.

Here you are using <b>into</b>

select material

plant

fiscper

fiscvarnt

/bic/zadjvr

amountvr

<b>into</b> table wa

from /bic/azcopc_0500.

... INTO TABLE itab works like:

Works like ... INTO wa, except that the selected data is not placed in the internal table itab line by line, but in one single operation. In this case, SELECT does not introduce a processing loop, so there can be no ENDSELECT statement. <b>The old contents of itab are overwritten.</b> Fields of the internal table itab which are not filled are initialized based on their ABAP data type (see DATA).

Into overwrites the exising data in Internal table.

Hope it Helps

Srini

Former Member
0 Kudos

Hello Srini,

Okay so I can see now that the internal table is being overwritten.

But for each data package that arrives does it keep overwriting itself with the same data? I know it isn't a big deal but it seems a bit inefficient.

Does the statement in the code:

IF WA IS INITIAL.

Prevent the table from getting loaded up again when the 2nd data package arrives?

For example. The first datapackage arrives. When it arrives the start routine runs and loads up the internal table.

The second data package arrives. When it arrives the start routine runs, but this time the table doesn't get written to because of that line of code "IF WAS IS INITIAL"

That is the only piece I still need clarification on.

Thanks so much for your help!

Nick

Former Member
0 Kudos

Hi Nick,

As you said write if <internal table> initial then use select statement.

Check the data. I dont think it will contains the data for 2nd data packet, untill you are using the option in infopackage(processing)3rd option: PSA, subsequnt to data target(check box).

Please check this and correct me(if i am wrong).

Thank you.

Srini

Former Member
0 Kudos

Hello Srini,

In the infopackage the option I use for loading data is the first one "PSA then into data targets (package by package)"

I am not sure how I can really test this scenario since when I debug/simulate I can only load 1 data package, thus I don't get to run the start routine more then once.

It'd be nice if I could run the start routine more then once, becuase then I could see if the steps that load the internal table actually execute again when the second data package arrives, or if they don't execute because of the statement (If <internal table> is initial.)

I am guessing this statement (If <internal table> is initial.) prevents the internal table from overwriting itself with the same data as each data package arrives.

Keep in mind that the internal table is populated from data in a separate ODS.

Thanks again for following up, I hope the information I provided may help us figure out if this internal table gets reloaded with data from a separate ODS for each data package that arrives

Nick

Former Member
0 Kudos

Hi Nick,

Try to simulate from monitor for data packet 2 and see.

or just execute the entire data and check data target data againest data package2 data(from Monitor, PSA Data). It will give some Idea. If iternal table not filled, I think you are filling some more fields based on this data, those fields will be empty...

Try to spend some time on this for infopackage processing options: both(PSA then into data targets and PSA and subsequent to data target(3rd option).

Cheers

Srini

Former Member
0 Kudos

Hi Nick,

Have a look : Processing TAB in InfoPackage. and options.

http://help.sap.com/saphelp_erp2005/helpdata/en/4e/4a75b87fe211d4b2c50050da4c74dc/frameset.htm

Hope it Helps

Srini

udayabhanupattabhiram_cha
Active Contributor
0 Kudos

Hi Nick:

AHP is correct. Global data including global internal table will not be refreshed with each data package.

Only data packages are automatically refreshed, not global data.

But, make sure you declare the internal table in global declerations.

So, you are good to go.

Ram Chamarthy.

Former Member
0 Kudos

Hi All..

Routine info in start routine :

Start Routine in the Update Rules

Definition:

The start routine only has the parameters MONITOR, MONITOR_RECNO, DATA_PACKAGE, RECORD_ALL, SOURCE_SYSTEM, and ABORT. DATA_PACKAGE is the complete data package here. The start routine has no return value. Its purpose is to execute preliminary calculations and to store them in a global data structure. <b>You can access this structure or table in the other routines</b>.

1. Between $$ begin of global ... and $$ end of global ... you define global data declarations included in all the routines.

In this way, you can use subtotals in other routines or you can re-use the results of the first call when calling up the same routine again.

<b>Note:</b>

During serial loading (processing option PSA only) this globaldata remains as long as the process continues to exist. For this reason, there must be a REFRESH statement in internal tables. This is not necessary for parallel loading since an individual process is created for each data package.

If you define globally, you can access these tables or fields any where in the update rules, like any field wise routine. But it will get filled for each data packet. Correct me if i am wrong..!!

Srini

Former Member
0 Kudos

Hi Nick,

start routine in Update Rules is run once per data package.

So all the code in start routine will execute once for each data packet. For each data packet your internal table will be filled and get refreshed. There is no redundancy.

If you are getting any redundancy... paste your code, so i may help you.

Hope it Helps

Srini