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

Wrong display of comp-3 variable


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
surya anem

New User


Joined: 20 Dec 2007
Posts: 54
Location: Hyderabad

PostPosted: Mon Feb 25, 2008 4:57 pm
Reply with quote

I have converted the comp-3 data into displayable format. Its working fine in most of the cases but in some cases it is displaying the value wrong

Ex: if the data is 78787 , it is displaying as 7c7c7

According to my observation it is displaying C for 8 and D for 9 icon_sad.gif
Suggest me on how to correct the problem

with regards,
surya
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Feb 25, 2008 5:33 pm
Reply with quote

Post your code to let us see exactly what you are doing.
Back to top
View user's profile Send private message
surya anem

New User


Joined: 20 Dec 2007
Posts: 54
Location: Hyderabad

PostPosted: Tue Feb 26, 2008 9:19 am
Reply with quote

The code for conversion from comp-3 to displayable format is as follows:

data=c2x(input)
sign=right(data,1)
datas=substr(data,1,length(datas)-1)
if sign = 'D' then
number = '-' || datas

This is what iam doing......
It is working well for most of the inputs except for some of then as i have told in the previous post

with regards,
surya
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 26, 2008 1:24 pm
Reply with quote

a snippet with full data checking is here
http://www.ibmmainframes.com/viewtopic.php?t=27921&highlight=unpack
Back to top
View user's profile Send private message
surya anem

New User


Joined: 20 Dec 2007
Posts: 54
Location: Hyderabad

PostPosted: Tue Feb 26, 2008 1:31 pm
Reply with quote

Yeah!!! I have checked your post and that is what i have done
i am putting the full code here:

ARG INPUT_DATA LEN DEC
DATAS = C2X(INPUT_DATA)
DATAS = STRIP(DATAS,'T','0')
MAIN = LEN
DTYPE = DATATYPE(DEC)
IF DEC\ = NUM THEN DEC = 0 */
SIGN = RIGHT(DATAS,1)
DATAS = SUBSTR(DATAS,1,LENGTH(DATAS)
DATAM = SUBSTR(DATAS,1,MAIN)
DATAD = SUBSTR(DATAS,(MAIN+1),DEC)
IF DEC\ = 0 THEN
NUMBER = DATAM||'.'||DATAD
ELSE
NUMBER = DATAM
IF SIGN = 'D' THEN
NUMBER='-'||NUMBER
OUTPUT_DATA = NUMBER
RETURN OUTPUT_DATA


But it is not working in some cases as i have mentioned.
It is displaying C for 8 and D for 9

with regards,
surya
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 26, 2008 2:10 pm
Reply with quote

Your code is different from my code ..
that' s why it does not work !

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ikj3a320/3.2?SHELF=IKJOSE20&DT=20000113164209#SPTREF23
Back to top
View user's profile Send private message
surya anem

New User


Joined: 20 Dec 2007
Posts: 54
Location: Hyderabad

PostPosted: Tue Feb 26, 2008 2:14 pm
Reply with quote

Can you please tell me what is the difference because i didnt find any difference and
one more thing is one of the line is mistyped in my code

it is actually
DATAS = SUBSTR(DATAS,1,LENGTH(DATAS)-1)

i forgot to subtract 1

with regards,
surya
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 26, 2008 2:26 pm
Reply with quote

did You look at the link...
review the difference between
Code:
ARG something
and
PARSE ARG something
Back to top
View user's profile Send private message
surya anem

New User


Joined: 20 Dec 2007
Posts: 54
Location: Hyderabad

PostPosted: Tue Feb 26, 2008 2:35 pm
Reply with quote

Yeah i have the seen the link....
Actually whatever i have put here is an internal subroutine. I am calling this subroutine whenever i encounter a comp-3 field

So Arg is correct
icon_confused.gif

surya
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 26, 2008 2:45 pm
Reply with quote

Then it should work, and we have just thrown away some bandwidth icon_cool.gif

Code:

/*REXX- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/*                                                                   */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
Trace "O"

string = "0123456789abcdef"x
chars  = c2x(hex)
say "string" string
say "chars " chars

call ok string
call ko_arg string
call ko_low string
call ko_upp string

exit

ok:  procedure
parse arg string
chars = c2x(string)
say "ok" chars
return 0

ko_arg:  procedure
arg string
chars = c2x(string)
say "ko_arg" chars
return 0

ko_low:  procedure
parse lower  arg string
chars = c2x(string)
say "ko_low" chars
return 0

ko_upp:  procedure
parse upper  arg string
chars = c2x(string)
say "ko_upp" chars
return 0


I never post without testing
Back to top
View user's profile Send private message
surya anem

New User


Joined: 20 Dec 2007
Posts: 54
Location: Hyderabad

PostPosted: Tue Feb 26, 2008 2:56 pm
Reply with quote

Hey!!! excellent. I got my mistake. i never thought that would be my mistake.

But why is the output changing from arg to parse arg.
can u please throw some light on this

thanks a lot
surya
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top