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
 

 

Using linkage section as a host variable in declare section.

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

New User


Joined: 25 Jul 2011
Posts: 14
Location: Philippines

PostPosted: Tue Oct 18, 2011 9:33 am    Post subject: Using linkage section as a host variable in declare section.
Reply with quote

Hello guys, I need a help on this. I'm currently working on a program.
Let's say the main program is X and subprograms A, B, C.

X called C by this parameter: rundate

rundate is a pic x(10) variable for date 'xxxx-xx-xx' for example.


Naturally, C will have a LINKAGE SECTION.


C's linkage section:

Code:
LINKAGE SECTION.
 000217        01 L400-ERR-CN                          PIC X(4).
 000218        01 L400-ERR-REF                         PIC X(8).
 000219        01 L400-ERR-LAST-TXN-NUM        PIC X(5).
 000220        01 L400-ERR-LAST-TXN-CNT        PIC 9(12).
 000221        01 L400-ERR-TOT-PREV-CNT        PIC 9(12).
 000222        01 L400-ERR-RC                          PIC 9(2).
 000223        01 L400-ERR-TRAILER-FLAG         PIC X.
 000224           88 L400-ERR-TRAILER-YES                      VALUE 'Y'.
 000225           88 L400-ERR-TRAILER-NO                       VALUE 'N'.
 000226        01 L400-ERR-RUNDATE             PIC 9(8).


the l400-err-rundate as you can see has a pic 9(8) attribute. That will be converted by using string command that will make the date a necessary format for querying.

Code:
              MOVE L400-ERR-RUNDATE TO W300-RUNDATE
 000279            STRING W300-YY DELIMITED BY SIZE
 000280                   '-' DELIMITED BY SIZE
 000281                   W300-MM DELIMITED BY SIZE
 000282                   '-' DELIMITED BY SIZE
 000283                   W300-DD DELIMITED BY SIZE
 000284                   INTO W300-RUNDATE2
 000285            END-STRING
 000286            DISPLAY 'RUNDATE: ' W300-RUNDATE2
 000287            MOVE W300-RUNDATE2 TO PAY-PERIOD


w300-rundate - is a group variable.

Code:
05 W300-RUNDATE.
 000092              10 W300-YY                PIC X(4).
 000093              10 W300-MM                PIC X(2).
 000094              10 W300-DD                PIC X(2).


and w300-rundate2 is a 10 byte variable.

i have an exec command in working storage as follows:


Code:
 000199             EXEC SQL
 000200                 DECLARE CUR1 CURSOR FOR
 000201             SELECT C.LOCATION, C.PROJECT, A.PERSONNEL_NBR, A.LAST_NAME,
 000202             A.FIRST_NAME, A.MIDDLE_INITIAL, E.POS_CODE, D.ACCT_NUM,
 000203             A.SALARY, B.TAX_AMT, B.S_AMT, B.P_AMT, B.A_AMT, B.PROV_AMT
 000204             FROM TBLEMP A,
 000205             TBLHIST B,
 000206             TBLASIGN C,
 000207             TBLACCNT D,
 000208             TBLPOS E
 000209             WHERE B.PAY_PERIOD = :w300-rundate AND
 000210                   A.POS_CODE = E.POS_CODE AND
 000211                   B.PERSONNEL_NBR = A.PERSONNEL_NBR AND
 000212                   A.ASSIGN_CODE = C.ASSIGN_CODE AND
 000213                   D.PERSONNEL_NBR = B.PERSONNEL_NBR
 000214                   ORDER BY C.LOCATION ASC, A.PERSONNEL_NBR ASC
 000215             END-EXEC.



Goal: I need to get employees with particular rundate (rundate depends on what the main program passes.)

The problem: The sql return code is 100, meaning it fetched no rows and obviously, the date I enter did not match the criteria.

In my theory, it must be EMPTY, in a way that the declare happened and the variable w300-rundate2 still don't have a value.

Order of declaration:

1. w300-variables
2. exec statement
3. linkage section

Before I open the cursor, I tried to transfer the values as you can see on the top (w300-rundate to w300-rundate2), but I guess it's useless or ineffective.


When I try to use the linkage section as a host variable, it returns an error in compile time, saying the the variable is undefined or unusable.

Help me on this guys. thanks a lot.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7254

PostPosted: Tue Oct 18, 2011 11:56 am    Post subject: Re: Using linkage section as a host variable in declare sect
Reply with quote

What is the result of your DISPLAY?

Why do you have so many 01 levels all called L400? Can you show your USING for the CALL and the PROCEDURE DIVISION?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Oct 18, 2011 12:05 pm    Post subject:
Reply with quote

Pay_Period is of what datatype? what does it contain?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Oct 18, 2011 1:18 pm    Post subject:
Reply with quote

this should be removed
Code:
MOVE W300-RUNDATE2 TO PAY-PERIOD


and since you are STRINGing everything into W300-RUNDATE2
why are you using w300-rundate in the WHERE predicate?

and answer my previous question.
Back to top
View user's profile Send private message
cyrus.e.cabrera

New User


Joined: 25 Jul 2011
Posts: 14
Location: Philippines

PostPosted: Thu Oct 27, 2011 10:52 am    Post subject:
Reply with quote

PAY_PERIOD data type is DATE.
Defined in DB2 which has a format of YYYY-MM-DD

I'm using the string statement because, the L400-RUNDATE only comprises of the YYYYMMDD data.

ex. 20110228, which is a date but when used as a parameter in "WHEN" area of the sql statement will not return any rows.

So, it has to be STRINGed to follow querying format.
And yes. The w300-rundate is my previous variable when I'm trying the possible solutions.

The program worked, the STRINGing process should be recieved by w300-rundate.

It worked actually. My fault on not inserting required information to other tables. Since I was joining tables the information must be somehow complete. I failed on that part. I end up scolding and laughing at myself.


Thank you for the help guys.
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 Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am
No new posts JOINKEYs and Variable files migusd SYNCSORT 8 Fri Jun 17, 2016 3:16 am
No new posts PC to Host for unicode file Tom Steiner TSO/ISPF 5 Mon May 16, 2016 10:38 pm


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