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 capture the first execution of a report

Former Member
0 Kudos

Hi,

I am executing a report in background. The first time the report is executed I have to do a different processing. After the 1st execution I have to different processing.

Someone please tell me how to capture the 1st execution of a report. Is there a system variable ?

Appreciate your <removed by moderator> response.

Thanks,

Dikshitha G

Edited by: Thomas Zloch on May 12, 2011 11:36 AM

1 ACCEPTED SOLUTION

former_member184578
Active Contributor
0 Kudos

Hi.,

Create a Z table with one field count .

now in the first line of your report ., check the value of count by writing a select quest., if the value is initial(first time) do different processing. else do different processing. now in your report at last insert value to count.

hope this helps u.,

Thanks & regards

Kiran

9 REPLIES 9

Former Member
0 Kudos

there is way i know of to find that out during runtime.

Manually you could use TA STAD for that.

But since it seems to be a report of your own, why dont you set some variable to X in your first run. Preferably a TVARVC record.

you can maintain it as blank before first run, when it is blank assume it is first run, and during your first run set it as 'X' or whatever.

Next time you run it you get your TVARVC record again and see if it is 'X' then behave accodingly.

kesavadas_thekkillath
Active Contributor
0 Kudos

Hi,

Did you mean first time on a particular day ???

If so then check this example


TYPE-POOLS:abap.
TABLES indx.


DATA: indxkey TYPE indx-srtfd VALUE 'KEYVALUE'.

DATA:v_flag TYPE c.

indx-aedat = sy-datum.
indx-pgmid = sy-repid.

IMPORT v_flag FROM DATABASE indx(st) ID indxkey .
IF v_flag = abap_false.
  WRITE: 'Not executed today'.
  v_flag = abap_true.
  EXPORT v_flag TO DATABASE indx(st) ID indxkey.
ELSE.
  WRITE: 'Executed today'.
ENDIF.

former_member184578
Active Contributor
0 Kudos

Hi.,

Create a Z table with one field count .

now in the first line of your report ., check the value of count by writing a select quest., if the value is initial(first time) do different processing. else do different processing. now in your report at last insert value to count.

hope this helps u.,

Thanks & regards

Kiran

0 Kudos

Hi,

I think I'll go with what Kiran says. Thanks all of you !

Regards,

Dikshitha G

0 Kudos

Are you going to create a Z table for this ???? ... Is there nobody to advice you in your firm ???

0 Kudos

Well Kiran proposes quite the same as me, i aint got no problem with that.

But it is really not needed to make a z-table for that. you can make use of an enrty in TVARVC.

That table is exactly forsuch purposes where you need to store just ONE field and dont want to make a z-table for that.

But yeah what you are trying to do will work.

0 Kudos

Are you going to create a Z table for this ???? ... Is there nobody to advice you in your firm ???

Hello Keshav,

A couple of years ago i would have recommended using the INDX table, but it has got it's demerits.

Maintenance of Z-table is easier than the INDX table. Say there is some error in the program & you want to override the flag. Will it be easier to do so in the INDX table or via SM30 for the Z-Table?

As a matter-of-fact i will recommend using the solution provided by Florian the TVARVC technique.

1. Create a parameter(specific to your program) & transport it.(See the trxn STVARV)

2. In your program check the value of this param & set it accordingly.

Using TVARVC you will 2 birds with one stone:

1. You don't have to create a custom table.

2. Easy maintenance via STVARV trxn.

Hope you get the point!

Cheers,

Suhas

PS: In our system we have a Z-table designed specifically for this particular purpose. All the programs having this kind of requirement refer to this table.

0 Kudos

Hi Suhas,

TVARVC did not come to my mind first. Actually creating table variables using TVARVC is a good approach . I am not advicing OP to use the INDX table as well ( instead he should have used TVARVC ) but i donot support creating a Z table when there is a facility already available to do this.

As you said when there is multiple programs then ok ( ztable can be used ) . Here i think its only for one program.

Anyways it depends upon OP's interest :).

Keshav

0 Kudos

Ok. I'm going to use the TVARVC table. Thank you all for your response.

Regards,

Dikshitha G