RPGLE CL Command to call aprogram with numeric parameter
PGM : TESTHEX
H DftActGrp(*NO) Option(*SRCSTMT)
D charval S 26a inz('123.00')
DRunCommand PR ExtPgm('QCMDEXC')
DpCommand 2560 const
DPCmdLen 15 5 const
DpCommand S 2560
DPCmdLen S 15 5 inz(2560)
/Free
Charval = %replace('':Charval:%Scan('.':CharVal):1); // to remove '.'
If %Rem(%len(%trim(Charval)):2) = 1; //length of numeric value must be odd //So When F is added at end it always even
Charval = 'X' + '''' + %Trim(Charval) + 'F''';
Else;
Charval = 'X' + '''' + '0' + %Trim(Charval) + 'F'''; // value will be X'12300F'
EndIf;
pCommand = 'CALL DEVDPRJ/TESTHEXO PARM('+%Trim(CharVal)+' ' +
%Trim(CharVal)+ ')';
Monitor;
RunCommand(pCommand:%Len(pCommand));
On-Error;
EndMon;
*inlr = *on;
Return;
/End-Free
PGM: TESTHEXO
H Option(*SrcStmt:*NoDebugIo)
*
*
*
DEntryPram PR ExtPgm('TESTHEXO')
DNumparm1 5 0
DNumparm2 5 2
DEntryPram PI
DNumparm1 5 0
DNumparm2 5 2
/Free
Dsply %Char(Numparm1);
Dsply %Char(Numparm2);
*inlr = *On;
Return;
/End-Free
Displays
12300
123.00
H DftActGrp(*NO) Option(*SRCSTMT)
D charval S 26a inz('123.00')
DRunCommand PR ExtPgm('QCMDEXC')
DpCommand 2560 const
DPCmdLen 15 5 const
DpCommand S 2560
DPCmdLen S 15 5 inz(2560)
/Free
Charval = %replace('':Charval:%Scan('.':CharVal):1); // to remove '.'
If %Rem(%len(%trim(Charval)):2) = 1; //length of numeric value must be odd //So When F is added at end it always even
Charval = 'X' + '''' + %Trim(Charval) + 'F''';
Else;
Charval = 'X' + '''' + '0' + %Trim(Charval) + 'F'''; // value will be X'12300F'
EndIf;
pCommand = 'CALL DEVDPRJ/TESTHEXO PARM('+%Trim(CharVal)+' ' +
%Trim(CharVal)+ ')';
Monitor;
RunCommand(pCommand:%Len(pCommand));
On-Error;
EndMon;
*inlr = *on;
Return;
/End-Free
PGM: TESTHEXO
H Option(*SrcStmt:*NoDebugIo)
*
*
*
DEntryPram PR ExtPgm('TESTHEXO')
DNumparm1 5 0
DNumparm2 5 2
DEntryPram PI
DNumparm1 5 0
DNumparm2 5 2
/Free
Dsply %Char(Numparm1);
Dsply %Char(Numparm2);
*inlr = *On;
Return;
/End-Free
Displays
12300
123.00
Comments
Post a Comment