Automic Workload Automation

 View Only
  • 1.  Drop double quote at end of 1400+ character string

    Posted Apr 10, 2025 05:23 PM

    I'm running a job to obtain a token. The token length is varying and over 1430 characters. I'm doing a SUBSTR starting at position 54 and dropping it into a static variable to be passed into a succeeding job. This is working, however, there is a double quote at the end of the string that I need to remove so I cannot simply use STR_CUT.

    None of the STR_* script elements seem appropriate to strip it out. Would anyone know how to solve this? 

    This is what I have so far: 

    :DELETE_VAR VARA.XXXX
    :SET &HND# = PREP_PROCESS_REPORT(,,,'*"access_token": "*')
    :PROCESS &HND#
    :  SET &TOKEN# = GET_PROCESS_LINE(&HND#)
    :  SET &TOKEN2# = SUBSTR(&TOKEN#,54)
    :  PUT_VAR VARA.XXXX,"&TODAY#","Bearer &TOKEN2#"
    :ENDPROCESS
    :CLOSE_PROCESS &HND#
     
    :PSET &TOKEN2# = GET_VAR(VARA.XXXX, &TODAY#, "1")
    Thanks! (I may have posted this twice.)


  • 2.  RE: Drop double quote at end of 1400+ character string

    Posted Apr 11, 2025 03:15 AM
    Hello Michele,
    here you can use STR_REVERSE, for example:
     
    :P &TOKEN2#
    :SET &TOKEN2# = STR_REVERSE(&TOKEN2#)
    :P &TOKEN2#
    :SET &TOKEN2# = SUBSTR(&TOKEN2#,2)
    :P &TOKEN2#
    :SET &TOKEN2# = STR_REVERSE(&TOKEN2#)
    :P &TOKEN2#
     
    I hope that it should work for you.
    Greetings Ralf



  • 3.  RE: Drop double quote at end of 1400+ character string

    Posted Apr 11, 2025 11:24 AM

    This was perfect and worked well. Thank you!




  • 4.  RE: Drop double quote at end of 1400+ character string

    Posted Apr 11, 2025 11:13 AM
    Edited by Eric Lontz Apr 11, 2025 11:14 AM

    So there are a couple of other ways you could go about this, as Ralf's will definitely work. I am assuming you are using a WebServiceRest JOBS due to the position 54 for your token start, as that is exactly where mine are at.

    Using str_find with str_cut you can do.

    :set &TODAY# = sys_date('MM-DD-YYYY')
    :DELETE_VAR 'VARA.XXXX'
    :SET &HND# = PREP_PROCESS_REPORT(,,,'*"access_token": "*')
    :PROCESS &HND#
    :  SET &TOKEN# = GET_PROCESS_LINE(&HND#)
    :  SET &TOKEN2# = SUBSTR(&TOKEN#,54)
    :  set &quotepos# = str_find(&TOKEN2#,'"')
    :  set &cutlen# = &quotepos# - 1
    :  set &TOKEN2# = str_cut(&TOKEN2#,1,&cutlen#)
    :  print &TOKEN2#
    :  PUT_VAR VARA.XXXX,"&TODAY#","Bearer &TOKEN2#"
    :ENDPROCESS
    :CLOSE_PROCESS &HND#

    :PSET &TOKEN2# = GET_VAR(VARA.XXXX, &TODAY#, "1")

    Alternately you can go to the Response tab and add parsing then you can just store it with put_var and retrieve with get_var

    :set &TODAY# = sys_date('MM-DD-YYYY')
    :PUT_VAR VARA.XXXX,"&TODAY#","Bearer &ACCESS_TOKEN#"
    :PSET &TOKEN2# = GET_VAR(VARA.XXXX, &TODAY#, "1")






  • 5.  RE: Drop double quote at end of 1400+ character string

    Posted Apr 11, 2025 11:28 AM

    You are correct that it was a REST job! Thank you for sharing this and for your time. I will be test with this solution, too. 

    This community is so great!