Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

writing a simple program

Posted on 2004-10-13
7
1,066 Views
Last Modified: 2007-12-19
I am creating a program that retrieves the current date and job name using the RTVJOBA Command,retrieves the current time
using the RTVSYSVAL command, and send a message that says "clpgm was run on DATE and TIME with job name JN"

This is my first program and I am having a little trouble setting it up.  I would appreciate some insight on how I might be going about this wrong.  Here is what I have so far.

clpgm:        PGM

/* defines the variables used in the program   */

                  DCL VAR(&DATE)  TYPE(*CHAR)  LEN(6)
                  DCL VAR(&TIME)  TYPE(*CHAR)  LEN(6)
                  DCL VAR(&JN)      TYPE(*CHAR)  LEN(2)
/*  RETRIEVES THE CURRENT DATE AND JOB NAME   */

                  RTVJOBA          DATE(&DATE)
                  RTVJOBA          JOB(&JN)

/* RETRIEVES THE CURRENT TIME
     
                  RTVSYSVAL SYSVAL(QTIME) TRNVAR(&TIME)

/* SENDS MESSAGE CONTAINING THE TIME, DATEM AND JOB NAME  */

                 SNDUSRMSG MSG('CLPGM WAS RUN ON ' *CAT &DATE  +
                       ' AT ' *CAT &TIME ' WITH JOB NAME. ' *CAT &JN)

END;           ENDPGM

I know this isnt correct, I appreciate your help!
0
Comment
Question by:SinSual
  • 2
7 Comments
 
LVL 6

Accepted Solution

by:
blkline earned 500 total points
ID: 12304523
Type things:

1) JobName must be *CHAR (10) .   If you use prompting for the command RTVJOBA (use F4) you'll see the recommended field lengths in parenthesis.  

2) Save yourself some serious headaches trying to do that concatenation within the SNDUSRMSG command.  It'll drive you nuts.  Instead, do this:

DCL VAR(&MSG)  TYPE(*CHAR) LEN(80)

CHGVAR &MSG ('CLPGM WAS RUN ON ' *CAT &DATE *CAT ' AT ' *CAT &TIME *CAT ' WITH JOB NAME ' +
                                         *CAT &JN)
SNDUSRMSG (&MSG)

I hope you typed this program instead of cut-and-pasting because if you didn't, you missed the closing comment */ and you shouldn't use a semi-colon (;) between the tag END and ENDPGM.  It's:    END:    ENDPGM
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 12317253
Hi SinSual,

Just my opinion about the *CAT opcodes (you dont have to agree)

Never use the *CAT, *BCAT or *TCAT commands it makes it unreadable (my own opinion).
I use the availble replacements for the CAT commands, it makes the total string more readable
and 3 positions shorter per CAT. Wauw big deal 3 whole positions ???
Yes and that is a lot 4 opcodes is saving 12 positions this is 15% of your CL-source line

Just use :

*CAT = ||
*BCAT = |>
*TCAT = |<

Now your command will look like this (BTW you forget 1 *CAT between &DATE and ' AT '):

     SNDUSRMSG MSG('CLPGM WAS RUN ON ' || &DATE || ' AT ' || &TIME ||' WITH JOB NAME. ' || &JN)

or (look to the trailing spaces in the text)

     SNDUSRMSG MSG('CLPGM WAS RUN ON' |> &DATE |> 'AT' |> &TIME |> 'WITH JOB NAME.' |> &JN)

This is even works beter, because you will get rid of trailing spaces in variables.

e.g.  

             DCL        VAR(&MYNAME) TYPE(*CHAR) LEN(25)        
             DCL        VAR(&MSGTXT) TYPE(*CHAR) LEN(100)      
                                                               
             CHGVAR     VAR(&MYNAME) VALUE('SinSual')            
             CHGVAR     VAR(&MSGTXT) VALUE('Hi ' || &MYNAME || ' how are you')

the contents of &MSGTXT:
     Hi SinSual                  how are you

replacing the || with |> the contents of &MSGTXT:
     Hi SinSual how are you

replacing the || with |< the contents of &MSGTXT:
     Hi SinSualhow are you
0
 
LVL 27

Expert Comment

by:tliotta
ID: 12322344
Comment on *CAT, etc...

_ALWAYS_ use *CAT, *TCAT, etc., rather than the special characters. Some of the special characters belong to the variant set of characters and are interpreted by displays and printers differently depending on specific device settings. This really tends to mess programs up as years go by, new devices are added, new programmers come and go, etc. It can cause major headaches when program code gets posted to international websites or is shared between company branches that cross national boundaries.

As for the program problem, some errors in the posted code have been pointed out. But the original question doesn't mention what the problem is. Is there an error message? Is the displayed message showing incorrect data? Does the program fail? Does it not compile?

If the code was copy/pasted, that's one thing. If typed, that's another.

Tom
0
 
LVL 27

Expert Comment

by:tliotta
ID: 12322390
...Also, the program retrieves Job Date but also retrieves Current Time. It's a minor point, but those two values can be inconsistent. Perhaps instead of Job Date, the program could retrieve Current Date. Or instead of Current Time, the program could retrieve Job Start Time which would be more consistent with the message "...was run on..."

It doesn't matter much in this simple program, but a more complex and important program should be more accurate.

Tom
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are looking at this article, you have most likely been hit by some version of ransomware and are trying to find out if there is anything you can do, or what way you should react - READ ON!
The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question