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

Is it possible to move PIC x(9) to pic X(7)


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
suvidha
Warnings : 1

New User


Joined: 06 Aug 2007
Posts: 1
Location: Bangalore

PostPosted: Tue Oct 30, 2007 12:33 pm
Reply with quote

Can I move value of variable of length 9 characters to variable of length 7.Only I want first 7 characters in final variable.If yes , then how?
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Oct 30, 2007 2:02 pm
Reply with quote

suvidha,

Quote:
I want first 7 characters in final variable.If yes , then how?



You can directly move the data from X(9) to X(7) as both the fields are declared as alphanumeric. The last two bytes would get truncated moving the first 7 characters to the X(7) field.

Even though this works, try using the reference modification technique.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Tue Oct 30, 2007 2:20 pm
Reply with quote

Hi !

In details:

Field9 pic x(9)
Field7 pic x(7)

Pos pic s9(4) comp
Lng pic s9(4) comp

Dlm pic x(1) value '$'

move field9 to field7 ...simple & clear !!!

move field9 (1:7) to field7 ...a very little bit more transparent

move 1 to pos ...for making it of variable use
move 7 to lng

move field9 (pos:lng) to field7
move field9 (pos:lng) to field7 (pos:lng)

move dlm to field9 (8:1) ...for making it more confusing

string field9 delimited by dlm into field7
unstring field9 delimited by dlm into field7

Regards, UmeySan
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Tue Oct 30, 2007 2:49 pm
Reply with quote

Hi all !

That's why i posted it. Because six answers had been posted before mine
for solving this simple question. So i was leaded into temptation to put in my two cents.

Only YES and "move field9 to field7" could have been enougth.

@ enrico-sorichetti

Right, i agree! A link to the fine manual would have been a good hint.

Regards, UmeySan
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts How to move DB2 Installation HLQ DB2 4
No new posts How to move values from single dimens... COBOL Programming 1
No new posts Reading the CSV data in COBOL and mov... COBOL Programming 4
Search our Forums:

Back to Top