Page 1 of 1

equalent datastage transaformer code

Posted: Thu Feb 28, 2013 3:29 am
by vsandu
Hi Gurus,
i am working on COBOL to DS conversion project , i am facing problem with generating a code for the cobol code

COMPUTE CLAT-CLMT-DSBLTY-DRTN(WS-CLAT-IDX) =
(FUNCTION INTEGER-OF-DATE (WS-VLTN-DT-YYYYMMDD) -
FUNCTION INTEGER-OF-DATE (WS-ONSETDT-YYYYMMDD) + 1)
/ 30.4375
END-COMPUTE
above two are dates , find the days b/w two dats and the divide by 30.4375
please send me equivalent ds code

Posted: Thu Feb 28, 2013 4:21 am
by ray.wurlod
Convert both dates to Julian then perform the arithmetic. Convert the result back from Julian.

Posted: Thu Feb 28, 2013 10:52 am
by sudha03_vpr
It will be much easier if you do it in the SQL query level i.e i mean at the DB level when fetching the data from the table.

Posted: Thu Feb 28, 2013 1:50 pm
by FranklinE
COMPUTE is a "wrapper" that permits complex arithmetic functions formerly restricted to other COBOL keywords like ADD, SUBTRACT, MULTIPLY, etc. If you want to maintain coding integrity in your conversion, I suggest rewriting the COMPUTE on the older standard.

Convert WS-VLTN-DT-YYYYMMDD and WS-ONSETDT-YYYYMMDD to integers in working storage fields defined for them. How you do that is dependent on what the integer values should look like. Julian dates might work best.

SUBTRACT first ws field FROM the other other ws field GIVING yet another ws field.

ADD 1 TO the last ws field.

Finally: DIVIDE [last ws field] BY 30.4376 GIVING CLAT-CLMT-DSBLTY-DRTN.

You will find it relatively easy to convert each step to a similar coding within the transformer, using stage variables in place of the working storage fields.