Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Creating Variants programatically

Dear Developers,

I am new to sap and need some help, so I am writing in this forum to seek help with regard to creating variants programatically.

I am creating variants programatically by using the function module 'RS_CREATE_VARIANT'. The variants are getting created and it is fine. But some of the variants require dynamic date calculations, how do i go about doing it.

for the present the low and high periods of date parameter are hard coded values but i want the date to dynamically change and the range to be set dynamically to 6 days starting from current date - 3, to current date + 3. So, how do i go about doing this.

Looking forward to solutions from all the experienced developers. Your quick help will highly be appreciated. Thank you

Regards,

kartik

Former Member replied

Hi Karthik,

I am not sure about the direct FM to create a variant with dynamic values, but you can use the FM "RS_VARIANT_VALUE_SAVE" to set the dynamic attributes to the variant parameters for an existing variant.May be you can create a normal variant and then change it to dynamic value. Please refer the below code to change the variant to dynamic values. To get an idea about tables parameters passed, call the FM "RS_VARIANT_FETCH" ( function - GET ) with a varaint which is already set to dynamic date.

ls_RSVARKEY-report = sy-repid.
ls_RSVARKEY-variant = 'VARIANT'.

CALL FUNCTION 'RS_VARIANT_VALUE_SAVE'
  EXPORTING
    rkey                = ls_RSVARKEY
    STATUS              = 'INT'
  tables
    selctab             = lt_selctab
    P_VARI              = lt_vari
    P_VARIVDAT          = lt_varidat
    P_VARISCREENS       = lt_variscreens
  EXCEPTIONS
   NOT_EXECUTED        = 1
   OTHERS              = 2.

Regards,

Suman Jagu

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question