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
 

 

How can fetch mutil-columns into COBOL array.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How can fetch mutil-columns into COBOL array.
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

Site Director


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

PostPosted: Sun Sep 14, 2008 9:26 pm    Post subject:
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: 356
Location: New York

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

linc,

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

http://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    Post subject: Reply to: How can fetch mutil-columns into COBOL array.
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    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
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. 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