Solved

Submit a batch job in one CL pgm

Posted on 2004-04-19
6
1,449 Views
Last Modified: 2012-08-14
I want to call a pgm in batch mode using one CL pgm only, by combining the batch call with the final pgm call.

I am passing parms and can do so with a DS or by passing the parms themselves.

The programmer before me would always have one CL interact with the screen, call the batch pgm with the final pgm in the parm list and the second CL would call the final pgm in batch mode.

How do I do this?

jjjjjjj
0
Comment
Question by:jjjjjjj
[X]
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
  • 3
  • 3
6 Comments
 
LVL 1

Expert Comment

by:Helixir
ID: 10862441
Your Key is RTVJOBA, I hope you'll understand what I write down !!

DCL   &TYPE  *CHAR 1

RTVJOBA TYPE(&TYPE)
&TYPE = '1' if interactive and = '0' if Batch

If you call CL1

*** CL1 ***
PGM

DCL   &TYPE *char 1
DCLF  Screen

RTVJOBA TYPE(&TYPE)

 * INTERACTIVE PART
if &TYPE = '1'

READ  Screen
SBMJOB(PGM(CL1) PARM(with Parm))
endif

 * BATCH PART
if &TYPE = '0'

 call RPG1

endif

endpgm

*** END CL1 ***

0
 
LVL 27

Accepted Solution

by:
tliotta earned 50 total points
ID: 10883964
jjjjjjj:

I'm a little confused... since you're going to need to do SBMJOB to get the CL into batch, why would you not SBMJOB for the batch function itself?

By trying to get it done in a single program, you're putting too much function into it. I assume the desired batch function is business logic of some sort. You seem to want to mix control logic with business logic.

For future maintenance and flexibility, the two kinds of function should be separated -- IMO.

However, the key to doing what you want is mentioned above, RTVJOBA to get the job type, either batch or interactive. Code your program to avoid any SNDRCVF or SNDF commands against a display file whenever you're in batch. Also, keep in mind that parms ought to be matched for both batch and interactive -- this can get tricky if parms exist, especially if you need to pass them after interaction with a display file.

You can access a display file from batch as long as you can attach a device. Use OVRDSPF DEV() to attach. The device needs to be varied on and at a signon screen, otherwise you'll get CPF4128. And you can handle parms that aren't passed by monitoring for MCH3601 when you reference each parm; this allows you to omit parms on the CALL and use default values.

Still, I'd use two separate programs without a _very_ good reason to use one.

Tom
0
 
LVL 1

Expert Comment

by:Helixir
ID: 10887955
You mean that if the interactive gives is Device name tu the Batch job, The batch job can overide a screen to that Device ?
0
[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

 
LVL 27

Expert Comment

by:tliotta
ID: 10892297
Helixir:

A sample DSPF and CLP:
---------------------------------- Begin DDS
     A                                      DSPSIZ(24 80 *DS3)
     A          R DUMMYFMT
     A                                      KEEP
     A                                      ASSUME
     A                                  1  2':'
     A          R ACQBCR1
     A                                      TEXT('Acquisition format')
     A                                      ALARM
     A                                      CLRL(*NO)
     A                                      OVERLAY
     A                                 13 25'..................................-
     A                                      ..'
     A                                      COLOR(BLU)
     A                                 14 25':'
     A                                      COLOR(BLU)
     A                                 14 27'Just testing...'
     A                                      COLOR(YLW)
     A            ACTION        10   B 14 46
     A                                 14 60':'
     A                                      COLOR(BLU)
     A                                 15 25':'
     A                                      COLOR(BLU)
     A            MSG1          32A  O 15 27
     A                                 15 60':'
     A                                      COLOR(BLU)
     A                                 16 25':'
     A                                      COLOR(BLU)
     A            MSG2          32A  O 16 27
     A                                 16 60':'
     A                                      COLOR(BLU)
     A                                 17 25':'
     A                                      COLOR(BLU)
     A            MSG3          32A  O 17 27
     A                                 17 60':'
     A                                      COLOR(BLU)
     A                                 18 25'..................................-
     A                                      ..'
     A                                      COLOR(BLU)
---------------------------------- End DDS
---------------------------------- Begin CL
pgm        ( &DEV )

   dcl       &DEV       *char      10

   dclf      ACQBCH


   ovrdspf   acqbch   dev( &DEV )

   chgvar    &msg1       ( 'Message line 1 (*char 32)' )
   chgvar    &msg2       ( 'Message line 2 (*char 32)' )
   chgvar    &msg3       ( 'Message line 3 (*char 32)' )

   sndrcvf   rcdfmt( ACQBCR1 )
   monmsg  ( CPF4128 )  exec( do )
      sndpgmmsg  msgid( CPF9898 ) msgf( QCPFMSG ) +
                   msgdta( 'Device is in use or not varied on' ) +
                   msgtype( *COMP )
      return
   enddo


   return
endpgm
---------------------------------- End CL

Compile both with appropriate names. Submit the CLP with something like:

 ==>  sbmjob cmd( call BCHDSP parm(DSP99))

Now, assuming DSP99 is varied on and available, i.e., not in use by another job, the DSPF should show up on its screen and wait for a respone. An interactive job could supply its _own_ device name _only_ if the interactive job releases the device -- e.g., signs off.

In RPG, see the ACQ op-code. In COBOL, see the ACQUIRE statement. Opening a second emulator session window and leaving it at a signon display is probably easiest to demo. This is commonly used for never-ending programs that continually provide updated status info.

Tom

0
 
LVL 1

Expert Comment

by:Helixir
ID: 10902952
It Works fine, thanks for your example.

But the fact you need a screen on signoff is not really usefull !! It would be great if you could be work on something and BANG a windows appear to ask you a price on something !! :)
0
 
LVL 27

Expert Comment

by:tliotta
ID: 10903301
Helixir:

Since multiple sessions is often not a problem, it usually doesn't matter.

But for your specific concern... That's what a break-handler would be good for. Technically, not a "break-handler" but a message queue monitor in any case.

Create a temporary message queue in job initial program or routing program or at whatever time is most useful, then assign the break-handling program to that message queue. Whenever you want to interrupt from somewhere else, send a message to that message queue. "Temporary message queue" does not mean "in QTEMP".

The break-handler gets control and can do whatever it's programmed to do including opening a new display file, setting an attention program or whatever. (Setting an attention program and sending a status message could notify the user to press <Attn>. The attn-program could open a display file, etc., and perhaps return the <Attn> key to it's previous setting.)

Tom
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

There is a lot to be said for protecting yourself and your accounts with 2 factor authentication.  I found to my own chagrin, that there is a big downside as well.
Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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