View previous topic :: View next topic
|
Author |
Message |
Mansik Kim
New User
Joined: 15 Dec 2006 Posts: 29 Location: Korea
|
|
|
|
Hi All,
I working PL/I program conversion from COBOLsource.
I want to know following COBOL code is to be converted to
PL/I code.
05. CONVCODE PIC S9(005)
LEADING SEPARATE.
Please let me know what is PL/I code.
Thanks,
Mansik |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
I believe it would be
Code: |
5 CONVCODE PIC'S99999', |
Garry. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
Back to top |
|
|
Mansik Kim
New User
Joined: 15 Dec 2006 Posts: 29 Location: Korea
|
|
|
|
I write this topic on mt iphone.
So take miss spelled.
05 CONVCODE PIC S9(005).
I think same to "FIXED DEC(005)" in PL/I.
Please confirm.
Thanks,
Mansik. |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
This should work:
Code: |
DCL 05 CONVCODE PIC'-99999';
|
|
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
Quote: |
05 CONVCODE PIC S9(005).
I think same to "FIXED DEC(005)" in PL/I.
|
I don't think so - the Cobol field is not a COMP-3 field.
Garry. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
mistah kurtz wrote: |
This should work:
Code: |
DCL 05 CONVCODE PIC'-99999';
|
|
... and if the sign is positive ?
Garry. |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Quote: |
... and if the sign is positive ?
|
oops..sorry..in that case it would have space.. |
|
Back to top |
|
|
Mansik Kim
New User
Joined: 15 Dec 2006 Posts: 29 Location: Korea
|
|
|
|
Thank you for your reply.
I write this topic on mt iphone.
So take miss spelled.
05 CONVCODE PIC S9(005).
I think same to "FIXED DEC(005)" in PL/I.
Please confirm.
Thanks,
Mansik. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Mansik Kim wrote: |
I write this topic on mt iphone. |
Mansik - should I suggest not to use that?
You've posted the same topic twice and an another question twice for which Garry has already given an answer. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
The TS being a "Software Consualtant" is probably very busy consulting a lot of different parties at the same time so a duplicate is very easily made. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
Mansik Kim wrote: |
I write this topic on mt iphone. |
Ah; a dumbphone.
Garry Carroll wrote: |
mistah kurtz wrote: |
This should work:
Code: |
DCL 05 CONVCODE PIC'-99999';
|
|
... and if the sign is positive ? |
Depends on what the implications of LEADING SEPARATE are in COBOL (it's been a few decades, and I've forgotten), but PIC 'S(5)9' would give a "+" if the value is >= 0, and "-" otherwise. PIC '+(5)9' and '-(5)9' will give signs only if >=0 and <0, respectively.
And, of course, you wouldn't declare an 05-level variable in PL/I, any more than you would in COBOL; the code would be like
Code: |
DCL 1 FOO UNAL,
5 CONVCODE PIC 'S(5)9', |
|
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Quote: |
PIC '+(5)9' and '-(5)9' will give signs only if >=0 and <0, respectively. |
Akatsukami - I hope 'am not interpreting it wrong, however in COBOL - for minus sign -- if the sending item is negative, a minus sign is printed. If the sending item is positive, a space is printed instead. And for Plus sign -- if the sending item is negative, a minus in printed and if the sending item is positive, a plus is inserted. Later is used when one always want the sign printed. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10889 Location: italy
|
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1316 Location: Vilnius, Lithuania
|
|
|
|
Code: |
DCL P1 PIC 's9';
DCL P2 PIC '+9';
DCL P3 PIC '-9';
P1,P2,P3 = 1; PUT DATA(P1,P2,P3);
P1,P2,P3 = -1; PUT DATA(P1,P2,P3); |
Output:
Code: |
P1=+1
P2=+1
P3= 1;
P1=-1
P2= 1
P3=-1; |
And in PL/I you use only FIXED DEC until the very last moment, i.e. the moment that you put your data into a format that needs to be read by mere mortals. Doing calculations with PIC variables is bad, very bad! |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
Anuj Dhawan wrote: |
Quote: |
PIC '+(5)9' and '-(5)9' will give signs only if >=0 and <0, respectively. |
Akatsukami - I hope 'am not interpreting it wrong, however in COBOL - for minus sign -- if the sending item is negative, a minus sign is printed. If the sending item is positive, a space is printed instead. And for Plus sign -- if the sending item is negative, a minus in printed and if the sending item is positive, a plus is inserted. Later is used when one always want the sign printed. |
That is true of COBOL; in PL/I, however, a "+" in the picture will print a space if the value is negative. A "S" prints either plus or minus sign depending on value.
ETA: After I wrote this, I noticed Mr. Prins' examples. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Okay, we both stand corrected but my intrepretation was wrong... |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
Not a problem; even I've been known to make mistakes |
|
Back to top |
|
|
|