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

thank so much for your help here what ibm said

The work around uses the community modules and ZOAU directly, not all ZOAU member operations are successful when using special chars, $ @ , etc, dcp works fine.

Steps:

Copy file from controller (assuming the file is on the controller else use remote_src:true to z/OS USS, this will be copied as what ever encoding it starts out with, likely UTF-8
Covert it from the source encoding (UTF-8) to desired encoding (likely IBM-1047) using z/OS USS iconv
Copy it from z/OS USS to a data set member with a special char.
Submit it using ZOAU jsub
Extract the JOB ID
Get the JOB output

  • hosts: zvm
    collections:

    • ibm.ibm_zos_core
      gather_facts: no
      environment: “{{ environment_vars }}”
      vars:

    Original file on control node

    org_file: “{{playbook_dir}}/files/hello.jcl”

    Transferred file in as UTF8

    utf_8_file: ‘/tmp/jcl-utf8.txt’

    Converted file resulting from ‘iconv’

    ibm_1047_file: ‘/tmp/jcl-1047.txt’

    PDSE(member) with a special char escaped

    pdse_member: ‘IMSTESTL.DIMATO.JCLCOPY(JCL$MEM)’

    tasks:

    • name: Copy “{{ org_file }}” from controller to USS “{{ utf_8_file }}”
      ansible.builtin.copy:
      src: “{{ org_file }}”
      dest: “{{ utf_8_file }}”
      register: result

    • name: Result
      ansible.builtin.debug:
      var: result

    • name: Convert file “{{ utf_8_file }}” from UTF-8 to ibm-1047 at location “{{ ibm_1047_file }}”
      shell: “iconv -f UTF-8 -t IBM-1047 {{ utf_8_file }}>{{ ibm_1047_file }}”
      register: result

    • name: Result
      ansible.builtin.debug:
      var: result

    • name: Use ZOAU dcp to copy IBM-1047 file “{{ ibm_1047_file }}” into data set “{{ pdse_member }}”
      ansible.builtin.shell: dcp “{{ ibm_1047_file }}” “{{ pdse_member }}”
      register: result

    • name: Result
      ansible.builtin.debug:
      var: result

    • name: Use ZOAU jsub to submit “{{ pdse_member }}”
      ansible.builtin.shell: jsub “{{ pdse_member }}”
      register: result

    • name: Result
      ansible.builtin.debug:
      var: result

    • name: Set Job ID variable for reuse.
      ansible.builtin.set_fact:
      job_id: “{{ result.stdout }}”

    • name: Get the Job output
      zos_job_output:
      job_id: “{{ job_id }}”
      register: result

    • name: Result
      ansible.builtin.debug:
      var: result


For reference, here is the Git issue with the work around and updates.