MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Get the Length of a variable String

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
ravi.alpha
Beginner


Joined: 31 Mar 2009
Posts: 18
Topics: 7

PostPosted: Mon Aug 03, 2009 1:18 pm    Post subject: Get the Length of a variable String Reply with quote

Input file's records contain field ORG-DESCR, defined in COBOL program as PIC X(100). Data in this field is the name of the product's issuing company, i.e. "PINE RIDGE PLANTATION CM NTY DEV DIST FLA CAP IMP", "GRUPO FINANCIERO BBVA BANCOMER S.A. DE C.V." etc.
Data has to be stored in the DB2 column, defined as VARCHAR(100), in
each case length of the company's name is required. E.g., for "PINE
RIDGE PLANTATION CM NTY DEV DIST FLA CAP IMP" it would be 49,
for "GRUPO FINANCIERO BBVA BANCOMER S.A. DE C.V." it would be
43 etc.

1) How do you find the length of the company name in the COBOL
program?
2) Which way is more efficient and why?
Note, the name can contain any type of the EBCDIC characters and
multiple spaces between words can be expected.
Back to top
View user's profile Send private message
ravi.alpha
Beginner


Joined: 31 Mar 2009
Posts: 18
Topics: 7

PostPosted: Mon Aug 03, 2009 1:21 pm    Post subject: Reply with quote

One more

COBOL program accesses two files:
1) Product pricing file, containing product's IDs that are expressed in
various currencies
2) Currency conversion rates

Program reads pricing file and must convert prices into US Dollars, using conversion rates from the currency conversion rate file.

I.e., pricing file contains approx 2,500,000 prices in following format:
34567 123456.789 AED
23456 000567.007 AUD
56783 098760.775 EUR

Rates conversion file contains rates in the following format:
AED 3.67310
AFN 47.54000
ALL 91.34000
AMD 366.03000
ANG 1.79000
AOA 77.80600
ARS 3.80950

To convert price into US Dollars, price must be divided by corresponding
rate, i.e. for the first pricing record:

usd-price = 123456.789 / 3.67310

What is the logic to calculate USD prices in the this program?

Please provide the matching logic and the calculation of the price.
Back to top
View user's profile Send private message
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Mon Aug 03, 2009 1:35 pm    Post subject: Reply with quote

Please use meaningful topics next time.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Mon Aug 03, 2009 1:42 pm    Post subject: Reply with quote

ravi.alpha,

what is wrong with you? Can't you even describe the problem in your title? bonk bonk
_________________
Kolusu
www.linkedin.com/in/kolusu


Last edited by kolusu on Mon Aug 03, 2009 3:01 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Mon Aug 03, 2009 1:43 pm    Post subject: Reply with quote

One option for determining the actual size of ORG-DESC is to use an INSPECT to determine the number of trailing blanks. See REVERSE function description in the Language Reference Manual. Knowing the number of trailing blanks and the length of ORG-DESC will give you what I think you want.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Mon Aug 03, 2009 1:57 pm    Post subject: Reply with quote

You can extract the needed code from my post here

http://www.mvsforums.com/helpboards/viewtopic.php?p=53125#53125
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Mon Aug 03, 2009 3:02 pm    Post subject: Reply with quote

ravi.alpha,

Are these interview questions?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Sat Oct 10, 2009 4:05 pm    Post subject: Reply with quote

Hi,

For posterity, here's my offering for a less complex, but maybe slightly less efficient solution:
Code:
01  L                     PIC S9(03) COMP.

INSPECT FUNCTION REVERSE(ORG-DESC) TALLYING L FOR LEADING SPACES
COMPUTE VCHAR-LEN = LENGTH OF ORG-DESC - L
MOVE ORG-DESC TO VCHAR-DATA

I forget whether the DB2 tbl variables need a leading ":", it's been a while since I've used DB2.
_________________
Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group