IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

What's the difference beween aligned and unaligned ?


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Joe_Song
Currently Banned

New User


Joined: 22 Jan 2008
Posts: 53
Location: china

PostPosted: Thu Jan 15, 2009 6:14 pm
Reply with quote

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
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Jan 15, 2009 6:25 pm
Reply with quote

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
View user's profile Send private message
Joe_Song
Currently Banned

New User


Joined: 22 Jan 2008
Posts: 53
Location: china

PostPosted: Thu Jan 15, 2009 6:27 pm
Reply with quote

Could you give me the reference for it? appreciate it.
Back to top
View user's profile Send private message
Joe_Song
Currently Banned

New User


Joined: 22 Jan 2008
Posts: 53
Location: china

PostPosted: Thu Jan 15, 2009 6:31 pm
Reply with quote

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
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Jan 15, 2009 6:38 pm
Reply with quote

check here

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ibm3lr60/8.14.4.4?SHELF=&DT=20071130131006
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Jan 15, 2009 6:40 pm
Reply with quote

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 icon_lol.gif
Back to top
View user's profile Send private message
Joe_Song
Currently Banned

New User


Joined: 22 Jan 2008
Posts: 53
Location: china

PostPosted: Thu Jan 15, 2009 6:42 pm
Reply with quote

any way to know how much it's added?
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Jan 15, 2009 6:59 pm
Reply with quote

... follow the rules ... icon_sad.gif

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Jan 15, 2009 7:03 pm
Reply with quote

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
View user's profile Send private message
Joe_Song
Currently Banned

New User


Joined: 22 Jan 2008
Posts: 53
Location: china

PostPosted: Thu Jan 15, 2009 7:18 pm
Reply with quote

sitll can find the right length. vey sad icon_sad.gif
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Jan 15, 2009 7:19 pm
Reply with quote

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
View user's profile Send private message
Joe_Song
Currently Banned

New User


Joined: 22 Jan 2008
Posts: 53
Location: china

PostPosted: Thu Jan 15, 2009 7:26 pm
Reply with quote

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
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Jan 15, 2009 7:36 pm
Reply with quote

???????? 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
View user's profile Send private message
Joe_Song
Currently Banned

New User


Joined: 22 Jan 2008
Posts: 53
Location: china

PostPosted: Thu Jan 15, 2009 7:42 pm
Reply with quote

So it's not fixed for the length, right? everytime the total length should not same according to the system allocation.
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Jan 15, 2009 7:51 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jan 15, 2009 10:17 pm
Reply with quote

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
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Jan 15, 2009 10:45 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Timestamp difference and its average ... DB2 11
No new posts Difference when accessing dataset in ... JCL & VSAM 7
No new posts What is the difference between Taskty... Compuware & Other Tools 2
No new posts Difference between VALIDPROC and CHEC... DB2 3
No new posts Difference between CEE3250C and CEE3204S COBOL Programming 2
Search our Forums:

Back to Top