Examples of Using Direct Commands

This section provides examples for using Object Handler direct commands.

Tip:
For additional examples, you can view the command generated for an Object Handler function. This command is automatically displayed when you use a wizard. In advanced-user mode, you can activate the display of the command by either entering the Object Handler command SET ADVANCEDCMD ON or setting the parameter Display-Cmd-in-Advanced-Mode to Y (Yes) in the Object Handler profile (see also Profile Settings).


Unloading Objects for the Same Platform

This section contains examples of how to unload objects in internal format to a work file in order to load them on the same platform, within either a local mainframe, UNIX, OpenVMS or Windows environment:

  • Unload all Natural programming objects (source objects only) from library ABC:

    UNLOAD * LIB ABC OBJTYPE N SCKIND S
  • Unload all Natural programming objects (cataloged objects only) from library ABC:

    UNLOAD * LIB ABC OBJTYPE N SCKIND C
  • Unload all Natural programming objects (cataloged objects and source objects) from library ABC:

    UNLOAD * LIB ABC OBJTYPE N SCKIND A
  • Unload all Natural programming objects (source objects only) from library ABC to load in library ABCNEW:

    UNLOAD * LIB ABC OBJTYPE N SCKIND S WITH NEWLIBRARY ABCNEW
  • On a mainframe: Unload all DDMs whose names start with EMP and which point to database 88:

    UNLOAD EMP* LIB * OBJTYPE D DDMDBID 88
  • On UNIX, OpenVMS or Windows: Unload all DDMs whose names start with EMP and which point to database 88:

    UNLOAD EMP* LIB * OBJTYPE N NATTYPE V DDMDBID 88
  • On UNIX, OpenVMS or Windows: Unload all DDMs whose names start with EMP from library VLIB to load in library VLIBNEW:

    UNLOAD EMP* LIB VLIB OBJTYPE N NATTYPE V WITH NEWLIBRARY VLIBNEW
  • Unload all user-defined error messages from library ERRLIB to load in library NEWERR:

    UNLOAD * LIB ERRLIB OBJTYPE E SLKIND A WITH NEWLIBRARY NEWERR
  • On Windows: Unload all Natural programming objects (cataloged objects and source objects) from library ABC to a portable work file on a PC:

    UNLOAD * LIB ABC OBJTYPE N WHERE WORKFILE C:\WF1.SAG WORKFILETYPE PORTABLE

    or

    UNLOAD * LIB ABC OBJTYPE N WHERE WORK C:\WF1.SAG WFT P

Unloading Objects for Different Platforms

This section contains command examples of how to unload objects in Transfer format to a work file in order to load them on a different platform such as unloading in a mainframe and loading in a UNIX, an OpenVMS or a Windows environment.

  • Unload all Natural programming objects (source objects only) from library ABC:

    UNLOAD * LIB ABC OBJTYPE N WHERE TRANSFER
  • Unload all Natural programming objects (source objects only) and user-defined error messages from library ABC:

    UNLOAD * LIB ABC WHERE TRANSFER
  • Unload all Natural programming objects (source objects only) from library ABC with fixed record length:

    UNLOAD * LIB ABC OBJTYPE N WHERE TRANSFER FIXEDLENGTH

Loading Objects in Internal Format

This section contains command examples of how to load objects from a work file in internal format.

  • Load all objects to library LIBNEW and replace any that already exist:

    LOADALL WITH NEWL LIBNEW WHERE REPLACE ALL
  • Load all object with target library TGTLIB to the new target library NEWTGT:

    LOAD * LIB TGTLIB WITH NEWLIBRARY NEWTGT
  • Load the user-defined error messages 1000 to 1500 from library ERRLIB only:

    LOAD * LIB ERRLIB OBJTYPE E FMNUM 1000 TONUM 1500

Loading Objects in Transfer Format

This section contains command examples of how to load objects from a work file in Transfer format.

  • Load all objects to library LIBNEW and replace any that already exist:

    LOADALL WITH NEWL LIBNEW WHERE TRANSFER REPLACE ALL
  • Load all object with target library TGTLIB to new target library NEWTGT:

    LOAD * LIB TGTLIB WITH NEWLIBRARY NEWTGT WHERE TRANSFER

Batch Processing in a Remote Environment

You can use direct commands to unload objects in batch mode from a remote Natural Development Server (NDV) environment or load objects in batch into a remote NDV environment.

The examples in this section illustrate the use of direct commands in batch to transfer objects from one remote NDV environment to another.

Input Commands in CMSYNIN File

MAP ENVIRONMENT=UX1 SUNNAT63 6312 SAG
SYSOBJH
UNMAP
MAP ENVIRONMENT=MF1 IBM2 4742 SAG
SYSOBJH
UNMAP
FIN

Input Data in CMOBJIN File

UNLOAD * LIB SAG-TEMP %
WHERE TRANS WFLOC PC WORK D:\NAT-Work\w1.dat REPORT
SHOW STATISTICS
END
LOADALL WHERE TRANS WFLOC PC WORK D:\NAT-Work\w1.dat %
REPLACE ALL REPORT
SHOW STATISTICS
END

Explanation of File Contents

MAP ENVIRONMENT=UX1 SUNNAT63 6312 SAG Maps to an NDV environment on a UNIX or an OpenVMS platform.
SYSOBJH Invokes the Object Handler (on the Windows client) that receives the following three commands from the input data in the CMOBJIN file:

UNLOAD * LIB SAG-TEMP %
WHERE TRANS WFLOC PC WORK D:\NAT-Work\w1.dat REPORT

Causes the Object Handler to unload all objects from library SAG-TEMP in the remote UNIX or OpenVMS environment into the work file contained in the local Windows directory D:\NAT-Work\w1.dat.

SHOW STATISTICS

Writes statistical data about the unloaded objects to the CMPRINT output file.

END

Terminates the Object Handler.

UNMAP Unmaps the NDV environment on the UNIX or OpenVMS platform.
MAP ENVIRONMENT=MF1 IBM2 4742 SAG Maps to an NDV environment on a mainframe platform.
SYSOBJH Invokes the Object Handler (on the Windows client) that receives the following three commands from the input data in the CMOBJIN file:

LOADALL WHERE TRANS WFLOC PC %
WORK D:\NAT-Work\w1.dat REPLACE ALL REPORT

Causes the Object Handler to load all objects from the work file in the local Windows directory D:\NAT-Work\w1.dat into the remote mainframe environment.

SHOW STATISTICS

Writes statistical data about the loaded objects to the CMPRINT output file.

END

Terminates the Object Handler.

UNMAP Unmaps the NDV environment on the mainframe platform.
FIN Terminates the Natural batch session.