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: 

Batch job variant

Former Member
0 Kudos

Hi All,

we have defined a batch job that runs at the end of every month. i.e before 24 hrs on 30th of evry month. The batch job creates invoices for the period from 1st -30th of every month.

In the variant,we have defined the date as variable and selected the option" last day of month". I think this option means that the date range is 1st onwards till 30th of the mothh.

now for example we want to create invoices for the monh of june. so as scheduled, the batch job will run on 30th June before 24 hrs . But for any reason the batch job stops running due to any dump etc and after anaylsing the problem,we run the batch job again but let's say at 00.25 hrs (1st July), then the date selected for the batch re run is 1st july--1st july and the date settings of 1st june to 30th june is lost and so none of the invoices for the month of june are created.

Kindly advice how to solve this date problem so that even if the batch job fails and the job is run again on the next day (1st day of july), then the date in the variant shud consider the last month dates (i.e from 1st till 30th jun)

regds

7 REPLIES 7

mukundkansara
Participant
0 Kudos

Hi,

For that you have to write code which fill up date range automatically. No need to write date in variant it will done by code and have to keep check if sy-datum is between 1 - 28 then consider get previous month last date.

E.G.

data: v_date like sy-datum,

v_mon(2) type c.

s_datum-sign = 'I'

s_datum-option = 'BT'.

If sy-datum+4(2) < '30'.

v_mon = sy-datum+4(2).

same do for year if month is 01.

v_mon = v_mon - 1.

concatenate sy-datum(4) '1' v_mon into sy-datum.

endif.

concatenate '1' sy-datum(6) into v_date

s_date-low = v_date

s_date-high = sy-datum

append s_date.

This is just exaple u have make changes as per your requirment

0 Kudos

Hi Mukund,

thanks for your reply.Actaully Iam an SD consultant. I need to know where to do the coding.

For example if the the Batch job name is A and it calls program zxy. Then are you saying to do the coding in zxy with no date in the variant of job zxy ??

regards

0 Kudos

Salai's reply is correct, if your process looks at the complete previous month, then it must be scheduled at the beginning of the following month. Then there is no problem with delayed execution and variant values.

It's not directly ABAP related anyway, so please properly close this thread now.

Thomas

0 Kudos

Hi,

You are right that is what i mean. But you can also follow Salai's reply. But it will work for few hours. and if you make changes to code then you dont need to add date in variant, program will automatically consider it. Now you decide which one is better option.

0 Kudos

>

then you dont need to add date in variant, program will automatically consider it. Now you decide which one is better option.

Now that's incorrect!!

A job scheduled month-end -in the way Salai advised- need never be adjusted: it reads the factory-calendar, you know? As for variants - like here in report SDBILLDL - you can use date-variables in variants ... - again, no adjustment necessary!

former_member212002
Active Contributor
0 Kudos

As you are not getting dump any more. Then go for a temporary variant for the required month like.



BEGDA = First day of the previous month.
ENDDA = Last day of the previous month.

After the job is over , move back to your original variant.

Regards

Mishra

0 Kudos

You should schedule the job on the first day of everymonth at 00:30 am and set the date in the variant to "last date of previous month"