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 

To determine file records starting with a particular digit..

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


Joined: 04 Apr 2007
Posts: 2
Topics: 2
Location: Calcutta, India

PostPosted: Thu Sep 06, 2007 3:20 am    Post subject: To determine file records starting with a particular digit.. Reply with quote

Hi,
I've an input customer file and my COBOL program needs to process all records having customer nos starting with 6. Now the customer no field is defined as PIC 9(7) in the file.

What is the COBOL syntax for the above, considering I write that statement, in an IF-ELSE block?

Thanks in advance,
Anirban
Back to top
View user's profile Send private message
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Thu Sep 06, 2007 4:29 am    Post subject: Reply with quote

thakuranirban,

Try this untested code:



[code:1:70ed303fc0]

05 WS03-CUST-NO-9 PIC 9(07).
05 WS03-CUST-NO-X REDEFINES WS03-CUST-NO.
10 WS03-CUST-NO PIC X(07).

05 WS03-TEMP-VAR PIC X(07).
05 WS03-TEMP-CNT PIC 9(09).

.....

INSPECT WS03-CUST-NO REPLACING ALL LEADING ZEROES BY SPACES.


INSPECT WS03-CUST-NO TALLYING WS-TEMP-CNT FOR CHARACTERS '6' AFTER
_________________
Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Back to top
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Thu Sep 06, 2007 4:35 am    Post subject: Reply with quote

If custno >= 6000000 and < 7000000 then ignore....
if custno(1:1) = '6' then ignore.....

Might I introduce you to the Fine COBOL Manual
and its section on the IF-ELSE?
Back to top
View user's profile Send private message
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Thu Sep 06, 2007 5:43 am    Post subject: Reply with quote

CICS Guy,

I think records having cust no like 6000, 66000 should also get processed which will get ignored in your code.

thakuranirban,

Please provide your inputs.

Vivek G
_________________
Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Back to top
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Thu Sep 06, 2007 6:10 am    Post subject: Reply with quote

Technically, the custnos you identify actually begin with zero.......
If the specs aren't clear, what can I say......

But, looking at it your way, IF-ELSE or better yet EVALUATE would still be a good option...
If custno >= 6000000 and < 7000000 then ignore....
else If custno >= 600000 and < 700000 then ignore....
else If custno >= 60000 and < 70000 then ignore....
else If custno >= 6000 and < 7000 then ignore....
else If custno >= 600 and < 700 then ignore....
else If custno >= 60 and < 70 then ignore....
else If custno >= 6 and < 7 then ignore....
else process......
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Sep 06, 2007 7:42 am    Post subject: Reply with quote

Code:

EVALUATE TRUE
     WHEN CUSTNO > 5999999 AND CUSTNO < 7000000
     WHEN CUSTNO > 599999 AND CUSTNO < 700000
     WHEN CUSTNO > 59999 AND CUSTNO < 70000
     WHEN CUSTNO > 5999 AND CUSTNO < 7000
     WHEN CUSTNO > 599 AND CUSTNO < 700
     WHEN CUSTNO > 59 AND CUSTNO < 70
     WHEN CUSTNO > 5 AND CUSTNO < 7
          PERFORM PROCESS-CUSTOMER
     WHEN OTHER
          CONTINUE
END-EVALUATE

_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
blitz2
Beginner


Joined: 23 Jan 2007
Posts: 84
Topics: 14

PostPosted: Fri Sep 07, 2007 1:44 am    Post subject: Reply with quote

ummm ... OP wants an 'IF-ELSE block'!!!
thakuranirban, please be clear about your problem, give examples if possible.
________
Utg Everblast Enforcement Airsoft Shotgun


Last edited by blitz2 on Thu Mar 10, 2011 5:35 pm; edited 1 time in total
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Fri Sep 07, 2007 3:00 am    Post subject: Reply with quote

ummmmmmmm,

The purpose of these forums is provide guidance and answers. Even though the OP wants an IF-ELSE block, those of us with experience know that a convoluted IF-ELSE block is dummmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmb!

With a properly stated EVALUATE statement, if there are changes in the future for the selection criteria, the EVALUATE statement can be easily modified. Whereas a convoluted IF-ELSE block (especially 7 levels) is not. Besides, good programming practices suggest that an IF-ELSE block should not exceed 3 levels.

besides, I thought the OP was clear with his request: if an account number starts with a 6, process the account.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Fri Sep 07, 2007 3:18 am    Post subject: Reply with quote

Actually, the easiest way to accomplish this is thru use of Level-88's
Code:

...
   05  CUST-NO                   PIC 9(7).
         88  PROCESS-THIS-CUSTOMER
                                 VALUES 6,
                                        60 thru 69,
                                        600 thru 699,
                                        6000 thru 6999,
                                        60000 thru 69999,
                                        600000 thru 699999,
                                        6000000 thru 6999999.

Code:

        IF PROCESS-THIS-CUSTOMER
        THEN
            PERFORM XXXX-PROCESS-CUSTOMER
        END-IF

_________________
Dick Brenholtz
American living in Varel, Germany
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