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: 

dynamically change a variant

Former Member
0 Kudos

We've developed a program with ONLY one input field: date.

Because we have to run this program against too many discrete dates, so it is too hard to create all variants before hand.

Is there a way to do this:

1) at SM37, run a pre-defined variant for this program;

2) after above run is done, select the job, select "change",

3) change the variant name (e.g. from 20110101 to 20110102) ,

4) We hope above name change can automatically create a variant with a date "20110102" .

Is there any way to make step 4) happen? In other word, can the variant content be changed by

changing the variant's name?

This will save us tons of time. Becasue if we pre-define thousands of varaints

1) it is time consuming to create them;

2) even looking for the right variant to run at SM37 will be very hard -- since the list is too long;

3) very easy to make mistake since the list is too long.

Therefore we want above improvement very much.

Thanks a lot!

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

Hi Helen,

you ma create a small trigger program to [submit the program several times as JOB steps..|http://help.sap.com/abapdocu_70/en/ABAPSUBMIT_VIA_JOB.htm].

First use

FUNCTION 'JOB_OPEN'

Then, in a loop,

SUBMIT submitable TO SAP-SPOOL
                    SPOOL PARAMETERS print_parameters
                    WITHOUT SPOOL DYNPRO
                    VIA JOB name NUMBER number
                    WITH date_parameter = date_value
                    AND RETURN.

and finally

CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount             = number
        jobname              = name
        strtimmed            = 'X'

You can use [Function Module GET_PRINT_PARAMETERS|http://help.sap.com/saphelp_nw70/helpdata/en/9f/dba56d35c111d1829f0000e829fbfe/content.htm] to determine SPOOL PARAMETERS value.

Regards,

Clemens

5 REPLIES 5

former_member235395
Contributor
0 Kudos

Helen,

Your need to use a dynamic variant and run your program using SM36 transaction. this way will allow you run program on date indicated.

Regards,

Former Member
0 Kudos

Hi,

create the dynamic variant and provide this variant name when you create back ground using SM36.

For creating Dynamic variant please go through below link

<<link removed, points unassigned>>

Hope this will help you

Regards,

Kiran

Edited by: kishan P on May 30, 2011 11:54 AM

Clemenss
Active Contributor
0 Kudos

Hi Helen,

you ma create a small trigger program to [submit the program several times as JOB steps..|http://help.sap.com/abapdocu_70/en/ABAPSUBMIT_VIA_JOB.htm].

First use

FUNCTION 'JOB_OPEN'

Then, in a loop,

SUBMIT submitable TO SAP-SPOOL
                    SPOOL PARAMETERS print_parameters
                    WITHOUT SPOOL DYNPRO
                    VIA JOB name NUMBER number
                    WITH date_parameter = date_value
                    AND RETURN.

and finally

CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount             = number
        jobname              = name
        strtimmed            = 'X'

You can use [Function Module GET_PRINT_PARAMETERS|http://help.sap.com/saphelp_nw70/helpdata/en/9f/dba56d35c111d1829f0000e829fbfe/content.htm] to determine SPOOL PARAMETERS value.

Regards,

Clemens

Former Member
0 Kudos

Thanks to all!!

Kiran:

Your link is great.

However, my goal is to by changing the variant's name TO set the date field = "variant name" automatically

at SM37.

For example:

I have a finished job.

1) I copy this finished job to a new job;

2) change this new job's variant name to a new date (e.g. 20110303)

3) then automatically the date field of above variant will be set to 20110303.

4) save job

I want to be able to do this without coding.

I appreciate your kindness.

0 Kudos

Hi Helen,

that's impossible to setup a parameter with the variant name without coding. Moreover, it does not really make sense. Maybe you should explain more about what is your real requirement. Something that would maybe fit your requirement is to use variant variables (for example, one variant where your date parameters equals "current date"). I give you the documentation link so that you can see the possibilities : http://help.sap.com/saphelp_nw70/helpdata/en/c0/980398e58611d194cc00a0c94260a5/frameset.htm

BR

Sandra