CALLNAT 'USR1058N' example

Hi, can someone help me with an example of CALLNAT ‘USR1058N’. I don’t know the structure of USR1058N

thanks

Hi,
not sure whether you mean USR1038N (your topic) or USR1058 (your text).
Anyway, the example program is always named USRnnnnP and further info is in the text member USRnnnnT.
Both are in the library SYSEXT.
Regards, Lukas

1 Like

sorry, USR1058.

How do I access the SYSEXT library?
. Thank you

At a command prompt
LOGON SYSEXT
or
SYSEXT
to display a list of USR modules.

Thanks.
I don’t have access to that library

Greetings

Two options:

  • Request access from your Natural administrator.

  • Install the Community Edition of Natural for Windows, where all libraries are available. You can copy/paste the structure into your mainframe editor session. You may still require the Natural Administrator to give you access to a copy of USR1058N.

Thank you,
Greetings

Thanks
Greetings

Read a DDM source code into an array
.
Documentation ......... USR1058T    /*  Text object
Interface ............. USR1058N    /*  Cataloged subprogram
Example Program ....... USR1058P    /*  Source program
.
Product Code .......... NAT
.
Category .............. DDMS
.
Keywords .............. +MOD-NAT-6.3.14,
                        DDM, FDIC, FNAT, FSEC ENABLED,
                        FUSER, READ, SOURCE, SYSTEM FILE
.
Function .............. This interface reads the source of a DDM
                        into an array. On some platforms a DDM
                        source is not available. On these platforms
                        the output of this program will be similar
                        to the output of the LIST command.
                        With OS6.3.14: code page support is provided
                        according to SRETAIN.
                        With OS6.3.14: support for FSEC switch
.
.
Parameters
----------
Define the following parameters with the DEFINE DATA statement:
.
1 USR1058L
  2 OBJECT-KEY
    3 LIBRARY        (A08)
    3 OBJECT-NAME    (A32)
    3 OBJECT-TYPE    (A02)
  2 INPUTS
    3 OPT-ACCESS     (A01)
    3 OPT-UNUSED-1   (L)
    3 OPT-UNUSED-2   (A01)
    3 OPT-LINE-NUM   (A01)
    3 OPT-UNUSED-3   (L)
    3 OPT-REDEF-DIR  (L)
    3 OPT-UNUSED-4   (A01)
    3 OPT-AMOUNT     (I02)
    3 OPT-LINESIZE   (I02)
  2 INPUT-OUTPUTS
    3 INT-HANDLE     (I04)
    3 NEXT-SEQ       (I04)
    3 NEXT-NUM       (I02)
  2 OUTPUTS
    3 RETURNED       (I02)
    3 SRC-NUM        (I02/1:nn)
    3 SRC-TEXT       (A01/1:nn,1:mm)
    3 REDEFINE SRC-TEXT
      4 SRC-GROUP    (1:nn)
        5 SRC-LINE   (A79)
        5 REDEFINE SRC-LINE
          6 #TYP     (A01)
          6 F1       (A01)
          6 #LEV     (A01)
          6 F2       (A01)
          6 #DB      (A02)
          6 F3       (A01)
          6 #NAME    (A32)
          6 F4       (A02)
          6 #FORMAT  (A01)
          6 F5       (A01)
          6 #LENGTH  (A04)
          6 F6       (A02)
          6 #SPE     (A01)
          6 F7       (A01)
          6 #DES     (A01)
          6 F8       (A01)
          6 #REMARK  (A24)
          6 F9       (A01)
    3 REDEFINE SRC-TEXT           /* Header information - Mainframe
      4 HD-DBID          (N05)
      4 HD-FNR           (N05)
      4 HD-DEFSEQ        (A02)
      4 HD-VSAM-SUBTYPE  (A01)
      4 HD-VSAM-NAME     (A08)
    3 REDEFINE SRC-TEXT           /* Directory - UNIX / PC platforms
      4 DIR-OBJNAME      (A32)    /* Object Name
      4 DIR-LIBRARY      (A08)    /* Library ID
      4 DIR-OBJTYPE      (A02)    /* Object Type
      4 DIR-OBJKIND      (A01)    /* Source or Module
      4 DIR-DBID         (A05)    /* DBID of System File
      4 DIR-FNR          (A05)    /* FNR of System File
      4 DIR-DATN         (A08)    /* Date in Format (YYYYMMDD)
      4 DIR-TIMN         (A07)    /* Time in Format (HHIISST)
      4 DIR-USERID       (A08)    /* User ID
      4 DIR-PROGMODE     (A01)    /* Programming Mode
      4 DIR-SRCSIZE      (A10)    /* Source Area Size
      4 DIR-GPSIZE       (A10)    /* Size of Module
      4 DIR-UNIQUE-ID    (A32)    /* Unique ID
      4 DIR-DDM-DBID     (A05)    /* DBID the DDM is cataloged with
      4 DIR-DDM-FNR      (A05)    /* FNR the DDM is cataloged with
    /* End of directory attributes
    3 SRC-SEQ        (I04/1:nn)
    3 SRC-LONG       (A01/1:nn)
.
1 USR1058N
  2 VERSION          (I01)     INIT <4>
  2 V0-WORK-AREA     (B125)    /* Work area; do not modify
  2 V0-WORK-AREA1    (B125)    /* Work area; do not modify
  2 V1-OPT-FORMAT    (A01)     /* Mainframe or UNIX/PC format
  2 V2-DBID          (N05)     /* FDIC DBID
  2 V2-FNR           (N05)     /* FDIC FNR
  2 V2-PASSWORD      (A08)     /* FDIC PASSWORD
  2 V2-CIPHERCODE    (N08)     /* FDIC CIPHERCODE
  2 V3-WORK-AREA2    (N03)     /* Work area; do not modify
  2 V4-WORK-AREA3    (A01)     /* MF only
  2 V4-WORK-AREA4    (A256)    /* MF only
  2 V4-ASK-CCHARS    (A01)     /* MF only
  2 V5-FSEC-DBID     (N05)     /* Fsec-dbid
  2 V5-FSEC-FNR      (N05)     /* Fsec-fnr
  2 V5-FSEC-PSW      (A08)     /* Fsec password
  2 V5-FSEC-CIP      (N08)     /* Fsec ciphercode
1 REDEFINE USR1058N
  2 EXTENDED-PARMS
    3 EXTENDED-DATA  (A01/1:565)
.
local using USR-MSG   /* Data for message exchange
local using USR-FLD   /* Description of the field in error
.
.
Interface Call
--------------
Use the interface with the CALLNAT statement:
.
CALLNAT 'USR1058N' USR1058L  USR1058N.EXTENDED-PARMS
                   USR-MSG   USR-FLD
.
.
Using the Application Programming Interface:
--------------------------------------------
Copy the subprogram USR1058N to the library SYSTEM or the steplib
library respectively, or to the required library.
.
.
In/Output .. LIBRARY (A08)
                    Library where the object is located. If
                    LIBRARY is blank, the current library is used.
                    This applies not to mainframe platforms.
.
Input ...... OBJECT-NAME (A32)
                    Name of the object.
.
In/Output .. OBJECT-TYPE (A02)
                    Type of the DDM.
                    If OBJECT-TYPE is filled, the object must be
                    of the specified type. This will be checked
                    during the open call.
                    The OBJECT-TYPE will be returned after the
                    open call (Output format 'C' only)
                    For VSAM DDMs the OBJECT-TYPE must not be reset.
.
Input ...... OPT-ACCESS (A01)
                    Access type. An open call starts the processing
                    and returns the directory data. The next calls
                    read the object until its end. The close call
                    is done automatically by the subprogram.
                    Possible values are:
                    'O' - Open processing
                    'R' - Read source lines
                    'C' - Close processing; only necessary in
                          a file system environment to force the end
                          of processing.
.
Input ...... OPT-LINE-NUM (A01)
                    Option if line numbers are to be returned.
                    This applies not to mainframe platforms.
                    Possible values are:
                    'Y' - Return line numbers
                    'N' - Do not return line numbers
.
Input ...... OPT-REDEF-DIR (L)
                    Option if the directory should be redefined
                    and interpreted in a UNIX/PC environment.
                    See USR1058P for the layout of the
                    redefinition.
                    DDMs do not have a directory on mainframe
                    platforms. Therefore the corresponding header
                    information of the DDM will be displayed always.
                    Possible values are:
                    FALSE - Do not interpret directory data
                    TRUE  - Interpret directory data
.
Input ...... OPT-AMOUNT (I02)
                    Amount of lines requested.
                    The maximum value is 255.
.
Input ...... OPT-LINESIZE (I02)
                    Length of each line. The value must be less or
                    equal 80 in a data base environment and up to
                    250 in a file system environment.
.
In/Output .. INT-HANDLE (I04)
                    Do not change. Passed out by the open call to
                    identify the caller during subsequent calls.
.
In/Output .. NEXT-SEQ (I04), NEXT-NUM (I02)
                    Unused.
.
Output ..... RETURNED (I02)
                    Number of filled occurrences.
.
Output ..... SRC-NUM (I02/1:nn), SRC-TEXT (A01/1:nn,1:mm),
             SRC-SEQ (I04/1:nn), SRC-LONG (A01/1:nn)
                    Line number (SRC-NUM), text of the source
                    (SRC-TEXT) sequence number (SRC-SEQ) where the
                    part of the source has been found (only if the
                    module is stored in a data base) and a long
                    line indicator (SRC-LONG).
                    SRC-NUM is always empty on mainframe platforms.
                    SRC-SEQ is always empty on mainframe plarfotms.
                    SRC-LONG (nn) = '-' means that the next line
                    has to be appended.
                    nn, mm: The upper index of the arrays is
                    variable.
                    nn corresponds to OPT-AMOUNT; mm corresponds
                    to OPT-LINESIZE.
                    OPT-ACCESS = 'O' returns the directory or the
                    header information of the DDM. This is the
                    DBID/FNR the DDM is cataloged with and the
                    default sequence.
                    For VSAM DDMs the subtype will be returned and
                    where applicable the file/link/catalog name.
                    The header lines for the DDM listing are
                    returned too.
                    ATTENTION: The size of the output buffer
                    SRC-TEXT must be at least 300 characters.
.
In/Output .. USR1058N.VERSION (I01)
                    Version number of the subprogram.
                    The actual version number is 1. Parameter
                    V1-OPT-FORMAT has been added.
                    The actual version number is 2. Parameter
                    DBID, FNR, PASSWORD, CIPHERCODE have been added.
                    The actual version number is 3. Parameter
                    WORK-AREA2 has been added (do not change).
.
In/Output .. V0-WORK-AREA     (B125)    /* Work area; do not modify
             V0-WORK-AREA1    (B125)    /* Work area; do not modify
.
Input ...... V1-OPT-FORMAT (A01)
                    Option to use a platform independent output
                    format. This option is applicable on
                    mainframe platforms only; on other platforms
                    the default format 'C' is always used.
                    Possible values are:
                    'C' - The source format used on UNIX and PC
                          platforms. The output is identical on
                          all platforms; this option is recommended.
                    'M' - On mainframe system you can choose an
                          output format which is similar to the
                          format used by the LIST VIEW command.
.
Input ...... V2-DBID (N05), V2-FNR (N05),
             V2-PASSWORD (A08), V2-CIPHERCODE (N08)
                    Description of the data base environment. If
                    no values are entered, the current FDIC
                    definition is used.
.
In/Output .. V3-WORK-AREA2 (N03)    /* Work area; do not modify
.
             V4-WORK-AREA3 (A01)    /* Work area; do not modify
                    MF only
.
Input ...... V4-ASK-CCHARS (A01)
                    MF only
.
Input ...... V5-FSEC-DBID (N5)
                    DBID of FSEC system file.
.
Input ...... V5-FSEC-FNR  (N4)
                    FNR of FSEC system file.
.
Input ...... V5-FSEC-PASSWORD (A08)
                    Password for FSEC system file.
.
Input ...... V5-FSEC-CIPHERCODE (N08)
                    Cipher code for FSEC system file.
.
Output ..... USR-MSG
                    Data used for message exchange.
                    For further information see the PDA USR-MSG.
                    The following message numbers are possible:
                    =  0000  Ok
                    =  0100  End of data reached
                    =  1001  Parameter error
                    =  1002  Parameter/internal error
                    =  1003  Parameter value is too small.
                    =  1004  Parameter value is too large.
                    =  1005  Invalid range specified
                    =  1006  Object does not exist
                    = -4125  The requested file description is not
                             available.
                    = -4261  View cannot be read/listed; FSIZE is
                             too small.
                             NSC check
                    = -0806 Library :1: not found.
                    = -0807 Logon to library :1: is not permitted.
                    = -0839 The library SYSSEC :1: has not been found.
                    = -4125 The requested file descr is not available.
                    = -4891 Invalid DBID/FNR specified for a library.
.
Output ..... USR-FLD
                    Description of the field in error.
                    For further information see the PDA USR-FLD.
.
.
*****  End of description  *****
/*  This program serves as example how to design a user-defined
/*  program to call 'USR1058N'.
/***********************************************************************
DEFINE DATA
LOCAL
1 V                  (I01)  CONST <20>
LOCAL
1 USR1058L
  2 OBJECT-KEY
    3 LIBRARY        (A08)
    3 OBJECT-NAME    (A32)
    3 OBJECT-TYPE    (A02)
      /*
  2 INPUTS
    3 OPT-ACCESS     (A01)
    3 OPT-UNUSED-1   (L)
    3 OPT-UNUSED-2   (A01)
    3 OPT-LINE-NUM   (A01)
    3 OPT-UNUSED-3   (L)
    3 OPT-REDEF-DIR  (L)
    3 OPT-UNUSED-4   (A01)
    3 OPT-AMOUNT     (I02)
    3 OPT-LINESIZE   (I02)
      /*
  2 INPUT-OUTPUTS
    3 INT-HANDLE     (I04)
    3 NEXT-SEQ       (I04)
    3 NEXT-NUM       (I02)
      /*
  2 OUTPUTS
    3 RETURNED       (I02)
    3 SRC-NUM        (I02/1:V)
    3 SRC-TEXT       (A01/1:V,1:79)
    3 REDEFINE SRC-TEXT
      4 SRC-GROUP    (1:V)
        5 SRC-LINE   (A79)
        5 REDEFINE SRC-LINE
          6 #TYP     (A01)
          6 F1       (A01)
          6 #LEV     (A01)
          6 F2       (A01)
          6 #DB      (A02)
          6 F3       (A01)
          6 #NAME    (A32)
          6 F4       (A02)
          6 #FORMAT  (A01)
          6 F5       (A01)
          6 #LENGTH  (A04)
          6 F6       (A02)
          6 #SPE     (A01)
          6 F7       (A01)
          6 #DES     (A01)
          6 F8       (A01)
          6 #REMARK  (A24)
          6 F9       (A01)
    3 REDEFINE SRC-TEXT           /* Header information - Mainframe
      4 HD-DBID          (N05)
      4 HD-FNR           (N05)
      4 HD-DEFSEQ        (A02)
      4 HD-VSAM-SUBTYPE  (A01)
      4 HD-VSAM-NAME     (A08)
    3 REDEFINE SRC-TEXT           /* Directory - UNIX / PC platforms
      4 DIR-OBJNAME      (A32)    /* Object Name
      4 DIR-LIBRARY      (A08)    /* Library ID
      4 DIR-OBJTYPE      (A02)    /* Object Type
      4 DIR-OBJKIND      (A01)    /* Source or Module
      4 DIR-DBID         (A05)    /* DBID of System File
      4 DIR-FNR          (A05)    /* FNR of System File
      4 DIR-DATN         (A08)    /* Date in Format (YYYYMMDD)
      4 DIR-TIMN         (A07)    /* Time in Format (HHIISST)
      4 DIR-USERID       (A08)    /* User ID
      4 DIR-PROGMODE     (A01)    /* Programming Mode
      4 DIR-SRCSIZE      (A10)    /* Source Area Size
      4 DIR-GPSIZE       (A10)    /* Size of Module
      4 DIR-UNIQUE-ID    (A32)    /* Unique ID
      4 DIR-DDM-DBID     (A05)    /* DBID the DDM is cataloged with
      4 DIR-DDM-FNR      (A05)    /* FNR the DDM is cataloged with
        /* End of directory attributes
    3 SRC-SEQ        (I04/1:V)
    3 SRC-LONG       (A01/1:V)
      /*
1 USR1058N
  2 VERSION          (I01)     INIT <5>
  2 V0-WORK-AREA     (B125)    /* Work area; do not modify
  2 V0-WORK-AREA1    (B125)    /* Work area; do not modify
  2 V1-OPT-FORMAT    (A01)     /* Mainframe or UNIX/PC format
  2 V2-DBID          (N05)     /* FDIC DBID
  2 V2-FNR           (N05)     /* FDIC FNR
  2 V2-PASSWORD      (A08)     /* FDIC PASSWORD
  2 V2-CIPHERCODE    (N08)     /* FDIC CIPHERCODE
  2 V3-WORK-AREA2    (N03)     /* Work area; do not modify
  2 V4-WORK-AREA3    (A01)     /* MF only
  2 V4-WORK-AREA4    (A256)    /* MF only
  2 V4-ASK-CCHARS    (A01)     /* MF only
  2 V5-FSEC-DBID     (N05)     /* FSEC DBID
  2 V5-FSEC-FNR      (N05)     /* FSEC FNR
  2 V5-FSEC-PSW      (A08)     /* FSEC PASSWORD
  2 V5-FSEC-CIP      (N08)     /* FSEC CIPHERCODE
1 REDEFINE USR1058N
  2 EXTENDED-PARMS
    3 EXTENDED-DATA  (A01/1:565)
      /*
LOCAL USING USR-MSG   /* Data for message exchange
LOCAL USING USR-FLD   /* Description of the field in error
/*
LOCAL
1 USR1038L
  2 OUTPUTS
    3 PLATFORM-DATA    (A16)
    3 REDEFINE PLATFORM-DATA
      4 NAT-IMPL       (A01)
      4 CHAR-SET       (A01)
      4 OP-SYSTEM      (A01)
      4 USER-INTERFACE (A01)
      4 BYTE-SWAPPING  (A01)
      4 FILLER         (A11)
        /*
1 USR1038N
  2 VERSION            (I01)     INIT <0>
1 REDEFINE USR1038N
  2 EXTENDED-PARMS
    3 EXTENDED-DATA    (A01/1:1)
LOCAL
1 LOCAL-MSG          (A79)
1 IX                 (I02)
1 INPUT-OK           (L)
END-DEFINE
/*
SET KEY ALL
/*
LIBRARY       := 'SYSTEM  '
OBJECT-NAME   := 'EMPLOYEES'
OPT-LINE-NUM  := 'Y'
OPT-REDEF-DIR := TRUE
OPT-AMOUNT    := 20
OPT-LINESIZE  := 79
V1-OPT-FORMAT := 'C'
/*
/*
REP1.
REPEAT
  OPT-ACCESS   := 'O'
  RETURNED := 0
*
  INPUT (AD=MITL'_' IP=OFF)
    TEXT NAD-MSG.MSG, MSG-DATA (1), MSG-DATA (2), MSG-DATA (3)
    MARK NAD-FLD.FIELD-POSITION
    / 10T 'Read the source of a DDM into an array:' (I)
    / 10T '-' (39) (I) /
    / 10T 'Library ..............'  LIBRARY
    / 10T 'DDM name .............'  OBJECT-NAME
    / 10T 'Object type ..........'  OBJECT-TYPE (AL=1)
    / 10T 'Amount of lines ......'  OPT-AMOUNT
    / 10T 'Line size ............'  OPT-LINESIZE
    / 10T 'Return line numbers ..'  OPT-LINE-NUM
    / 10T 'Redefine directory ...'  OPT-REDEF-DIR (EM=F/T)
    / 10T 'Output format ........'  V1-OPT-FORMAT
    / 10T 'Ask for conversion ...'  V4-ASK-CCHARS
    / 10T 'DBID of FDIC .........'  V2-DBID
          'Password of FDIC .....'  V2-PASSWORD
    / 10T 'FNR of FDIC ..........'  V2-FNR
          'Cipherkey of FDIC ....'  V2-CIPHERCODE
    / 10T 'DBID of FSEC .........'  V5-FSEC-DBID
          'PSW of FSEC ..........'  V5-FSEC-PSW
    / 10T 'FNR of FSEC ..........'  V5-FSEC-FNR
          'Cipherkey of FSEC ....'  V5-FSEC-CIP
    /// 10T 'Press any PF-key to stop.'
/*
  IF *PF-KEY NE 'ENTR'
    ESCAPE BOTTOM
  END-IF
/*
  IF OPT-AMOUNT > V
    COMPRESS 'The maximum for the amount is' V
      'in this example program.' INTO LOCAL-MSG
    NAD-MSG.MSG := LOCAL-MSG
    NAD-FLD.FIELD-POSITION := 4
    ESCAPE TOP
  END-IF
/*
  IF OPT-LINESIZE > 79
    COMPRESS 'The maximum for the line size is'  79
      'in this example program.' INTO LOCAL-MSG
    NAD-MSG.MSG := LOCAL-MSG
    NAD-FLD.FIELD-POSITION := 5
    ESCAPE TOP
  END-IF
/*
  CALLNAT 'USR1038N'  USR1038L  USR1038N.EXTENDED-PARMS
  /*
  REPEAT
    CALLNAT 'USR1058N' USR1058L  USR1058N.EXTENDED-PARMS
      NAD-MSG   NAD-FLD
    /*
    FOR IX = 1 TO RETURNED
      IF OPT-ACCESS = 'O' AND MSG-NR = 0 AND IX = 1
        IF OPT-REDEF-DIR AND NAT-IMPL = 'C'    /* write directory
          WRITE (AD=LI) 'Back with message number:' MSG-NR /
            / '=' DIR-OBJNAME
            / '=' DIR-LIBRARY
            / '=' DIR-OBJKIND
            / '=' DIR-OBJTYPE
            / '=' DIR-DATN
            / '=' DIR-TIMN
            / '=' DIR-USERID
            / '=' DIR-PROGMODE
            / '=' DIR-SRCSIZE
            / '=' DIR-GPSIZE
            / '=' DIR-DDM-DBID
            / '=' DIR-DDM-FNR
          NEWPAGE
        END-IF
        /*
        IF NAT-IMPL = 'A'     /* Write header information
          WRITE (AD=LI)
            / 'DBID of DDM .......' HD-DBID
            / 'FNR of DDM ........' HD-FNR
            / 'Default sequence ..' HD-DEFSEQ
            / 'VSAM Subtype ......' HD-VSAM-SUBTYPE
            / 'VSAM Name .........' HD-VSAM-NAME
            /
        END-IF
        ESCAPE TOP
      END-IF
    /*
      IF SRC-LINE (IX) = MASK ('* /')    /* New page intended
        NEWPAGE
      END-IF
      WRITE SRC-LINE (IX)
    END-FOR
    /*
    OPT-ACCESS := 'R'
    /*
    IF *PF-KEY NE 'ENTR'
      OPT-ACCESS := 'C'
      CALLNAT 'USR1058N' USR1058L  USR1058N.EXTENDED-PARMS
        NAD-MSG   NAD-FLD
      ESCAPE BOTTOM (REP1.)
    END-IF
    /*
    IF MSG-NR NE 0
      IF NOT INPUT-OK AND RETURNED = 0
* NAD-MSG.MSG, MSG-DATA (1), MSG-DATA (2), MSG-DATA (3) and
* NAD-FLD.FIELD-POSITION is set
        ESCAPE BOTTOM
      ELSE
        WRITE (AD=LI)
          / 'Message number ....' NAD-MSG.MSG-NR
          / 'Message ...........' NAD-MSG.MSG (AL=59)
          / 'Message type ......' NAD-MSG.MSG-TYPE
          / 'Message data ......' NAD-MSG.MSG-DATA (1:3)
          // 'Field structure ...' NAD-FLD.FIELD-STRUCTURE
          / 'Field name ........' NAD-FLD.FIELD-NAME
          / 'Field position ....' NAD-FLD.FIELD-POSITION
          / 'Field index .......' NAD-FLD.FIELD-INDEX1
          NAD-FLD.FIELD-INDEX2
          NAD-FLD.FIELD-INDEX3
        ESCAPE BOTTOM (REP1.)
      END-IF
    END-IF
    /*
    INPUT-OK := TRUE    /* All parameter checks are done
  END-REPEAT
END-REPEAT
END
1 Like

thank you very much
Greetings