30 pts.
 Database fields as part of Data Structure in a Service program getting blanked out
I've a file HPHOSP having patient details. It has 8 fields to store diagnosis codes - LPCD01, LPCD02....LPCD08. I've declared these fields as a part od DS so that these can be accessed by array LPCD.

Now in my program, when I chain file HPHOSP, then all fields fo file has correct value but these 8 fields (LPCD*) always has blank value, although these are non-blank in database file.

The above code is part of a procedure. File HPHOSP is declared in F-specs at global level and not inside procedure. And this procesure is part of a service program.

What could be the reason for this:

1. Is it because file is declared in global F-specs and not inside procedure definition?

2. This is part of service program that is inducing some error?

3. Any other reason.

0085.00      D                 DS                                     0086.00      D  LPCD                   1     64                       0087.00      D                                     DIM(8)             0088.00      D  LPCD01                 1      8                       0089.00      D  LPCD02                 9     16                       0090.00      D  LPCD03                17     24                       0091.00      D  LPCD04                25     32                       0092.00      D  LPCD05                33     40                       0093.00      D  LPCD06                41     48                       0094.00      D  LPCD07                49     56                       0095.00      D  LPCD08                57     64                      

 

 



Software/Hardware used:
AS400. OS/400 V6R1
ASKED: Feb 6, 2012  11:04 AM GMT
UPDATED: March 17, 2012  1:51:11 AM GMT
66,925 pts.

Answer Wiki:
Last Wiki Answer Submitted:  Mar 17, 2012  1:51 AM (GMT)  by  TomLiotta   66,925 pts.
Latest Answer Wiki Contributors:  Rebek4love   3,500 pts., MTidmarsh   145 pts., Glory35   4,765 pts.
To see other answers submitted to the Answer Wiki View Answer History.
Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _




 
0085.00      D                 DS
0086.00      D  LPCD                   1     64
0087.00      D                                                      DIM(8)
0088.00      D  LPCD01                 1      8
0089.00      D  LPCD02                 9     16
0090.00      D  LPCD03                17     24
0091.00      D  LPCD04                25     32
0092.00      D  LPCD05                33     40
0093.00      D  LPCD06                41     48
0094.00      D  LPCD07                49     56
0095.00      D  LPCD08                57     64

This might make the code a bit clearer.

 36,410 pts.

 

This is part of a procedure.
Is the F spec and chain in a different procedure?
Does the F spec include a PreFix keyword?

 36,410 pts.

 

Since LPCD is defined as 64 bytes in length, it appears that you want an array that is 512 bytes long. (I.e., DIM(8) * 64 = 512 )

But your file fields are only 8 bytes long…?

So, do you really want all of your file fields to overlay just the first element of your array?

If the LPCDnn fields are in a subprocedure, how are you putting the values from the file into those fields? They won’t be populated by reading records. You can’t define a memory layout in a subprocedure that affects where the main procedure stores its data. The fields in the subprocedure are different variables from those in the main procedure, even though they might have the same names.

Tom

 66,925 pts.

 

Yup, Tom has got it, he always does.
LPCD should be 8A DIM(8)
and if you move the structure to the mainline or pass the variables to the procedure you’ll be cooking. Variables like LPCD01 defined in a procedure are local (even if they have the same name as a global variable they don’t share a memory area or data. That’s the scope thing.
webcam.on.Phil

 36,410 pts.