<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Changing Variant Parameters Programmatically in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223777#M477683</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you save a variant, in SE38, on the selection, by pressing CTRL+S.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you have to tick the checkbox, which is called "Save field without values". In this case the variant will not overwrite this field, and the field will contain the values, you entered from the program's INITIALIZATION event.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Tamá&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 May 2007 14:00:39 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-05-11T14:00:39Z</dc:date>
    <item>
      <title>Changing Variant Parameters Programmatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223773#M477679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys/Dolls&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've developed a program that has a user selection date range on it and I have saved this program as a variant. I submit this program has a batch job on a monthly basis but need to change the dates on the variant each month to be the start and end date of the previous month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe I need to use the following Function Modules; please correct me if I am barking up the wrong tree. Unfortunately I have absolutely no idea how to use them within ABAP. Do I need anything else to change my variant parameters?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;RS_VARIANT_CONTENTS&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;RS_CHANGE_CREATED_VARIANT&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anybody have a very small snippet of code that will allow me to change the date of the variant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Raj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2007 10:15:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223773#M477679</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-11T10:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Variant Parameters Programmatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223774#M477680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;u can use the option of 'Dynamic Date Calculation' of the Variant.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2007 10:23:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223774#M477680</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-11T10:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Variant Parameters Programmatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223775#M477681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;follow these steps&lt;/P&gt;&lt;P&gt;1.click on the 'Save' button of the seleciton screen&lt;/P&gt;&lt;P&gt;2. Find &amp;lt;b&amp;gt;Objects for selection screen&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;    select ur variable in the selection screen&lt;/P&gt;&lt;P&gt;3.scroll to the column 'Selection Variables'    &lt;/P&gt;&lt;P&gt;   select F4 help, choose the value 'D'&lt;/P&gt;&lt;P&gt;4.now scroll to the column 'Name of the variable'&lt;/P&gt;&lt;P&gt;   click on F4 and select the value according to ur requirement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2007 10:27:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223775#M477681</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-11T10:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Variant Parameters Programmatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223776#M477682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok Guys/Dolls&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've managed to hack a solution and have posted this for reference.&lt;/P&gt;&lt;P&gt;The code is as follows:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

FORM change_variant .

  DATA: h_rc LIKE sy-subrc.
  DATA: ival TYPE STANDARD TABLE OF rsparams WITH HEADER LINE.
  DATA: ls_variantdesc LIKE varid.

*1st check to see that the variant exists.
  CALL FUNCTION 'RS_VARIANT_EXISTS'
    EXPORTING
      report              = sy-repid
      variant             = variant_name
    IMPORTING
      r_c                 = h_rc
    EXCEPTIONS
      not_authorized      = 01
      no_report           = 02
      report_not_existent = 03
      report_not_supplied = 04.

* If variant exists then obtain the contents of the variants.
  IF h_rc = 0.

    CALL FUNCTION 'RS_VARIANT_CONTENTS'
      EXPORTING
        report                      = sy-repid
        variant                     = variant_name
        move_or_write               = 'W'
*   NO_IMPORT                   = ' '
*   EXECUTE_DIRECT              = ' '
* IMPORTING
*   SP                          =
      TABLES
*   L_PARAMS                    =
*   L_PARAMS_NONV               =
*   L_SELOP                     =
*   L_SELOP_NONV                =
        valutab                     = ival
*   OBJECTS                     =
*   FREE_SELECTIONS_DESC        =
*   FREE_SELECTIONS_VALUE       =
* EXCEPTIONS
*   VARIANT_NON_EXISTENT        = 1
*   VARIANT_OBSOLETE            = 2
*   REPORT_NOT_EXISTENT         = 3
*   OTHERS                      = 4
              .
    IF sy-subrc = 0.

*     Change value of the variants to what you want it to be.
      LOOP AT ival WHERE selname EQ 'PNPBEGDA' OR
                         selname EQ 'PNPBEGPS' OR
                         selname EQ 'PNPENDDA' OR
                         selname EQ 'PNPENDPS'.
        ival-low = ''.
        MODIFY ival.
      ENDLOOP.

      LOOP AT ival WHERE selname EQ 'P_CNGDAT'.
        ival-low  = '20000201'.
        ival-high = '20001231'.
        MODIFY ival.
      ENDLOOP.

*   Now re-save the variant with the appropriate changes.

*     Clear and re-populate the variant description.
      CLEAR ls_variantdesc.
      ls_variantdesc-aename   = sy-mandt.
      ls_variantdesc-aename   = sy-uname.
      ls_variantdesc-aedat    = sy-datum.
      ls_variantdesc-aetime   = sy-uzeit.


      CALL FUNCTION 'RS_CHANGE_CREATED_VARIANT'
        EXPORTING
          curr_report                     = sy-repid
          curr_variant                    = variant_name
          vari_desc                       = ls_variantdesc
*   ONLY_CONTENTS                   =
        TABLES
          vari_contents                   = ival
*   VARI_TEXT                       =
*   VARI_SEL_DESC                   =
*   OBJECTS                         =
       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.

      IF sy-subrc = 0.
        PERFORM set_pnp_default.
      ENDIF.

    ENDIF.

  ENDIF.

ENDFORM.                    " change_variant


FORM set_pnp_default.

* The following 2 statement will set Today as the default on the PNP
* selection and also move the cursor to that field.
* IMPORTANT NOTE - you must have 'PNPTIMR1' in capitals otherwise it
* doesn't work.
  pnptimed = 'D'.
  SET CURSOR FIELD 'PNPTIMR1'.

ENDFORM.                    " set_pnp_default


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2007 13:39:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223776#M477682</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-11T13:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Variant Parameters Programmatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223777#M477683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you save a variant, in SE38, on the selection, by pressing CTRL+S.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you have to tick the checkbox, which is called "Save field without values". In this case the variant will not overwrite this field, and the field will contain the values, you entered from the program's INITIALIZATION event.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Tamá&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2007 14:00:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223777#M477683</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-11T14:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Variant Parameters Programmatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223778#M477684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See solution posted by myself on 11.05.07&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2007 08:59:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/changing-variant-parameters-programmatically/m-p/2223778#M477684</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-14T08:59:37Z</dc:date>
    </item>
  </channel>
</rss>

