× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Okay, so I have massively butchered my toolkit (which contains date tools,
numeric tools, character tools, etc.) for simplicity of this example. It's
been a really long time since I messed with this stuff, but I HOPE this is
everything you need to get up and running. Feel free to modify...

*First, here's the code for the date tools program (QRPGLESRC /
DTTOOLS.SQLRPGLE).*

H NOMAIN STGMDL(*SNGLVL)
/DEFINE copy_dtTools
/INCLUDE CDSRCLIB/QPROTOTYPE,COPYCOMMON

// ////////////////////////////////////////////////////////
// // IMPORTANT - Any program that uses these tools must //
// // include the following lines before the D Specs: //
// ////////////////////////////////////////////////////////
//
// H DFTACTGRP(*NO) BNDDIR('DTTOOLSBD')
// /DEFINE copy_dtTools
// /INCLUDE QPROTOTYPE,COPYCOMMON


//=======================================================================
//Gets Day of Week (Num: 1-7; Name: SUNDAY-SATURDAY) for Input Date.

//=======================================================================
PDtGetDay B Export
DDtGetDay PI LikeDS(DtDay)
D InputDt D Const
//Local Variables
D TmpNum S 1S 0 Inz
D DSDtDay DS LikeDS(DtDay) Inz
/Free

//1=Sun, 2=Mon, 3=Tues, 4=Wed, 5=Thu, 6=Fri, 7=Sat
Exec SQL Set :TmpNum = DayOfWeek(:InputDt);
DSDtDay.Num = TmpNum;
Select;
When DSDtDay.Num = 1;
DSDtDay.Name = 'SUNDAY';
When DSDtDay.Num = 2;
DSDtDay.Name = 'MONDAY';
When DSDtDay.Num = 3;
DSDtDay.Name = 'TUESDAY';
When DSDtDay.Num = 4;
DSDtDay.Name = 'WEDNESDAY';
When DSDtDay.Num = 5;
DSDtDay.Name = 'THURSDAY';
When DSDtDay.Num = 6;
DSDtDay.Name = 'FRIDAY';
When DSDtDay.Num = 7;
DSDtDay.Name = 'SATURDAY';
EndSl;

Return DSDtDay;

/End-Free
PDtGetDay E


*Next, you will need this binding text (QSRVSRC / DTTOOLSSP.TEXT)*

StrPgmExp PgmLvl(*CURRENT) Signature('FIRST')
Export Symbol('DTGETDAY')
EndPgmExp

*I also put my prototypes (and any data-structure templates) into a
prototype file (QPROTOTYPE / DTTOOLSPR.RPGLE)*

DDtDay DS Qualified
D Based(Template)
D Num 1S 0
D Name 9A Varying


//=======================================================================
//Gets Day of Week (Num: 1-7; Name: SUNDAY-SATURDAY) for Input Date.
//
// *** RETURN
**********************************************************
// Data Sturcutre LIKEDS(DtDay)
// Must be defined in calling program (i.e.):
// D DSDay DS LikeDS(DtDay)
//
*********************************************************************
//
// Example:
// DSDay = DtGetDay(%date());

//=======================================================================
DDtGetDay PR LikeDS(DtDay)
D InputDt D Const

*And, finally, I have a copy-book that I use to define tool sets and
include the prototype file (QPROTOTYPE / COPYCOMMON.RPGLE)*

//Date Toolkit
/IF DEFINED(Copy_DtTools)
/INCLUDE QPROTOTYPE,DTTOOLSPR
/ENDIF

*Once all of this exists, compile the DTTOOLS program as a module with
option 15. Then create a service program (DTTOOLSSP) using this command,
specifying your own compile and source libraries (notice, it's using the
source file in QSRVSRC that we created above).*

CRTSRVPGM SRVPGM(*lib*/DTTOOLSSP) MODULE(*lib*/DTTOOLS)
EXPORT(*SRCFILE) SRCFILE(*srclib*/QSRVSRC)

*Any program that you want to include this tool in, just add these 3 lines
of code before your D-specs*

H DFTACTGRP(*NO) BNDDIR('DTTOOLSBD')
// or fully free: ctl-opt dftActGrp(*no) bndDir('GENTOOLSBD');
/DEFINE copy_dtTools
/INCLUDE QPROTOTYPE,COPYCOMMON

*Here's an example of use:*

ctl-opt dftActGrp(*no) bndDir('GENTOOLSBD');
/define copy_dtTools
/include qprototype,copyCommon

dcl-s today inz;
dcl-ds dsDtDay likeds(dtDay) inz;

today = %date();
dsDtDay = dtGetDay(today);

On Tue, Sep 3, 2019 at 6:11 AM Gad Miron <gadmiron@xxxxxxxxx> wrote:

Hello Guys

I need to create a callable PGM that accept a date parameter (YYYYMMDD)
and returns a DayOfWeek parameter

I've created a free format PGM alright (with Pr and PI) but I'm
stymied with making
a no-Cycle version.

I've read that using a clt- option *NOMAIN is for a Module only.

Is it possible to write such a (no cycle) program and compile it with
CRTBNDRPG in one pass
Or do I have to resort to CRTRPGMOD + CRTPGM ?

TIA
Gad
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.