View previous topic :: View next topic |
Author |
Message |
raj_m Beginner
Joined: 24 May 2005 Posts: 5 Topics: 2
|
Posted: Tue May 24, 2005 9:19 pm Post subject: Wrapping texts dynamically in Cobol Reporting |
|
|
Hi ALL,
I'm not an expert in cobol report writing. I have a specific requirement from the users which goes as below.
I have to print the following detail line of the report.
the length of the report line is 80 bytes.( first 10 bytes and last 5 bytes - always spaces)
" TODAY WE RECEIVED A DEPOSIT FROM YOU IN THE AMOUNT OF '
$$,$$$,$$$,$$$,$$9.99, WITH $$,$$$,$$$,$$$,$$9.99 IN CASH. PLEASE BE ASSURED '
THIS WAS DEPOSITED INTO YOUR ACCOUNT "
I am dynamically populating both the amount fields. Based on the amount field, the leading spaces before the $ sign should be truncated. I am able to do this using the string function.
But the task is how do I wrap all the text after the amont fields.
in effect what i need is
if the amt 1 is $99.99 and amt2 is $999.99 then my detail line should read
" TODAY WE RECEIVED A DEPOSIT FROM YOU IN THE AMOUNT OF '
$99.99, WITH $999.99 IN CASH. PLEASE BE ASSURED THIS WAS DEPOSITED INTO '
YOUR ACCOUNT "
if the amt1 is $1,000,000,000,000.00 and amt2 is $1,000,000,000,000.00 then my detail line should read
" TODAY WE RECEIVED A DEPOSIT FROM YOU IN THE AMOUNT OF '
$1,000,000,000,000.00, WITH $1,000,000,000,000.00 IN CASH. PLEASE BE ASSURED '
THIS WAS DEPOSITED INTO YOUR ACCOUNT "
Can anyone suggest me how to come up with a logic to accomplish this?
Thanks
Raj |
|
Back to top |
|
|
acevedo Beginner
Joined: 03 Dec 2002 Posts: 127 Topics: 0 Location: Europe
|
Posted: Wed May 25, 2005 9:25 am Post subject: |
|
|
this could be one approach:
Count the leading spaces of the field wheare you have the amount edited:
inspect YOUREDITEDAMOUNT tallying WS-FROM for leading spaces
WS-TO = Length YOUREDITEDAMOUNT - WS-FROM
and then use the initial/end to wrap it using a string sentence:
string
' TODAY WE RECEIVED A DEPOSIT FROM YOU IN THE AMOUNT OF '
YOUREDITEDAMOUNT (WS-FROM:WS-TO)
' ,WITH '
----------SAME WITH AMOUNT2-------------
' IN CASH.PLEASE BE ASSURED THIS WAS DEPOSITED INTO '
' YOUR ACCOUNT'
delimited by size into YOURTEXT
end-string
I've written from scratch, take a look at the manuals.
HTH |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Wed May 25, 2005 9:30 am Post subject: |
|
|
Raj,
when you use STRING statement , you will also get the length of the total string using the pointer parm.
ex:
Code: |
01 W-MSG1 PIC X(54) VALUE
'TODAY WE RECEIVED A DEPOSIT FROM YOU IN THE AMOUNT OF'.
01 W-MSG2 PIC X(27) VALUE
'IN CASH. PLEASE BE ASSURED'.
01 W-MSG3 PIC X(37) VALUE
'THIS WAS DEPOSITED INTO YOUR ACCOUNT'.
01 W-DYNAM-TXT.
05 W-TXT-LENGTH PIC S9(4) COMP.
05 W-TOT-TXT PIC X(160) VALUE SPACE.
STRING ' ' DELIMITED BY SIZE
W-AMT DELIMITED BY SPACE
' WITH ' DELIMITED BY SIZE
W-CASH DELIMITED BY SPACE
' ' DELIMITED BY SIZE
W-MSG2 DELIMITED BY SIZE
W-MSG3 DELIMITED BY SIZE
QUOTE DELIMITED BY SIZE
INTO W-TOT-TXT
POINTER W-TXT-LENGTH
END-STRING.
|
Now W-txt-length will have the total length of the string.
You can check it and see if it is greater than 80 , then split the message into the next line.
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Bithead Advanced
Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Wed May 25, 2005 9:37 am Post subject: |
|
|
I usually build the line in a large working storage field then I set my pointer to the maximum length of the report field plus 1 (in your case 81). I then work back until I find a space (you may also want to check for the period). I then move the first part into line 1 and the rest into line 2.
It would me nice to see $1,000,000,000,000.00 deposited into my account! |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Wed May 25, 2005 9:45 am Post subject: |
|
|
Quote: |
It would me nice to see $1,000,000,000,000.00 deposited into my account!
|
Wouldn't it be nice if it was all in CASH? _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
dtf Beginner
Joined: 10 Dec 2004 Posts: 110 Topics: 8 Location: Colorado USA
|
Posted: Wed May 25, 2005 11:18 am Post subject: |
|
|
If I count this right, it is a trillion dollars. I wonder if that much "cash" even exist.
________
vaporizer shop
Last edited by dtf on Tue Feb 01, 2011 1:54 pm; edited 1 time in total |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Wed May 25, 2005 11:40 am Post subject: |
|
|
Quote: |
If I count this right, it is a trillion dollars.
|
dtf,
You are right as an American, but mervyn from UK might not agree with you as in England they call a trillion a billion
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Mervyn Moderator
Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
Posted: Wed May 25, 2005 2:38 pm Post subject: |
|
|
Absolutely right! And a billion pounds sounds FAR more than a trillion dollars! _________________ The day you stop learning the dinosaur becomes extinct |
|
Back to top |
|
|
Bithead Advanced
Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Wed May 25, 2005 2:43 pm Post subject: |
|
|
I guess it depends if it falls on you! |
|
Back to top |
|
|
Mervyn Moderator
Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
Posted: Wed May 25, 2005 3:03 pm Post subject: |
|
|
You see the big hat in my picture? You wouldn't believe just how quickly I can turn that the other way up!!! _________________ The day you stop learning the dinosaur becomes extinct |
|
Back to top |
|
|
Bithead Advanced
Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Wed May 25, 2005 3:11 pm Post subject: |
|
|
If it was a million pounds (lbs), I am not sure it matters which way up your hat is.....
It does have a remarkable slimming effect tho! |
|
Back to top |
|
|
raj_m Beginner
Joined: 24 May 2005 Posts: 5 Topics: 2
|
Posted: Wed May 25, 2005 11:10 pm Post subject: |
|
|
Thanks a Million!!!!!! Guyz
I got the logic to accomplish this..
Raaj |
|
Back to top |
|
|
|
|