MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Right justifying alpha numeric data

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
vkrishna2001
Beginner


Joined: 07 Aug 2003
Posts: 46
Topics: 18
Location: Danbury

PostPosted: Fri Mar 04, 2005 4:50 am    Post subject: Right justifying alpha numeric data Reply with quote

We have VS Cobol II Release 4.0 on mainframe. Though this compiler accepts defining a alpha numeric data item as right justified in the data division it does not right justify a value in the procedure division. So for this requirement we use a algorithm which involves tables. But this is consuming lot of CPU. Now we have a requirement to reduce CPU. Can the same be performed with other tools with less CPU.

We have SYNCSORT, EASYTRIEVE, FILD-AID BATCH.

Thanks,
Vijay
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Fri Mar 04, 2005 10:26 am    Post subject: Reply with quote

vkrishna2001,

Post a sample of input and desired output along with the lengths of the fields.

Also check out this topics

http://www.mvsforums.com/helpboards/viewtopic.php?t=2429&highlight=right

http://www.mvsforums.com/helpboards/viewtopic.php?t=2354&highlight=right

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkrishna2001
Beginner


Joined: 07 Aug 2003
Posts: 46
Topics: 18
Location: Danbury

PostPosted: Mon Mar 07, 2005 10:30 am    Post subject: Reply with quote

Hi Kolusu,

In the application program I need to right justify 17 byte alphanumeric data.

Sample input is
Code:

1H9651216T1011003
1GDG6H1P6MJ520593
2081
1A9AU4036YP463004
1A9AU4031YP463006
1A9AU4037YP463009
1F9FS1023V1025524
1F9FS1028V1025521
22746
751001
CA717568
CA416485
CA746008
CA717574

Thanks,
Vijay
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Mon Mar 07, 2005 11:01 am    Post subject: Reply with quote

vkrishna2001,

Try this piece of code.

Code:

IDENTIFICATION DIVISION.                                 
PROGRAM-ID.    SAMPLE                                   
ENVIRONMENT DIVISION.                                   
DATA DIVISION.                                           
WORKING-STORAGE SECTION.                                 
                                           
01 WS-INPUT     PIC X(17) VALUE '22746'.
01 WS-OUTPUT    PIC X(17).                               
01 WS-LENGTH    PIC S9(04) COMP.                         
01 WS-TALLY     PIC S9(04) COMP.                         
                                                         
PROCEDURE DIVISION.                                     
                                                         
    INSPECT FUNCTION REVERSE(WS-INPUT) TALLYING WS-TALLY
        FOR LEADING SPACES                               
    COMPUTE WS-LENGTH = LENGTH OF WS-INPUT - WS-TALLY   
    MOVE WS-INPUT(1: WS-LENGTH) TO                       
         WS-OUTPUT(WS-TALLY + 1 : WS-LENGTH)             
    GOBACK.                                             


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkrishna2001
Beginner


Joined: 07 Aug 2003
Posts: 46
Topics: 18
Location: Danbury

PostPosted: Mon Mar 07, 2005 11:25 am    Post subject: Reply with quote

Hi Kolusu,

When I compile the code I receive the following error messages

IGYPS2121-S "FUNCTION" was not defined as a data-name. The statement was discarded.

"REVERSE" was found in the "INSPECT" statement. The statement was discarded.

I am compiling program on z/OS.


Regards,
Vijay
Back to top
View user's profile Send private message Send e-mail
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Mon Mar 07, 2005 12:38 pm    Post subject: Reply with quote

I think, coding WS-OUTPUT with JUST RIGHT will do the job. For e.g.

Code:

01 WS-OUTPUT PIC X(17) JUST RIGHT.

_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
nithinravi
Beginner


Joined: 07 Jul 2005
Posts: 1
Topics: 0
Location: Hartford CT

PostPosted: Thu Jul 07, 2005 3:05 pm    Post subject: My First posting - Right Justification Reply with quote

I only have a programatic solution - Extract from one of my Programs.
Code:

Woking storage
--------------------
01  INPUT-FIELD        PIC X(50).
       01  INPUT-FIELD-TABLE REDEFINES INPUT-FIELD.
           05  INPUT-BYTE OCCURS 50 TIMES INDEXED BY INP-IND
                              PIC X(01).
       01  OUTPUT-FIELD       PIC X(50).
       01  OUTPUT-FIELD-TABLE REDEFINES OUTPUT-FIELD.
       05  OUTPUT-BYTE OCCURS 50 TIMES INDEXED BY OUT-IND
                              PIC X(01).

Here Input/Output Field is Alpha it can be Numeric also.

Body
-------
I call this para to do the Right Just

11000-RT-JUST.
                MOVE WS-CONTR-DESC TO INPUT-FIELD
                MOVE 'N' TO WS-FLAG
                MOVE SPACE TO OUTPUT-FIELD
                    SET OUT-IND TO 50
                    PERFORM VARYING INP-IND FROM 50 BY -1
                                       UNTIL INP-IND  < 1
                        IF WS-FLAG = 'N'
                           IF INPUT-BYTE (INP-IND) NOT = SPACE
                              MOVE 'Y' TO WS-FLAG
                              MOVE INPUT-BYTE (INP-IND) TO
                                             OUTPUT-BYTE (OUT-IND)
                              SET OUT-IND DOWN BY 1
                           END-IF
                        ELSE
                            MOVE INPUT-BYTE (INP-IND) TO
                                          OUTPUT-BYTE (OUT-IND)
                            SET OUT-IND DOWN BY 1
                        END-IF
                    END-PERFORM.
                    MOVE OUTPUT-FIELD TO WSS-CONTR-DESC.
       11000-EXIT.



----------------------------
This code works . If anybody have any questions let me know !!!
Smile
Back to top
View user's profile Send private message
bonnie_mathew
Beginner


Joined: 05 Aug 2005
Posts: 8
Topics: 0

PostPosted: Sat Aug 06, 2005 12:25 am    Post subject: Reply with quote

Hi,

Actually justify works in procedure division also. In your case if you move from the PIC X(17) variable to a PIC X(18) JUST variable you will get it right justified. Please try this out and see if it serves your purpose.
Back to top
View user's profile Send private message
bonnie_mathew
Beginner


Joined: 05 Aug 2005
Posts: 8
Topics: 0

PostPosted: Sat Aug 06, 2005 12:27 am    Post subject: Reply with quote

sorry for that.
Hi,

Actually justify works in procedure division also. In your case if you move from the PIC X(17) variable to a PIC X(18) JUST variable you will get it right justified. Please try this out and see if it serves your purpose.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group