Topic
3 replies Latest Post - ‏2014-05-07T18:41:16Z by george.baker
george.baker
george.baker
312 Posts
ACCEPTED ANSWER

Pinned topic Return contents of macro variable

‏2014-04-30T19:27:03Z |

I've been doing a lot of Web services lately.  I frequently use macro variables to do things like count the number of records extracted in a loop.  I need to return this count as an output.  Currently the only way I have found to do this is to insert the contents of the macro variable into a field and then extract the contents with an <extract> statement.

Another example is detecting error conditions for which there is no suitable information on the screen to indicate the error.  In these cases I use a macro variable to contain the error condition, but I must find a field on the screen into which I insert the value then <extract> it.  Lately, I've come across situations where there is not an input field into which I can insert the contents of the macro variable.  Either the field is to small, or there is no input field at all.

What I need is a technique or capability of doing and <extract> FROM a global variable.  Does anyone know how to do this?

  • tmparker
    tmparker
    516 Posts
    ACCEPTED ANSWER

    Re: Return contents of macro variable

    ‏2014-05-01T15:26:10Z  in response to george.baker

    Hi George,

    What I think you're missing here is the fundamental issue that global variables do not exist when you are running under the context of an IO or web service.  The reason this is the case is due to the fact that we don't generate the internal objects that are responsible for handling global variables in this scenario.  As a result, there is no way to use the features of global variables and then convert it to a macro variable.  I can make this happen in a macro in a normal web project but it will fails when you run it as an IO.

    So what is it we need here exactly for this to work for you?  It sounds like you want to be able to have a way to return any variable you create in the macro without having to do it only through an extract.  I'm not sure if there is a direct way or if this would require a code change to the IO template or somewhere else.  I'll have to look into this to see if there is a simple way you can do yourself.

    Thanks
    Tim

    • tmparker
      tmparker
      516 Posts
      ACCEPTED ANSWER

      Re: Return contents of macro variable

      ‏2014-05-01T18:17:40Z  in response to tmparker

      Hi George,

      After messing around with this for a little bit this morning I found a way to return the contents of my macro variable that I created in the macro and filled using varupdate actions in an IO.  As I mentioned earlier, I had to make a few changes to the IO template to make this work.

      Here is what I did:

      1. Change the IO template used by HATS from HPubTemplateHODBean.Default to HPubTemplateHODBean.Customize.  This is done in the RAD Preference, under HATS > Integration object.

      2. In my macro I created a string variable that I then updated using the varupdate action.

      3. I then used a custom macro action to trigger my code in the template to store the contents of the macro variable as a string that can then be returned through the IO.

      This is just a quick solution I came up with so I had to hard code some the stuff I needed to use.  This is designed to give you an idea of how this works and hopefully help you on the way to a more custom solution if needs be.

      In the IO template I attached here you will see the changes I made with the comment tags //TIM.

      On Screen6 of the macro you will find the custom action tag.

      Also, you may get compile errors with the template if you don't have Portal support in your studio currently.  if that happens, just comment out the else if block in the code and that will fix it.

      Attachments

      • george.baker
        george.baker
        312 Posts
        ACCEPTED ANSWER

        Re: Return contents of macro variable

        ‏2014-05-07T18:41:16Z  in response to tmparker

        I'm just now seeing this post as I was not notified that you had responded like I used to.

        I'll evaluate this information that you sent to me and respond later.

        Thank you for doing this.