Substring
Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
Substring
I am a new Goanywhere user and I am trying to create a project and having some difficulties. I want to create a project that I call from a cl in the Iseries and pass values to. Then I want to create an XML document using those variables and post it to a server. I have most of the logic down and am using the RUNPROJECT command to pass variables and I think I defined my variables correctly and started to create my XML. The issue I am having is I wish to substring from one of the variables I passed and am getting blanks in my XML even though it looks correct in debug. I have attached a document showing some of the methods I tried. Any help is greatly appreciated
- Attachments
-
- project name.docx
- (11.9 KiB) Downloaded 1487 times
- Support_Rick Offline
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
- Contact:
Re: Substring
Rem,
Your best bet is to substring and push the variables from your CL [%sst( var, 1, 60)] or create vars within your project to do the same after passing the variable from your CL. As in,
Parm Var: MyVar
SetVariable Part1 as ${ Substring( MyVar, 1, 60 ) }
SetVariable Part2 as ${ Substring( MyVar, 61, 3 ) }
...
<element name="Element1" value="${teststip}" type="CHAR" pattern="${Part1}" />
<element name="Element2" value="${teststip2}" type="CHAR" pattern="${Part2}" />
etc...
Your best bet is to substring and push the variables from your CL [%sst( var, 1, 60)] or create vars within your project to do the same after passing the variable from your CL. As in,
Parm Var: MyVar
SetVariable Part1 as ${ Substring( MyVar, 1, 60 ) }
SetVariable Part2 as ${ Substring( MyVar, 61, 3 ) }
...
<element name="Element1" value="${teststip}" type="CHAR" pattern="${Part1}" />
<element name="Element2" value="${teststip2}" type="CHAR" pattern="${Part2}" />
etc...
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Re: Substring
I cannot substring it in the CL as it has about 40 values in the variable and the command only allows 25 values. I tried thas suggested and maybe I am missing something as when I debug it says the pattern cannot be white spaces. here is my current code
Code: Select all
<project name="TESTsst5" mainModule="Main" version="2.0" logLevel="normal" threadSafe="true">
<description>Be careful moving to PROD. Resources are currently pointing at QC for ITSME.</description>
<module name="Main" logLevel="normal">
<createWorkspace label="XMLWorkspace" version="1.0" logLevel="normal" />
<print label="Incoming Variables" version="1.0">
<![CDATA[SetVariable Part1 as ${ Substring( stipa, 1, 60 ) }]]>
</print>
<xmlWrite outputFile="${xmlFile}" version="1.0" disabled="false">
<header><?xml version="1.0" encoding="UTF-8" ?></header>
<element name="Element1" value="${teststip}" type="CHAR" pattern="${Part1}">
<element name="element2" value="${stipulations2}" />
</element>
</xmlWrite>
<deleteWorkspace label="DeleteWorkspace" version="1.0" disabled="false" />
</module>
<variable name="xmlFile" value="AppData.xml" />
<variable name="stipa" value="abcdefghijklm this is a test of the Substring function 5657585960616263646566" />
<variable name="teststip" value="" />
<variable name="Part1" value="" />
</project>
Re: Substring
I managed to get this figured out. What was breaking things was the other users here told me to use an incoming variables task. Once I changed that to a set variable task the substring function worked as expected. Thanks for the Assistance
- Support_Rick Offline
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
- Contact:
Re: Substring
Rem,
The Following Project XML will take the values passed (like you are simulating) and generate the XML file (shown below). Please review for ways to make this apply to your situation. Remember, Element1 (TestStip) isn't added because it's a blank value.
Generated XML File:
Project Log:
The Following Project XML will take the values passed (like you are simulating) and generate the XML file (shown below). Please review for ways to make this apply to your situation. Remember, Element1 (TestStip) isn't added because it's a blank value.
Code: Select all
<project name="TESTsst5" mainModule="Main" version="2.0" logLevel="normal" threadSafe="true">
<description>Be careful moving to PROD. Resources are currently pointing at QC for ITSME.</description>
<variable name="xmlFile" value="AppData.xml" />
<variable name="stipa" value="abcdefghijklm this is a test of the Substring function 5657585960616263646566" />
<variable name="teststip" value="" />
<module name="Main" logLevel="normal">
<createWorkspace label="XMLWorkspace" version="1.0" logLevel="normal" />
<setVariable label="Setvar: Stipluations2" name="Stipulations2" value="${ Substring( stipa, 1, 60 ) }" version="2.0" />
<print label="Incoming Variables" version="1.0">
<![CDATA[XMLFile: ${XMLFile}
Stipa: ${Stipa}
TestStip: ${TestStip}
]]>
</print>
<xmlWrite outputFile="${xmlFile}" version="1.0" disabled="false">
<header><?xml version="1.0" encoding="UTF-8" ?></header>
<element name="Element1" value="${teststip}">
<element name="element2" value="${stipulations2}" />
</element>
</xmlWrite>
<deleteWorkspace label="DeleteWorkspace" version="1.0" disabled="true" />
</module>
</project>
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<Element1>
<element2>abcdefghijklm this is a test of the Substring function 56575</element2>
</Element1>
Code: Select all
2015-07-24 08:02:00 INFO Start Date and Time: 2015-07-24 08:02:00
2015-07-24 08:02:00 INFO Job Number: 1000000000804
2015-07-24 08:02:00 INFO Project Name: /Forum/TESTsst5
2015-07-24 08:02:00 INFO Submitted By: RElliott
2015-07-24 08:02:00 INFO Submitted From: Administrator UI
2015-07-24 08:02:00 INFO System: GA-MFT-01
2015-07-24 08:02:00 INFO GoAnywhere 5.0.1 running on Windows 7 6.1 (amd64)
2015-07-24 08:02:00 INFO Executing project 'TESTsst5'
2015-07-24 08:02:00 INFO Project location: \\R901RHE9\GANetwork\GADFolders\projects\Forum\TESTsst5.xml
2015-07-24 08:02:01 INFO Executing module 'Main'
2015-07-24 08:02:01 INFO Executing task 'createWorkspace 1.0 (XMLWorkspace)'
2015-07-24 08:02:01 INFO Workspace directory for this job is set to '\\R901RHE9\GANetwork\GADFolders\workspace\1000000000804'.
2015-07-24 08:02:01 INFO Finished task 'createWorkspace 1.0 (XMLWorkspace)'
2015-07-24 08:02:01 INFO Executing task 'setVariable 2.0 (Setvar: Stipluations2)'
2015-07-24 08:02:01 INFO Variable 'Stipulations2' was created and set to 'abcdefghijklm this is a test of the Substring function 56575'.
2015-07-24 08:02:01 INFO Finished task 'setVariable 2.0 (Setvar: Stipluations2)'
2015-07-24 08:02:01 INFO Executing task 'print 1.0 (Incoming Variables)'
2015-07-24 08:02:01 INFO XMLFile: AppData.xml
Stipa: abcdefghijklm this is a test of the Substring function 5657585960616263646566
TestStip:
2015-07-24 08:02:01 INFO Finished task 'print 1.0 (Incoming Variables)'
2015-07-24 08:02:01 INFO Executing task 'xmlWrite 1.0'
2015-07-24 08:02:01 INFO File '\\R901RHE9\GANetwork\GADFolders\Workspace\1000000000804\AppData.xml' (145 bytes) was created successfully
2015-07-24 08:02:01 INFO Finished task 'xmlWrite 1.0'
2015-07-24 08:02:01 INFO Finished module 'Main'
2015-07-24 08:02:01 INFO Finished project 'TESTsst5'
2015-07-24 08:02:01 INFO End Date and Time: 2015-07-24 08:02:01
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696