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: 

Variant Creation for Background mode

Former Member
0 Kudos

hi

I am trying to create variants which will run the background jobs for CFM1 transaction with materials having 6000 records every time.

Can you tell me how to create variants for a particular transaction A using some other program B.

if I have 24000 records I want 4 different variants with 6000 records each for CFM1

All helpful answers will be rewarded

5 REPLIES 5

Azeemquadri
Contributor
0 Kudos

Try submit prog a using selection sets of program b.

see different variations of submit for clarity.

0 Kudos

I want this in the background mode not in foreground mode

Former Member
0 Kudos

Hi

Check these function modules

RS_CREATE_VARIANT_RFC to create the variants. create a program to call this function module as we can;t call function modules in background

BAPI_XBP_JOB_OPEN To create the background Job

BAPI_XBP_JOB_ADD_ABAP_STEP Add the report name to the background job

BAPI_XBP_JOB_START_IMMEDIATELY To start the job immidiately

Hope this helps

Award if it helps

Krishna

Former Member
0 Kudos

hi ,

you can categorize ur data for putting into different variants and create 4 different variant names. use the fm 'RS_CREATE_VARIANT' for creating variants in ur program B. use the following code in ur program..

DATA : ls_variantdesc TYPE varid.

DATA : lt_varianttext TYPE TABLE OF varit ,

wa_varianttext TYPE varit.

DATA : tt_reportparam TYPE TABLE OF rsparams,

wa_reportparam TYPE rsparams.

DATA: jobcnt TYPE tbtcjob-jobcount,

jobnam TYPE tbtcjob-jobname VALUE 'ZMIGO_RESERVE105'.

*Variant parameters

wa_reportparam-selname = 'S_WERKS'.

wa_reportparam-kind = 'P'.

wa_reportparam-low = mseg_wa-werks.

APPEND wa_reportparam TO tt_reportparam.

wa_reportparam-selname = 'S_MATNR'.

wa_reportparam-kind = 'P'.

wa_reportparam-low = mseg_wa-matnr.

APPEND wa_reportparam TO tt_reportparam.

wa_reportparam-selname = 'S_BWTAR'.

wa_reportparam-kind = 'P'.

wa_reportparam-low = mseg_wa-bwtar.

APPEND wa_reportparam TO tt_reportparam.

wa_reportparam-selname = 'S_ERFMG'.

wa_reportparam-kind = 'P'.

wa_reportparam-low = mseg_wa-erfmg.

APPEND wa_reportparam TO tt_reportparam.

wa_reportparam-selname = 'S_LGORT'.

wa_reportparam-kind = 'P'.

wa_reportparam-low = mseg_wa-lgort.

APPEND wa_reportparam TO tt_reportparam.

wa_reportparam-selname = 'S_WEMPF'.

wa_reportparam-kind = 'P'.

wa_reportparam-low = mseg_wa-lfbnr.

APPEND wa_reportparam TO tt_reportparam.

wa_reportparam-selname = 'S_BDTER'.

wa_reportparam-kind = 'P'.

wa_reportparam-low = sy-datum.

APPEND wa_reportparam TO tt_reportparam.

CLEAR ls_variantdesc.

ls_variantdesc-mandt = sy-mandt.

ls_variantdesc-report = 'ZMIGO_RESERVE105'.

ls_variantdesc-variant = 'VARIANT'.

ls_variantdesc-ename = sy-uname.

ls_variantdesc-edat = sy-datum.

ls_variantdesc-etime = sy-uzeit.

REFRESH lt_varianttext.

CLEAR wa_varianttext.

wa_varianttext-mandt = sy-mandt.

wa_varianttext-langu = sy-langu.

wa_varianttext-report = 'ZMIGO_RESERVE105'.

wa_varianttext-variant = 'VARIANT'.

APPEND wa_varianttext TO lt_varianttext.

*Create Variant

CALL FUNCTION 'RS_CREATE_VARIANT'

EXPORTING

curr_report = 'ZMIGO_RESERVE105'

curr_variant = 'VARIANT'

vari_desc = ls_variantdesc

TABLES

vari_contents = tt_reportparam

vari_text = lt_varianttext

EXCEPTIONS

illegal_report_or_variant = 1

illegal_variantname = 2

not_authorized = 3

not_executed = 4

report_not_existent = 5

report_not_supplied = 6

variant_exists = 7

variant_locked = 8

OTHERS = 9.

IF sy-subrc EQ 7.

  • If variant with same name already exists, change variant

CALL FUNCTION 'RS_CHANGE_CREATED_VARIANT'

EXPORTING

curr_report = 'ZMIGO_RESERVE105'

curr_variant = 'VARIANT'

vari_desc = ls_variantdesc

TABLES

vari_contents = tt_reportparam

EXCEPTIONS

illegal_report_or_variant = 1

illegal_variantname = 2

not_authorized = 3

not_executed = 4

report_not_existent = 5

report_not_supplied = 6

variant_doesnt_exist = 7

variant_locked = 8

selections_no_match = 9

OTHERS = 10.

ELSEIF sy-subrc NE 0.

MESSAGE s999(ymigo) WITH 'Cannot create/change variant for'

sy-uname.

ENDIF.

*Schedule background job

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = jobnam

sdlstrtdt = sy-datum

sdlstrttm = sy-uzeit

IMPORTING

jobcount = jobcnt.

CALL FUNCTION 'JOB_SUBMIT'

EXPORTING

authcknam = sy-uname

jobcount = jobcnt

jobname = jobnam

report = 'ZMIGO_RESERVE105'

variant = 'VARIANT'.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = jobcnt

jobname = jobnam

strtimmed = 'X'.

COMMIT WORK AND WAIT.

for job name, u can give your transactions program name.

Former Member
0 Kudos

hI,

1. What u can do list.

Get all the variant of the standard report and

data: variant(14).

variant = 'VARIANT1'. " Based on ur condition change the value to the variable

SUBMIT REPORT01

VIA SELECTION-SCREEN

USING SELECTION-SET VARIANT "Check here

USING SELECTION-SETS OF PROGRAM 'REPORT00'

AND RETURN.

2 .Use the fm: RS_VARIANT_CONTENTS to get the values of the different values in the screen.

move those values to screen fields in the INITIALIZATION event

<b>*Reward points</b>

Regards