<?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 Dynamic Variable Declarations in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692745#M1577086</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In a program I'm writing we are consuming webservices from another server.  There are two webservices, one on a DEV server, and another on a PRD server.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'm wondering is if there is a way I can use the same variable name, but change it's TYPE based on if the program is being used in the DEV or PRD system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pseudo-example&lt;/P&gt;&lt;P&gt;if sy-sysid = 'DEV'&lt;/P&gt;&lt;P&gt;     data: my_webservice type ref to Z_DEV_WS_CLASS&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;     data: my_webservice type ref to Z_PRD_WS_CLASS&lt;/P&gt;&lt;P&gt;endif&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do know I could use different variable names, but with all the structures and such that go with them, I was wondering if this could be done or something else to make it easier to read instead of huge if thens where i'm only changing variable names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Curtis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Feb 2011 15:38:17 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-02-10T15:38:17Z</dc:date>
    <item>
      <title>Dynamic Variable Declarations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692745#M1577086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In a program I'm writing we are consuming webservices from another server.  There are two webservices, one on a DEV server, and another on a PRD server.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'm wondering is if there is a way I can use the same variable name, but change it's TYPE based on if the program is being used in the DEV or PRD system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pseudo-example&lt;/P&gt;&lt;P&gt;if sy-sysid = 'DEV'&lt;/P&gt;&lt;P&gt;     data: my_webservice type ref to Z_DEV_WS_CLASS&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;     data: my_webservice type ref to Z_PRD_WS_CLASS&lt;/P&gt;&lt;P&gt;endif&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do know I could use different variable names, but with all the structures and such that go with them, I was wondering if this could be done or something else to make it easier to read instead of huge if thens where i'm only changing variable names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Curtis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Feb 2011 15:38:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692745#M1577086</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-10T15:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Variable Declarations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692746#M1577087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Curtis, &lt;/P&gt;&lt;P&gt;I am surprised that you have two different webservices on your DEV and PRD server? Do you mean to say that there are two different WSDL (one for dev and one for production with just different input/ output?)if the purpose of webservice is same, it does not seem normal that webservice would have the different name and different structures (associated with it). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure if you can use the variable name... may be you can try out the field symbols... I would try to see if I can get a single webservice for both DEV and PRD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How are you consuming webservice? are you converting the webservices to proxy as per the link below? meaning you are creating two proxies for the two WSDLS?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/bf/d005244e9d1d4d92b2fe7935556b4c/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/bf/d005244e9d1d4d92b2fe7935556b4c/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Feb 2011 16:03:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692746#M1577087</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-10T16:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Variable Declarations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692747#M1577088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This seems to be a easy question but it's not &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA o_data TYPE REF TO object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: v_object TYPE char10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-sysid = 'DEV'.&lt;/P&gt;&lt;P&gt;  v_object = 'CLASS1'.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;  v_object = 'CLASS2'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OBJECT o_data TYPE (v_object).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;o_data will be a generic object, and you can create if making reference to your devclass or prdclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helped!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Feb 2011 16:16:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692747#M1577088</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-10T16:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Variable Declarations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692748#M1577089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What Mauricio has suggested is of course very correct but would require a generic access of any method/attribute in each class. This then starts to be troublesome as components must be addressed indirectly. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ideal way would be having an interface which both classes would implement, so that you could access different objects (of those two classes) by means of this interface w/o knowledge of which one in fact you are accessing. This would ahere to &lt;STRONG&gt;program to an interface. not an implementation&lt;/STRONG&gt; design rule. Unfortunately not sure if you can do that for Web Services as the classes are generated by ESR automatically. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Feb 2011 16:34:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692748#M1577089</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2011-02-10T16:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Variable Declarations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692749#M1577090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Totally agree that method acesses would be rather difficult by what I suggested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would have to call methods like this: CALL METHOD o_object-&amp;gt;('METHOD_NAME').&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Feb 2011 16:42:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692749#M1577090</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-10T16:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Variable Declarations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692750#M1577091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've done something similar recently in Visual Studio.NET using VB (the concept is the same though). My two webservices were the same but one was called inside my intranet and the other accross the Internet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made an interface (I'll call it ZIF) which contained methods and attributes for the needed functionality of the web services.&lt;/P&gt;&lt;P&gt;Implementing ZIF, I had ZLOCAL and ZGLOBAL. In the implementations of the ZIF methods, ZLOCAL called the needed functionality of the generated class for the local web service and ZGLOBAL did the same for the Internet service.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on an if statement, I either created an instance of ZLOCAL or ZGLOBAL but I used it purely as a ZIF instance, letting me not care which web service I was using. This approach will let you avoid using dynamic programming statements such as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL METHOD o_object-&amp;gt;('METHOD_NAME').&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which can be problematic sometimes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Erik Peterson on Feb 11, 2011 1:09 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Feb 2011 18:09:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-declarations/m-p/7692750#M1577091</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-11T18:09:34Z</dc:date>
    </item>
  </channel>
</rss>

