Automic Workload Automation

  • 1.  If STR_FIND in Line 1 output the next line

    Posted Dec 11, 2018 06:22 AM

    Hello community,

    thanks for clicking my question - I had trouble making myself clear in the title.

     

    I get a Process Report which contains a XML answer from a server I get with cURL.

    Excerpt:

    <Envelope>
       <JOB_STATUS>COMPLETE</JOB_STATUS>
       <PARAMETER>

          <NAME>SQL_UPDATED</NAME>
          <VALUE>12</VALUE>
       </PARAMETER>

       <PARAMETER>
          <NAME>DUPLICATES</NAME>
          <VALUE>0</VALUE>
       </PARAMETER>

    [...]

     

    First I wanted to check for the JOB_STATUS to be complete. I found the answer in the forum here:

    :SET &HND# = PREP_PROCESS_REPORT(,,"REP","*<JOB_STATUS>*")
    :PROCESS &HND#
    : SET &RET# = GET_PROCESS_LINE(&HND#)
    : set &pos1# = str_find(&RET#,"<JOB_STATUS>")
    : set &pos1# = &pos1# + 12
    : set &AlertID# = substr(&RET#,&pos1#)
    : SET &RET# = STR_SUBSTITUTE (&AlertID#, "</JOB_STATUS>", "")
    : print &RET#
    : IF &RET# <> "COMPLETE"
    : PRINT "Der Job lässt die Complete Meldung in der XML Response vermissen."
    : EXIT 1
    : ENDIF
    :ENDPROCESS

    This code browses through the report to find <JOB_STATUS>. Go to position + 12 characters (which is the C of the word COMPLETE) until the end. In a second step it deletes </JOB_STATUS> which leaves nothing then COMPLETE.

    Wonderful so far.

     

    But getting the complete message from the server is not 100% save. The parameter SQL_UPDATED, which describes updates SQL rows, is more save. So I want to check for VALUE containing <> 0. But in the report there is more than one parameter - name - value structure.

     

    How to search for a line containing SQL_UPDATED, take the next line and extract the value from there?

     

    I can't thank you enough if I get an answer again from the real automic professionals.

     

    Thanks in advance

    Sönke



  • 2.  Re: If STR_FIND in Line 1 output the next line
    Best Answer

    Posted Dec 11, 2018 10:07 AM

    Hi

     

    Plan A: what about using XML_PROCESS_TO_DOM or XML_DOM_TO_PROCESS or the other XML- script functions, could they help?

    Automic 

     

    Automic 

     

    Plan B could be counting the rows of your Process handle (within PROCESS &HND# increment a counter variable and add 1and save it as &Target_line_no#)

    If the next iteration of the prep_process_xy is equal to your   &Target_line_no# and a string comparison is successful you can be sure its the next line.

     

    bit weird but could work :-)

     

    cheers, Wolfgang



  • 3.  Re: If STR_FIND in Line 1 output the next line

    Posted Dec 13, 2018 06:47 AM

    See also this document I created recently:

    Working with XML in the Automation Engine 



  • 4.  Re: If STR_FIND in Line 1 output the next line

    Posted Dec 17, 2018 07:19 AM

    Thank you very much Michael_Lowry and FrankMuffke for your answers. I will dive more deeply into the mentioned documents. 

    Enjoy the christmas season.