# Z/OS Submitting jcl

**URL:** <https://forum.ansible.com/t/z-os-submitting-jcl/5778>\
**Category:** Get Help\
**Created:** [May 13, 2024, 12:46pm UTC](https://forum.ansible.com/t/z-os-submitting-jcl/5778 "2024-05-13T12:46:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![U6crgb0](https://avatars.discourse-cdn.com/v4/letter/u/2bfe46/32.png) [@U6crgb0](https://forum.ansible.com/u/U6crgb0)\
**Post date:** [May 13, 2024, 12:46pm UTC](https://forum.ansible.com/t/z-os-submitting-jcl/5778/1 "2024-05-13T12:46:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ddimatos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ddimatos/32/1040_2.png) [@ddimatos](https://forum.ansible.com/u/ddimatos)\
**Post date:** [May 13, 2024, 9:12pm UTC](https://forum.ansible.com/t/z-os-submitting-jcl/5778/2 "2024-05-13T21:12:52Z")

</div>

> [@U6crgb0](#):
>
> msglog

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](https://docs.ansible.com/ansible/2.7/user_guide/playbooks_filters.html) like the [regex filter](https://docs.ansible.com/ansible/2.7/user_guide/playbooks_filters.html#regular-expression-filters) 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.

```auto
    - 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](https://github.com/IBM/z_ansible_collections_samples/tree/main/zos_basics/constructs), 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](https://github.com/IBM/z_ansible_collections_samples/tree/main/zos_basics/constructs).

---

<div class="post-metadata">

**Author:** ![U6crgb0](https://avatars.discourse-cdn.com/v4/letter/u/2bfe46/32.png) [@U6crgb0](https://forum.ansible.com/u/U6crgb0)\
**Post date:** [May 16, 2024, 11:17am UTC](https://forum.ansible.com/t/z-os-submitting-jcl/5778/3 "2024-05-16T11:17:39Z")

</div>

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:

“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)"’}”,

---

<div class="post-metadata">

**Author:** ![ddimatos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ddimatos/32/1040_2.png) [@ddimatos](https://forum.ansible.com/u/ddimatos)\
**Post date:** [May 17, 2024, 5:35pm UTC](https://forum.ansible.com/t/z-os-submitting-jcl/5778/4 "2024-05-17T17:35:35Z")

</div>

@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](https://github.com/ansible-collections/ibm_zos_core/issues/1366)

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](https://github.com/ansible-collections/ibm_zos_core/issues/724)

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](https://github.com/ansible-collections/ibm_zos_core/issues/1375) 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`

---

<div class="post-metadata">

**Author:** ![U6crgb0](https://avatars.discourse-cdn.com/v4/letter/u/2bfe46/32.png) [@U6crgb0](https://forum.ansible.com/u/U6crgb0)\
**Post date:** [June 18, 2024, 12:43pm UTC](https://forum.ansible.com/t/z-os-submitting-jcl/5778/5 "2024-06-18T12:43:32Z")

</div>

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:

* * *

---

<div class="post-metadata">

**Author:** ![ddimatos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ddimatos/32/1040_2.png) [@ddimatos](https://forum.ansible.com/u/ddimatos)\
**Post date:** [June 21, 2024, 4:36pm UTC](https://forum.ansible.com/t/z-os-submitting-jcl/5778/6 "2024-06-21T16:36:17Z")

</div>

For reference, [here is the Git issue](https://github.com/ansible-collections/ibm_zos_core/issues/724) with the work around and updates.
