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
 

 

Variable numeric editing in Cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
AntonioS

New User


Joined: 27 Mar 2012
Posts: 8
Location: EU

PostPosted: Fri May 31, 2013 4:58 pm    Post subject: Variable numeric editing in Cobol
Reply with quote

Hi folks

I need to find a way to implement variable numeric editing. Let me explain this using the following example.

Code:
01   FLD-NUM   PIC S9(3)V9(2) USAGE COMP-3.
01   FLD-EDIT  PIC 'ZZ9,99' USAGE DISPLAY.

         MOVE FLD-NUM TO FLD-EDIT


Now my requirement is to be able to provide a variable picture string for the numeric edited field. It should also be variable in length.

I would know how to do this in Assembler by creating a variable string mask for EDMK. But does anyone know a way in to solve this in Cobol?
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Fri May 31, 2013 5:03 pm    Post subject:
Reply with quote

Quote:
Now my requirement is to be able to provide a variable picture string for the numeric edited field. It should also be variable in length.


Please explain with expected input and output marked in code tags
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri May 31, 2013 5:17 pm    Post subject:
Reply with quote

Quote:
Now my requirement is to be able to provide a variable picture string for the numeric edited field. It should also be variable in length.


in COBOL an edit mask is defined to the compiler, which the compiler uses to build the appropriate 'mask' and code.

you need to define all the edit masks (that you may need) as elementary data items in your data division.

Since you have spoken about building variable edit masks,
that means that you will have code to 'decipher' the input numeric data in order to determine what edit mask is needed.
and instead of building an edit mask,
simply perform the move to the appropriate edit mask that you have already defined.
Back to top
View user's profile Send private message
AntonioS

New User


Joined: 27 Mar 2012
Posts: 8
Location: EU

PostPosted: Fri May 31, 2013 6:59 pm    Post subject:
Reply with quote

dbzTHEdinosauer wrote:
in COBOL an edit mask is defined to the compiler, which the compiler uses to build the appropriate 'mask' and code.

you need to define all the edit masks (that you may need) as elementary data items in your data division.


I am afraid that is not possible because I need to be able to use virtually any edit mask.

Seems like an assembler subprogram must help me out.

However, thanks for replying!
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Fri May 31, 2013 7:19 pm    Post subject: Reply to: Variable numeric editing in Cobol
Reply with quote

If we had a bit of a clue as to what you specifically want, there may be suggestions. A sub-program definitely if you are looking for something "general purpose".
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri May 31, 2013 7:22 pm    Post subject:
Reply with quote

Hello,

Quote:
I am afraid that is not possible because I need to be able to use virtually any edit mask.
Not very likely . . .

Even if some method is kluged together, there will still be code changes for every new edit mask . . . icon_confused.gif

I suspect the requirement needs a much more clear definition before choosing the implementation method (i.e. assembler).

FWIW - many (most) organizations will not permit developers to write new assembler code to be promoted.
Back to top
View user's profile Send private message
AntonioS

New User


Joined: 27 Mar 2012
Posts: 8
Location: EU

PostPosted: Fri May 31, 2013 7:36 pm    Post subject:
Reply with quote

Here's my requirements:

The program gets (a list of) numeric data together with an edit mask for each of these. The edit mask may be of any format allowed by the Cobol syntax. The program must be able to format the numeric data accordingly.

Even more, I need it the other way as well: Parse a format given by an edit mask back into a numeric data field.

Of course, I could write some Cobol code which parses the edit mask and formats the numeric data accordingly. However, if compared to the assembler solution, this seems to be quite a big effort. Since this is a very technical requirement, an assembler solution for this specific detail should be acceptable.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri May 31, 2013 7:45 pm    Post subject:
Reply with quote

Hello,

Quote:
The program gets (a list of) numeric data together with an edit mask for each of these.
How was it decided that this approach was desirable (or even acceptable)?

How are the "edit masks" provided? How did they get together with the "data"?

Quote:
an assembler solution for this specific detail should be acceptable.
To you, perhaps. Your management may have a different take on this. Keep in mind that "someone" has to maintain this after you are no longer associated with this application.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Fri May 31, 2013 10:25 pm    Post subject: Reply to: Variable numeric editing in Cobol
Reply with quote

Is this some type of exercise, or is it supposed to have a practical purpose?

In strict terms, what you want is not possible.
Code:

01  B PIC Z,99.

01 A PIC 999 VALUE 123.

MOVE A TO B


Now, I might get 1,23 or 3,00 in B.
Back to top
View user's profile Send private message
AntonioS

New User


Joined: 27 Mar 2012
Posts: 8
Location: EU

PostPosted: Sat Jun 01, 2013 3:17 pm    Post subject:
Reply with quote

dick scherrer wrote:


Quote:
an assembler solution for this specific detail should be acceptable.
To you, perhaps. Your management may have a different take on this. Keep in mind that "someone" has to maintain this after you are no longer associated with this application.


To be honest, I find it a bit embarrassing that you concentrate on questioning my requirements. For confidence reasons, I am unable to tell you details about how and why this requirements occurred, but be assured that we do have this requirements. And I am definitely able to estimate if a solution is acceptable or not because I am the one who decides this.

Anyway, thanks to everybody who contributed to the discussion!
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Sat Jun 01, 2013 5:37 pm    Post subject: Reply to: Variable numeric editing in Cobol
Reply with quote

Quote:
To be honest, I find it a bit embarrassing that you concentrate on questioning my requirements. For confidence reasons, I am unable to tell you details about how and why this requirements occurred, but be assured that we do have this requirements. And I am definitely able to estimate if a solution is acceptable or not because I am the one who decides this.


since we reply on our own time and free of charge
we are entitled to more explanations than a paid donkey <consultant>
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Sat Jun 01, 2013 6:21 pm    Post subject:
Reply with quote

Quote:
Now my requirement is to be able to provide a variable picture string for the numeric edited field. It should also be variable in length.
Your post indicates a lack of knowledge of COBOL, to wit:
1. COBOL does not have strings in the sense that C or Java or other languages have strings.
2. COBOL variables MUST have their length known at compile time, and the length of variables in WORKING-STORAGE cannot be changed at run time. The only exceptions are LINKAGE SECTION items and variables under the FD, which can have variable lengths.

YOU may think the requirement makes sense, but the posted opinions of IT professionals with a combined total of well over 100 years of experience in IT is that your requirement does not make sense. For a person with common sense, this would be a red flag. I suspect, however, that you will not be deterred in the least.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Jun 02, 2013 3:27 am    Post subject:
Reply with quote

Hello,

Quote:
To be honest, I find it a bit embarrassing that you concentrate on questioning my requirements.
When something like this is posted as "the requirement" an alarm goes off for most of us with the appropriate background. If is basically completely non-productive for us to post "solutions" for the "requirement" posted.

Quote:
For confidence reasons, I am unable to tell you details about how and why this requirements occurred
Sorry, causing a bit of COBOL code to properly edit numerics should Not be that big a "security" issue.

Quote:
And I am definitely able to estimate if a solution is acceptable or not because I am the one who decides this.
No problem with self-assurance<s>

Quote:
IT professionals with a combined total of well over 100 years of experience in IT
Hi Robert, from my rather simplistic calculation, only part of the participants in this topic have over 200 years . . . icon_wink.gif

@Antonio - while we may sound harsh, we are on your side and are happy to help when we understand what we are helping with.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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