View previous topic :: View next topic |
Author |
Message |
vkrishna2001 Beginner
Joined: 07 Aug 2003 Posts: 46 Topics: 18 Location: Danbury
|
Posted: Fri Mar 04, 2005 4:50 am Post subject: Right justifying alpha numeric data |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
vkrishna2001 Beginner
Joined: 07 Aug 2003 Posts: 46 Topics: 18 Location: Danbury
|
Posted: Mon Mar 07, 2005 10:30 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Mon Mar 07, 2005 11:01 am Post subject: |
|
|
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 |
|
|
vkrishna2001 Beginner
Joined: 07 Aug 2003 Posts: 46 Topics: 18 Location: Danbury
|
Posted: Mon Mar 07, 2005 11:25 am Post subject: |
|
|
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 |
|
|
Cogito-Ergo-Sum Advanced
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
|
Posted: Mon Mar 07, 2005 12:38 pm Post subject: |
|
|
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 |
|
|
nithinravi Beginner
Joined: 07 Jul 2005 Posts: 1 Topics: 0 Location: Hartford CT
|
Posted: Thu Jul 07, 2005 3:05 pm Post subject: My First posting - Right Justification |
|
|
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 !!!
|
|
Back to top |
|
|
bonnie_mathew Beginner
Joined: 05 Aug 2005 Posts: 8 Topics: 0
|
Posted: Sat Aug 06, 2005 12:25 am Post subject: |
|
|
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 |
|
|
bonnie_mathew Beginner
Joined: 05 Aug 2005 Posts: 8 Topics: 0
|
Posted: Sat Aug 06, 2005 12:27 am Post subject: |
|
|
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 |
|
|
|
|