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



On 30 Sep 2013 10:13, Kari Zeglin wrote:

I am a newbie at RPGLE. What I am doing is a migration conversion
program from the HP to IBM for my work. I currently have the program
scan for one line and change the HP command to an AS400 one. I have
it working perfectly in most areas but one.

I need to scan these two lines as example:
FILE DATAIN=FEDRECD1
FILE DATAOUT=FEDSRTD

From there I need to turn those two lines into:
CPYF FROMFILE(FEDRECD1) TOFILE(QTEMP/FEDSRTD) +
CRTFILE(*YES)

I can get my output to be, using EVAL %SUBST:
CPYF FROMFILE(FEDRECD1) TO FILE(QTEMP/ ) +
CRTFILE(*YES)

<<SNIP code>>

My question is what can I use/do to have my program scan these two
lines of code and get it into one line, or have my separate SR's
<ed:¿SubRoutines?> talk to get DATAIN/OUT in the correct positions
on one line?

FWiW: Changing those *two lines* of FILE control [¿JCL-like?] statements into the effective equivalent of the shown *two lines* of a Copy File (CPYF) request [conspicuously, not merged into one line], the following SQL UPDATE could suffice. There are a number of mostly unstated assumptions for that SQL statement, aside from: no non-blank data follows the file name in each. Some reliance on hard assumptions are potentially softened [e.g. by use of the LOCATE scalar and the EXISTS predicate] if the selection must similarly must be loosened from what is shown in the WHERE clause, but with even more hardened\fixed rules, the statement could be reduced in complexity.

The RPG could use the same idea to resolve the described issue; i.e. reformat the CPYF request so that both... the FROMFILE is written to the line with the DATAIN= and the TOFILE is written to the line with the DATAOUT=.

<code>

update TheSrcFile /* either ALIAS or OVRDBF to specific mbr */
set srcdta =
case left(srcdta, 12)
when 'FILE DATAIN=' then 'CPYF FROMFILE(' concat
rtrim( substr( srcdta
, nullif( locate( 'DATAIN=' , srcdta ), 0 ) + 7)
) concat ') +'
when 'FILE DATAOUT' then ' TOFILE(QTEMP/' concat
rtrim( substr( srcdta
, nullif( locate( 'DATAOUT=' , srcdta ), 0 ) + 8)
) concat ') CRTFILE(*YES)'
end
where srcdta like 'FILE DATAIN=%'
or srcdta like 'FILE DATAOUT=%'
and exists ( select count(*)
from TheSrcFile
where srcdta like 'FILE DATAIN=%'
or srcdta like 'FILE DATAOUT=%'
having count(*)=2 )

</code>

The effect of that UPDATE for the given example [given all assumptions hold true] would become the following, reformatted from the as-described desired effect, but the overall effect in function, is identical. Again, the /same command string formatting/ to resolve the described issue could be employed using the RPG vs the SQL:

CPYF FROMFILE(FILEINPUT) +
TOFILE(QTEMP/FILEOUTPUT) CRTFILE(*YES)


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.