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

Assign the values of char to fixdec


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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

Senior Member


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

PostPosted: Mon May 17, 2010 4:59 pm
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
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: 1193
Location: Dublin, Ireland

PostPosted: Wed May 19, 2010 12:50 pm
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
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
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: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Aug 06, 2010 1:03 am
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
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: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Aug 06, 2010 1:56 am
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: 1193
Location: Dublin, Ireland

PostPosted: Fri Aug 06, 2010 12:37 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
Search our Forums:

Back to Top