Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Assign the values of char to fixdec

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
donateeye
Warnings : 2

New User


Joined: 01 Jun 2007
Posts: 62
Location: chennai

PostPosted: Mon May 17, 2010 12:37 pm    Post subject: Assign the values of char to fixdec
Reply with quote

If I want to assign the values of char to fixdec, what is the best way to do it.

example :

DCL A FIX DEC (5,0) INIT (234);
DCL B CHAR (5) INIT ' ';

what is the best way to move B to A?
Back to top
View user's profile Send private message

Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 967
Location: Richmond, Virginia

PostPosted: Mon May 17, 2010 4:59 pm    Post subject:
Reply with quote

What are you trying to do? I.e., what is your final goal?

Can spaces be represented numerically?
Back to top
View user's profile Send private message
donateeye
Warnings : 2

New User


Joined: 01 Jun 2007
Posts: 62
Location: chennai

PostPosted: Wed May 19, 2010 11:36 am    Post subject:
Reply with quote

Sorry.... trying to move from A to B
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1002
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Wed May 19, 2010 12:50 pm    Post subject:
Reply with quote

Code:
DCL A FIX DEC (5,0) INIT (234);
DCL B CHAR (5) INIT ' ';
DCL B_PIC PIC'(5)9' BASED ADDR(B);

B_PIC = A;


Since B_PIC occupies the same storage as B, the decimal to picture assignment achieves what you want.

Garry.
Back to top
View user's profile Send private message
donateeye
Warnings : 2

New User


Joined: 01 Jun 2007
Posts: 62
Location: chennai

PostPosted: Wed May 19, 2010 2:27 pm    Post subject:
Reply with quote

Thanks Garry
Back to top
View user's profile Send private message
sudhaaa

New User


Joined: 24 Mar 2005
Posts: 51

PostPosted: Thu Aug 05, 2010 11:00 pm    Post subject: Re:Assign the values of char to fixdec
Reply with quote

Hi,

I have a CHAR field which can have values as below
DCL Amount CHAR(18);
Amount can be
123,420.05

Now I have a field which is FOXED DEC as below
DCL Amount_to_use_on_search FIXED DEC(15,2);

As you aware I can't directly move value in Amount to Amount_to_use_on_search field

I tried with intermediate variable declaring with PIC 'zzz,zz9.V99' clause
But still I was not able to move the values

Please suggest

(Note - Please let me know if this query is already answered in the forum. I referred the books for above, but not find any exact answer)
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1072
Location: Oostende, Belgium

PostPosted: Fri Aug 06, 2010 1:03 am    Post subject: Re:Assign the values of char to fixdec
Reply with quote

sudhaaa wrote:
I have a CHAR field which can have values as below
DCL Amount CHAR(18);
Amount can be
123,420.05

Now I have a field which is FOXED DEC as below
DCL Amount_to_use_on_search FIXED DEC(15,2);

As you aware I can't directly move value in Amount to Amount_to_use_on_search field

I tried with intermediate variable declaring with PIC 'zzz,zz9.V99' clause
But still I was not able to move the values

Please suggest


Suggest what? using the PIC it is possible, but you will have to make sure that the decimal point in the char field and that in the PIC field are in the same position, so some use of SUBSTR and STRING might be required...
Back to top
View user's profile Send private message
sudhaaa

New User


Joined: 24 Mar 2005
Posts: 51

PostPosted: Fri Aug 06, 2010 1:41 am    Post subject:
Reply with quote

Thank Prino.. But I can use SUBSTR to store only partial value to the PIC variable

I belive you are saying about TRIm, which will remove spaces from the Amount CHAR variable. Please correct if I understood it correctly

For example, I wil consider a maximum value
834,547,123,456.00 CHAR(18)
zzz,zzz,zzz,zz9.v99 PIC variable

Now when I debug my module, I can see that it is failing when I try to move CHAR value to PIC
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1072
Location: Oostende, Belgium

PostPosted: Fri Aug 06, 2010 1:56 am    Post subject:
Reply with quote

The "RIGHT" builtin might also be useful, but I suggest you RTFM to see why. icon_idea.gif
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1002
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Fri Aug 06, 2010 12:37 pm    Post subject:
Reply with quote

You should NOT tag your query onto an existing one. You should open a new thread.

In any case, the comma in the PIC declaration is for OUTPUT.

Garry.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us