No announcement yet.

using listagg and %lookup

  • Filter
  • Time
  • Show
Clear All
new posts

  • using listagg and %lookup

    I have not used listagg in RPGLE pgm before but figured I'd give it a try, so my result set could be up to 50 rows from the CONFIG table (and I want 2 char codes for each) and it seems the listagg only like a "standalone" field to load into, I'm stuck on how to get the lookup. Can I not just lookup from a qualified array structure?

    This code did not compile with an error on the lookup

    D LoadDc DS Qualified Dim(50)
    D DCList 100A
    D dcListA 2A Overlay(DCList:1)


    Exec Sql
    Select listagg(extchar)
    Within group (order by extchar) as List
    Into: LoadDc.DCList
    From CONFIG
    Where config_name = 'TESTING';

    If %lookup(29:LoadDc(*).dcListA) > 0;
    'found lookup';
    'not found';
    Last edited by kast1; 1 week ago.
    Golf is a game in which you yell "fore," shoot six, and write down five.

  • #2
    Your %Lookup syntax is wrong. Since you declared the array to be 2A then the search argument must be character. i.e. it should be %lookup('29':LoadDc(*).dcListA) > 0;

    But that may not end up giving the results you want. You could declare the array as zoned and that would work with the numeric 25.

    As to the use of ListsAgg - sorry not familiar with it and don't have time to play.