IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

SUSBSCRIPT WITH SIGN IN PIC CLAUSE


 
IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
RIGICDS32

New User


Joined: 24 Jun 2020
Posts: 4
Location: India

PostPosted: Wed Jun 24, 2020 5:49 pm
Reply with quote

I am writing this piece of code -
Code:
IDENTIFICATION DIVISION.
program-id. Hello.
data division.
WORKING-STORAGE SECTION.
01 INPUT-RECORD.
   02 VAR1 OCCURS 4 TIMES.
      03 VAR2 PIC X(11) OCCURS 1 TIMES.
      03 VAR22 REDEFINES VAR2 PIC S9(10) SIGN IS LEADING SEPARATE CHARACTER.
PROCEDURE DIVISION.
MOVE '012|323|121|2|1' TO INPUT-RECORD.
UNSTRING INPUT-RECORD DELIMITED BY "|"
                 INTO VAR2(1,1)
              DISPLAY VAR22(1)
stop run.


Output -
12 -

I want to get it displayed as +012.

Thanks for the help in advance.
Back to top
View user's profile Send private message
RIGICDS32

New User


Joined: 24 Jun 2020
Posts: 4
Location: India

PostPosted: Wed Jun 24, 2020 6:31 pm
Reply with quote

Code:
IDENTIFICATION DIVISION.
program-id. Hello.
data division.
WORKING-STORAGE SECTION.
01 INPUT-RECORD.
   02 VAR1 OCCURS 4 TIMES.
      03 VAR2 PIC X(10) OCCURS 1 TIMES.
01 VAR22 PIC S9(10) LEADING.
PROCEDURE DIVISION.
MOVE '012|323|121|2|1' TO INPUT-RECORD.
UNSTRING INPUT-RECORD DELIMITED BY "|"
                 INTO VAR2(1,1)
END-UNSTRING.
MOVE VAR2(1,1) TO VAR22.
DISPLAY VAR22.
stop run.

OUTPUT - +0000000012

It's kinda solved.
Thank you.
Back to top
View user's profile Send private message
RIGICDS32

New User


Joined: 24 Jun 2020
Posts: 4
Location: India

PostPosted: Fri Jun 26, 2020 2:34 pm
Reply with quote

No it's not solved actually.

The subscript thing is adding trailing zeroes to the number.
How to avoid it?
Back to top
View user's profile Send private message
RIGICDS32

New User


Joined: 24 Jun 2020
Posts: 4
Location: India

PostPosted: Fri Jun 26, 2020 3:35 pm
Reply with quote

Solved using numval icon_sad.gif icon_razz.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> COBOL Programming
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. Missing Negative sign in COBOL COBOL Programming 6
No new posts NOT IN clause in COBOL pgm COBOL Programming 8
No new posts Typing the CENT sign ยข on mainframe,... All Other Mainframe Topics 2
No new posts usage of CASE in WHERE clause DB2 10
No new posts Cobol redefines for Signed pictured c... COBOL Programming 4

Back to Top