Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String to Integer...Sugestion:

Status
Not open for further replies.

mfcobol2002

Programmer
Feb 3, 2003
73
BR
Netexpress 3.1 (Microfocus Cobol)

01 var-a pic x(?????).
01 var-b pic 9(?????).

move function numval(var-a) to var-b
move funcition numval(var-a) to var-a

Sample:

var-a 123,456,789 new value 123456789
var-a 01/01/2003 new value 01012003
var-a pic x(80) value "4" new value 4

Marcos Antonio de Souza
Brasil
 
I'm guessing we need to help him make his school assignments :-(

DWTH
TonHu
 
01 number-x pic x(5).
01 filler redefines number-x.
05 number-9 pic 9(05).

This assumes the number uses all the characters!

This is quite often used. If the text number is actually packed you have to redefine it as comp-3 and move it to a pic 9 field.

Example 01 variable pic 9(05) comp-3 actually occupy's the same space as 01 variable pic x(03). However if you move it to 01 variable pic 9(05) it now will occupy a 5 character field. The larger the file the more packed the numbers probably are. If you do not like my post feel free to point out your opinion or my errors.
 
If netexpress is designed for input, it might have a way to handle numbers already. If you do not like my post feel free to point out your opinion or my errors.
 
Hi Marcos,

If your ques is "What do I do to force var-b to contain the 'new value'?", you can try this for all but the date:

COMPUTE VAR-B = FUNCTION NUMVAL-C (VAR-A)

I don't recall any function that will remove the "/"s, but you can try this.
Code:
01 var-c. 
   05 c-m2   pic x(002).
   05 c-d2   pic x(002).
   05 c-y4   pic x(004).
01 var-c-num redefines 
   var-c. 

UNSTRING VAR-A DELIMITED BY '/' 
    INTO C-M2
         C-D2
         C-Y4
Marco, please show the courtesy of a reply to let us know if any of our suggestions worked. As you can see, these replies require some time and effort. It's the least you can do.

Also, it would be instructive to those who use the search facility in the future.

Regards, Jack.



 
Don't forget, COBOL now supports de-edited moves:
Code:
01  SOME-DATE        PIC 99/99/9999.
01  SOME-NUMERIC     PIC 9(8).
...
MOVE SOME-DATE       TO SOME-NUMERIC
[\CODE]
This will effectively strip out the virgules.

Glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top