× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 28-Oct-2015 06:33 -0500, Paul Roy wrote:
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>


FWiW: An unstated assumption of the above, is that the /packed/ Binary Coded Decimal (BCD) variable must be declared with an odd-length for the following expression to be functional [and, though not as noteworthy per the specific implied usage as shown for which a positive value is required, yet if more generally applied, negative values also would not be functional] with the given character-string expression of:

'X''' + %EDITC(Packed:'X') + 'F''

To overcome those restrictions\assumptions, the same Char2Hex() could be used against the storage for the Packed variable, thus eliminating the %EDITC; e.g. with no explanation for the chosen storage sizes, initialization, lack of %trimr, et al, the following addenda\revisions to the quoted code:

D LPacked S 10I 0 inz(4)
D CPacked S 8

Char2Hex(%addr(CPacked):%addr(Packed):LPacked) ;
Command = ... +
Pgmname + ') PARM( X''' +
CPacked + ''' X''' +
...


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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

This mailing list archive is Copyright 1997-2024 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.