View previous topic :: View next topic
|
Author |
Message |
Joe_Song Currently Banned New User
Joined: 22 Jan 2008 Posts: 53 Location: china
|
|
|
|
when i define varinat as below;
DCL 1 INPUT_REC ,
2 FILLER15 CHAR(01),
2 SAP_ORDER_LINE FIXED BINARY(31) UNALIGNED;
By default the fixed binary is alighend, so anyone can tell me why the input_rect length is 5 when using unaligned attribute. If by default, what's the length? |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
The length of fields never changed : FILLER15 is 1 and SAP_..... is 4.
When Aligned is used the starting position can change and the mapping can add extra bytes. If you really want to learn that, I can give you a reference.
Ah Good old days !!! |
|
Back to top |
|
|
Joe_Song Currently Banned New User
Joined: 22 Jan 2008 Posts: 53 Location: china
|
|
|
|
Could you give me the reference for it? appreciate it. |
|
Back to top |
|
|
Joe_Song Currently Banned New User
Joined: 22 Jan 2008 Posts: 53 Location: china
|
|
|
|
in fact in my program , i though the record lenth is 5 so i write it to the output file which i define 5 length, but when i use the default aligned attribute to the SAP... field, the job run error at the record variant length is greater than the file length.
so it means the length changed ,right? or what happend in detail? |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
As said, when aligned, extra bytes can be added.
So if the length of every field is constant, the total length of the structure can be bigger.
Follow the rules |
|
Back to top |
|
|
Joe_Song Currently Banned New User
Joined: 22 Jan 2008 Posts: 53 Location: china
|
|
|
|
any way to know how much it's added? |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
... follow the rules ...
But you can also see that with :
- File Aid will tell you when you use the entry 8 if I remember well,
- your compiling list will tell you also.
- maybe FileManager ( don't know - possibly ).
- you can edit your file ans inspect the locations and count
- ..... |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
The PL/I Language Reference (link at top of this page) section 8.5 on Data Alignment indicates in some cases doubleword alignment will be used, so as much as 7 bytes could be added. Specifics depend, though -- BINARY (31) is fullword aligned, so based on your layout 3 filler bytes would be added. |
|
Back to top |
|
|
Joe_Song Currently Banned New User
Joined: 22 Jan 2008 Posts: 53 Location: china
|
|
|
|
sitll can find the right length. vey sad |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
Robert,
Not sure. It is more complex.
Joe,
have a look here ( via File-Aid rules )
Code: |
FIELD
--------- FIELD LEVEL/NAME ---------- -PICTURE- -NUMBER START END LENGTH
INPUT_REC 1 13 13
2 FILLER15 CHAR(1) 1 1 1 1
2 SAP_ORDER_LINE BFX(31) 2 2 5 4
2 FILLER15 CHAR(1) 3 6 6 1
2 SAP_ORDER_LINE BFX(31) 4 10 13 4
******************************* Bottom of data ********************************
|
|
|
Back to top |
|
|
Joe_Song Currently Banned New User
Joined: 22 Jan 2008 Posts: 53 Location: china
|
|
|
|
yes, if we just sum every field , it's sure the length is the total of every field. but for the structure, the total length will change, it's not 38 . not sure where really take effect? |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
???????? the sum of every field is ( in my exemple ) 10.
The length of the structure is ( not 38 ?? ) but 13.
And the data are stored accordingly by the program in the file.
It is a question of addressing. |
|
Back to top |
|
|
Joe_Song Currently Banned New User
Joined: 22 Jan 2008 Posts: 53 Location: china
|
|
|
|
So it's not fixed for the length, right? everytime the total length should not same according to the system allocation. |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
I am not sure I understang correctly.
But...
To keep consistancy in your data, you MUST keep the same structure applied on the file.
It must be a matching between the data in the file and the layout.
Cheers |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I don't "speak" pl/i, but is there not a compiler option that shows the displacement of each field from some "base".
Looking at these displacements, could one see what alignment caused to the data layout? |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
That's what I said, Dick.
On the other hand, it can be a pure academic discussion.
If you use the fileds in a PL/I program, each field is written/read by its name. So no problem.
The problem - the difficulty - can happen when you read "manually-visually" data from a file with the help of a structure with aligned attribute.
Some times it is confusing. |
|
Back to top |
|
|
|