如何於 CLP 中取得 Dataarea 的屬性(Command: CHKDTAARA by API QWCRDTAA)
File : QRPGLESRC
Member: CHKDTAARAR
Type : RPGLE
Usage : CRTBNDPGM CHKDTAARAR
OS : V5R1(含)以後
*************************************************************
* *
* Program Name: CHKDTAARA Author: Vengoal Chang *
* Create Date: 03/08/2007 *
* Purpose: To Retrieve Data Area Attributes *
* *
*************************************************************
h debug
* Parameter Definition
dMain PR ExtPgm('CHKDTAARA')
d DataArea 20a Const
d DataType 10a
d Length 5 0
d DecPos 5 0
d ErrMsgId 7
* Parameter Entry
dMain PI
d DataArea 20a Const
d DataType 10a
d Length 5 0
d DecPos 5 0
d ErrMsgId 7
* Retrieve Data Area API
dChkDtaAra PR ExtPgm('QWCRDTAA')
d ReturnVar 255a Options(*VarSize)
d ReturnLen 10i 0 Const
d QualDataArea 20a Const
d StartPos 10i 0 Const
d DataLen 10i 0 Const
d ErrorCode LikeDS(ApiError)
* Returned Data Structure
D ReturnDS ds Qualified
d BytesAvail 10i 0
d BytesReturned 10i 0
d DataType 10a
d Library 10a
d RtnLength 10i 0
d DecPos 10i 0
d Data 300a
* Work Variables
**-- Api error data structure: -----------------------------------------**
D ApiError Ds
D AeBytPro 10i 0 Inz( %Size( ApiError ))
D AeBytAvl 10i 0 Inz
D AeMsgId 7a
D 1a
D AeMsgDta 128a
**
/free
// Retrieve The Data Area Attributes
ChkDtaAra( ReturnDS :
%Size(ReturnDS) :
DataArea :
-1:
32000:
ApiError);
if (AeBytAvl = 0);
// Load Return Variables
DataType = ReturnDS.DataType;
Length = ReturnDS.RtnLength;
DecPos = ReturnDS.DecPos;
ErrMsgId = *blanks;
else;
dump;
DataType = ' ';
ErrMsgId = AeMsgId;
Length = 0;
DecPos = 0;
endif;
// Terminate
*inlr=*on;
return;
/end-free
File : QCMDSRC
Member: CHKDTAARA
Type : CMD
Usage : CRTCMD CMD(CHKDTAARA) PGM(CHKDTAARAR) ALLOW(*IPGM *BPGM)
OS : V5R1(含)以後
[code]
/* TO COMPILE SPECIFY */
/* ALLOW(*IPGM *BPGM *IMOD *BMOD *IREXX *BREXX) */
/* ON THE CRTCMD COMMAND */
/*__________________________________________________________*/
CMD PROMPT('Check Data Area Attributes')
PARM KWD(DTAARA) TYPE(Q1) MIN(1) PROMPT('Data +
Area:')
PARM KWD(TYPE) TYPE(*CHAR) LEN(10) RTNVAL(*YES) +
PROMPT('Data Type:')
PARM KWD(LEN) TYPE(*DEC) LEN(5 0) RTNVAL(*YES) +
PROMPT('Data Length:')
PARM KWD(DECPOS) TYPE(*DEC) LEN(5 0) RTNVAL(*YES) +
PROMPT('Decimal Positions:')
PARM KWD(ERRMSGID) TYPE(*CHAR) LEN(7) +
RTNVAL(*YES) PROMPT('API Error MsgId:')
Q1: QUAL TYPE(*NAME) LEN(10)
QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) +
SPCVAL((*LIBL) (*CURLIB)) PROMPT('Library:')
[/code]
File : QCLSRC
Member: CHKDTAARAT
Type : CLP
Usage : CRTCLPGM PGM(CHKDTAARAT)
CALL CHKDTAARAT ('library' 'dataarea-name')
你可以使用 CRTDTAARA DTAARA(QTEMP/TEMP) TYPE(*CHAR) LEN(10)
call CHKDTAARAT ('QTEMP' 'TEMP')
[code]
PGM (&LIB &DTAARA)
DCL &LIB *CHAR 10
DCL &DTAARA *CHAR 10
DCL &TYPE *CHAR 10
DCL &DTALEN *DEC 5 0
DCL &DECPOS *DEC 5 0
DCL &DTALENC *CHAR 5
DCL &DECPOSC *CHAR 5
DCL &ERRMSGID *CHAR 7
CHKDTAARA DTAARA(&LIB/&DTAARA) TYPE(&TYPE) +
LEN(&DTALEN) DECPOS(&DECPOS) +
ERRMSGID(&ERRMSGID)
CHGVAR &DTALENC &DTALEN
CHGVAR &DECPOSC &DECPOS
SNDPGMMSG MSG('Data area' *bcat +
&lib *TCAT '/' *CAT &DTAARA *tcat +
', Type:' *bcat &type *tcat +
', Length:' *bcat &DTALENC *tcat +
', Decpos:' *bcat &DECPOSC *tcat +
', ApiErrMsgId:' *bcat &ErrMsgId)
ENDPGM
A blog about IBM i (AS/400), MQ and other things developers or Admins need to know.
星期二, 11月 07, 2023
2007-03-09 如何於 CLP 中取得 Dataarea 的屬性(Command: CHKDTAARA by API QWCRDTAA)
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言