Page 1 of 1

Query Regarding Edited Picture clause in Cobol

PostPosted: Tue Mar 08, 2016 2:28 pm
by ascd001
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.

Re: Query Regarding Edited Picture clause in Cobol

PostPosted: Tue Mar 08, 2016 3:17 pm
by NicC
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?

Re: Query Regarding Edited Picture clause in Cobol

PostPosted: Tue Mar 08, 2016 7:45 pm
by Robert Sample
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.

Re: Query Regarding Edited Picture clause in Cobol

PostPosted: Tue Mar 08, 2016 8:21 pm
by Terry Heinze
As mentioned, see the COBOL Language Reference Manual, chapter on Data Division, Picture Clause, Picture Clause Editing.

Re: Query Regarding Edited Picture clause in Cobol

PostPosted: Wed Mar 09, 2016 12:05 pm
by ascd001
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.

Re: Query Regarding Edited Picture clause in Cobol

PostPosted: Wed Mar 09, 2016 2:41 pm
by NicC
Have you read the part of the manual referred to by Terry?

Re: Query Regarding Edited Picture clause in Cobol

PostPosted: Wed Mar 09, 2016 3:13 pm
by ascd001
Got the Result.

Thanks for your inputs :)