I am somewhat rusty in Cobol and have not kept up with the latest versions in Cobol. Is there some good functions available now to shift a field that is left-justified to a field that will make it right-justified? Thanks for any help you can offer me!!
No, nothing new. I assume you want to get rid of leading/trailing blanks. The JUSTIFY clause in the DD only works for fields of differing lengths.
If you're trying to get blanks out of a numeric field you could use the new NUMVAL intrinsic function. Else you'd have to use something like string/unstring or inspect (they combined some/most of the functions of transform and, I think, examine).
There is no native function for such justification. (The Justify clause comes close, but doesn't do EXACTLY what you are looking for). For example if you have a field that contains:
"XX " and you move it to a 10 byte field with justify, you will get: " XX ".
You still have the trailing spaces.
Tell me what compiler and version you are using. I might have some code.
MOVE LENGTH OF DATANAME-LEFT TO DATA-LENGTH.
SUBTRACT DATANAME-LENGTH FROM 30 GIVING DATA-START.
MOVE DATANAME-LEFT TO DATANAME-RIGHT(DATA-STARTATA-LENGTH).
HI GOTLURU....I DONT THINK UR METHOD CAN GIVE THE DESIRED RESULT..LENGTH OF GIVES THE LENGTH AS 30 (MENTIONED IN UR ABOVE EG) WE DONT GET THE LENGTH OF THE VARIABLE ENTERED BUT WE GET THE LENGTH AS IS DECLARED...
UR METHOD CAN BE MODIFIED AND CORRECTED USING AN ARRAY USED TO RETRIEVE THE LENGTH OF THE VARIABLE ENTERED AND THEN USING IT IN PLACE OF DATA-LENGTH....AM I CORRECT....?
KURUP
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.