IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How can fetch mutil-columns into COBOL array.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
linc

New User


Joined: 25 Aug 2008
Posts: 25
Location: china

PostPosted: Sun Sep 14, 2008 7:21 pm
Reply with quote

Hi guys:
I have one problem described as following:
1. The Working storage:
Code:
01 ws-record   
      05  W-SSN-NBR              PIC X(09).                       
      05  FILLER                 PIC X(01).                       
                                         
      05  W-ARRAY-WEEKDAY OCCURS 7 TIMES.                         
           10  W-TOTAL-HOURS-WORKED   PIC X(03).                   
           10  FILLER                 PIC X(01).                   
           10  W-TKS-ABSENCE-CODE-1   PIC X(01).                   
           10  FILLER                 PIC X(01).                   
           10  W-ABSENCE-HOURS-CODE-1       PIC ZZ.Z.             
           10  FILLER                 PIC X(01).                   
           10  W-TKS-ABSENCE-CODE-2         PIC X(01).             
           10  FILLER                 PIC X(01).                   
           10  W-ABSENCE-HOURS-CODE-2       PIC ZZ.Z.             
           10  FILLER                 PIC X(01).                   
           10  W-HOLIDAY-INDICATOR          PIC X(01).             
           10  W-HOLIDAY-INDICATOR          PIC X(01).

2.The Declare cursor:
Code:
EXEC SQL                                             
     DECLARE   DETAIL_CSR CURSOR WITH HOLD FOR       
      SELECT SSN-NBR,                                 
             MON_OT_HRS,MON_ABS_CODE1,MON_ABS_HRS1,   
             MON_ABS_CODE2,MON_ABS_HRS2,MON_HOL_CD,   
             TUE_OT_HRS,TUE_ABS_CODE1,TUE_ABS_HRS1,   
             TUE_ABS_CODE2,TUE_ABS_HRS2,TUE_HOL_CD,   
             WED_OT_HRS,WED_ABS_CODE1,WED_ABS_HRS1,   
             WED_ABS_CODE2,WED_ABS_HRS2,WED_HOL_CD,   
             THU_OT_HRS,THU_ABS_CODE1,THU_ABS_HRS1,   
             THU_ABS_CODE2,THU_ABS_HRS2,THU_HOL_CD,   
             FRI_OT_HRS,FRI_ABS_CODE1,FRI_ABS_HRS1,   
             FRI_ABS_CODE2,FRI_ABS_HRS2,FRI_HOL_CD,   
             SAT_OT_HRS,SAT_ABS_CODE1,SAT_ABS_HRS1,   
             SAT_ABS_CODE2,SAT_ABS_HRS2,SAT_HOL_CD,   
             SUN_OT_HRS,SUN_ABS_CODE1,SUN_ABS_HRS1,   
             SUN_ABS_CODE2,SUN_ABS_HRS2,SUN_HOL_CD   
      FROM  table             
      WHERE
end-exec


3.The Fetch statement I wrote:
Code:
EXEC SQL                   
                           
    FETCH DETAIL_CSR       
    INTO  :W-SSN-NBR,     
          :W-ARRAY-WEEKDAY
END-EXEC             

Due the selcted the columns are from Monday to Sunday,and repeate 7 times,so I just want to define one array occurs 7 times,then write one simple fetch statemetns to fetch in all of those columns.
But,The pre-complie said me the HOST VARIABLE W-ARRAY-WEEKDAY not defined or not useable.What's the problem here?

Thanks for all of your kindly proposel.[/code]
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Sep 14, 2008 9:26 pm
Reply with quote

Hello,

I believe the pre-compiler said it all. . . The array is not usable the way you are trying to use it.

You can name the working-storage fields with the subscript in the FETCH.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Mon Sep 15, 2008 10:33 am
Reply with quote

linc,

Following link might be useful for your requirement. Just check.

it.toolbox.com/blogs/db2zos/kewl-db2-for-zos-version-8-feature-part-2a-multirow-insert-fetch-7377

Regards,
KSK
Back to top
View user's profile Send private message
vicky11121982

New User


Joined: 21 Jun 2007
Posts: 9
Location: gurgaon

PostPosted: Mon Sep 15, 2008 11:45 am
Reply with quote

10 W-HOLIDAY-INDICATOR is defined twice maybe a typo from ur end

U declare a table in COBOL to use it with an index or subscript.

Create a fetch like
FETCH DETAIL_CSR
INTO
:W-SSN-NBR,
:W-TOTAL-HOURS-WORKED(1),
:W-TKS-ABSENCE-CODE-1(1),
:W-ABSENCE-HOURS-CODE-1(1),
:W-TKS-ABSENCE-CODE-2(1),
:W-ABSENCE-HOURS-CODE-2(1),
:W-HOLIDAY-INDICATOR(1),
-
-
-
upto seventh occurance
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top