0 pts.
 How to operating with Multiple Member PF in RPG ?
I have a multiple member physical file and I want to operate(read/update/delete) with specific member in RPG. The member name for that PF need to be set at runtime depending upon from which program this rpg program is called. I am writing the sample code that I was trying, but it ends up with compilation errors on setll and read statements. FFileA IF F 731 Disk Extfile(File) F Extmbr(Mbr) F Usropn FFile1 UF A E K Disk DFile S 10 Inz(' ') DMbr S 10 Inz(' ') c *entry plist c parm pgmname c* c eval File = 'File1' c if pgmname = 'Pgm1' c eval Mbr = 'Mbr1' c endif c if pgmname = 'Pgm2' c eval Mbr = 'Mbr2' c endif c open FileA c *loval setll FileA c read FileA c dow not %eof(FileA) c* rcdfmt is record format name of File1 c delete rcdfmt c read FileA c enddo Thanks & regards, Alok.

Software/Hardware used:
ASKED: November 18, 2005  12:06 AM
UPDATED: November 20, 2009  7:50 AM

Answer Wiki:
Hi Alok The secret is to override the member name before opening the file in the RPG program. The easiest way to do this is to have a CL program that accepts the PGMNAME parameter and have that perform the override before calling the RPG program. For example, something along the lines of: PGM PARM(&PGMNAME) DCL &PGMNAME *CHAR 10 DCL &MBR *CHAR 10 IF COND(&PGMNAME *EQ 'PGM1') THEN(DO) CHGVAR &MBR 'MBR1' ENDDO ELSE DO IF COND(&PGMNAME *EQ 'PGM2') THEN(DO) CHGVAR &MBR 'MBR2' ENDDO ELSE DO CHGVAR &MBR 'MBR3' ENDDO ENDDO OVRDBF FILE(MULTIPF) TOMBR(&MBR) CALL PGM(RPGPGM) ENDPGM All the best Jonathan
Last Wiki Answer Submitted:  December 1, 2005  6:42 pm  by  astradyne   370 pts.
All Answer Wiki Contributors:  astradyne   370 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

It’s one thing to say that an error occurs on a particular statement. It’s altogether something different to say what the error is.

BTW, your program doesn’t make any sense. Is there meaning to setting File = ‘File1′ and also having a F-spec for File1? And how are you expecting the DELETE statement to do anything if you haven’t done any input or even positioning for File1? Surely you’re not expecting the ‘File1′ and File1 to somehow mean the same thing?

The compiler can’t read your mind. It cannot predict what value be put into the File variable.

Tom

 110,135 pts.