|
If you set the size of your variable to the largest size you would need then you would only need one routine that you could move any size variable into and remove the trailing spaces. The routine below was designed to remove the trailing spaces from a 30 byte variable - the only downside to expanding the variable size to 1000 or more would be table processing cycles (not very expensive). Perform 2420-inspect-it thru 2420-exit Varying sub from 1 by 1 until sub > 30. 2420-inspect-it. compute suba = 30 - sub. compute subB = sub - 1. if your-Input-variable(sub:suba) = spaces Move replace-it to your-output-variable move 31 to sub end-if. 2420-EXIT. EXIT. John A Arnold (301) 214-8939 jarnold@xxxxxxxxxxxxx -----Original Message----- From: cobol400-l-request@xxxxxxxxxxxx [mailto:cobol400-l-request@xxxxxxxxxxxx] Sent: Thursday, August 19, 2004 1:00 PM To: cobol400-l@xxxxxxxxxxxx Subject: COBOL400-L Digest, Vol 2, Issue 91 Send COBOL400-L mailing list submissions to cobol400-l@xxxxxxxxxxxx To subscribe or unsubscribe via the World Wide Web, visit http://lists.midrange.com/mailman/listinfo/cobol400-l or, via email, send a message with subject or body 'help' to cobol400-l-request@xxxxxxxxxxxx You can reach the person managing the list at cobol400-l-owner@xxxxxxxxxxxx When replying, please edit your Subject line so it is more specific than "Re: Contents of COBOL400-L digest..." Today's Topics: 1. Re: Conversion of numeric data to character format? (MichaelQuigley@xxxxxxxxxx) 2. Problem with relative file (Aseem Sehgal) 3. RE: Conversion of numeric data to character format? (Jon Paris) 4. RE: Conversion of numeric data to character format? (Terry Grider) ---------------------------------------------------------------------- message: 1 date: Wed, 18 Aug 2004 14:05:37 -0400 from: MichaelQuigley@xxxxxxxxxx subject: Re: [COBOL400-L] Conversion of numeric data to character format? Jon, I think that works for a single case, but you can't write a generic routine unless you always are converting the same size field. Or can you? I would rather avoid writing ugly COBOL code if it can easily be avoided. Original message: ------------------------------ Since RPG provides a simple, elegant solution and is an ILE language, why not simply write this (and any other similar routines in RPG?). It is not as if you have to buy the compiler - you own it if you own the COBOL one. I see no point in writing ugly COBOL code when the RPG option is available. -------------- next part -------------- Checked by AVG Anti-Virus (http://www.grisoft.com). Version: 7.0.262 / Virus Database: 264.6.3 - Release Date: 8/16/2004 ------------------------------ message: 2 date: Wed, 18 Aug 2004 20:22:03 +0200 from: "Aseem Sehgal" <saseem@xxxxxxxxxxx> subject: [COBOL400-L] Problem with relative file Hi, Has anybody seen such a problem on Iseries. We have a CL which calls the cobol program , in the CL we create a file with following command CRTPF XXLIB/XXFILE RCDLEN(250) OVRDBF F05TRAV TOFILE(XXLIB/XXFILE) CALL COBOLXYZ In the Cobol program COBOLXYZ we have following defination for the file SELECT F05TRAV ASSIGN TO DATABASE-F05TRAV ORGANIZATION IS RELATIVE ACCESS MODE IS RANDOM RELATIVE KEY IS F05-KEY. And just before opening of file the code we call to a CL to do a CLRPFM on file XXLIB/XXFILE (I know it is not required but we have done it as this is a generic customer requirement) And then we have following code OPEN OUTPUT F05TRAV. CLOSE F05TRAV. OPEN I-O F05TRAV. The problem is that as soon as the code reaches point where we do OPEN OUTPUT F05TRAV the size of file XXLIB/XXFILE starts increasing at a phenomenal rate and it eats all the disk space and there is no way to end the job , only solution is a PWRDWNSYS. Please suggest if you have seen this problem earlier. The Iseries is running V5R2M0. Regards Aseem ------------------------------ message: 3 date: Wed, 18 Aug 2004 20:41:54 -0400 from: "Jon Paris" <Jon.Paris@xxxxxxxxxxxxxx> subject: RE: [COBOL400-L] Conversion of numeric data to character format? >> I think that works for a single case, but you can't write a generic routine .... I agree that writing a generic routine is not always possible. I honestly don't recall the full details of the original request, but in some cases it is possible. For example - a generic trim routine could be written by utilizing descriptors to determine the size of the field passed and then doing %trim(%subst(...... of course the RPG is a little uglier. If only COBOL had implemented a more generic FUNCTION option with some form of prototyping (not the 400 folks fault I know) then it would be much easier to tap into the RPG and C functions directly. I have always found COBOL's string handling to be a royal pain in the proverbial. Jon Paris Partner400 www.Partner400.com ------------------------------ message: 4 date: Thu, 19 Aug 2004 10:53:24 -0500 from: "Terry Grider" <Terry.Grider@xxxxxxxxxxxxxxxx> subject: RE: [COBOL400-L] Conversion of numeric data to character format? WORKING-STORAGE SECTION. 01 WS-WORK-FIELDS. 03 CUSTNBR PIC S9(6) USAGE DISPLAY. 03 MESSAGE-DATA PIC X(30). 03 L PIC S9(5) VALUE +0. PROCEDURE DIVISION. MOVE SPACES TO MESSAGE-DATA. MOVE 123.00 TO CUSTNBR. INSPECT CUSTNBR TALLYING L FOR LEADING '0'. STRING 'CUSTOMER NUMBER ' CUSTNBR(L + 1:6 - L) INTO MESSAGE-DATA. -----Original Message----- From: Jay Sulzmann [mailto:jsulzmann@xxxxxxxxxxx] Sent: Monday, August 16, 2004 10:28 AM To: COBOL Programming on the iSeries/AS400 Subject: [COBOL400-L] Conversion of numeric data to character format? Dear COBOL experts, Is there any equivalent of the following in COBOL, or an easier way to do it than fooling around with numeric-edited fields? CustNbr is a 6-digit signed (USAGE IS DISPLAY) field. I want to put the Customer Number (CustNbr) into message data (MessageData) to pass to the QMHSNDPM API. If the customer number is 123,and I do the following using free-format RPG-IV, MessageData = %char( CustNbr ); the input is 000123 and the output would be 123 (left-justified and all). The message looks like Customer Number 123 is not on file. The only way I know how to do this in COBOL results in Customer Number 123 is not on file. Cheers -- Jay ================================= Jay Sulzmann AS/400 Senior Programmer/Analyst AS/400 Certified RPG IV Developer Hainey Business Systems LLC 8 East Canal Street Dover, PA 17315 Tel: 717-718-9601 Ext. 231 Fax: 717-292-9474 AIM: bluejay0827 Web: www.hbs-inc.com ____________________________________ Providing E-Business, EDI, AS/400 Development and related services nationwide. _______________________________________________ This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing list To post a message email: COBOL400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/cobol400-l or email: COBOL400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/cobol400-l. ------------------------------ _______________________________________________ This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) digest list To post a message email: COBOL400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/cobol400-l or email: COBOL400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/cobol400-l. End of COBOL400-L Digest, Vol 2, Issue 91 *****************************************
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.