简体   繁体   中英

Connect:Direct syntax on IBM z/OS Mainframe

I am writing a C# program to parse a Connect:Direct file and extract from it source and destination information.

I am not very fluent with Mainframe code. In particular, I am trying to understand the syntax of the destination Windows path. The following is my interpretation but there are holes that I want to fill in order to write a parser that is able to handle any valid syntax variation that I may encounter.

The backslash character must be an escape character, so that two backslashes represent one. However the concatenation operation, || , seems to throw a monkey wrench in that. I presume that the slash character is the line continuation character. The quoted path also is enclosed with a backslash on each side. I'm not sure what this indicates. I'm guessing that it may mean that the enclosed string contains escape characters, suggesting that two backslashes should equal one.

NDMHGM30 PROCESS  SNODE=MYSNODE PACCT='G,HG1'                  -
 &SUBS=SUBSYS(ESP2)                                                 -
 &DMNDH=ESPM2D.DEMANDH                                              -
 &APPL=APPL(STHG102M.0)
STEP1  COPY FROM (PNODE DSN=GIO.HG1.CDB.ACCTEXT.T1(0)               -
               DISP=SHR)                                            -
       COMPRESS EXT                                                 -
       TO (SNODE                                                    -
 DSN=\'\\\\MyServerName\\IMDATA\\CLASS_SOURCE\\SYSTEM_INPUTS\   ||  -
     \\\CDB\\ACCOUNT.TXT'\                                      -
       SYSOPTS="STRIP.BLANKS(NO)"                                   -
               DISP=RPL)
   IF ( STEP1=0 ) THEN
STEP1A   RUN TASK (PGM=ESP,                                         -
 PARM=("&SUBS NOSTACK;AJ USERREQ.GHG30GOD &APPL COMPLETE;END"))
    ELSE
STEP1B   RUN TASK (PGM=ESP,                                         -
 PARM=("&SUBS NOSTACK;TR &DMNDH USER1('GHG30BAD');END"))
   EIF

Any wrong assumptions so far?

Given that, I would expect that the above path would be invalid because it would be interpreted as

\\MyServerName\IMDATA\CLASS_SOURCE\SYSTEM_INPUTS\\CDB\ACCOUNT.TXT

In other words, there would be an extra backslash in one of the levels. But I know that the Connect Direct works and correctly interprets the path as

\\MyServerName\IMDATA\CLASS_SOURCE\SYSTEM_INPUTS\CDB\ACCOUNT.TXT

How does the concatenation operator and/or line continuation impact the number of slashes that are needed here? What other syntax variables might also be valid that would result in the same valid Windows path?

From the documentation ( IBM Sterling Connect:Direct for z/OS User Guide ):

Special Purpose Bracketing

You must often maintain special characters as part of a string. To maintain special characters, enclose the string in bracketing characters. Bracketing characters are backslashes (\\), single quotation marks ('), and double quotation marks (").

Bracketing backslashes are indicators of special processing of a character string.

Sterling Connect:Direct does not maintain them as part of the string at its final resolution. Use bracketing backslashes to:

1 Continue a string containing special characters across multiple lines

2 Ensure that quotation marks within the string are maintained

The following is an example of using bracketing backslashes in a command: PACCT=\\'DEPT\\MIS\\ || -
\\602'\\

Sterling Connect:Direct resolves the command as follows:

PACCT='DEPT\\MIS602'

Combine that with this reference ( Sterling Connect:Direct for Microsoft Windows System Guide - it is probably also detailed elsewhere in the Windows documentation for Connect:Direct)

Microsoft Windows Services treats a backslash (\\) as an escape character, so type two backslashes for each backslash in the file path.

The line you want to understand is this:

 DSN=\'\\\\MyServerName\\IMDATA\\CLASS_SOURCE\\SYSTEM_INPUTS\   ||  -
     \\\CDB\\ACCOUNT.TXT'\

On each of those two lines, the first and last backslashes (\\) are for this reason:

Continue a string containing special characters across multiple lines

and

Sterling Connect:Direct does not maintain them as part of the string at its final resolution

Sterling Connect:Direct will resolve it to this:

 DSN='\\\\MyServerName\\IMDATA\\CLASS_SOURCE\\SYSTEM_INPUTS\\CDB\\ACCOUNT.TXT'

Windows will be presented with

 \\\\MyServerName\\IMDATA\\CLASS_SOURCE\\SYSTEM_INPUTS\\CDB\\ACCOUNT.TXT'

And Windows will then do its escape-processing, giving you this:

 \\MyServerName\IMDATA\CLASS_SOURCE\SYSTEM_INPUTS\CDB\ACCOUNT.TXT

This particular use of the backslash (\\) is due to the presence of the continuation character (the - as the last character on the line) and the presence of special characters (what those are is listed in the documentation), not due to the use of the concatenation (||) (which, for information, is whatever symbol in the character-set you are using is X'4F', which is not necessarily the | symbol).

All the Sterling Connect:Direct documentation, for all platforms, is freely available from IBM's Information Centre, either usable directly online or downloadable as PDFs. Your choice. Just pick your favourite search-engine, and find the documentation for your versions of the product.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM