Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Tables in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Nirav721

New User


Joined: 11 Feb 2008
Posts: 53
Location: NJ

PostPosted: Fri Mar 07, 2008 5:37 am    Post subject: Tables in cobol
Reply with quote

I am not sure if what I want to do is possible or not...but here it goes....

I have 3 work areas with fields that has following characteristics

1st area has fields with XXXX-WS
2nd area has fields with SCA-XXXXX
3rd area has fields with IND-XXXXX

Now, field lengths are the same across -WS and -SCA area. IND- are indicators being populated with either -1 or 0 when I do SELECT from DB2.

Right now, I have individual checks to say that

IF IND-XXXX = 0 then
move XXXXX-WS to SCA-XXXXX
end-if


And then I have

If SCA-XXXX-R not = high-values
move SCA-XXXXX to XXXXX-WS
else
move -1 to IND-XXXX
end-if

Now, I am wondering if there is a way I can make a table that would have 3 columns and X number of rows where X would equal number of fields so that I do not have to do in excess of 100 if statements?

If this is not clear, please excuse me. I will try to explain it better...


Thanks!!
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Mar 07, 2008 6:19 am    Post subject:
Reply with quote

Jeez, if this was much more unclear, you would have won the 'Huh?' award.....
Back to top
View user's profile Send private message
Nirav721

New User


Joined: 11 Feb 2008
Posts: 53
Location: NJ

PostPosted: Fri Mar 07, 2008 6:50 am    Post subject: Reply to: Tables in cobol
Reply with quote

Lets try it this way...

I have a WS area as follows...

10 FIELD-WS.
15 PART-NUMBER-WS PIC X(2).
15 PURE-NIRAV-AMT-WS PIC S9(5)V USAGE COMP-3.
15 CURR-CICS-GUY-AMT-WS PIC S9(3)V USAGE COMP-3.


Then, I have the Indicator area...

10 INDICATOR-WS.
15 IND-PURE-NIRAV-AMT PIC S9(4) COMP.
15 IND-CURR-CICS-GUY-AMT PIC S9(4) COMP.


Then I have the SCA area....

01 SCA-BUILD-AREA.
05 SCA-PURE-NIRAV-AMT PIC S9(5)V USAGE COMP-3.
05 SCA-PURE-NIRAV-AMT-R
REDEFINES SCA-PURE-NIRAV-AMT.
10 FILLER PIC X(3).
05 SCA-CURR-CICS-GUY-AMT PIC S9(3)V USAGE COMP-3.
05 SCA-CURR-CICS-GUY-AMT-R
REDEFINES SCA-CURR-CICS-GUY-AMT.
10 FILLER PIC X(2).




Then I perform a select...

SELECT PURE_NIRAV_AMT,
CURR_CICS_GUY_AMT
INTO :PURE-NIRAV-AMT-WS:IND-PURE-NIRAV-AMT,
:CURR-CICS-GUY-AMT-WS:IND-CURR-CICS-GUY-AMT


IF SQLCODE = 0

IF IND-PURE-NIRAV-AMT = 0 THEN
MOVE PURE-NIRAV-AMT-WS TO SCA-PURE-NIRAV-AMT
END-IF

IF IND-CURR-CICS-GUY-AMT = 0
MOVE CURR-CICS-GUY-AMT-WS TO SCA-CURR-CICS-GUY-AMT
END-IF

END-IF.



Note that in this example, I am only using two fields, we could potentially have up to 150 fields...so I am trying to find a way to avoid typing in 150 if-end-if statements....I thought that table might be a way to do this, but I am not too savy with cobol yet, so needed little nudge in the right direction....?

Thanks!!
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Mar 07, 2008 10:42 am    Post subject:
Reply with quote

If you are using DB2 you can not select into a table item!
Back to top
View user's profile Send private message
Nirav721

New User


Joined: 11 Feb 2008
Posts: 53
Location: NJ

PostPosted: Fri Mar 07, 2008 4:28 pm    Post subject: Reply to: Tables in cobol
Reply with quote

Hmm, I thought it would be possible if I specify each index individually. I just want to get rid of the if statements....?

Something similar to...

10 FIELD-WS-TABLE occurs 3 times indexed by Index-ws
15 PART-NUMBER-WS PIC X(2).
15 PURE-NIRAV-AMT-WS PIC S9(5)V USAGE COMP-3.
15 CURR-CICS-GUY-AMT-WS PIC S9(3)V USAGE COMP-3.

10 INDICATOR-WS-TAble occurs 2 times indexed by Index-ind
15 IND-PURE-NIRAV-AMT PIC S9(4) COMP.
15 IND-CURR-CICS-GUY-AMT PIC S9(4) COMP.


01 SCA-BUILD-AREA occurs 2 times indexed by Index-SCA
05 SCA-PURE-NIRAV-AMT PIC S9(5)V USAGE COMP-3.
05 SCA-PURE-NIRAV-AMT-R
REDEFINES SCA-PURE-NIRAV-AMT.
10 FILLER PIC X(3).
05 SCA-CURR-CICS-GUY-AMT PIC S9(3)V USAGE COMP-3.
05 SCA-CURR-CICS-GUY-AMT-R
REDEFINES SCA-CURR-CICS-GUY-AMT.
10 FILLER PIC X(2).


Then I suppose I should be able to

SELECT PURE_NIRAV_AMT,
CURR_CICS_GUY_AMT
INTO :FIELD-WS-TABLE(2):INDICATOR-WS-TABLE(1),
:FIELD-WS-TABLE(3):INDICATOR-WS-TABLE(2)



Is this possible to do? If yes, then is there a way to incorporate the whole logic into If? sorry, little confused
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Mar 07, 2008 4:57 pm    Post subject:
Reply with quote

if your db2 vsn supports rowS select - can'T remember the techi name, but you can select multiple rows into a cobol table if you have set it up correctly.

but, you are still (and always will be) stuck with providing a host variable for every column that you retrieve.
Back to top
View user's profile Send private message
Nirav721

New User


Joined: 11 Feb 2008
Posts: 53
Location: NJ

PostPosted: Fri Mar 07, 2008 6:05 pm    Post subject: Reply to: Tables in cobol
Reply with quote

Yes, I am fine with having to specify each column for the select, and the host variables for them...I just don't want to write out 150 if statements...So anyone think its possible?
Back to top
View user's profile Send private message
Pcrummey

New User


Joined: 26 Feb 2008
Posts: 4
Location: Van Wert, OH

PostPosted: Sat Mar 08, 2008 1:25 am    Post subject:
Reply with quote

Your occurs clause specifies the number of rows in your table not the number of columns, those are defined by the level 15 items. Why can't you select to a Working Storage item and then load that to your occurs table like this.

SELECT PURE_NIRAV_AMT,
CURR_CICS_GUY_AMT
INTO :PURE-NIRAV-AMT-WS:IND-PURE-NIRAV-AMT,
:CURR-CICS-GUY-AMT-WS:IND-CURR-CICS-GUY-AMT

Then after the select

MOVE PURE-NIRAV-AMT-WS TO WS-PURE-NIRAV-AMT(Index-ws)
MOVE IND-PURE-NIRAV-AMT TO WS-IND-PURE-NIRAV-AMT(Index-ind)
MOVE CURR-CICS-GUY-AMT-WS TO WS-CURR-CICS-GUY-AMT(Index-ws)
MOVE IND-CURR-CICS-GUY-AMT TO WS-IND-CURR-CICS-GUY-AM(Index-ind)

SET INDEX-WS UP BY 1
SET INDEX-IND UP BY 1

Then you do a PERFORM later in your code

SET INDEX-WS TO 1
SET INDEX-IND TO 1
PERFORM UNTIL END-OF-TABLE-WS
IF WS-IND-PURE-NIRAV-AMT(Index-ind) = 0
MOVE WS-PURE-NIRAV-AMT(Index-ws) TO SCA-PURE-NIRAV-AMT (INDEX-SCA)
END-IF
SET INDEX-IND UP BY 1
SET INDEX-WS UP BY 1
SET INDEX-SCA UP BY 1
IF INDEX-WS > OCCURS AMOUNT
MOVE 'Y' TO END-OF-TABLE-WS-SW
END-IF
END-PERFORM

Or the Mutli Row Fetch mentioned above would work as well. Only for Version 8 of DB2 I think.
Back to top
View user's profile Send private message
Nirav721

New User


Joined: 11 Feb 2008
Posts: 53
Location: NJ

PostPosted: Sat Mar 08, 2008 1:41 am    Post subject: Reply to: Tables in cobol
Reply with quote

Thanks all, I think this helps me go in right direction...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
No new posts COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us