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
 

 

Converting '1 ' to '0001' in CICS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CICS
View previous topic :: :: View next topic  
Author Message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 176
Location: Pune, Maharashtra, India

PostPosted: Thu Mar 14, 2013 11:14 pm    Post subject: Converting '1 ' to '0001' in CICS
Reply with quote

I am in a requirement to convert value
Code:
'1   '
(1 appended with 3 spaces) to
Code:
'0001'
in efficient way in CICS SCREEN.
This means all trailing spaces should get converted into leading zeros for entered value by user....
e.g.
Code:
'5   ' --> '0005'
'68  ' --> '0068'

I have logic of reference modification but it seems complicated and redundant as i have to develop it for so many input flags.

I am trying to search some easy mechanism to do this.
Back to top
View user's profile Send private message

Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Thu Mar 14, 2013 11:23 pm    Post subject:
Reply with quote

Am guessing defining your field as ZZZ9 should do the trick... Maybe you might have to REDEFINE the field to write your code effectively...
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Mar 14, 2013 11:30 pm    Post subject: Reply to: Converting '1 ' to '0001' in CICS
Reply with quote

Use the "PICIN" and "PICOUT" BMS Keywords at the DFHMDF level. Your Map Copybook will then be generated with fields defined as PIC 9 as opposed to PIC X.

Your attribute must still be "NUM" (you're probably using "UNPROT" as well), because Users can still enter non-numeric special-characters, even with "NUM".

Never underestimate the ability of a User to mess things up.... icon_eek.gif
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 176
Location: Pune, Maharashtra, India

PostPosted: Thu Mar 14, 2013 11:46 pm    Post subject:
Reply with quote

Absolutely Bill, i am using NUM UNPROT attributes.
PICIN and PICOUT.. i dont think so we can use in our shop...

I tried to send the input value to X(4) JUSTIFIED RIGHT and redefined same by 9(4) but it didnt workk.. icon_sad.gif
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Mar 15, 2013 12:07 am    Post subject: Reply to: Converting '1 ' to '0001' in CICS
Reply with quote

PICIN/PICOUT is the easiest method to deal with this "opportunity" and their use shouldn't warrant their restriction.

Management decision? icon_eek.gif

Frightening.... icon_rolleyes.gif

Take a look at the CICS Builtin Function DEEDIT. I think that will work for you....
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Fri Mar 15, 2013 1:04 am    Post subject:
Reply with quote

Why not NUMVAL?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Mar 15, 2013 1:09 am    Post subject:
Reply with quote

EXEC CICS BIF DEEDIT will do what you want; in COBOL you can use FUNCTION NUMVAL to achieve amost the same result (the CICS code handles non-numeric characters but FUNCTION NUMVAL expects the data to be spaces / digits).
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Mar 15, 2013 1:12 am    Post subject: Reply to: Converting '1 ' to '0001' in CICS
Reply with quote

FUNCTION NUMVAL is another method, but requires COBOL/370 and above and has its limitations.

Wasn't sure what version of COBOL was being used. Many times in overseas shops, VS/COBOL II (the predecessor to COBOL/370) as well as OS/VS COBOL are still quite popular.

BIF DEEDIT has been around for 30+ years and will work on any version of COBOL.
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 176
Location: Pune, Maharashtra, India

PostPosted: Fri Mar 15, 2013 7:43 am    Post subject:
Reply with quote

I will try both options n let our forum know...
Very very thankful to all of you.. Hope BIF DEEDIT will work for me..
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 176
Location: Pune, Maharashtra, India

PostPosted: Fri Mar 15, 2013 8:00 am    Post subject: Reply to: Converting '1 ' to '0001' in CICS
Reply with quote

But there is doubt...
I have to convert it to '0001' only if user enters '1 ' not '1@@@' and not '1###'..

Let me give a hand on this ... But your valuable suggestions gave me track to sail thru...

thanks
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Mar 15, 2013 8:37 am    Post subject: Reply to: Converting '1 ' to '0001' in CICS
Reply with quote

If you have access to transid CECI (CICS Command Level Interpreter) then you can experiment (using BIF DEEDIT) to ensure you've covered all data-scenarios.

CECI comes in very handy and is a good way to learn command level CICS.

Ask your CICS System Programmer whether you already have or request to have access (non-Production region(s) only).

HTH....
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 176
Location: Pune, Maharashtra, India

PostPosted: Fri Mar 15, 2013 11:54 pm    Post subject:
Reply with quote

Thanks a lot Bill...
I tried both NUMVAL and DEEDIT options...
both gave me almost right results.

Now i am just waiting for approval on usage of either of them so that i can go ahead !!!

I think NUMVAL has some issues of compiler versions so lets see if i can go ahead with DEEDIT cics command...

I passed control to above options by using IF condition construct for checking only numeric and spaces... !!
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Sat Mar 16, 2013 11:42 am    Post subject:
Reply with quote

rohanthengal wrote:
I think NUMVAL has some issues of compiler versions so lets see if i can go ahead with DEEDIT cics command...
What version of COBOL are you using?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Sun Mar 17, 2013 5:26 am    Post subject: Reply to: Converting '1 ' to '0001' in CICS
Reply with quote

Code:
01  The-field.
   88  blank-field value space.
    05  FILLER PIC 9.
    05  last-three-bytes.
       88  three-trailing-spaces  value space.
       10  second-byte PIC X.
       10  last-two-bytes.
           88  two-trailing-spaces value space.
           15  third-byte PIC X.
           15  fourth-byte PIC X.
               88  one-trailing-space value space.
01  FILLER REDEFINES The-field.
    05  first-three-bytes PIC 999.
    05  FILLER REDEFINES first-three-bytes.
        10  first-two-bytes PIC 99.
        10  FILLER REDEFINES first-two-bytes.
            15  first-byte PIC 9.
            15  FILLER PIC X.
        10  FILLER PIC X.
01  FILLER REDEFINES The-field.
    05  The-field-as-numeric PIC 9(4).



Code:
EVALUATE TRUE
  WHEN blank-field
    do something for a blank field
  WHEN three-trailing-spaces
    MOVE first-byte TO somewhere-numeric
  WHEN two-trailing-spaces
    MOVE first-two-bytes TO somewhere-numeric
  WHEN one-trailing-space
    MOVE first-three-bytes TO somewhere-numeric
  WHEN OTHER
    IF The-field NUMERIC
        MOVE The-field-as-numeric TO somewhere-numeric
    ELSE
        do something for invalid numeric data
    END-IF
END-EVALUATE



If you want to "code less" but have the CPU do more work, you could use UNSTRING .... DELIMITED BY SPACE into two output fields, the first a JUSTIFIED RIGHT PIC X(4), setting both the space before the UNSTRING. If the second field is not space afterwards, you have an embedded blank.

INSPECT the JUST RIGHT REPLACING LEADING SPACE BY ZERO, test the field for NUMERIC, and, if it is, MOVE a 9(4) definition of that field to where you desire.

Code:
" 111"
"1   "
"11  "
"111 "
"1 11"
"1111"
"1@11"
"1.11"


Whichever you go with, include the above test data alongside your own.
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 176
Location: Pune, Maharashtra, India

PostPosted: Mon Mar 18, 2013 10:14 pm    Post subject: Reply to: Converting '1 ' to '0001' in CICS
Reply with quote

Finally, we have decided to go with NUMVAL...
Its working nicely in all above test cases.

I have placed NUMVAL function under IF construct after checking for valid combination of numerics and spaces in INPUT.

so only when input has:
numerics prefixed/suffixed with zeros or spaces
any other combination will through an error as per requirement..
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 19, 2013 12:00 am    Post subject: Reply to: Converting '1 ' to '0001' in CICS
Reply with quote

After receiving the map, issue the following, which will ensure that SPACES will replace any other character except numerics 0-9, which will be retained. In the example below, WS-MAP-FIELD contains a '1' in the first-position and special-characters in positions 2-4. After the INSPECT, WS-MAP-FIELD will contain '1bbb' with 'bbb' representing blanks/spaces. NUMVAL should operate much cleaner, based upon the fact that WS-MAP-FIELD now only contains numerics and/or spaces.

Code:

           03  WS-XLATE-FROM-TBL   PIC  X(256).
           03  WS-XLATE-TO-TBL     PIC  X(256).
           03  WS-SUB              PIC  9(008)     BINARY.
           03  WS-SUB-X            REDEFINES WS-SUB
                                   PIC  X(004).
           03  WS-MAP-FIELD        PIC  X(004).
      *
           PERFORM VARYING TALLY FROM 1 BY 1
               UNTIL TALLY > LENGTH OF WS-XLATE-FROM-TBL
                   COMPUTE WS-SUB      = (TALLY - 1)
                   MOVE WS-SUB-X (4:1) TO WS-XLATE-FROM-TBL (TALLY:1)
           END-PERFORM.
      *
           MOVE SPACES                 TO WS-XLATE-TO-TBL.
           MOVE WS-XLATE-FROM-TBL (241:)
                                       TO WS-XLATE-TO-TBL (241:10).
           MOVE '1#^!'                 TO WS-MAP-FIELD.
      *
           INSPECT WS-MAP-FIELD        CONVERTING WS-XLATE-FROM-TBL
                                       TO WS-XLATE-TO-TBL.

The following code eliminates the need to issue FUNCTION NUMVAL and/or BIF DEEDIT as it right justifies the map field, padding it with high-order zeros. For example, if WS-MAP-FIELD is populated with '1bb1', after the PERFORM, it would equal '0011'.

Code:

           03  WS-MAP-FIELD        PIC  X(04).
           03  WS-WORK-FIELD       PIC  X(04).
           03  WS-SUB              PIC  9(08)      BINARY.
      *
           MOVE LENGTH OF WS-MAP-FIELD TO TALLY.
           MOVE LENGTH OF WS-MAP-FIELD TO WS-SUB.
           MOVE ZERO                   TO WS-WORK-FIELD.
           MOVE '1  1'                 TO WS-MAP-FIELD.

      *
           PERFORM UNTIL TALLY < 1
               IF (WS-MAP-FIELD (TALLY:1) NOT < '1'
               AND WS-MAP-FIELD (TALLY:1) NOT > '9')
                   MOVE WS-MAP-FIELD (TALLY:1)
                                        TO WS-WORK-FIELD (WS-SUB:1)
                   SUBTRACT 1           FROM WS-SUB
               END-IF
               SUBTRACT 1               FROM TALLY
           END-PERFORM.
      *
           MOVE WS-WORK-FIELD           TO WS-MAP-FIELD.

HTH....
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 -> CICS All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How does a called pgm know if its cal... Graeme Westerman COBOL Programming 4 Tue Nov 29, 2016 9:25 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts CICS NEW SIT PARAMETERS CICS BEHAVIOR... Kyle Carroll CICS 0 Fri Nov 04, 2016 11:55 pm
No new posts Single COPY CICS TS datasets and when... Kyle Carroll CICS 2 Tue Oct 11, 2016 9:47 pm
No new posts CICS VSAM RLS READ akodakka CICS 3 Tue Oct 04, 2016 3:09 pm


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