COBOL: Is it possible to apply a different Pic clause to a single variable?

50 pts.
Tags:
CL/400
COBOL
COBOL/400
Is it possible to use a different  Pic clause from a single variable? based on the condition.

DEBIT             PIC ZZZZZZZ,ZZZ,ZZ9.99                      PIC ZZZ,ZZZ,ZZZ,ZZ9.99 For example              When true                          DEBIT should act as a PIC ZZZZZZZ,ZZZ,ZZ9.99              else                         DEBIT should act as a PIC  ZZZ,ZZZ,ZZZ,ZZ9.99

Please Suggesst me..



Software/Hardware used:
COBOL/400

Answer Wiki

Thanks. We'll let you know when a new response is added.

AFAIK, no.

However, the result that you apparently want can be obtained in at least two different ways.

You can REDEFINE an area with multiple definitons. At run-time, choose which field will be the target for the data you MOVE into it.

You can also simply declare the field as PIC X(18) or however long the space is. Then use edit APIs to apply whatever edit word you want to a value and move the edited value into the field.

Tom

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Or have two edit patterns and move the appropriate one to your output line.

05 DEBIT-TRUE PIC ZZZZZZZ,ZZZ,ZZ9.99.
05 DEBIT-FALSE PIC ZZZ,ZZZ,ZZZ,ZZ9.99.

05 OP-LINE.
10 OP-DEBIT PIC x(18).

IF condition-is-true
MOVE debit-field TO DEBIT-TRUE
MOVE DEBIT-TRUE TO OP-DEBIT
ELSE
MOVE debit-field TO DEBIT-FALSE
MOVE DEBIT-FALSE TO OP-DEBIT.
WRITE op-file FROM OP-LINE.

Hi Your answer is good but my program is very big so i need to change so many lines instead of that only i asked is there any possibility by using single var… Thanks for ur reply..

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • RossHowatson
    Try externally described printer file. From that set up multiple print lines. Print the corresponding line you need.
    245 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following