IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Why this function SUBTRACT-DURATION can't be used in cobol?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
linc

New User


Joined: 25 Aug 2008
Posts: 25
Location: china

PostPosted: Mon Sep 15, 2008 9:08 am
Reply with quote

Anybody knows why this function can't be used in cobol?
IGYPS2130-S Expected a function-name, but found "SUBTRACT-DURATION"The "MOVE" statement was discarded.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Sep 15, 2008 10:07 am
Reply with quote

Hello,

Quote:
Anybody knows why this function can't be used in cobol?
Because IBM has not chosen to support it in the compiler. . . Possibly because it is not part of the cobol standard. . .

Quote:
FUNCTION SUBTRACT-DURATION is not a valid COBOL FUNCTION, regardless of the COBOL version/release.
From another topic - maybe something from that topic will help with what you need:
ibmmainframes.com/about30525.html
Back to top
View user's profile Send private message
linc

New User


Joined: 25 Aug 2008
Posts: 25
Location: china

PostPosted: Mon Sep 15, 2008 10:17 am
Reply with quote

Thanks for your quick reply.Now I am looking for that topic and find some useful information as following:
Quote:
What is your version/release of COBOL?

The minimum is COBOL/370 (released over 15 years ago) for the support of FUNCTION's, which is the successor to COBOL2.

FUNCTION SUBTRACT-DURATION is not a valid COBOL FUNCTION, regardless of the COBOL version/release.

When you say you need the "previous system-date", what is the amount of time do you need to subtract from the current-date? Minutes, Hours, Days, etc? We're all unsure.

To use the supported COBOL FUNCTION's, check out -

01) FUNCTION CURRENT-DATE
02) FUNCTION INTEGER-OF-DATE
03) ADJUST RESULT FROM INTEGER-OF-DATE
04) FUNCTION DATE-OF-INTEGER

However, I second Dick's suggestion regarding a standardized date methodology sub-system and you should speak with some of your other colleagues.

Regards,

Bill

So according to this,should I use those 4 COBOL function to code?I am not clearly about the "03) ADJUST RESULT FROM INTEGER-OF-DATE " usage?
Thanks very much.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Sep 15, 2008 10:32 am
Reply with quote

Hello,

#3 is not actually a function. It is a suggestion that someone could "adjust the result" of the integer-of-date function.

Yes, you should be able to use those functions (assuming you are using a compiler that supports them). As mentioned, functions have been around for a long time. When you run a complie, the compiler version is shown at the top of the page. Most systems are using Enterprise COBOL now.

You can also use db2 for date arithmetic. Look in the db2 forum, there are multiple examples.
Back to top
View user's profile Send private message
linc

New User


Joined: 25 Aug 2008
Posts: 25
Location: china

PostPosted: Mon Sep 15, 2008 10:57 am
Reply with quote

Hi :
The program need to subtract from the current system date for every week.So I just want to find an easy way to perform this .
Maybe it is a little bit complicated to subtract 1 day from the current-date?So is there any exist function or some sample program for reference?
Many thanks.I use Endevor to complie my program and specify the program type as C3PTD2.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Sep 15, 2008 11:17 am
Reply with quote

Hello,

If i understand what you want to do, i believe you can do what you want with the "integer-of-date" and the "date-of-integer" fumnction. Suggest you make up a small test routine and ust the current data as inlut to the integer-of-date function. Subtract 1 from that result and use this as input to the date-of-integer function. The standard date returned should be "yesterday".

I'd suggest you do this isolated test and be sure the functions work as you need before incorporating them into the full code.

Someone should be here if there are questions.
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Mon Sep 15, 2008 11:24 am
Reply with quote

Linc,

May be the format which you are using for computation or in a Cobol Verb is not compatible format

The Date should be in this format YYYYMMDD

Check it out fallowing link for further clarification

publib.boulder.ibm.com/infocenter/comphelp/v7v91/index.jsp?topic=/com.ibm.aix.cbl.doc/rlinfdi.htm

Hope this helps
Back to top
View user's profile Send private message
linc

New User


Joined: 25 Aug 2008
Posts: 25
Location: china

PostPosted: Mon Sep 15, 2008 11:32 am
Reply with quote

Yes,that's exactly what I want to do.Thanks for your proposel.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top