Hi guys, how can I retrieve the program name in a CLLE program? I don't want to hard coded the name, thanks.
Announcement
Collapse
No announcement yet.
Retrieve program name in CLLE
Collapse
X
-
found a solution and it seems to work
DCL VAR(&MSGKEY) TYPE(*CHAR) LEN(4) DCL VAR(&PGMNAME) TYPE(*CHAR) LEN(10) DCL VAR(&MODNAME) TYPE(*CHAR) LEN(10) DCL VAR(&LIBNAME) TYPE(*CHAR) LEN(10) DCL VAR(&SENDER) TYPE(*CHAR) LEN(720) SNDPGMMSG MSG(' ') TOPGMQ(*SAME) MSGTYPE(*INFO) + KEYVAR(&MSGKEY) RCVMSG PGMQ(*SAME) MSGTYPE(*INFO) RMV(*YES) + SENDER(&SENDER) SENDERFMT(*LONG) CHGVAR VAR(&PGMNAME) VALUE(%SST(&SENDER 42 10)) CHGVAR VAR(&MODNAME) VALUE(%SST(&SENDER 54 10)) CHGVAR VAR(&LIBNAME) VALUE(%SST(&SENDER 681 10))
-
The following is code from Barsa Consulting and Dave Schnee (any credit goes to them):
The Long Island Systems User Group (LISUG) is a vibrant community where learning, networking, and innovation converge. We cater to all computer users, across all platforms, fostering an environment of continuous growth and knowledge sharing.
It uses an unblocked procedure name that has been available since 1996 (Materialized Program Name)
Code:Testpgm: PGM DCL VAR(&DATA) TYPE(*CHAR) LEN(80) DCL VAR(&MSG) TYPE(*CHAR) LEN(80) CHGVAR VAR(%BIN(&DATA 1 4)) VALUE(80) CHGVAR VAR(%BIN(&DATA 5 4)) VALUE(80) CHGVAR VAR(%BIN(&DATA 9 4)) VALUE( 0) CHGVAR VAR(%BIN(&DATA 13 4)) VALUE( 0) CALLPRC PRC('_MATPGMNM') PARM(&DATA) CHGVAR VAR(&MSG) VALUE('This program is ' *CAT + %SST(&DATA 51 10) *BCAT 'in library ' + *CAT %SST(&DATA 19 10)) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) ENDPGM
- Likes 1
Comment
-
Here's a proc I wrote quite a few years ago:
Code:pgm ( + &pProgram + &pLibrary + ) dcl &pProgram *char 10 dcl &pLibrary *char 10 dcl &PgmInfo *char 80 dcl &BytPrv *int dcl &BytAvl *int dcl &Format *int dcl &Rsv *char 4 dcl &Lib *char 30 dcl &Pgm *char 30 chgvar &BytPrv ( 80 ) chgvar &Format ( 0 ) chgvar &Rsv ( x'00000000' ) chgvar %bin( &PgmInfo 1 4 ) &BytPrv chgvar %bin( &PgmInfo 5 4 ) ( 0 ) chgvar %bin( &PgmInfo 9 4 ) &Format chgvar %sst( &PgmInfo 13 4 ) &Rsv callprc '_MATPGMNM' ( &PgmInfo ) chgvar &Lib %sst( &PgmInfo 19 30 ) chgvar &Pgm %sst( &PgmInfo 51 30 ) chgvar &pLibrary &Lib chgvar &pProgram &Pgm return EndPgm
It not only returns the simple *PGM object name but also the library that the program was called out of. Handy when multiples might exist.Tom
There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.
Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?
Comment
-
I use this, Voicu. It's similar to what you found. I've found it be adequate.
If you use such a routine, you might want to put it in copybooks.
Code:dcl &MsgKey *char 4 dcl &PgmName *char 10 dcl &Sender *char 80 sndpgmmsg msg(' ') topgmq(*same) msgtype(*info) keyvar(&msgkey) rcvmsg pgmq(*same) msgtype(*info) sender(&sender) rmv(*yes) chgvar &PgmName %sst(&Sender 56 10)
Comment
-
Thought I might add my $0.02 worth from the _MATPGMNM API posted. It could be modernised and simplified with the newer features of CL - notably using its *DEFINED storage:
Code:DCL &PgmInfo *CHAR 80 DCL &BytesPr *INT STG(*DEFINED) DEFVAR(&pgminfo) DCL &BytesAv *INT STG(*DEFINED) DEFVAR(&pgminfo 5) DCL &Format *INT STG(*DEFINED) DEFVAR(&pgminfo 9) DCL &Reserved *INT STG(*DEFINED) DEFVAR(&pgminfo 13) DCL &Lib *CHAR 30 STG(*DEFINED) DEFVAR(&pgminfo 19) DCL &PgmName *CHAR 30 STG(*DEFINED) DEFVAR(&pgminfo 51) CHGVAR VAR(&bytespr) VALUE(80) CHGVAR VAR(&bytesav) VALUE(0) CHGVAR VAR(&format) VALUE(0) CHGVAR VAR(&reserved) VALUE(0) CALLPRC PRC('_MATPGMNM') PARM((&pgminfo))
Comment
Comment