<?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: Update TVARV variables... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-tvarv-variables/m-p/1216718#M135070</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;lt;i&amp;gt;&lt;/P&gt;&lt;P&gt;I was thinking, is there a way to update it through 'select' statements. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure what you mean here.   I guess you can do a direct database update using MODIFY or UPDATE statements, but direct db updates are frowned apond, hence the reason for the BDC code.  But I guess if you are allowed to do it via SM31, then why not directly update it, right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can update the table using MODIFY or UPDATE like normal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3a94358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3a94358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3ac8358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3ac8358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REgards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Mar 2006 23:25:33 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2006-03-13T23:25:33Z</dc:date>
    <item>
      <title>Update TVARV variables...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-tvarv-variables/m-p/1216715#M135067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would greatly appreciate it if someone could send me a sample program to update table TVARV with a variable for 'From' and 'To' date and time. I have already declared 4 parameters in TVARV.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i.e. User will enter 'From' and 'To' dates and time in parameters and TVARV table will be updated, and when report is run next time, the 'To' date/time will become 'From' date/time. In other words, it will take the latest value of the variables.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Eddie.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Mar 2006 22:12:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-tvarv-variables/m-p/1216715#M135067</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-13T22:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: Update TVARV variables...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-tvarv-variables/m-p/1216716#M135068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We actually use a BDC do update the table using SM31.  I have it encapsulated in a subroutine(form) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Send the variable name, the variable type(P or S) and the low and high.  The BDC code will take care of the rest.  It will handle Parameters and Select-options.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


************************************************************************
*      Form REUSE_BDC_SESSION
************************************************************************
form reuse_bdc_session using var_name
                             var_type
                             variable
                             variable_low
                             variable_high.

  perform bdc_dynpro      using 'SAPMSVMA' '0100'.
  perform bdc_field       using 'BDC_CURSOR'
                                'VIEWNAME'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=UPD'.
  perform bdc_field       using 'VIEWNAME'
                            'TVARV'.
  perform bdc_field       using 'VIMDYNFLDS-LTD_DTA_NO'
                                'X'.
  perform bdc_dynpro      using 'SAPMS38V' '1100'.
  perform bdc_field       using 'BDC_CURSOR'
                                '%#AUTOTEXT001'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=TOGGLE'.
  perform bdc_dynpro      using 'SAPMS38V' '1100'.
  perform bdc_field       using 'BDC_CURSOR'
                                '%#AUTOTEXT001'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=SINGLE'.
  perform bdc_dynpro      using 'SAPMS38V' '1001'.
  perform bdc_field       using 'BDC_CURSOR'
                                'TVARV-NAME'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=CHNG'.
  perform bdc_field       using 'TVARV-NAME'
                            var_name.
  if var_type = 'P'.
    perform bdc_field       using 'RB_TYPE_P'
                                  'X '.
    perform bdc_field       using 'RB_TYPE_S'
                                      ' '.
    perform bdc_dynpro      using 'SAPMS38V' '0600'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'PAR_VAL'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=USAV'.
    perform bdc_field       using 'PAR_VAL'
                                variable.
  endif.

  if var_type = 'S'.
    perform bdc_field       using 'RB_TYPE_P'
                                  ' '.
    perform bdc_field       using 'RB_TYPE_S'
                                  'X'.
    perform bdc_dynpro      using 'SAPMS38V' '0600'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'SEL_VAL-LOW'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=%015'.
    perform bdc_dynpro      using 'SAPLALDB' '3000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=INTL'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RSCSEL-SLOW_I(01)'.
    perform bdc_dynpro      using 'SAPLALDB' '3000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ACPT'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RSCSEL-IHIGH_I(01)'.
    perform bdc_field       using 'RSCSEL-ILOW_I(01)'
                              variable_low.
    perform bdc_field       using 'RSCSEL-IHIGH_I(01)'
                             variable_high.
    perform bdc_dynpro      using 'SAPMS38V' '0600'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'SEL_VAL-LOW'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=USAV'.
  endif.

  perform bdc_dynpro      using 'SAPMS38V' '1001'.
  perform bdc_field       using 'BDC_CURSOR'
                                'TVARV-NAME'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=RETN'.
  perform bdc_dynpro      using 'SAPMS38V' '1100'.
  perform bdc_field       using 'BDC_CURSOR'
                                '%#AUTOTEXT001'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=SAVE'.
  perform bdc_dynpro      using 'SAPMS38V' '1100'.
  perform bdc_field       using 'BDC_CURSOR'
                                '%#AUTOTEXT001'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=RETN'.
  perform bdc_dynpro      using 'SAPMSVMA' '0100'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/EBACK'.
  perform bdc_field       using 'BDC_CURSOR'
                                'VIEWNAME'.

  call transaction 'SM31' using  bdcdata
                          mode   mode
                          update 'S'.

  if sy-subrc = 0.
    write:/ i_tvarv-name, at 40 'Variable updated successfully'.
    case var_type.
      when 'P'.
        write:80 variable.
      when 'S'.
        write:80 variable_low, at 100 variable_high.
    endcase.

  else.
    write:/ i_tvarv-name, at 40 'Error occured during update process'.
  endif.

  commit work and wait.
  clear bdcdata. refresh bdcdata.

endform.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Rich Heilman&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Mar 2006 22:14:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-tvarv-variables/m-p/1216716#M135068</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-03-13T22:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Update TVARV variables...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-tvarv-variables/m-p/1216717#M135069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanx for the bdc code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was thinking, is there a way to update it through 'select' statements. I have something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parameters: p_matl like mara-mtart,&lt;/P&gt;&lt;P&gt;            beg_date like sy-datum,&lt;/P&gt;&lt;P&gt;            end_date like sy-datum,&lt;/P&gt;&lt;P&gt;            beg_time like sy-uzeit,&lt;/P&gt;&lt;P&gt;            end_time like sy-uzeit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: pt_cdhdr TYPE cdhdr_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT * FROM cdhdr APPENDING TABLE pt_cdhdr&lt;/P&gt;&lt;P&gt;                   WHERE objectclas  = 'material'&lt;/P&gt;&lt;P&gt;                   AND   username = sy-uname&lt;/P&gt;&lt;P&gt;                   AND (&lt;/P&gt;&lt;P&gt;                        (&lt;/P&gt;&lt;P&gt;                          udate =  beg_date&lt;/P&gt;&lt;P&gt;                          AND&lt;/P&gt;&lt;P&gt;                          utime &amp;gt;= beg_time&lt;/P&gt;&lt;P&gt;                         )&lt;/P&gt;&lt;P&gt;                         OR&lt;/P&gt;&lt;P&gt;                          udate &amp;gt;  beg_date&lt;/P&gt;&lt;P&gt;                        )&lt;/P&gt;&lt;P&gt;                   AND (&lt;/P&gt;&lt;P&gt;                        (&lt;/P&gt;&lt;P&gt;                          udate =  end_date&lt;/P&gt;&lt;P&gt;                          AND&lt;/P&gt;&lt;P&gt;                          utime &amp;lt;= end_time&lt;/P&gt;&lt;P&gt;                         )&lt;/P&gt;&lt;P&gt;                         OR&lt;/P&gt;&lt;P&gt;                          udate &amp;lt;  end_date&lt;/P&gt;&lt;P&gt;                        ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have already declared parameters for begin/end dates and times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Eddie.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Mar 2006 22:33:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-tvarv-variables/m-p/1216717#M135069</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-13T22:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Update TVARV variables...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-tvarv-variables/m-p/1216718#M135070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;lt;i&amp;gt;&lt;/P&gt;&lt;P&gt;I was thinking, is there a way to update it through 'select' statements. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure what you mean here.   I guess you can do a direct database update using MODIFY or UPDATE statements, but direct db updates are frowned apond, hence the reason for the BDC code.  But I guess if you are allowed to do it via SM31, then why not directly update it, right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can update the table using MODIFY or UPDATE like normal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3a94358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3a94358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3ac8358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3ac8358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REgards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Mar 2006 23:25:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-tvarv-variables/m-p/1216718#M135070</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-03-13T23:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Update TVARV variables...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-tvarv-variables/m-p/1216719#M135071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eddie,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pl check the following code &amp;amp; use whta is relevant for you..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*Lock TVARV rcord with ESVARV.
  CALL FUNCTION 'ENQUEUE_ESVARV'
       EXPORTING
            MODE_TVARV     = 'E'
            NAME           = VAR_NAME "name
            TYPE           = VAR_TYPE  " 'S' or 'P'
            _SCOPE         = '2'
       EXCEPTIONS
            FOREIGN_LOCK   = 1
            SYSTEM_FAILURE = 2
            OTHERS         = 3.

* Select from TVARV all the fields, as all of them are needed
  SELECT SINGLE * FROM TVARV WHERE NAME = VAR_NAME AND
                                   TYPE = VAR_TYPE .
  IF SY-SUBRC &amp;lt;&amp;gt; 0.
    FL_NO_RECORD_TVARV = 'X'.                             
*   RAISE RECORD_NOT_FOUND.               
  ENDIF.

* If variable option is Initial
  IF VAR_OPTION IS INITIAL.
    TVARV-OPTI = 'EQ'.
  ELSE.
    TVARV-OPTI = VAR_OPTION.
  ENDIF.

* If variable Sign is Initial
  IF VAR_SIGN IS INITIAL.
    TVARV-SIGN = 'I'.
  ELSE.
    TVARV-SIGN = VAR_SIGN.
  ENDIF.

  TVARV-LOW = LOW_VALUE.

  IF VAR_TYPE = 'S'.
    TVARV-HIGH = HIGH_VALUE.
  ENDIF.

* Update TVARV
  IF FL_NO_RECORD_TVARV = SPACE.               
     update TVARV.
     IF SY-SUBRC &amp;lt;&amp;gt; 0.
      RAISE UPDATE_FAILED.
    ENDIF.
  ENDIF.                                       
*Unlock TVARV rcord with ESVARV.
  CALL FUNCTION 'DEQUEUE_ESVARV'
       EXPORTING
            MODE_TVARV = 'E'
            NAME       = VAR_NAME
            TYPE       = VAR_TYPE
            _SCOPE     = '3'
            _SYNCHRON  = ' '.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suresh Datti&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Mar 2006 23:27:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-tvarv-variables/m-p/1216719#M135071</guid>
      <dc:creator>suresh_datti</dc:creator>
      <dc:date>2006-03-13T23:27:50Z</dc:date>
    </item>
  </channel>
</rss>

