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



HI Martin

I have followed Nadir's example and attaching the same code snippet as well



P getAll B EXPORT

D getAll PI

D students_...

D LENGTH 10i 0

D students likeds(studentRec) dim(1000)

D options(*varsize)

D httpStatus 10i 0

D httpHeaders 100a dim(10)

/FREE

clear httpHeaders;

clear students;

students_LENGTH = 0;



openStudentDB();



setll *loval STUDENTDB;

read(e) studentR;

if (%ERROR);

httpStatus = H_SERVERERROR;

return;

endif;



dow (NOT %eof);

students_LENGTH = students_LENGTH+1;

students(students_LENGTH).studentID = studentID;

students(students_LENGTH).firstName = firstName;

students(students_LENGTH).lastName = lastName;

students(students_LENGTH).gender = gender;



read(e) studentR;

if (%ERROR);

httpStatus = H_SERVERERROR;

return;

endif;

enddo;



httpStatus = H_OK;

httpHeaders(1) = 'Cache-Control: no-cache, no-store';



closeStudentDB();

/END-FREE
P getAll E


"STUDENTS_LENGTH": 5,
"STUDENTS": [
{
"STUDENT1": {
"STUDENTID": "ty3411",
"FIRSTNAME": "test3",
"LASTNAME": "test2",
"GENDER": "male"
},
{
"STUDENT1": {
"STUDENTID": "ty3433",
"FIRSTNAME": "test3",
"LASTNAME": "test2",
"GENDER": "male"
},

{
"STUDENT1": {
"STUDENTID": "ty3456",
"FIRSTNAME": "test1",
"LASTNAME": "test2",
"GENDER": "male"
},

{
"STUDENT1": {
"STUDENTID": "ty3457",
"FIRSTNAME": "test1",
"LASTNAME": "test2",
"GENDER": "male"
},
{
"STUDENT1": {
"STUDENTID": "ty3458",
"FIRSTNAME": "test1",
"LASTNAME": "test2",
"GENDER": "male"
}
}
]


There are 5 records in database only. This works like a charm . It helps
in performance and resources as well.

Hope it helps

Thanks
Anshul

On Mon, Jul 15, 2019 at 9:11 PM Booth Martin <booth@xxxxxxxxxxxx> wrote:

huh? This is totally new to me... Let me say it back...

So, if this time there are 3 rows of data then I will get 3. If there
are 9 rows, I will get 9 and only 9?

I would very much like to see an example of that.

On 7/15/2019 8:00 PM, anshul narang wrote:
So to avoid that issue of populating blank values . We use the concept
Nadir/Martin pointed out in which we will have two output prams length
and
datastructure . When you are deploying yhe webservices , please uncheck
the
detect field length. Then you will have option with length of 20 and in
drop down you can use length for dim.a

Benefit of using it is you will have now 3 rows not 20 and you will have
one more output called length,

{
"XXX_DS": [
{ first datastructure row },
{ second datastructure row},
{third datastructure row } ]
"length":3 }

Without Length concept
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.




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