<?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 Can a stored process save and restore state?  Or should I use a custom task? in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Can-a-stored-process-save-and-restore-state-Or-should-I-use-a/m-p/589557#M5925</link>
    <description>&lt;P&gt;&lt;STRONG&gt;TL,DR;&lt;/STRONG&gt;&amp;nbsp; In EG:&amp;nbsp; Should I use a stored process or a custom task if I want to initialize a UI to the last saved state?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have a business process where an end user runs an EG project, and has to either:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Create a brand new Project (row in a SQL Server table)&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Create a new Service (row in a SQL Server table) owned by an existing project.&amp;nbsp; A service is always bound to a project.&lt;/LI&gt;
&lt;LI&gt;Create both a new Project and Service at the same time (first execution of a new project)&lt;/LI&gt;
&lt;LI&gt;Search for an existing Project and Service (re-run a service after an error)&amp;nbsp; (there's another table for batch executions bound to a service)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Right now we're using macro variables, SQL passthrough processing, and the process is error prone.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The current table structure is flat.&amp;nbsp; Very simplified dummy data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data operational;
   length Project Service $20;
   input Project Service;
   datalines;
Project1 ServiceA
Project1 ServiceB
Project1 ServiceC
Project2 ServiceD
Project2 ServiceE
Project3 ServiceF
Project3 ServiceG
Project3 ServiceH
Project3 ServiceI
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm working on splitting the table into separate normalized tables using FK's.&amp;nbsp; Again very simplified example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Project;
   length ProjectID 8 Project $20;
   input Project;
   ProjectID+1;
   datalines;
Project1
Project2
Project3
   ;
run;

data Service;
   length ProjectID ServiceID 8 Service $10;
   input ProjectID Service;
   ServiceID+1;
   datalines;
1 ServiceA
1 ServiceB
1 ServiceC
2 ServiceD
2 ServiceE
3 ServiceF
3 ServiceG
3 ServiceH
3 ServiceI
;
run;

proc sql;
   create view vwOperational as
   select
       a.ProjectID
      ,ServiceID
      ,Project
      ,Service
   from
      Project a
   join
      Service b
   on
      a.ProjectID=b.ProjectID
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That's probably overkill on the description of the business process.&amp;nbsp; But, in summary, they need to either create a row or select an existing data, and IMO some sort of UI is the best approach and least error prone for the end user.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is fairly simple drilldown processing in a stored process (at least for the select part).&amp;nbsp; However, in the past, I could never get a stored process to save and restore state.&amp;nbsp; IOW, I can create a UI where the user drills down to a row, but the next time he/she has to select all over again.&amp;nbsp; There's no way to initialize the stored process to the last saved state.&amp;nbsp; For example, by setting a macro variable, and have the stored process pre-selected to that macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm thinking the best approach may be a custom task which would display the UI, allow the user to create a new project and/or service, select an existing project/service, and save the state so the next time the user runs the project they don't have to select again.&amp;nbsp; I'll have to work out the best approach to save state (XML/JSON), and store this in a place (UNC path) accessible to both the custom task and the SAS workspace server.&amp;nbsp; I'd like the option for the user to not have to display the UI, in which case some macro variables would be set from the previous state (i.e. read the XML/JSON).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I really want is SAS/AF for EG ;-).&amp;nbsp; But I guess you can say that's analogous to a custom task?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Apologies if this is cryptic.&amp;nbsp; I can provide more details if needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your thoughts?&amp;nbsp; How would you approach this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks...&lt;/P&gt;</description>
    <pubDate>Wed, 18 Sep 2019 08:27:19 GMT</pubDate>
    <dc:creator>ScottBass</dc:creator>
    <dc:date>2019-09-18T08:27:19Z</dc:date>
    <item>
      <title>Can a stored process save and restore state?  Or should I use a custom task?</title>
      <link>https://communities.sas.com/t5/Developers/Can-a-stored-process-save-and-restore-state-Or-should-I-use-a/m-p/589557#M5925</link>
      <description>&lt;P&gt;&lt;STRONG&gt;TL,DR;&lt;/STRONG&gt;&amp;nbsp; In EG:&amp;nbsp; Should I use a stored process or a custom task if I want to initialize a UI to the last saved state?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have a business process where an end user runs an EG project, and has to either:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Create a brand new Project (row in a SQL Server table)&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Create a new Service (row in a SQL Server table) owned by an existing project.&amp;nbsp; A service is always bound to a project.&lt;/LI&gt;
&lt;LI&gt;Create both a new Project and Service at the same time (first execution of a new project)&lt;/LI&gt;
&lt;LI&gt;Search for an existing Project and Service (re-run a service after an error)&amp;nbsp; (there's another table for batch executions bound to a service)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Right now we're using macro variables, SQL passthrough processing, and the process is error prone.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The current table structure is flat.&amp;nbsp; Very simplified dummy data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data operational;
   length Project Service $20;
   input Project Service;
   datalines;
Project1 ServiceA
Project1 ServiceB
Project1 ServiceC
Project2 ServiceD
Project2 ServiceE
Project3 ServiceF
Project3 ServiceG
Project3 ServiceH
Project3 ServiceI
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm working on splitting the table into separate normalized tables using FK's.&amp;nbsp; Again very simplified example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Project;
   length ProjectID 8 Project $20;
   input Project;
   ProjectID+1;
   datalines;
Project1
Project2
Project3
   ;
run;

data Service;
   length ProjectID ServiceID 8 Service $10;
   input ProjectID Service;
   ServiceID+1;
   datalines;
1 ServiceA
1 ServiceB
1 ServiceC
2 ServiceD
2 ServiceE
3 ServiceF
3 ServiceG
3 ServiceH
3 ServiceI
;
run;

proc sql;
   create view vwOperational as
   select
       a.ProjectID
      ,ServiceID
      ,Project
      ,Service
   from
      Project a
   join
      Service b
   on
      a.ProjectID=b.ProjectID
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That's probably overkill on the description of the business process.&amp;nbsp; But, in summary, they need to either create a row or select an existing data, and IMO some sort of UI is the best approach and least error prone for the end user.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is fairly simple drilldown processing in a stored process (at least for the select part).&amp;nbsp; However, in the past, I could never get a stored process to save and restore state.&amp;nbsp; IOW, I can create a UI where the user drills down to a row, but the next time he/she has to select all over again.&amp;nbsp; There's no way to initialize the stored process to the last saved state.&amp;nbsp; For example, by setting a macro variable, and have the stored process pre-selected to that macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm thinking the best approach may be a custom task which would display the UI, allow the user to create a new project and/or service, select an existing project/service, and save the state so the next time the user runs the project they don't have to select again.&amp;nbsp; I'll have to work out the best approach to save state (XML/JSON), and store this in a place (UNC path) accessible to both the custom task and the SAS workspace server.&amp;nbsp; I'd like the option for the user to not have to display the UI, in which case some macro variables would be set from the previous state (i.e. read the XML/JSON).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I really want is SAS/AF for EG ;-).&amp;nbsp; But I guess you can say that's analogous to a custom task?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Apologies if this is cryptic.&amp;nbsp; I can provide more details if needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your thoughts?&amp;nbsp; How would you approach this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks...&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 08:27:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Can-a-stored-process-save-and-restore-state-Or-should-I-use-a/m-p/589557#M5925</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-09-18T08:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can a stored process save and restore state?  Or should I use a custom task?</title>
      <link>https://communities.sas.com/t5/Developers/Can-a-stored-process-save-and-restore-state-Or-should-I-use-a/m-p/589566#M5926</link>
      <description>&lt;P&gt;For sure, it can!&amp;nbsp; As for where, it depends on your UI type and use case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wish to build apps on SAS you already have your 'AF alternative'.&amp;nbsp; It's free (mostly), and immensely powerful, and you've probably used it before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's HTML5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can save state in users browsers through cookies or local storage.&amp;nbsp; You save state at the backend through network drives (like you say) or a database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some resources for this approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Building Web Apps&lt;/STRONG&gt;&lt;SPAN style="font-weight: 400;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;"&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings17/1091-2017.pdf" target="_blank"&gt;&lt;SPAN style="font-weight: 400;"&gt;https://support.sas.com/resources/papers/proceedings17/1091-2017.pdf&lt;/SPAN&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;"&gt;&lt;A href="https://www.rawsas.com/building-web-apps-with-sas/" target="_blank"&gt;&lt;SPAN style="font-weight: 400;"&gt;https://www.rawsas.com/building-web-apps-with-sas/&lt;/SPAN&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;"&gt;&lt;A href="https://www.linkedin.com/pulse/5-tips-sas-app-developers-allan-bowe/" target="_blank"&gt;&lt;SPAN style="font-weight: 400;"&gt;https://www.linkedin.com/pulse/5-tips-sas-app-developers-allan-bowe/&lt;/SPAN&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;"&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings17/1372-2017.pdf" target="_blank"&gt;&lt;SPAN style="font-weight: 400;"&gt;http://support.sas.com/resources/papers/proceedings17/1372-2017.pdf&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="font-weight: 400;"&gt;&amp;nbsp; (apps for enterprise)&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;Build an app in 10 minutes;&amp;nbsp; &lt;/SPAN&gt;&lt;A href="https://drive.google.com/file/d/1kAbbKDYWZ1wmgLWiwTYctR4QbQzxLlWX/view" target="_blank"&gt;&lt;SPAN style="font-weight: 400;"&gt;https://drive.google.com/file/d/1kAbbKDYWZ1wmgLWiwTYctR4QbQzxLlWX/view&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;Build an app in 5 minutes:&amp;nbsp;&lt;A href="https://vimeo.com/349223867" target="_blank"&gt;https://vimeo.com/349223867&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Existing Web Apps&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;Data Controller&amp;nbsp; - &lt;A href="https://datacontroller.io" target="_blank"&gt;https://datacontroller.io&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;Metadata Explorer -&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/Boemska/metanav" target="_blank"&gt;&lt;SPAN style="font-weight: 400;"&gt;https://github.com/Boemska/metanav&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;User Navigator -&amp;nbsp;&lt;A href="https://github.com/Boemska/user-navigator" target="_blank"&gt;https://github.com/Boemska/user-navigator&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you'd like to get stuck into building web apps on SAS I'd be happy to talk more, just drop me a PM.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 08:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Can-a-stored-process-save-and-restore-state-Or-should-I-use-a/m-p/589566#M5926</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2019-09-18T08:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Can a stored process save and restore state?  Or should I use a custom task?</title>
      <link>https://communities.sas.com/t5/Developers/Can-a-stored-process-save-and-restore-state-Or-should-I-use-a/m-p/589850#M5927</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28909"&gt;@AllanBowe&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this would be really cool.&amp;nbsp; But...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) How would I integrate this with EG, which is the tool my end users use?&lt;/P&gt;
&lt;P&gt;2) How do I create this if I don't have access to a web server in my environment?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers...&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 22:10:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Can-a-stored-process-save-and-restore-state-Or-should-I-use-a/m-p/589850#M5927</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-09-18T22:10:13Z</dc:date>
    </item>
  </channel>
</rss>

