Solved

Submit a batch job in one CL pgm

Posted on 2004-04-19
6
1,397 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now