Monthly Data



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Monthly Data

Postby aroraaj » Thu Feb 21, 2013 8:58 pm

Hello,

I need to create a new COBOL program which will generate a monthly GDG file for a table. The table has data for couple of years and they are looking for data only for current month and current year. I am very new to this and I was wondering if anyone can guide me on how I can do this.

Thanks!!
aroraaj
 
Posts: 2
Joined: Thu Feb 21, 2013 8:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Monthly Data

 

Re: Monthly Data

Postby Akatsukami » Thu Feb 21, 2013 9:28 pm

Well, I'm not a COBOL programmer -- this century, anyway -- but logic is logic, and there are a myriad of (OK, several ;)) people on this board who can help with COBOL-specific details.

The table, I presume, is DB2. It should have on it a column identifying the data date -- depending on the processing done elsewhere, it might be an "add date" or "last updated date". There may also be a "logical delete" indicator -- perhaps a simple flag, perhaps a timestamp -- indicating the row is to be ignored in normal processing.

The data date column should ideally have a data type of TIMESTAMP or DATE -- but since DBAs and analysts are not always ideally competent, it may have a type of CHAR(n), INTEGER, or even, Kamisama forbid, DECIMAL(p,q). What do your specifications and/or research show the data type to be?
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Monthly Data

Postby aroraaj » Thu Feb 21, 2013 9:54 pm

Yes, the table is a DB2 table.

The data will be coming from the effective data column which is in the format of YYYY-MM-DD.
aroraaj
 
Posts: 2
Joined: Thu Feb 21, 2013 8:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Monthly Data

Postby Akatsukami » Thu Feb 21, 2013 11:18 pm

Well, that tells me the format of the data, but not the type of the column. See this thread for a brief discussion of the difference.

You want data for the current month and year. Mr. Boyo has pointed out why it is a bad idea to reply on system date as your business date; you may or may not have a separate business date available. If not, then as a compromise I recommend that you get the system date once, at the beginning of your program, and store it for use thereafter, to eliminate midnight-crossing problems.

The SQL will look about like:
EXEC-SQL
DECLARE CURSOR FOO FOR SELECT THIS_COL, THAT_COL, EFFECTIVE_DATE FROM TARGET_TABLE
INTO :WS-THIS-FIELD, :WS-THAT-FIELD
WHERE EFFECTIVE_DATE >= :WS-START-OF-MONTH.
END-EXEC.


WS-START-OF-MONTH, of course, will just be the processing date with “01” substituted for the current by reference modification. If EFFECTIVE_DATE is CHAR(10) it may be necessary to check for invalid values.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Monthly Data

Postby pmartyn » Thu Feb 28, 2013 11:42 pm

Sure, after defining your GDG base in IDCAMS, your process should look something like this;

Step01 - unload the DB2 table so you will be working with a flat file and not interfering with any other work.
For details review DB2 lock escalation (even an S lock can hold up an X).

Step02 - COBOL program that reads the unload file and selects the ones you want via either System Date (once, at start of process) or a Business Date Parameter fed into the COBOL Program. Use the (+1) GDG parameter on the output dataset in the JCL.

That should do it.
pmartyn
 
Posts: 42
Joined: Thu Feb 28, 2013 7:11 pm
Has thanked: 5 times
Been thanked: 3 times

Re: Monthly Data

Postby Akatsukami » Fri Mar 01, 2013 1:25 am

pmartyn wrote:Step01 - unload the DB2 table so you will be working with a flat file and not interfering with any other work.
For details review DB2 lock escalation (even an S lock can hold up an X).

And as the TS is not updating the table, heesh will be locking objects how?
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post