The code below performs the same function without requiring a massive if
structure.  It basically looks at the input variable from the first
position to the last steadily increasing the first position examined
until all the last positions are equal spaces.

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: Tuesday, August 17, 2004 1:00 PM
To: cobol400-l@xxxxxxxxxxxx
Subject: COBOL400-L Digest, Vol 2, Issue 89

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?
      (Sundhararaman L)


----------------------------------------------------------------------

message: 1
date: Tue, 17 Aug 2004 16:26:47 +0530
from: "Sundhararaman L" <Sundhararaman.L@xxxxxxxxxxxxxxx>
subject: Re: [COBOL400-L] Conversion of numeric data to character
        format?

Hi Jay,
        Incase you require the DDS which i have used for this sample 



Hope this helps,
Sundhararaman.
Larsen & Toubro Infotech Ltd.,

This document is classified as :
( ) L&T Infotech Proprietary            ( ) L&T Infotech Confidential
( ) L&T Infotech Internal Use only              (x) L&T Infotech General

Business 




"Sundhararaman L" <Sundhararaman.L@xxxxxxxxxxxxxxx>
Sent by: cobol400-l-bounces@xxxxxxxxxxxx
17/08/2004 03:33 PM
Please respond to COBOL Programming on the iSeries/AS400

 
        To:     COBOL Programming on the iSeries/AS400
<cobol400-l@xxxxxxxxxxxx>
        cc: 
        Subject:        Re: [COBOL400-L] Conversion of numeric data to
character format?


Hi Jay,
        Let me tell you what I understood of your problem.
You need to remove the leading zeros in a numeric data and display it in
a 

character string (basically to left align).
 
I've faced that problem and I devised a round about method, as I
couldn't 
find a straightforward way. This could be an ugly method but certainly 
works. 

        These are the steps I'd suggest.
                1. Check the numeric variable for zeros for all the
digits 

you care on display (i.e., if you believe that you              will 
receive a zero filled value and care to display only one zero search in 
for first 5 positions). 

                        When you find the position in the string not
zero 
move the data from that position till the end of the            string 
(which  you know already) to a temp variable that is of character data 
type. Length of temp                    variable can be same as the
source 

variable (X(6) in this case) . Where by you will have the leading zeros 
trimmed and left aligned character data in the temp variable. 
 
                Find the sample code for this in the attached file " IF 
Statement.txt".

                2. Using the String statement you can formulate your 
required output string with the formatted data.

Find the sample code in the attached file " String Statement.txt ".


 

Best wishes,
Sundhararaman.
Larsen & Toubro Infotech Ltd.,

This document is classified as :
( ) L&T Infotech Proprietary            ( ) L&T Infotech Confidential
( ) L&T Infotech Internal Use only              (x) L&T Infotech General

Business 




"Jay Sulzmann" <jsulzmann@xxxxxxxxxxx>
Sent by: cobol400-l-bounces@xxxxxxxxxxxx
16/08/2004 08:58 PM
Please respond to COBOL Programming on the iSeries/AS400

 
        To:     "COBOL Programming on the iSeries/AS400" 
<cobol400-l@xxxxxxxxxxxx>
        cc: 
        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) 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.





______________________________________________________________________
-------------- next part --------------
Note.
-----
This code for a 4 digit numeric field. you should use change this logic
for your 6 digit field accordingly.
   
            IF CustNbr  OF CUST-REC (1:1) = '0'
                  IF CustNbr  OF CUST-REC (2:1) = '0'
                        IF CustNbr  OF CUST-REC (3:1) = '0'
                              IF CustNbr  OF CUST-REC (4:1) = '0'
                                    MOVE CustNbr  OF CUST-REC (4:1) TO
TMP-CustNbr
                                    MOVE TMP-CustNbr TO CustNbr OF
CUST-REC1
                              ELSE
                                    MOVE CustNbr  OF CUST-REC1 (4:1) TO
TMP-CustNbr
                                    MOVE TMP-CustNbr TO CustNbr OF
CUST-REC1
                              END-IF
                        ELSE
                          MOVE CustNbr OF CUST-REC1 (3:2) TO TMP-CustNbr
                          MOVE TMP-CustNbr TO CustNbr OF CUST-REC1
                      END-IF
                ELSE
                   MOVE CustNbr OF CUST-REC1 (2:3) TO TMP-CustNbr
                   MOVE TMP-CustNbr TO CustNbr OF CUST-REC1
                END-IF
             ELSE
               MOVE CustNbr OF CUST-REC1 (1:4) TO TMP-CustNbr
               MOVE TMP-CustNbr TO CustNbr OF CUST-REC1
          END-IF.



-------------- next part --------------
MOVE 'Customer Number ' TO VAR1.

MOVE ' is not on file' TO VAR2.

STRING  
        VAR1 DELIMITED BY SIZE

        CustNbr OF CUST-REC1 DELIMITED BY SPACES
                
        VAR2 DELIMITED BY SIZE

        INTO MSG-VAR
END-STRING. 

**** 
**** the following statement displays the concatenated output statement
like 
**** Customer Number 123 is not on file
**** 

DISPLAY MSG-VAR 

-------------- next part --------------
01  CUST-REC.
    05 CustNbr          PIC 9(6) VALUE ZEROS.   

01  CUST-REC1 REDEFINES CUST-REC.
    05 CustNbr          PIC X(6) VALUE SPACES.  

01  TMP-CustNbr         PIC X(6) vALUE SPACES.

01  VAR1                PIC X(16) vALUE SPACES. 
01  VAR2                PIC X(15) vALUE SPACES. 

------------------------------

_______________________________________________
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 89
*****************************************


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 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.