Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Data movement to alphanumeric field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> ABENDS & Debugging
View previous topic :: :: View next topic  
Author Message
sanjaykavita

New User


Joined: 13 Aug 2009
Posts: 6
Location: Pune

PostPosted: Thu Aug 14, 2014 4:37 pm    Post subject: Data movement to alphanumeric field
Reply with quote

Hi,
Could you please help me with requirment where I need to move CUSTOMER-ID[PIC S9(9) USAGE COMP] value to
alphanumeric field. I tried to achieve this by moving the value between below variables where

WS-CIN-NUM PIC 9(10)
WS-CIN-CHAR PIC X(10)

move CUSTOMER-ID to WS-CIN-NUM
move WS-CIN-NUM to WS-CIN-CHAR


But while movement first digit is getting truncated. (e.g 1234569875 is becoming 0234569875).

While searching in the forum I found that it happes due to comiler option. I am compiling myprogram by moving the element into endevor. Hence not getting any option related to TRUNC. Any help will be much appreciated.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Aug 14, 2014 4:50 pm    Post subject: Reply to: Data movement.
Reply with quote

What value do you have for compiler option TRUNC?

You show 10 digits, but your COMP field only defines nine.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Thu Aug 14, 2014 8:37 pm    Post subject:
Reply with quote

Try with
Code:
TRUNC(OPT)
As well as review this,
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/igy3pg20/2.4?

Also, As Bill noticed, the problem is with
Code:
PIC S9(9) USAGE COMP
You need to expand this to store 10 digits.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Aug 14, 2014 9:14 pm    Post subject: Reply to: Data movement.
Reply with quote

Rohit,

TRUNC(OPT) should never be used when will be excess decimal digits. For 9(9) it would be a maximum, decimal, value of 999,999,999. The field must never contain a figure greater than that (similar for signed). TRUNC(OPT) will either lose or retain that value, depending on the instructions generated, nothing else. This will make it look like it "works" sometimes, and doesn't others. It works all the time, it is just that if using TRUNC(OPT) you promise never to exceed the decimal value represented by the PICture clause.

TRUNC(BIN), or, better, defining the individual field as COMP-5, will retain some 10-digit values, as it allows all bits in the four bytes of storage to be used to express a value, and truncation of that field will be binary (field-size) not decimal (PICture definition).

sanjaykavita,

If you still need assistance, you have to explain the source of that field and the maximum value it can hold. If you change the PICture to 9(10) remember that the field will double in size, which may not be what you want.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Fri Aug 15, 2014 8:55 pm    Post subject:
Reply with quote

Thanks for further infotmation Bill.
Back to top
View user's profile Send private message
sanjaykavita

New User


Joined: 13 Aug 2009
Posts: 6
Location: Pune

PostPosted: Mon Aug 18, 2014 7:05 pm    Post subject:
Reply with quote

CUSTOMER-ID value I am retrieving from DB2 table and tring to move this value through my program to alphanumeric field for reporting purpose.

CUSTOMER-ID(max lenght of each customer id is 10)


COLUMN DEFINATION IN DB2 TABLE:-

NAME :-CUSTOMER_ID ,, TYPE :- INTEGER ,, LENGTH :- 4


COBOL DECLARATION FOR COLUMN:-

CUSTOMER-ID PIC S9(9) USAGE COMP.

As I am compiling myprogram by moving the element into endevor.
Hence not sure about any option related to TRUNC. Any help will be much appreciated.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Aug 18, 2014 7:19 pm    Post subject: Reply to: Data movement.
Reply with quote

Look at the output listing of the compile. The first couple of pages show the settings of all the options you've specified, or which have been set by default.

They are also available in the Compiler Information Bytes in the loadmodule (if you need to know from something you don't have the listing for, for some reason). See the Enterprise COBOL Programming Guide on how to de-code them.

Have you tried to allocate customer number 9 999 999 999 in your db?

With TRUNC(STD) or TRUNC(OPT) and COMP you have a maximum value of 999 999 999 (nine decimal digits). With TRUNC(BIN) and COMP (or with COMP-5) you have a maxium of 2 xxx xxx xxx or 4 xxx xxx xxx (depending on whether a sign is present in the definition). The xxx xxx xxx bit is (power of 2 which has 10 digits starting with 2 and 10 digits starting with 4, minus one).
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Aug 18, 2014 7:22 pm    Post subject: Reply to: Data movement.
Reply with quote

Look at the output listing of the compile. The first couple of pages show the settings of all the options you've specified, or which have been set by default.

They are also available in the Compiler Information Bytes in the loadmodule (if you need to know from something you don't have the listing for, for some reason). See the Enterprise COBOL Programming Guide on how to de-code them.

Have you tried to allocate customer number 9 999 999 999 in your db?

With TRUNC(STD) or TRUNC(OPT) and COMP you have a maximum value of 999 999 999 (nine decimal digits). With TRUNC(BIN) and COMP (or with COMP-5) you have a maxium of 2 xxx xxx xxx or 4 xxx xxx xxx (depending on whether a sign is present in the definition). The xxx xxx xxx bit is (power of 2 which has 10 digits starting with 2 and 10 digits starting with 4, minus one).
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1218
Location: Israel

PostPosted: Mon Aug 18, 2014 8:07 pm    Post subject:
Reply with quote

In order to use TRUNC(BIN) when you're compiling with endevor (and when you apparently cannot change compiler options),
insert a line before the ID DIVISION:
Code:
CBL TRUNC(BIN)
or
Code:
PROCESS TRUNC(BIN)

CBL or PROCESS can start from column 1 but if you have a cobol sequence in cols 1-6 then it should start from col 8.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Aug 18, 2014 8:19 pm    Post subject: Reply to: Data movement.
Reply with quote

However: this may not work for the data (the table can't hold less than 50% of the 10-digit numbers alleged (so far) to be valid), let alone the COBOL program; this may not be possible (compiler options can be "nailed in" at installation time, preventing their being changed); this may not be a good idea (to mix different options of TRUNC in a system is asking for trouble unless perfectly managed).

For a full 10 digits. the column has to hold more digits, not just "10 sometimes". Then any intermediate files, etc.

sanjaykavita,

Can you show an example of the comparison you want to do?
Back to top
View user's profile Send private message
sanjaykavita

New User


Joined: 13 Aug 2009
Posts: 6
Location: Pune

PostPosted: Mon Aug 18, 2014 9:00 pm    Post subject:
Reply with quote

Thanks Marso, Bill Woodger and Rohit. After adding CBL TRUNC(BIN) in my cobol program I am getting desired output.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Aug 18, 2014 9:36 pm    Post subject: Reply to: Data movement.
Reply with quote

OK, but I think it is the wrong thing to do. 2147483647 is the maximum you can have. The DB2 column I believe has a maximum of 4294967295. Any customer id above 2147u483647 is going to give you an "interesting" result.

You've now changed all you COMP/COMP-4/BINARY fields in your program to COMP-5 through the use of TRUNC(BIN). This may not be what you want. You many not notice any difference. There may be a difference which you haven't yet noticed. There may be a difference that you do notice. You may not be able to get this program going "up the line". It is not common (in my experience) that Production code contains CBL/PROCESS cards, and for good reason.

If you customer id is actually less than or equal to 2147483647 you should change the definition from COMP to COMP-5 and ditch the CBL/PROCESS. If less than or equal to 4294967295 you should also remove the sign. If greater than 4294967295 you have more work to do yet.

However, you saw the answer you wanted with your intensive testing, so why should I worry?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1218
Location: Israel

PostPosted: Tue Aug 19, 2014 6:16 pm    Post subject:
Reply with quote

The trick here is to reach retirement time before the company reaches 2147483647 customers.
icon_biggrin.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Aug 19, 2014 6:26 pm    Post subject: Reply to: Data movement.
Reply with quote

Yeah, but some clever-type is using a (modulus-some-prime-number-over-a-million) checkdigit, so they've not got as much time as they think....*

* actually, that's still quite a lot of customers even after that :-)
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 -> ABENDS & Debugging All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts Amount field is getting corrupted whe... thesumitk SYNCSORT 5 Tue Oct 18, 2016 8:20 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us