How to use OVRDBF via ‘QCMDEXC’ for Creating Override Database File in RPGLE?

Tags:
AS/400
OVRDBF
RPGLE
Hi All, I am trying to do Prompt option for my disply file. So that I created *OUTFILE (PPROMPT) using DSPFFD. Then I declared Program-Described File (TPPROMPT) with USROPN. Then while trying to Create Override Database File (OVRDBF) using CALL 'QCMDEXC' PLIST1, It couldn't create that. When try to Open the file TPPROMPT it's shows the Error 'File Not Found'. I have attached my code here. Anyone please give an idea!
FPPROMPT   IF   E           K DISK                                      
FTPPROMPT  IF   F 2000     4AIDISK    USROPN                            
DCMD              S            200A                                     
DLEN              S             15P 5                                   
DFPOS             S              5P 0                                   
DFLEN             S              5P 0                                   
DOUT              S             10A                                     
DDS1              DS                  LIKEREC(REC001) /* Like PF PPROMPT */ 
DDS2              DS          2000                                      
 *                                                                   
C     'ENTER FIELD' DSPLY                   FIELD            10         
C     FIELD         CHAIN     PPROMPT       DS1                         
C                   EVAL      FPOS = DS1.WHIBO                          
C                   EVAL      FLEN = DS1.WHFLDB                         
 **********************************************************
 *  Parameter for cl                                                    
 **********************************************************
C                   EVAL      CMD='OVRDBF FILE(BUS_PF2) +               
C                                 TOFILE(LOGU1/TPPROMPT)'               
C                   EVAL      LEN=%SIZE(CMD)                            
C     PLIST1        PLIST                                               
C                   PARM                    CMD                         
C                   PARM                    LEN                         
 ***********************************************************
 *  Calling CL Program                                                  
 ***********************************************************
C                   CALL      'QCMDEXC'     PLIST1                      
 *                                                                      
C                   OPEN      TPPROMPT                                  
C     *LOVAL        SETLL     TPPROMPT
C                   READ      TPPROMPT      DS2                       
C                   DOW       NOT %EOF(TPPROMPT)                            
C                   EVAL      OUT=%SUBST(DS2:FPOS:FLEN)                 
C     OUT           DSPLY                                               
C                   READ      TPPROMPT      DS2
C                   ENDDO                                               
C                   CLOSE     TPPROMPT                                  
C                   SETON                                            LR 
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • philpl1jb

    Perhaps this: EVAL LEN=%SIZE(CMD)

    Typically this is: EVAL LEN=%LEN(%TRIM(CMD))

    54,090 pointsBadges:
    report
  • pdraebel
    Also look at your OVRDBF command. You are trying to use TPPROMPT when addresseing BUS_PF2. Should be the other way around. Also you will need to specify OVRSCOPE(*JOB) to have the override survive the call.

    7,545 pointsBadges:
    report
  • philpl1jb
    It couldn't create that (the override) are there messages in your job log? Could you share them with us, please.
    54,090 pointsBadges:
    report
  • TheRealRaven
    Since your program doesn't have any reference to a file named 'BUS_PF2', it's not useful to override it to anything else. Change
    'BUS_PF2' to 'TPROMPT' because 'TPROMPT' is the name your program is using.

    You could change the name on your F-spec to

    'BUS_PF2', but then you'd also need to change the OPEN, READ and CLOSE. (Delete the SETLL instruction since it doesn't do anything in your program.)

    But why are you using it as a "program described" file? That's just asking for trouble. Also, why do you need OVRDBF at all? Is it created in a library that your job doesn't know about?
    36,035 pointsBadges:
    report
  • smmloganathan
    I did what you all said, Now its working fine. I have attached working code below. Actually am trying to do Generic code for multiple Prompt option for my Disply file. I have two diffrent Prompt field using two diffrent PF but only one WDWSFL. So that I need to use "program described" file for temporary use with OVRDBF. If there is any other best way to do that you can suggest me. Please forgive me if still I am not clear with my point. Could you tell where and how I can find the messages in my job log (philpl1jb: Sorry if am asking silly qus). Note:Am using Free Version-MochaSoft TN5250. Thank u all. 
    FPPROMPT   IF   E           K DISK    RENAME(REC001:REC002)
    FBUS_PF2   IF   E           K DISK                         
    FTPPROMPT  IF   F 2000     4AIDisk    USROPN               
    DCMD              S            200A                        
    DLEN              S             15P 5                      
    DFPOS             S              5P 0
    DFLEN             S              5P 0
    DOUT              S             10A  
    DDS1              DS                  LIKEREC(REC002)
    DDS2              DS          2000                   
    D                                                                        
    C     'ENTER FIELD' DSPLY                   FIELD            10          
    C     FIELD         CHAIN     PPROMPT       DS1                          
    C                   EVAL      FPOS = DS1.WHIBO                           
    C                   EVAL      FLEN = DS1.WHFLDB                          
     ********************************************
     * Parameter for cl                                                     
     ********************************************
    C                   EVAL      CMD='OVRDBF FILE(TPPROMPT) +               
    C                                 TOFILE(LOGU1/BUS_PF2)'                 
    C                   EVAL      LEN=%LEN(%TRIM(CMD))                       
    C     PLIST1        PLIST                      
    C                   PARM                    CMD
    C                   PARM                    LEN
    ***********************************************
     * Calling CL Program                                                   
     **********************************************
    C                   CALL      'QCMDEXC'     PLIST1                       
    C                   OPEN      TPPROMPT                                   
    C                   DOU       %EOF(TPPROMPT)                             
    C                   READ      TPPROMPT      DS2                          
    C                   EVAL      OUT=%SUBST(DS2:FPOS:FLEN)                  
    C     OUT           DSPLY                                                
    C                   ENDDO                                                
    C                   CLOSE     TPPROMPT                                   
    C                   SETON                                            LR  
    
    50 pointsBadges:
    report
  • TheRealRaven
    Now you have F-specs for both BUS_PF2 and TPROMPT, but you only use TPROMPT in your program. And if the BUS_PF2 file in your job changes, then the F-spec will potentially be wrong for different formats anyway. There doesn't seem to be any reason for the BUS_PF2 reference. You chose to stay with TPROMPT, so remove the BUS_PF2 F-spec.

    Also, it's not clear why you need to define TPROMPT as an indexed file with a key. That could potentially be a problem if you're creating BUS_PF2 every time the job runs. And if you don't create BUS_PF2 every time, then there doesn't seem to be any reason for a "program described" file and no reason for the OVRDBF.

    We don't know anything about how you created BUS_PF2 nor how you put records into it, so we can only make guesses. It's always named "BUS_PF2" is all we know. Maybe it's all right.

    Also, it's not clear what PPROMPT is. It seems to be an *OUTFILE from DSPFFD, but you're CHAINing to it with FIELD as a key. Since DSPFFD doesn't create a keyed file, you must have somehow created PPROMPT with the right format and then assigned a key to it. That can be fairly easy to do, but it doesn't seem like it fits with the programming. It's not wrong; it just seems odd.

    Also, you don't have the end-of-file quite right in your DO-loop. You will process the last record twice. You need to either have an IF-test after the READ or change the logic to have an added 'priming' READ outside the loop and put the existing READ at the end of the loop.

    Overall, nothing seems actually "wrong". There are simply a few things that don't make clear sense. If you are beginning to learn RPG and also to learn some general things about IBM i, it's not bad. Over time, you'll learn much better ways to do what you seem to be trying to do.
    36,035 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: