Page 1 of 1

Monthly Data

PostPosted: Thu Feb 21, 2013 8:58 pm
by aroraaj
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!!

Re: Monthly Data

PostPosted: Thu Feb 21, 2013 9:28 pm
by Akatsukami
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?

Re: Monthly Data

PostPosted: Thu Feb 21, 2013 9:54 pm
by aroraaj
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.

Re: Monthly Data

PostPosted: Thu Feb 21, 2013 11:18 pm
by Akatsukami
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.

Re: Monthly Data

PostPosted: Thu Feb 28, 2013 11:42 pm
by pmartyn
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.

Re: Monthly Data

PostPosted: Fri Mar 01, 2013 1:25 am
by Akatsukami
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?