Filed in D specs is not getting initialized on the 2nd call to program.

25 pts.
Tags:
AS/400
AS/400 administration
RPG
RPG Date Formatting
My RPG programs fields in the D specs that are set to initialize Example(D Fld1    S      1A     INZ('Y') will work the first time the program is called but not on the second call of the same program.

Software/Hardware used:
AS/400
ASKED: September 6, 2011  4:48 PM
UPDATED: March 31, 2012  5:05 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you do not close the program when exiting on the first call, it will not go through the initialization routine on the second call.
Just add an initialization statement at the beginning of your calc specs.

Discuss This Question: 9  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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Amjim
    I ended the program with an eval *inlr = *on and a 'return' after that. Maybe I need to drop the return op code.
    25 pointsBadges:
    report
  • Amjim
    I may be missing your point, is their another e=way of 'CLOSING' the program then the typical eval *inlr = *on and an 'RETURN' op code after that?
    25 pointsBadges:
    report
  • TomLiotta
    Are the fields in static storage or automatic storage? Use DSPPGM to view the 'Program statistics' section. What does the 'Allow static storage reinitialization' attribute say? Have you freed the program storage yet? I.e., has the program been deactivated or has the activation group been reclaimed? Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    is their another way of ‘CLOSING’ the program then the typical eval *inlr = *on and an ‘RETURN’ op code after that? Yes, to keep a program memory resident the *INLR is not turned on..program ends when it encounters the RETURN or end of code. The *INLR may be in an If ..structure. This isn't a service program or a *NOMAIN module? Pil
    48,545 pointsBadges:
    report
  • TomLiotta
    A HLL ILE program will remain "resident" until it is deactivated. For ILE RPG, *INLR doesn't affect its "resident" status; *INLR affects closing of files and writing of data areas plus returning to the caller. For ILE, "returning to the caller" doesn't get rid of the program from the job. See the 'Program Activation Creation' topic and related topics in ILE concepts for some background. See the Deactivate Program (DEACTPG) MI builtin for related info about ILE programs in a default activation group (or perhaps the RPG/400 FREE op-code for OPM programs and note that RPG IV doesn't include FREE). See the 'Detailed RPG IV Program Cycle' topic in the ILE RPG Reference and check note 2:
    • RPG IV checks for the first invocation of the program. If it is the first invocation, program initialization continues. ...
    That is, the initialization routine is called on first call, not on second or later calls... that is, unless you have deactivated the program, usually by reclaiming the activation group (automatically done for a *NEW activation group and never done for a default activation group except by ending the job). If you want reinitialization, then code for it with RESET. Or deactivate/reactivate the program. Normally, there should be no problem if a field isn't set to its INZ() on second call. An INZ() value really should have only a couple purposes. First, it should be a value that remains constant through the life of the program such as blanks or zeros in DS subfields that aren't used for holding dynamic values. Second, it may indicate a kind of 'first time' condition; but a program really only needs a single boolean variable for that -- it shouldn't need to have to go through every variable. In those cases, reinitialization shouldn't be needed. If a variable isn't being assigned dynamic values, its value will still be the same on the second call as it was initialized to on first call. If a 'first time' variable has been changed, then it's not 'first time' on the second call. For variables that do have dynamic value changes, the program should always set a valid value no matter what. Automatic initialization shouldn't be involved. In short, if reinitialization is desired, add a RESET at the top of the program as CharlieBrowne suggested. Better would probably be to code the program in a way that doesn't need reinitialization and call it within an appropriate activation group structure. Tom
    125,585 pointsBadges:
    report
  • Amjim
    [...] Filed in D specs is not getting initialized on the 2nd call to program [...]
    0 pointsBadges:
    report
  • bvining
    I'm clearly missing something here. With the following program, both variables XChar and X are set to their INZ values on repititive calls to the program.
    h dftactgrp(*no)                                        
                                                            
    d                 ds                                    
    dXChar                           1a   inz('A')          
                                                            
    dX                s              5s 0 inz(10)           
                                                            
     /free                                                  
                                                            
      X += 1;                                               
      dsply %char(X);                                       
                                                            
      dsply XChar;                                          
      XChar = 'B';                                          
                                                            
      *inlr = *on;                                          
      return;                        
                                     
     /end-free                       
    
    What am I doing/not doing that the original poster was/was not (and that everyone is evidently seeing)? Thanks, Bruce
    6,240 pointsBadges:
    report
  • Amjim
    [...] 5. CharlieBrowne, Philpl1jb, TomLiotta, and Yorkshireman are trying to help solve a strange problem with locking of records. 6. CharlieBrowne, TomLiotta, Philpl1jb, and Bvining are helping a member complaining that RPG programs filed in D specs are not getting initialized on the second call to the program. [...]
    0 pointsBadges:
    report
  • Amjim
    [...] 4. CharlieBrowne, TomLiotta, and Bvining chip in on a question about files in D specs not getting initialized on the second call to the program. [...]
    0 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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following