View previous topic :: View next topic
|
Author |
Message |
AntonioS
New User
Joined: 27 Mar 2012 Posts: 8 Location: EU
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
AntonioS
New User
Joined: 27 Mar 2012 Posts: 8 Location: EU
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 . . .
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 |
|
|
AntonioS
New User
Joined: 27 Mar 2012 Posts: 8 Location: EU
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
AntonioS
New User
Joined: 27 Mar 2012 Posts: 8 Location: EU
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 . . .
@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 |
|
|
|