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 pass variant in background job.

Former Member
0 Kudos

Hi Experts,

i have one program which is running inbackground job with variant.but my variant value is not capturing in background job.

can anybody some inputs please.

Thanks in Advance,

venkat

5 REPLIES 5

Former Member
0 Kudos

Hi venkat

Are you tyring to schedule the program manually by just giving the selection screen parameters or is there a code that does it for u?

former_member181995
Active Contributor
0 Kudos

Just refer:

Former Member
0 Kudos

hi venkat,

Variants are the only method for passing values to a report program in a background job. Therefore, when you run a program in the background, you must use a variant (or SUBMIT... VIA JOB). To avoid you having to create a new variant each time you run the report, ABAP contains a mechanism allowing you to pass variable values to variants. See Variable Values in Variants.

To ensure that an executable program is always started using a variant, you can specify in the program attributes that the program may only be started in this way.

Features

· Creation of variants

· Display, change, copy, print, and delete variants

· Use and definition of variables in variants

u2013 Variable date calculation

u2013 User-specific fixed values.also refer the link below:

http://help.sap.com/saphelp_nw70/helpdata/EN/c0/98037ae58611d194cc00a0c94260a5/content.htm

u2013 Fixed values in table TVARVC

Former Member
0 Kudos

HI I hope this should help for u.

suppose u r using 'zxxxxx' program. U WANT TO RUN THE PROGRAM 'ZYYYYY' using backgrounjon and using varint of 'ZXXXXXX'.

so create a varient for the program 'zxxxxx'.

that varient updated in the database table 'VARID'. by using select statement get the varient.

SELECT VARIANT

INTO TABLE IT_VAR

FROM VARID

WHERE REPORT = 'zxxxxxxx'.

Then take one varient from the table it_var.

using this statement. "zzz is the background job name'

EXPORT IT_VAR-VARIANT IT_VAR-BUKRS TO DATABASE INDX(HK) ID 'ZZZ'.

then use the function modules.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

  • DELANFREP = ' '

  • JOBGROUP = ' '

JOBNAME = GEP

  • SDLSTRTDT = NO_DATE

  • SDLSTRTTM = NO_TIME

IMPORTING

JOBCOUNT = GEPCOUNT

EXCEPTIONS

CANT_CREATE_JOB = 1

INVALID_JOB_DATA = 2

JOBNAME_MISSING = 3

OTHERS = 4.

  • submit the ABAP ZYYYYYY

CALL FUNCTION 'JOB_SUBMIT'

EXPORTING

  • ARCPARAMS = ' '

AUTHCKNAM = SY-UNAME

  • COMMANDNAME = ' '

  • OPERATINGSYSTEM = ' '

  • EXTPGM_NAME = ' '

  • EXTPGM_PARAM = ' '

  • EXTPGM_SET_TRACE_ON = ' '

  • EXTPGM_STDERR_IN_JOBLOG = 'X'

  • EXTPGM_STDOUT_IN_JOBLOG = 'X'

  • EXTPGM_SYSTEM = ' '

  • EXTPGM_WAIT_FOR_TERMINATION = 'X'

JOBCOUNT = GEPCOUNT

JOBNAME = GEP

  • LANGUAGE = SY-LANGU

  • PRIPARAMS = ' '

REPORT = 'ZYYYYYY'

  • variant = ' '

  • IMPORTING

  • step_number =

EXCEPTIONS

BAD_PRIPARAMS = 1

BAD_XPGFLAGS = 2

INVALID_JOBDATA = 3

JOBNAME_MISSING = 4

JOB_NOTEX = 5

JOB_SUBMIT_FAILED = 6

LOCK_FAILED = 7

PROGRAM_MISSING = 8

PROG_ABAP_AND_EXTPG_SET = 9

OTHERS = 10.

  • close the background job

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

  • AT_OPMODE = ' '

  • AT_OPMODE_PERIODIC = ' '

  • CALENDAR_ID = ' '

  • EVENT_ID = ' '

  • EVENT_PARAM = ' '

  • EVENT_PERIODIC = ' '

JOBCOUNT = GEPCOUNT

JOBNAME = GEP

  • LASTSTRTDT = NO_DATE

  • LASTSTRTTM = NO_TIME

  • PRDDAYS = 0

  • PRDHOURS = 0

  • PRDMINS = 0

  • PRDMONTHS = 0

  • PRDWEEKS = 0

  • PREDJOB_CHECKSTAT = ' '

  • PRED_JOBCOUNT = ' '

  • PRED_JOBNAME = ' '

  • SDLSTRTDT = NO_DATE

  • SDLSTRTTM = NO_TIME

  • STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS

STRTIMMED = 'X'

  • TARGETSYSTEM = ' '

  • START_ON_WORKDAY_NOT_BEFORE = SY-DATUM

  • START_ON_WORKDAY_NR = 0

  • WORKDAY_COUNT_DIRECTION = 0

  • RECIPIENT_OBJ =

  • IMPORTING

  • JOB_WAS_RELEASED =

EXCEPTIONS

CANT_START_IMMEDIATE = 1

INVALID_STARTDATE = 2

JOBNAME_MISSING = 3

JOB_CLOSE_FAILED = 4

JOB_NOSTEPS = 5

JOB_NOTEX = 6

LOCK_FAILED = 7

OTHERS = 8.

IF SY-SUBRC = 0.

MESSAGE I999 WITH TEXT-008 TEXT-009 TEXT-010.

ENDIF.

I hope this will help for u. please give me points if it is useful for u.

Regards

Srini.N

Former Member
0 Kudos

Hi Venkat ,

If you want to schedule the same program in the background job in that you can call the same variant which you have deifned in the program . For that if you want to schedule the program then you goto to Transaction Code SM36 .

There you will find the Job Name : Difine any job name of your own .

Job Class as C.

Then in the Top you Click on the Step

There in the Selection of Abap Program : Mention your program name .

Then in the Variant you can specify your own variant that has been deifned in the program.

Then save the Job .

The program will be automatically run at the time mentioned .

with the variant which you have defined .

I hope this will solve your program

Regards

Shankar