1,285 pts.
 LIKEDS with DIM() in RPGLE
Hi Gurus, I need some help. I have the following code and it can not be compiled. It says: *RNF7030 30        596700  The name or indicator ADDRESS is not defined. Here is my code:

D sndemail        pr                  Extpgm('SNDEMAIL')

D  subject                      80A   const

D  htmlmsg                    5000a   const

D  toaddrs                            likeds(emailaddrs) dim(20)

D  fromaddr                    100a   const

D  fromname                    100a   const





demailaddrs       ds                  qualified inz

D  count                            4b 0

D  to_type                         3a

D  name                        100a

D  address                      50a

The fields COUNT, TO_TYPE, NAME and ADDRESS are getting the 7030 errors. When I'm putting in to the D spec, then I'm getting: *RNF3315 20   The Name entry is already defined on a Definition Specification; defaults to blanks. Any suggestion? Thanks, YuVa

Software/Hardware used:
V5R3
ASKED: May 7, 2012  11:07 AM
UPDATED: May 10, 2012  3:34 AM

Answer Wiki:
BigKat; I already tried your suggestion, but unfortunately I'm getting there the same RNF7030 error for the fields within the emailaddrs DS:
Last Wiki Answer Submitted:  May 9, 2012  5:29 am  by  YuVa47   1,285 pts.
All Answer Wiki Contributors:  YuVa47   1,285 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


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


 

qualified field names include the DS

demailaddrs.address is the field name.
Phil

 44,070 pts.

 

and in an array
demailaddrs(1).address

 44,070 pts.

 

Thank you Phil,
Unfortunately I’m getting the same errors. Here is the code where I’m trying to fill the data:

     For x = 1 to 20;
       select;
         when x > 4;
           leave;
         when x = 1;
           toaddrs.emailaddrs(x).e_type = 'TO ';
           toaddrs.emailaddrs(x).name   = *blanks;
           toaddrs.emailaddrs(x).address= 'yehudav@bagir.com';
         when x = 2;
           toaddrs.emailaddrs(x).e_type = 'TO ';
 1,285 pts.

 

toaddrs(x).to_type = ‘TO ‘;

From the structure above toaddrs is the name of a qualified data structure that is like the data structure emailaddrs. And the subfield names seemed to have changed from the structure above the the code sample.
Phil

 44,070 pts.

 

*RNF7030 30 596700

Statement 596700 is a long, long way down the source for an RPG procedure. I wouldn’t expect it to refer to a D-spec, so I assume it’s a C-spec.

Can you show us that emailaddrs is defined within the same scope as statement 596700?

Tom

 107,735 pts.

 

Phil,
You are correct but it was wrong typing from my side. The e_type is to_type.

Tom,
I’m not really understanding what you mean. In my original question I included the code both for the ExtPgm(‘SNDEMAIL’) and the DS for emailaddrsDS. Anyway here are the codes around statement 596700:

   If  %scan('CS':SRNMBR)<>0 and stsemail<>'1';
     fromaddr = '*CURRENT';
     fromname = '*CURRENT';
     srnumcs  = srnmbr;

     For x = 1 to 20;
       select;
         when x = 1;
           toaddrs.emailaddrs(x).to_type = 'TO ';
           toaddrs.emailaddrs(x).name   = *blanks;
           toaddrs.emailaddrs(x).address= 'yehudav@bagir.com';
         when x = 2;
           toaddrs.emailaddrs(x).to_type = 'TO ';
           toaddrs.emailaddrs(x).name   = *blanks;

           ...
       EndSl;
     EndFor;

     Monitor;
       sndemail (subject:htmlmsg:toaddrs:fromaddr:fromname);
       stsemail ='1';
     on-error;
       stsemail = ' ';
     Endmon;
  
    Endif;


Is it what you mentioned Tom?

 1,285 pts.

 

I think this is what you want:

     For x = 1 to 20;
       select;
         when x > 4;
           leave;
         when x = 1;
           toaddrs(x).to_type = ‘TO ‘;
           toaddrs(x).name   = *blanks;
           toaddrs(x).address= ‘yehudav@bagir.com’;
         when x = 2;
           toaddrs(x).to_type = ‘TO ‘;
 7,175 pts.

 

Tom asked about the scope of the declarations.
You’ve shown us the ‘D’ specs
Are they at the beginning of the program–making then global declarations
Or are they at the beginning of this procedure–making them local declarations.
Or are they at the beginning of another procedure — making them invisible to the procedure that contains this code.
Phil

 44,070 pts.

 

There are many possible problems. The error message shows that there are almost 6000 source lines at least, so it’s impossible to tell what actual errors there are. With that many source lines, especially when a PR shows that procedures are being prototyped, some errors could be explained by “scope” problems. There is no way for us to see what the scope of the definitions is by just seeing snippets. I wanted to be sure that “scope” hadn’t been overlooked, so I only added the comment in case more needed to be looked at.

However, my comment was added after Phil’s original comment.

His comment indicates a very likely source of the error, but the source lines that had the errors weren’t shown. The RNF7030 error message in a listing will only show the lowest level name rather than the qualified name, so we can’t tell about an error without both the error message and the source statements at the same time. We can’t tell if the source line actually included qualification unless the source with the error is shown.

Since emailaddrs is a qualified DS, you can’t reference the subfields without qualification. That was the point of Phil’s first comment from what I read.

Now, after that, I don’t see where toaddrs is defined. We’re now missing the D-specs for it. So far, you have only shown it referenced under the PR. But where is it defined? You can’t use the name without defining it first. The PR doesn’t define it; it only reserves a parameter interface for it. Whatever you use for that parameter when you call the proc has to meet the requirements of the parameter, but the name under the PR is not relevant.

Also, it looks as if you expect the PR parameter to reference an area of memory that can hold up to 20 copies of the emailaddrs DS. And the source shows emailaddrs with an index. But emailaddrs isn’t an array, so an index doesn’t really belong there. (It might be valid; I haven’t tried it like that. But it won’t matter until a D-spec is created for toaddrs.)

Maybe that’s enough rambling to help clear up some confusion. Ask about parts that need more discussion.

Tom

 107,735 pts.

 

Thank you Tom the explanation.
First of all this program is a monster and I shouldn’t write it in that way.

Everything is declared in the D spec as global variables.

0122.00 D subject         s             80a
0123.00 D htmlmsg         s           5000a
0124.00 D toaddrs         s           3106a
0125.00 d srnumcs         s              8a
0126.00 D fromaddr        s            100a
0127.00 D fromname        s            100a
 1,285 pts.

 

0124.00 D toaddrs s 3106a

Okay, so toaddrs is neither a DS nor an array. Since it’s not a DS, it can’t be qualified and it won’t have any subfields. It’s just a long character field.

Consider changing this to a DS with likeds(emailaddrs) dim(20).

Tom

 107,735 pts.

 

Tom, thank you for the suggestion, but how could I do that?

 1,285 pts.

 

Fixed, thank you all for your valuable suggestions.
YuVa

 1,285 pts.

 

Sometimes the easiest thing to do is to code a few lines into a test member to see what happens. I have a few dozen members in different languages that focus on different things. This is one that I have used to play around with DSs:

     D ds1             ds
     D  v1                            3
     D  v2                            3

     D ds2             ds                  qualified
     D  v3                            3
     D  v4                            3

     D ds3             ds                  likeds( ds2 )
      /free

       v1        = 'ABC' ;
       v2        = 'DEF' ;
       v3        = 'GHI' ;
       v4        = 'JKL' ;
       ds3.v4    = 'JKL' ;
       ds3.v5    = 'JKL' ;

       *inlr = *on ;
       return ;
      /end-free

With little examples like that, you can always add or remove a line, add or remove a keyword, just to see what the compiler does. Sometimes it just takes seeing the error messages from a compile to help make things clearer. Other times you might scan down to the cross-reference in the listing to get clues.

Tom

 107,735 pts.

 

“We know that he did not come through the door, the window, or the chimney. We also know that he could not have been concealed in the room, as there is no concealment possible. When, then, did he come?”
Arthur Conan Doyle, The Sign of the Four, 1890

 44,070 pts.