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

Numeric variable movement


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Wed May 26, 2010 12:06 pm
Reply with quote

Hi,

I have below two variables in input file defined as shown below

Code:

05 CUR-MTH-TTL-ADJUSTMENTS   PIC 9(13).9(2).
05 CUR-MTH-FTP-BASE-RATE     PIC 9(13).9(2).


I have below table variables in which above variables are populating

Code:

05 FTP-FTP-RT-AJ-AM                PIC S9(13)V9(5) COMP-3.
05 FTP-FTP-BAS-RT                  PIC S9(9)V9(9) COMP-3.


Kindly advise if direct movement is possible or need any workaround.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed May 26, 2010 1:39 pm
Reply with quote

What have you tried out till now? what is the problem you are facing?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed May 26, 2010 4:31 pm
Reply with quote

Your source variables are numeric edited variables. Section 6.2.24.1.1 of the COBOL Language Reference manual (link at the top of the page) gives you the rules for elementary moves, including numeric edited variables.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed May 26, 2010 5:12 pm
Reply with quote

Please search the COBOL part of Forum - you might search with author as "Robert Sample" or "Bill O'Boyle", for example. They have given very nifty explanations on such questions many times.
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Wed May 26, 2010 6:04 pm
Reply with quote

I am surprise to see that direct movement is possible but dont know how.

It would be really great If someone could explain how that really works (NO bookish answer pleasee) as till date I was thinking direct movement from 9(13).9(2) to PIC S9(09)V9(9) COMP-3 is not possible.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed May 26, 2010 6:07 pm
Reply with quote

nileshyp wrote:
(NO bookish answer pleasee)
ok, what "bookish answer" do you have with you?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed May 26, 2010 6:18 pm
Reply with quote

I'm not quite sure why you would ever think that movement of a numeric variable would not be allowed to a numeric variable in COBOL. There is a link to manuals at the top of the page. You would benefit from spending some time in the COBOL Language Reference and Programming Guide manuals, reading them.

Code:
Code:
      01  WS-VARS.
          05 CUR-MTH-TTL-ADJUSTMENTS  PIC 9(13).9(2).
          05 CUR-MTH-FTP-BASE-RATE    PIC 9(13).9(2).
          05 FTP-FTP-RT-AJ-AM         PIC S9(13)V9(5) COMP-3.
          05 FTP-FTP-BAS-RT           PIC S9(9)V9(9)  COMP-3.
      LINKAGE SECTION.
     /
      PROCEDURE DIVISION.
      S1000-MAIN       SECTION.
          MOVE 1234567891234.56       TO  CUR-MTH-TTL-ADJUSTMENTS.
          MOVE 9876543218765.54       TO  CUR-MTH-FTP-BASE-RATE.
          MOVE CUR-MTH-TTL-ADJUSTMENTS
                                      TO  FTP-FTP-RT-AJ-AM.
          MOVE CUR-MTH-FTP-BASE-RATE  TO  FTP-FTP-BAS-RT.
          DISPLAY 'CUR-MTH-TTL-ADJUSTMENTS ' CUR-MTH-TTL-ADJUSTMENTS.
          DISPLAY 'CUR-MTH-FTP-BASE-RATE   ' CUR-MTH-FTP-BASE-RATE.
          DISPLAY 'FTP-FTP-RT-AJ-AM        ' FTP-FTP-RT-AJ-AM.
          DISPLAY 'FTP-FTP-BAS-RT          ' FTP-FTP-BAS-RT.
produces output of
Code:
 CUR-MTH-TTL-ADJUSTMENTS 1234567891234.56
 CUR-MTH-FTP-BASE-RATE   9876543218765.54
 FTP-FTP-RT-AJ-AM        123456789123456000
 FTP-FTP-BAS-RT          543218765540000000
As to why it works, unless you are willing to spend time in the COBOL manuals you will not be able to learn the rules for variables and variable movement and hence it would be useless to explain. There are times when ONLY "bookish answers" can explain things.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
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