Query Regarding Edited Picture clause in Cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Query Regarding Edited Picture clause in Cobol

Postby ascd001 » Tue Mar 08, 2016 2:28 pm

Hi frnds,

I have a requirement. I need to display + or - symbols along with the output.

For example input value is '03' then I have to display it like '-03' or '+'03'.

For doing that I tried defining the edited picture clause as PIC ZZ99- and PIC zz99+ and then moving it to destination data type.

But its not working. can anyone please help me with it.

The destination datatype should be s9(8) comp-3.

Thanks.
ascd001
 
Posts: 3
Joined: Tue Mar 08, 2016 12:40 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Query Regarding Edited Picture clause in Cobol

 

Re: Query Regarding Edited Picture clause in Cobol

Postby NicC » Tue Mar 08, 2016 3:17 pm

How is it not working? Show the full definition of the variable and those that affect it (i.e. are MOVEd to it or ar the target of the MOVE.

Have you looked in the manual regarding numeric variables and working with them? Also look up SIGN in the index.

Have you searched the forum? or Googled?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2630
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 95 times

Re: Query Regarding Edited Picture clause in Cobol

Postby Robert Sample » Tue Mar 08, 2016 7:45 pm

Your post is contradictory -- you will NOT, under any circumstances, get a value of -03 or +03 when you have a PICTURE of ZZ99- or ZZ99+. You would get 03- or 03+, but not something with the sign in front of the value. Perhaps you need to explain again precisely what you are looking for? And, as Nic said, post what you have tried, the results you got, and the results you expected for each value so we can see what "not working" means to you.
Robert Sample
Global moderator
 
Posts: 3260
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 208 times

Re: Query Regarding Edited Picture clause in Cobol

Postby Terry Heinze » Tue Mar 08, 2016 8:21 pm

As mentioned, see the COBOL Language Reference Manual, chapter on Data Division, Picture Clause, Picture Clause Editing.
.... Terry
Terry Heinze
 
Posts: 180
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 10 times
Been thanked: 11 times

Re: Query Regarding Edited Picture clause in Cobol

Postby ascd001 » Wed Mar 09, 2016 12:05 pm

Hi all,

Thanks for your replies.

See below explanation for clarity.

Defined the varaibles as below:

WS-CNT            PIC S9(7) comp-3.
WS-EDITED-POS PIC +zzzzzz99
WS-EDITED-NEG PIC -zzzzzz99
WS-WRK-DAYS PIC S9(8)V USAGE COMP-3 (TABLE DCLEGEN Variable).


For Example,if WS-CNT value is 19.

After MOVE statement.... Getting WS-EDITED-POS value as + 19.
WS-EDITED-NEG value as 19.

For WS-EDITED-NEG variable Negative sign is not coming in output.
Because of Datatype definition zzzzzz99 Spaces are coming between + symbol and value.

After Moving WS-EDITED-POS to TABLE DCLGEN Variable WS-WRK-DAYS for insert.

WS-WRK-DAYS Contains value as 00000019.

I need to insert the WS-WRK-DAYS value into the table as +19 or -19 depending on requirement.

I hope you guys understood .

Thanks.
ascd001
 
Posts: 3
Joined: Tue Mar 08, 2016 12:40 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Query Regarding Edited Picture clause in Cobol

Postby NicC » Wed Mar 09, 2016 2:41 pm

Have you read the part of the manual referred to by Terry?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2630
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 95 times

Re: Query Regarding Edited Picture clause in Cobol

Postby ascd001 » Wed Mar 09, 2016 3:13 pm

Got the Result.

Thanks for your inputs :)
ascd001
 
Posts: 3
Joined: Tue Mar 08, 2016 12:40 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post