*************** Beginning of data **************************************** CMD PROMPT('Retrieve Short Name(QDBRTVSN)') PARM KWD(File) TYPE(Obj) MIN(1) PROMPT('Long File Name') obj: QUAL TYPE(*NAME) LEN(128) MIN(1) QUAL TYPE(*CHAR) LEN(10) DFT(*LIBL) + SPCVAL((*LIBL) (*USRLIBL) (*LIB)) + CHOICE('*LIBL,*USRLIBL,*LIB if Library') + PROMPT('Library') ****************** End of data ******************************************* *************** Beginning of data **************************************** h DFTACTGRP(*NO) * The Retrieve Short Name(QDBRTVSN) API allows you to get the 10-character * object name of a database file or library by providing the long object name. * The information is returned as a qualified object name. * (Objects with long object names can be created using SQL CREATE statements. * An object with a long name also has a short 10-character name.) *http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=/apis/qdbrtvsn.htm D RTVSHRTNAM Pr EXTPGM('RTVSHRTNAM') D LName LikeDs(LongName) D RTVSHRTNAM Pi D LName LikeDs(LongName) D QDBRTVSN PR ExtPgm('QDBRTVSN') D QualObj 20a const D LongName 128a const D LenLongNam 10i 0 const D LongNameLib 10a const D errorCode 32783a options(*varsize) D QUILNGTX PR ExtPgm('QUILNGTX') D text 65535a const options(*varsize) D length 10i 0 const D msgid 7a const D qualmsgf 20a const D errorCode 32783a options(*varsize) D SndPgmMsg Pr ExtPgm( 'QMHSNDPM' ) D MsgId 7a Const D MsgFq 20a Const D MsgDta 128a Const D MsgDtaLen 10i 0 Const D MsgTyp 10a Const D CalStkE 10a Const Options( *VarSize ) D CalStkCtr 10i 0 Const D MsgKey 4a D Error 32767a Options( *VarSize ) D SndEscMsg Pr 10i 0 D MsgId 7a Const D MsgF 10a Const D MsgDta 512a Const Varying D ErrorNull ds qualified D BytesProv 10i 0 inz(0) D BytesAvail 10i 0 inz(0) D ERRC0100 Ds Qualified D BytPrv 10i 0 Inz( %Size( ERRC0100 )) D BytAvl 10i 0 D MsgId 7a D 1a D MsgDta 1024a D LongName ds qualified D Object 128a D Library 10a D ShortName ds qualified D Object 10a D Library 10a d msg s 512a D NULL c '' D Slash s 1a inz('/') /free if LName.Library = '*LIB'; LName.Library = ' '; //Must pass *blanks if longname is a library endif; QDBRTVSN( ShortName : LName.Object : %len(LName.Object) : LName.Library : ERRC0100); If ERRC0100.BytAvl > *Zero; ExSr EscApiErr; EndIf; if LName.Library = ' '; slash = ' '; endif; msg = 'Long name: ' + %trim(LName.Library) + Slash + %trim(LName.Object) + ' Short Name: ' + %trim(ShortName.Library) + '/' + %trim(ShortName.Object) ; QUILNGTX( msg : %len(msg) : ' ' : ' ' : ErrorNull ); *inlr = *on; //------------- BegSr EscApiErr; If ERRC0100.BytAvl < 16 ; ERRC0100.BytAvl = 16 ; EndIf; SndEscMsg( ERRC0100.MsgId : 'QCPFMSG' : %Subst( ERRC0100.MsgDta: 1: ERRC0100.BytAvl - 16 ) ); EndSr; /end-free P SndEscMsg B D Pi 10i 0 D MsgId 7a Const D MsgF 10a Const D MsgDta 512a Const Varying ** D MsgKey s 4a /Free SndPgmMsg( MsgId : MsgF + '*LIBL' : MsgDta : %Len( MsgDta ) : '*ESCAPE' : '*PGMBDY' : 1 : MsgKey : ERRC0100 ); If ERRC0100.BytAvl > *Zero; Return -1; Else; Return 0; EndIf; /End-Free P SndEscMsg E ****************** End of data *******************************************