Sample codes to add a new OS/400 share for MS Windows Client

This OS/400 CL creates new MS Windows share for OS/400.

Objective:
Sample Codes for ADD New OS/400 share for MS Windows Client (not required Client Access)

This OS/400 CL creates New MS Windows share for OS/400.

Requirements:
OS/400 V4R4 or above
Valid an IFS share
IFS Related subsystems must be running

CL used OS/400 "Add File Server Share (QZLSADFS) API"


 

Usage sample:
Share OS/400 CD Drive for Windows users

 
ADDSHARE SHARENAME(AS400CD) PATHNAME('/QOPT') TEXTDESC('AS400 CD DRIVER')
-----------------------------------------------------------------------
CMD Creation

CRTCMD CMD(yourlib/ADDSHARE) PGM(yourlib/ADDSHARE) +
    SRCFILE(yourlib/yourPFSourceFile) SRCMBR(ADDSHARECM)

-----------------------------------------------------------------------
ADDSHARECM.CMD Source

CMD
             PARM       KWD(SHARENAME) TYPE(*CHAR) LEN(12) +
                          CHOICE('New Share Name (MAX:12 chars)') +
                          PMTCTL(*PMTRQS) PROMPT('Share Name')
             PARM       KWD(PATHNAME) TYPE(*CHAR) LEN(20) +
                          CHOICE('First char must be slash U/U') +
                          PMTCTL(*PMTRQS) PROMPT('Share Path') /* +
                          'First char must be slash U/U' */
             PARM       KWD(TEXTDESC) TYPE(*CHAR) LEN(50) +
                          CHOICE('Share Comment') PMTCTL(*PMTRQS) +
                          PROMPT('Share comment') /* 'Share comment' */
             PARM       KWD(PERMS) TYPE(*CHAR) LEN(4) RTNVAL(*NO) +
                          RSTD(*YES) DFT(1) VALUES(1 2) +
                          CHOICE('''Permissions (1: R/O, 2:R/W)') +
                          PMTCTL(*PMTRQS) PROMPT('Permissons') /* +
                          '1: READ/ONLY 2:READ/WRITE' */
             PARM       KWD(MAXUSERS) TYPE(*CHAR) LEN(4) RSTD(*NO) +
                          DFT(-1) RANGE(-1 255) CHOICE('Max users +
                          (-1 to 255,-1:NOMAX)') PMTCTL(*PMTRQS) +
                          PROMPT('Max users')
-----------------------------------------------------------------------
ADDSHARE.CLP Source

/*****************************************************************/
/*                                                               */
/* ADD WINDOWS SHARE FOR AS/400                                  */
/*                                21.02.2002 MAB13               */
/*****************************************************************/
PGM PARM(&SHARENAME &PATHNAME &TEXTDESC &PERMS &MAXUSERS)

DCL VAR(&SHARENAME ) TYPE(*CHAR) LEN(12)

DCL VAR(&PATHNAME )  TYPE(*CHAR) LEN(20)
DCL VAR(&PATHNAMEL)  TYPE(*CHAR) LEN(4)

DCL VAR(&CCSPATHN)   TYPE(*CHAR) LEN(4)
DCL VAR(&TEXTDESC)   TYPE(*CHAR) LEN(50)
DCL VAR(&PERMS)      TYPE(*CHAR) LEN(4)
DCL VAR(&PERMSP)     TYPE(*CHAR) LEN(4)

DCL VAR(&MAXUSERS)   TYPE(*CHAR) LEN(4)
DCL VAR(&MAXUSERSP)  TYPE(*CHAR) LEN(4)

DCL VAR(&ERRORCODE)  TYPE(*CHAR) LEN(255)

DCL &LENGTH *DEC LEN(2) VALUE(20)
DCL &LENGTHC *CHAR LEN(4)


CHGVAR     VAR(%BIN(&CCSPATHN)) VALUE(0)
CHGVAR     VAR(%BIN(&MAXUSERSP)) VALUE(&MAXUSERS)
CHGVAR     VAR(%BIN(&PERMSP)) VALUE(&PERMS)

LOOP:
IF (%SUBSTRING(&PATHNAME &LENGTH 1) *EQ ' ') (DO)
    CHGVAR VAR(&LENGTH) VALUE(&LENGTH - 1)
    IF (&LENGTH *EQ 0) GOTO CMDLBL(EXIT)
    GOTO CMDLBL(LOOP)
ENDDO

CHGVAR VAR(&LENGTHC) VALUE(&LENGTH)
CHGVAR VAR(%BIN(&PATHNAMEL)) VALUE(&LENGTHC)


CALL       PGM(QZLSADFS) +
                PARM(&SHARENAME  +
                     &PATHNAME   +
                     &PATHNAMEL  +
                     &CCSPATHN   +
                     &TEXTDESC   +
                     &PERMSP     +
                     &MAXUSERS   +
                     &ERRORCODE)

IF (&ERRORCODE *NE '*') +
   SNDPGMMSG MSG('ERROR CODE:' *CAT &ERRORCODE)
   ELSE SNDPGMMSG MSG('SHARED RESOURCES SUCCESSFULY ADDED')
EXIT:
ENDPGM

-----------------------------------------------------------------------

Add File Server Share (QZLSADFS) API Parameters

 Required Parameter Group: 

1  Share name  Input  CHAR(12)  
2  Path name  Input  CHAR(*)  
3  Length of path name  Input  BINARY(4)  
4  CCSID encoding of path name  Input  BINARY(4)  
5  Text description  Input  CHAR(50)  
6  Permissions  Input  BINARY(4)  
7  Maximum users  Input  BINARY(4)  
8  Error code  I/O  CHAR(*)  
-----------------------------------------------------------------------
API Error Messages
CPF3C1E E  Required parameter &1 omitted.  
CPF3C36 E  Number of parameters, &1, entered for this API was not valid.  
CPF3CF1 E  Error code parameter not valid.  
CPF3CF2 E  Error(s) occurred during running of &1 API.  
CPFA0D4 E  File system error occurred.  
CPFB682 E  API &1 failed with reason code &2.  
CPFB683 E  Data conversion failed for API &1.  
CPFB684 E  User does not have the correct authority for API &1.  
CPFB68A E  Error occurred while working with shared resource &2.  
CPFB68B E  Character is not valid for value &3.  
CPFB68D E  Length specified in parameter &2 for API &1 not valid.  
CPFB693 E  Data conversion failed for &5 API.  
CPIB685 E  Error occurred on AS/400 Support for Windows Network Neighborhood (AS/400 NetServer) 

request.  

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your systems management questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our systems management gurus are waiting to answer your technical questions.

This was last published in February 2002

Dig Deeper on Performance

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close