05-23-2011 8:22 AM
Hi Gurus,
We developed one report. In that report we have creation date field as select-option in the selection screen. But when we are creating variant there is no option for the default values which are coming from the report.
Ex: Creation date 01.05.2011 to 23.05.2011 (i.e. sy-datum).
We have n number of POs in our production system. So we are taking POs created after May 1st 2011(creation date-low it should be constant) and creation date-high should be sy-datum.
But when I am saving it as varaint, I am not able to get the exact dates in the field.
1. Is it necessary to run a report with varaint in background?
2. If variant is mandatory to run report in background, then how to get creation date-low as 01.05.2011 and date-high as sy-datum.
Kindly help me to sort out the problem facing.
Thanks,
Kiran.
05-23-2011 8:35 AM
You always need a variant for background execution. You can do two things in the variant:
- choose option "save field without values" in the variant attributes for the selection field where the default values should remain unchanged
- try choosing a dynamic date calculation for the field, e.g. "current period"
Thomas
05-23-2011 8:43 AM
Hi ACC10583516 ;
if you cant use variant in background process, You can use bellow code in your program.
SELECT-OPTIONS : S_DATE FOR MKPF-BLDAT.
INITIALIZATION.
concatenate SY-DATUM+0(4) SY-DATUM+4(2) '01' into S_DATE-LOW.
S_DATE-HIGH = SY-DATUM.
APPEND S_DATE.
Best regards.
05-23-2011 11:10 AM
Hi,
You can call your report like this
SUBMIT report_name AND RETURN
WITH p_dats = your value
USER v_user
VIA JOB v_jobname
NUMBER v_jobcnt
USING SELECTION-SET v_variant.
where v_variant is a dummy variant.
Do your date calculations in the program and pass them as parameter while submitting the job.
05-23-2011 2:43 PM
You must use a variant (else system will create and use a variant with a name &0000000000001....) When recording your variant, go to "Variant Attributes" there you can check the "Save field without values" box and/or select a "Selection variable" and then a "Name of variable" value. If you check the "Save field without values" box, then fill the value in the [INITIALIZATION|http://help.sap.com/abapdocu_70/en/ABAPINITIALIZATION.htm] part of your report. (Check [Variant Attributes|http://help.sap.com/saphelp_NW70EHP1core/helpdata/en/c0/98038ce58611d194cc00a0c94260a5/content.htm])
Some remarks,
1-Could you select from constants 01.05.2011 to 31.12.9999 (ddmmyyyy) as no order should have a creation in the future (if it is a system creation date and not a user-input one) ?
2-In some months or years the selection will be very large, no ?
Regards,
Raymond
05-23-2011 3:21 PM
1. Is it necessary to run a report with varaint in background?
No, not at all. But since you declared a selection screen, it is required as Thomas and Raymond have already told you. Since you are hardcoding everything you could easily remove the selection-screen, but then of course you'd lose control/flexibility. You can also use TVARVC in addition to what Thomas & Raymond suggested.
12-11-2012 6:35 AM
Brad Bohn wrote:
1. Is it necessary to run a report with varaint in background?
No, not at all. But since you declared a selection screen, it is required as Thomas and Raymond have already told you. Since you are hardcoding everything you could easily remove the selection-screen, but then of course you'd lose control/flexibility. You can also use TVARVC in addition to what Thomas & Raymond suggested.
I would like to confirm that a variant is NOT mandatory for background processing.
When you define a background job (T-code : SM36), you can just leave the "variant" field blank. If your report contains a selection screen, you can leave the "variant" field blank. If your report contains NO selection screen, you can leave the "variant" field blank, too.
I tested both scenarios in SAP, and SAP triggered my background job on time. My version is SAP ECC 6.0, (SAP_ABA is release 700 update 12 and SAP_BASIS is release 700 update 25).