×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




as parameters are passed as pointers.... depending on the format expected
by the called program you could use the following example :
you need to pass packed decimal as X'0000000F' or to expand binary data
to hexadecimal characters (using for example the MI cvthc
instruction/procedure)


<code>
H DFTACTGRP(*NO)
D PgmName S 10
D Packed S 7P 0
D Bin S 10I 0
D Lbin S 10I 0
D Command S 1024
D CmdLen S 15P 5
D CBin S 16
D RunCmd PR extpgm('QCMDEXC')
D cm 3000 options(*VarSize)
D const
D ln 15P 5 const
D Char2Hex PR ExtProc( 'cvthc' )
D * value
D * value
D 10I 0 value
C/free
PgmName = 'PGM000';
Packed = 1234;
Bin = 1234;
Lbin= 8;
Char2Hex(%addr(CBin):%addr(Bin):Lbin) ;
Command = 'SBMJOB CMD(CALL PGM(' +
PgmName + ') PARM( X''' +
%EDITC(Packed:'X') + 'F'' X''' +
%trim(CBin ) + ''') )' ;
CmdLen = %Len(%Trim(Command));
RunCmd(Command : CmdLen);
*INLR = *ON;
Return;
/End-free

</code>



From: CRPence <crpbottle@xxxxxxxxx>
To: midrange-l@xxxxxxxxxxxx
Date: 27/10/2015 21:34
Subject: Re: SBMJOB From RPGLE Passing numeric Fields
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx>



On 27-Oct-2015 14:30 -0500, gio.cot wrote:

I would from RPGLE run a SBMJOB that call a program passing numeric
parameters .. is it possible ?

The means to do so are possible from any language, and the
requirements remain the same irrespective of language. So despite the
topic seemingly more appropriate on the language-specific forum, my
reply is generically presented for any language.


Example

D Runcmd PR EXTPGM('QCMDEXC')
D Cmdstr 3000A CONST OPTIONS(*VARSIZE)
D Cmdlen 15P 5 CONST
D Cmddbcs 3A CONST OPTIONS(*NOPASS)

D Q C ''''

D Command_String S 3000A Varying

Command_String =
'SBMJOB CMD(CALL PGM('+ q + MyPgm + q +') PARM(' +
Q + DbTrgDs + Q DbTrgLen '))';

Runcmd(Command_String : %LEN(%TRIMR (Command_String)));


Whatever is being done in the above, is probably worth discussion in
a fresh topic, *before* attempting to continue down that path; depending
on requirements, the path possibly of a downward spiral, into a
nightmarish hellhole.

The passing of a Data Structure (DS) is almost sure to fail, if not
pervasively and catastrophically, then worse, sometimes and\or only
subtly with unexpected effects. What is alluded by the described [or
should I suggest, what I infer from the described] could be functional
more generally, only *if* the DS were exposed as a hexadecimal string
prefixed by X to denote that the character string is passed as a
hexadecimal character string.


N.B. DBTRGLEN is B(9,0)

The proper designation for the data type\length of the second
argument for a trigger program is INTEGER, or for the RPG, that would be
in fixed-form 10I00 [instead of the 09B00 shown {expressed however, as
B(9,0)}].


How can I do it ?


As a command /string/, a numeric value must appear as the character
representation of the numeric value.

In a concatenation expression to place the numeric value within that
string, requires one of:
? that the numeric variable would be replaced by an expression that
explicitly converts the numeric value into a character-string value
? a character [string] variable takes the place of the numeric
variable in the concatenation expression, after a conversion casting the
value from the numeric variable into the character variable has already
transpired
? that the language has an implicit casting from numeric to
character [and that the effect meets the requirements] thus allowing the
numeric variable to remain in the character concatenation expression

For the RPG language, the %EDITC() built-in is one means to convert
the numeric value for the variable DbTrgLen into a character-string,
thus allowing the first of the above; e.g. %editc(DbTrgLen:'L') in place
of DbTrgLen in the currently coded expression. Or that same Editing
expression could assign a variable, perhaps named CharDbTrgLen, and
declared as 11 or more characters; e.g. prior to the currently coded
expression, include a CharDbTrgLen=%editc(DbTrgLen:'L'), and replace the
DbTrgLen in the concatenation expression with CharDbTrgLen. But for
lack [of my knowing of] any implicit casting in the RPG, I do not
believe the last of those options are possible.

For any other language, the effective equivalent; both the issues
with the scenario [notably an effective DS, expressed as a
character-string, is likely to be problematic at best], and the
requirement to convert the numeric value into a character string
[because the input to the command-interpreter APIs will be a
command-string].


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.