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 - 2019 days ago
Last viewed on: 17 Oct 2019 (3673 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* rtvCustInfo - Customer Information Retrieval procedure


prtvCustInfo b

drtvCustInfo pi

d pordno 8p 0

d* local variables definition



  // 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 ';


           btctry = oacntr;


       // retrieve bill to name and phone number

      chain(pordno:oadlpt) sodzad;

      if %found(sodzad);

        btphon = oatphn;

        btfnam = oafnam;

        btlnam = oalnam;

        btemal = oaeml1;


// 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 ';


     stctry = oacntr;


  // retrieve ship to name

   chain(oaohno:oadlpt) sodzad;

   if %found;

     stphon = oatphn;

     stfnam = oafnam;

     stlnam = oalnam;

     stemal = oaeml1;



    // retrieve shipping menthod

    chain(pordno:2) sodadd;

   if %found(sodadd);

     shpmth = %trim(oacarr); 



readepordno sodadr;




prtvCustInfo e

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