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

Moving x(3) to 9(3) where x(3) having numeric values


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Mr.Niceguy

New User


Joined: 16 Jun 2005
Posts: 63

PostPosted: Mon Nov 06, 2006 10:30 am
Reply with quote

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

New User


Joined: 16 Jun 2005
Posts: 63

PostPosted: Mon Nov 06, 2006 10:56 am
Reply with quote

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Nov 06, 2006 4:42 pm
Reply with quote

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

New User


Joined: 16 Jun 2005
Posts: 63

PostPosted: Tue Nov 07, 2006 9:20 am
Reply with quote

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

New User


Joined: 03 Nov 2006
Posts: 87
Location: Plymouth, MN USA

PostPosted: Tue Nov 07, 2006 11:43 am
Reply with quote

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

New User


Joined: 16 Jun 2005
Posts: 63

PostPosted: Tue Nov 07, 2006 12:15 pm
Reply with quote

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

New User


Joined: 18 Jan 2006
Posts: 16
Location: PUNE

PostPosted: Tue Nov 07, 2006 4:04 pm
Reply with quote

Hi can u give me idea how u have done thats!!!
Back to top
View user's profile Send private message
shunmuga

New User


Joined: 12 Sep 2006
Posts: 1
Location: bangalore

PostPosted: Wed Nov 08, 2006 8:48 pm
Reply with quote

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

New User


Joined: 18 Jan 2006
Posts: 16
Location: PUNE

PostPosted: Thu Nov 09, 2006 10:33 am
Reply with quote

Hi Mr.Niceguy
plz let me know how u have did move x(3) to 9(3) through unstring method......
Back to top
View user's profile Send private message
chandu321
Currently Banned

New User


Joined: 27 Jun 2006
Posts: 8

PostPosted: Thu Nov 09, 2006 2:20 pm
Reply with quote

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

New User


Joined: 03 Nov 2006
Posts: 87
Location: Plymouth, MN USA

PostPosted: Fri Nov 10, 2006 7:52 pm
Reply with quote

if u are not aware of string length then instead of a(1:2) u can use a(1icon_smile.gif this will take entire length.
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 Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
Search our Forums:

Back to Top