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



Comments in-line.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Jul 5, 2019, at 7:41 PM, Dexter Thompson <dexter.thompson@xxxxxxxxx> wrote:

I had an issue with a DS being passed to a Service Program and my updates
to it was not being passed back to the calling program.

Only way this could happen is if the keywords Const or Value were used on the parameter definition in the prototype which if the fields were to be updated should not have been use. In fact even with Const it would still have worked sometimes.

When a coworker
suggested pointers, my reaction is very similar to yours. But I had a lot
of respect for the person making he suggestion, so I tried it and worked
great. Since the data itself is not being passed, there is a little less
overhead, with my company, that is a premium.

This is simply not true. As I alluded in my previous response the normal way of passing parameters is for a pointer to be passed. There is no "overhead" in that - what you are doing potentially _adds_ overhead - minimal admittedly but nevertheless. If you want to get into the fundamentals of parameter passing try these: https://www.itjungle.com/2016/11/29/fhg112916-story01/ <https://www.itjungle.com/2016/11/29/fhg112916-story01/>. And the follow up https://www.itjungle.com/2017/02/20/guru-parameter-passing-fundamentals-programs-versus-procedures/ <https://www.itjungle.com/2017/02/20/guru-parameter-passing-fundamentals-programs-versus-procedures/> which discusses the differences between calling programs and procedures.

There are multiple ways to
accomplish your task and which works best for you is up to you.

True - but you also need to understand what works and why. In my opinion (and I think most folks here would agree with me) for a straightforward DS the approach you are using has no benefit and significantly raises the risk of a parameter mis-match thereby defeating the mechanisms provided by prototypes.

For me,
this worked great and gave me the flexibility to be able to pass parameters
in multiple formats.

And now you have identified the one possible benefit of this approach although I cannot for the life of me see how it would really work unless your DS structure is such that there is an identifier at the start of the DS that identifies its format. If that is the case then you can do the same thing without the risk of reverting to pointers. The latest updates to RPG (7.3 and 7.4 only) make this easy https://www.itjungle.com/2019/06/03/guru-7-4-brings-new-rpg-goodies/ <https://www.itjungle.com/2019/06/03/guru-7-4-brings-new-rpg-goodies/> and in particular the bit on "S/36 style" records towards the end. The same thing can be achieved with group fields but it is a lot more work.

Previously, there were middle programs taking
different parameter formats and then calling the service program with
single parameter format (the DS). By using the pointer and passing the
different parameter formats I was able to eliminate the middle programs and
reduce run time (again a premium where I work). Good luck.

On Fri, Jul 5, 2019 at 5:17 PM Justin Taylor <JUSTIN@xxxxxxxxxxxxx> wrote:

I don't entirely follow the details of what you're asking.

I often use DS as parameters or return values using the LikeDS() keyword.
I'll define the DS in the /copybook for the *SRVPGM (specifying Template)
and then have all the references use LikeDS().

HTH



-----Original Message-----
From: Greg Wilburn [mailto:gwilburn@xxxxxxxxxxxxxxxxxxxxxxx]
Sent: Friday, July 05, 2019 3:03 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: How best to pass a DS or DS Array

I don't know why I always struggle with this

I have created a sub procedure that uses an SQL cursor to gather a list of
ID numbers (see below). I mean this will work if I move the DS definition
to the main part of the pgm

So my question is how to define a parameter to return this data to the
main part of the pgm?
And how do I define the variable in the main part of the pgm?


dcl-pi CheckShipIDs;
inPID like(phpid#) const;
inPO like(phpo#) const;
end-pi;


dcl-ds ship qualified dim(10);
id char(20);
end-ds;
dcl-s maxrows uns(5) inz(%elem(ship));

Exec Sql
Declare pscsr Cursor for
Select distinct(psidcd) from POSDQPS
exception join ADRESSAD on adent#=:wkent# and adaltk=:psidcd
where pspid#=:inPID and pspo#=:inPO;

Exec Sql Open pscsr;
Exec Sql Fetch Next from pscsr For :maxrows Rows into :ship;



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

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com



--

*Dexter Thompson*
Software Engineer, iSeries Applications Support and Development

[image: Inmar]
<https://www.inmar.com/?utm_source=email%20signature&utm_medium=email&utm_campaign=Associate%20Email%20Signature&utm_content=Inmar%20Logo>

dexter.thompson@xxxxxxxxx
635 Vine Street, Winston Salem, NC 27101
*p: *555-555-5555 | *c: *123-123-1234 | *f: *123-456-7890
www.inmar.com
<https://www.inmar.com/?utm_source=email%20signature&utm_medium=email&utm_campaign=Associate%20Email%20Signature&utm_content=URL%20link>
| LinkedIn <https://www.linkedin.com/company/inmar> | Facebook
<https://www.facebook.com/inmarinc> | Twitter
<https://twitter.com/inmarinc>

--


********************************************





*Inmar Confidentiality
Note*: This e-mail and any attachments are confidential and intended to be
viewed and used solely by the intended recipient. If you are not the
intended recipient, be aware that any disclosure, dissemination,
distribution, copying or use of this e-mail or any attachment is
prohibited. If you received this e-mail in error, please notify us
immediately by returning it to the sender and delete this copy and all
attachments from your system and destroy any printed copies. Thank you for
your cooperation.





*Notice of Protected Rights*: The removal of any
copyright, trademark, or proprietary legend contained in this e-mail or any
attachment is prohibited without the express, written permission of Inmar,
Inc. Furthermore, the intended recipient must maintain all copyright
notices, trademarks, and proprietary legends within this e-mail and any
attachments in their original form and location if the e-mail or any
attachments are reproduced, printed or distributed.




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

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com


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.