Midrange News for the IBM i Community


Posted by: Chris Proctor
Programmer Analyst
Columbia Sports Company
Portland, OR
Issue with a program being called simultaneously
has no ratings.
Published: 07 Apr 2014
Revised: 07 Apr 2014 - 3671 days ago
Last viewed on: 25 Apr 2024 (7038 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Issue with a program being called simultaneously Published by: Chris Proctor on 07 Apr 2014 view comments(5)

Good morning. I'm really hoping someone might have some suggestions, because this issue has me baffled. I have an SQLRPGLE program that is running in batch, called by multiple programs simultaneously. There are a few fields in one of the output files that are randomly not being populated. It is very simple straight forward code, so it's driving me crazy.

Here's how it works:

There is a file that is being read as the driver file. I'm using a SELECT statement with the "FOR UPDATE OF' clause so that the record is locked to that instance of the program.

I have a procedure that is call and passed an order number. It retrieves customer information from 3 different files, populating a data structure (The reason I populate a data structure is because this customer information retrieval process is a copy module used by multiple different programs).

When the program returns from the call to the customer information procedure it populates fields in the output file from the data structure and writes the record. The fields that are randomly not being populated are in this output file.

Here's a snippet of the procedure code, below. You can assume that the key fields are correct. The issue is where I am trying to retrieve the SODZAD records. Those fields in the data structure are the ones that are randomly blank. Now, I know that if that record was locked by some other process, the chain may not work, but wouldn't I at least get an error on the chain? Should I change it to chain(e) and if an error, loop retrying the chain until it's successful? Or perhaps I missed something I should have selected in the compile?

Any help would be greatly appreciated. I'm going nuts here!! Thanks!!!

d*------------------------------------------------------------------------

d* rtvCustInfo - Customer Information Retrieval procedure

d*------------------------------------------------------------------------

prtvCustInfo b

drtvCustInfo pi

d pordno 8p 0

d* local variables definition

/free

   resetcustInfoDS;

  // retrieve SODA order header

   chainpordno sodhdr;

   if %found;

     setllpordno sodadr;

     readepordno sodadr;

     dow not %eof(sodadr);

// B I L L - T O I N F O R M A T I O N P R O C E S S I N G

      if oadlpt = ohbilp;

        btadr1 = oaadr1;

        btadr2 = oaadr2;

        btadr3 = oaadr3;

        btcity = oacity;

        btcnty = oacnty;

        btzip = oaptzc;

        btstat = oaprst;

        if oacntr = 'USA';

           btctry = 'US ';

       else;

           btctry = oacntr;

       endif;

       // retrieve bill to name and phone number

      chain(pordno:oadlpt) sodzad;

      if %found(sodzad);

        btphon = oatphn;

        btfnam = oafnam;

        btlnam = oalnam;

        btemal = oaeml1;

     endif;

// S H I P - T O I N F O R M A T I O N P R O C E S S I N G

else<- This ELSE would skip the BTxxx fields assignment above.

   stadr1 = oaadr1;

   stadr2 = oaadr2;

   stadr3 = oaadr2;

   stcity = oacity;

   stcnty = oacnty;

   stzip = oaptzc;

   ststat = oaprst;

   if oacntr = 'USA';

     stctry = 'US ';

   else;

     stctry = oacntr;

   endif;

  // retrieve ship to name

   chain(oaohno:oadlpt) sodzad;

   if %found;

     stphon = oatphn;

     stfnam = oafnam;

     stlnam = oalnam;

     stemal = oaeml1;

   endif;

 

    // retrieve shipping menthod

    chain(pordno:2) sodadd;

   if %found(sodadd);

     shpmth = %trim(oacarr); 

   endif;

endif;

readepordno sodadr;

enddo;

endif;

/end-free

prtvCustInfo e

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Issue with a program being called simultaneously
Posted: 10 years 19 days 8 hours 27 minutes ago
Edited: Mon, 07 Apr, 2014 at 09:08:22 (3671 days ago)

The only two things I would guess is either:

  1. The field is blank before and after the call to the subproc (you don't seem to pass a DS as a parm).
  2. The EVAL/assignment of the fields that are blank are conditioned based on if oadlpt = ohbilp; and skipped if this condition is not true--so the logic does bypass that section of code. (See my highlight in your code).

If the solution isn't clear, my guess would be that the section of code resulting in blanks (which I speculate isn't being called) should probably be moved to just under the DOW statement.

Posted by: chrisp
Premium member *
Portland, OR
Comment on: Issue with a program being called simultaneously
Posted: 10 years 19 days 7 hours 36 minutes ago

Hi Bob

You're right, I'm not passing the DS as a parm. It's just defined up in the D specs and cleared and populated in this procedure. As for the "else", there are two SODADR records per order. The first record has an OADLPT value of 1 (Billing info) and 2 (Shipping info). So each read populates a different part of the DS.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Issue with a program being called simultaneously
Posted: 10 years 19 days 6 hours 14 minutes ago

You are CHAINing to sodzad before the fields in question.

Posted by: chrisp
Premium member *
Portland, OR
Comment on: Issue with a program being called simultaneously
Posted: 10 years 19 days 5 hours 42 minutes ago

Yes, I am, Bob. The weird thing is, that sometimes it may even get the name, but leave the email address blank even tho both are populated in the SODZAD file. It really makes no sense.

// retrieve bill to name and phone number

chain(pordno:oadlpt) sodzad;

if %found(sodzad);

btphon = oatphn;

btfnam = oafnam;

btlnam = oalnam;

btemal = oaeml1;

endif;

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Issue with a program being called simultaneously
Posted: 10 years 19 days 3 hours 7 minutes ago
Edited: Mon, 07 Apr, 2014 at 16:20:42 (3671 days ago)

Can you post your struct used for BTxxxx fields? Or do those field names come directly out of the file itself?