Help with nested data structures/arrays

<dfreinkel-cbKQUZO/W6aaLr2CDSiKrwC/[email protected]>
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <[email protected]>
This is something I have not done before, working with nested data
structures.

 

Here is an abbreviated definition of the data structure.

 

        dcl-ds dsOBK368 qualified;

 

          CMSnumber               varchar(6) ;   // obcsq100.kcms#

          EnteredBy               varchar(10);   // obcsq100.kenusr

 

          Currency                varchar(3);    // mscmp100.ccrcd

                                                 // Use USD if blank

 

          dcl-ds dsErrorUsers     likeds(dsErrorUsers_t) dim(5) ;

 

          SalesmanNumber          varchar(3);    // obcsq100.ksalno

          SalesManName            varchar(25);   // sasmp100.smnam

          

          dcl-ds dsCMSLines       likeds(dsCMSLines_t) dim(100) ;

        end-ds;

 

        dcl-ds dsErrorUsers_t           qualified Template;

          User                varchar(10);   // obcsq100.ke1usr

                                             // obcsq100.ke2usr

                                             // obcsq100.ke3usr

                                             // obcsq100.ke4usr

                                             // obcsq100.ke5usr

        end-ds;

 

        dcl-ds dsCMSLines_t              qualified Template;

          LineNumber          varchar(3);    // obcsq200.kline

          Product             varchar(15);   // obcsq200.kprdn

          ReasonCode          varchar(3);    // obcsq200.klrcd

          ReturnQuantity      varchar(6);    // obcsq200.klnqty (5,0)

          InvoicePrice        varchar(15);   // obcsq200.kinvpr (13,3)

          RequestedPrice      varchar(15);   // obcsq200.kreqpr (13,3)

          ListPrice           varchar(15);   // obcsq200.kprice (13,3)

          CMSAmount           varchar(15);   // List Price * Return Qty

          ApprovalType        char(1);       // obcsq100.kcmsty

          NextUser            varchar(10);   // obcsq100.knxusr

          NextApprover        varchar(10);   // obcsq100.knxapv

          EditAllowed         char(1);       // Default Y

        end-ds;

 

Snippet of RPG

 

            dsOBK368.dsCMSLines[wCount].LineNumber     =
%char(dsOBCSQ200_a.KLINE) ;

            dsCMSLines[wCount].Product        = dsOBCSQ200_a.KPRDNO ;

            dsOBK368.dsCMSLines.ReasonCode     = dsOBCSQ200_a.KLRCD ;

 

 

Question:

1.	How do I increment the element number ? The above does not get past
the compiler. I have tried it the other way too. 

dsCMSLines.Product[wCount]        = dsOBCSQ200_a.KPRDNO ;

 

2.	Compiler complains about the first lines saying the field types are
not the same. However, I am converting the packed to character using %CHAR.

 

This is an SQLRPGLE program on v7.4.

 

 

Thank you.

Darryl Freinkel

A4G

Telephone: 770.321.8562 

 

-- 
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org for any subscription related questions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.