Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Can I pass a variable to an RPG program and have it open the referenced file?Can I use another file to hold a list of fields I want to read?

0
Posted

Can I pass a variable to an RPG program and have it open the referenced file?Can I use another file to hold a list of fields I want to read?

0

Both of these questions are asking if RPG can use indirection to get files fields instead of declaring them directly in the program.The answer is a qualified yes. Using SQL, you can construct a dynamic SELECT statement to fetch data into your program. What you actually do with the buffer is up to you.The following sample code has no error handling and assumes that the values you are looking for are character, not decimal. If you try it with a decimal, you’ll get a -303 SQLCOD, telling you that the host variable is not compatible. It’s also missing the WHERE clause on the prepared SELECT statement – that’s where you’d select “that particular customer.” Also, you should probably use SQLSTT instead of SQLCOD.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123