There are several ways to use structures when calling a function or subroutine. One with a direct reference to the sent structure, the other with a copy of it.
- Function declaration implicitly makes structure being sent the same 'pointer' as what's been used when function is called
function carrier_api_resp(ref s_lineitem as_li)
s_lineitem lineitem
return_code = carrier_api_resp(lineitem)
In this case, lineitem, and as_li are identical pointers to the structure and no copy was created
- Function declaration is that it takes only the structure, but not automatically by reference. In this case, a copy of the structure is made and sent to the function. Modifying any data in the structure will be lost when function is complete (unless you return the structure and assign/use it in the calling code).
function carrier_api_resp(s_lineitem as_li)
s_lineitem lineitem
return_code = carrier_api_resp(lineitem)
lineitem and as_li are different values here because the point to two different sets of data.
- Function declaration same as prev item, but when called, has the REF statement used, so it's functionally identical to first usage above
function carrier_api_resp(s_lineitem as_li)
s_lineitem lineitem
return_code = carrier_api_resp(ref lineitem)
lineitem and as_li are same when used this way as well, but you always need to remember the "ref" to make sure you're sending the actual structure and not a copy.
The help files do contain this info, but it's kinda spread out. Hopefully this helps condense it some and make it more understandable.
Hope this helps.