View previous topic :: View next topic
|
Author |
Message |
Mr.Niceguy
New User
Joined: 16 Jun 2005 Posts: 63
|
|
|
|
Hi all,
Here I have a condition like.
Moving x(3) to 9(3) where x(3) having numeric values. Let us say I'm moving value '53'
x(3) = (-53) is moved as 9(3) =(053)
Again I just want to move 9(3) to 9(4).
9(3) = (053) is moved as 9(4) = (0530). ---> I just want this value as (0053).
Plz find a solution and post it
Thanks in advance |
|
Back to top |
|
|
Mr.Niceguy
New User
Joined: 16 Jun 2005 Posts: 63
|
|
|
|
Sorry guys,
when I try to move x(3) to 9(3) itself it moved as
-53 to 530
Here I just want to supress last digit of 530. Please let me knw if u have solution
Thanks in advance. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
really depends on what is in the x(3) field. If you want to extract the numeric value contained in the x(3) field, suggest you use NUMVAL and a SIGNED NUMERIC field to receive the conversion. Then move the Signed Numeric to unsigned.
If you only want to drop the last (right most) digit, either divide by 10 or redefine your numeric display field with two fields. |
|
Back to top |
|
|
Mr.Niceguy
New User
Joined: 16 Jun 2005 Posts: 63
|
|
|
|
Hi Dick,
the input value of x(3) is numeric, it may three digit, two digit or single digit. I want to move this x(3) to 9(3) . If input value is single digit say an example 4. i want to get it as 004 in 9(3) variable. If it is double digit i want to get it as 053.
Can you help me how to handle this one.
Thanks in advance |
|
Back to top |
|
|
star_dhruv2000
New User
Joined: 03 Nov 2006 Posts: 87 Location: Plymouth, MN USA
|
|
|
|
hey bro u can do it by using reference modification. I dont think there is any other option for this. but this works for sure.
ID DIVISION.
PROGRAM-ID. 'HEMANT'.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC X(3) VALUE '53'.
01 B PIC Z9(2).
PROCEDURE DIVISION.
MOVE A(1:2) TO B.
DISPLAY B.
STOP RUN. |
|
Back to top |
|
|
Mr.Niceguy
New User
Joined: 16 Jun 2005 Posts: 63
|
|
|
|
Hemant,
Thanks for your response.
The input may come as single digit also.. It will not applicable for that I think.. I just did by unstring method. It performs well..
Thanks Alot Guys.. |
|
Back to top |
|
|
mani_jnumca
New User
Joined: 18 Jan 2006 Posts: 16 Location: PUNE
|
|
|
|
Hi can u give me idea how u have done thats!!! |
|
Back to top |
|
|
shunmuga
New User
Joined: 12 Sep 2006 Posts: 1 Location: bangalore
|
|
|
|
hi dude!!!
IM shunmugaa , i think i can solve ur prblm.
you know digit are right justify when we try to insert into a working storage variable.if there is a blank spaces,then it will add zeros to those blank spaces.....ok got it...
so if u dont want at it when output use zero supressor,refer cobol book
about data transfer.......you will get clear picture ok..... |
|
Back to top |
|
|
mani_jnumca
New User
Joined: 18 Jan 2006 Posts: 16 Location: PUNE
|
|
|
|
Hi Mr.Niceguy
plz let me know how u have did move x(3) to 9(3) through unstring method...... |
|
Back to top |
|
|
chandu321 Currently Banned New User
Joined: 27 Jun 2006 Posts: 8
|
|
|
|
Hi
I guess if u right justify x(3) u may get proper results. ex 53 is moved fitst byte will be blank and other two bytes will have 53 and this u can easily move to 9(3) since 9(3) will be right justified by default.
Thanks
Chandu |
|
Back to top |
|
|
star_dhruv2000
New User
Joined: 03 Nov 2006 Posts: 87 Location: Plymouth, MN USA
|
|
|
|
if u are not aware of string length then instead of a(1:2) u can use a(1 this will take entire length. |
|
Back to top |
|
|
|