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

Variable numeric editing in Cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Global Moderator


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

PostPosted: Fri May 31, 2013 5:03 pm
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
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 31, 2013 7:19 pm
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

Moderator Emeritus


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

PostPosted: Fri May 31, 2013 7:22 pm
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
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

Moderator Emeritus


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

PostPosted: Fri May 31, 2013 7:45 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 31, 2013 10:25 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Sat Jun 01, 2013 5:37 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Jun 01, 2013 6:21 pm
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

Moderator Emeritus


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

PostPosted: Sun Jun 02, 2013 3:27 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top