× 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.



Another advantage is that these definitions can be in sub procedures.
CTDATA is always global.


You do want to be careful with "Ascend' on these types of data structures because Ascend kicks the lookup into a Binary tree lookup. You must sort the values as you load them in the source. Otherwise the lookup may fail even though the element exists in the list.


You can also use the definition from the array on the sub elements. Makes it easier for when you suddenly decide they all need to be longer.

dcl-ds *N;
*N Like(OkList) Inz('CPF3C51');
*N Like(OkList) Inz('CPF3C52');
*N Like(OkList) Inz('CPF3C53');
*N Like(OkList) Inz('CPF3C54');
*N Like(OkList) Inz('CPF3C55');
OkList Char(7) Dim(5) Pos(1) Ascend;
end-ds;


And you are not limited to one array wide.

Dcl-Ds *N;
*N Like(Sorts) INZ('DDescription,Upc');
*N Like(Sorts) INZ('UUPC');
*N Like(Sorts) INZ('SSize, Upc');
*N Like(Sorts) INZ('CCategory Dpt/Cat/Sub');
*N Like(Sorts) INZ('IItem Code');
*N Like(Sorts) INZ('AAlt Item Code');
*N Like(Sorts) INZ('PCase Pack, UPC');
Sorts Char(26) POS(1) DIM(7);
Sortkey Char(1) OVERLAY(Sorts);
Sortdesc Char(25) OVERLAY(Sorts:*NEXT);
End-Ds;

IF %LOOKUP(S0SORT:SortKey) = 0;
*IN89 = *ON;
CALLP MSGSEND('ERR9996':'Invalid sort by.');
ELSE;
S0SORTDESC = SortDesc( %LOOKUP(S0SORT:SortKey));
Endif;





Chris Hiebert
Senior Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the author and do not necessarily represent those of the company.
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Alan Campin
Sent: Friday, July 28, 2017 12:04 PM
To: RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
Subject: This is cool.

dcl-ds *N;
*N Char(7) Inz('CPF3C51');
*N Char(7) Inz('CPF3C52');
*N Char(7) Inz('CPF3C53');
*N Char(7) Inz('CPF3C54');
*N Char(7) Inz('CPF3C55');
OkList Char(7) Dim(5) Pos(1) Ascend;
end-ds;


If %Lookup(ErrorReturn.MessageId:OkList) > 0;

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.