Z/OS Submitting jcl

need some help on JCl output on msglog
my task is to find 4 active devices in the msglog then copy them to file
my problem is i need to know how to that can anyone help me

  • name: Submit a long running PDS job and wait up to 30 seconds for completion.
    zos_job_submit:
    src: SYS2.DR.VERIFY.JCL($#JCLCAI)
    location: DATA_SET
    wait_time_s: 10

    • name: Retrieve output of XXC91ND1 job
      zos_job_output:
      job_name: $#JCLCAI
      ddname: “JESMSGLG”

Hi,
If I understand correctly, you are asking how to capture a response and parse it for results, your current tasks don’t have a variable registered to capture that output.

My suggestion is you capture the result into a registered variable, print it with a debug task for inspection then begin to drill down into the JSON with the debug task, later use filters like the regex filter to access the details and/or set those to a fact for later use in the playbook.

This does not fully address your inquiry but will get you very close, at least up to the point you need to start filtering.

    - name: Convert a local JCL file to IBM-037 and submit the job
      zos_job_submit:
        src: "{{playbook_dir}}/files/HELLO.jcl"
        location: LOCAL
        wait: false
        encoding:
          from: ISO8859-1
          to: IBM-037
      register: job_sub_result_production

    - name: Set fact `job_sub_result` with live production content
      set_fact:
        job_sub_result: "{{job_sub_result_production}}"

    - name: Set facts used in this playbook
      set_fact:
        submit_job_name: "{{ job_sub_result.jobs[0].job_name }}"
        submit_job_id: "{{ job_sub_result.jobs[0].job_id }}"
        submit_jobs_ddnames_length: "{{ job_sub_result.jobs[0].ddnames |length }}"
        submit_job_ddnames_list: "{{ job_sub_result.jobs[0].ddnames }}"
        submit_job_list: "{{ job_sub_result.jobs[0] }}"

    - name: Print values used in this playbook
      debug:
        msg:
          - Job name={{submit_job_name}}
          - Job ID={{submit_job_id}}
          - DD Count={{submit_jobs_ddnames_length}}
          - "{{submit_job_ddnames_list}}"
          - "{{submit_job_list}}"

Please use the zos tag when creating z/OS related posts it will help ensure awareness.

Please review the playbook I created here, I have not run it in a few years but should still work just fine; the playbook is designed to help you parse z/OS batch job results ‘offline’ meaning there is static content from a real job submission embedded in the playbook you can keep reusing and then tweak the playbook task to achieve your result without ever having to run a job on z/OS (eg mock playbook development).

You can find that here.

1 Like

thanks i will try that and get back with you, i see another problem when submitting this job. it dont like the job name $#JCLCAI how do you write this

  • name: Submit a long running PDS job and wait up to 30 seconds for completion.
    zos_job_submit:

    src: XXC91.JCL.CNTL($#JCLCAI)
    location: DATA_SET
    wait_time_s: 10

“stderr”: “Unable to submit Job: {‘rc’: 4, ‘response_format’: ‘UTF-8’, ‘stdout_response’: ‘’, ‘stderr_response’: ‘BGYSC4002E Invalid dataset name SYS2.DR.VERIFY.JCL(0JCLCAI).\n’, ‘command’: ‘jsub "SYS2.DR.VERIFY.JCL($#JCLCAI)"’}”,

@U6crgb0 - currently special characters are not supported, this support will come in ibm_zos_core version 1.11.0-beta.1 releasing early Q3, we included special char support with GDG support, you can follow this epic here to see when all the issues close. [Epic] [Enabler] [GDG] Support GDG and special characters. · Issue #1366 · ansible-collections/ibm_zos_core · GitHub

There is also a related issue which is inclusive to the above epic here [Bug] [zos_job_submit] unable to submit member that contain $ · Issue #724 · ansible-collections/ibm_zos_core · GitHub

You are welcome to grab development builds and try them out if you have ZOAU 1.3.0 or later, for example watch the this specific GDG/Special char support issue, [Enabler] [zos_job_submit] GDG/GDS and special character support · Issue #1375 · ansible-collections/ibm_zos_core · GitHub when its done, grab a development build and test only zos_job_submit; you can do that with this simple command: ansible-galaxy collection install git+https://github.com/ansible-collections/ibm_zos_core.git,dev