Codes for retrieving data in an RPG program

Asked By 10 points N/A Posted on -
qa-featured

If I want to retrieve the data for the next 7th date in an RPG program, do you have any simple way of coding? Thanks.

SHARE
Best Answer by Techie1
Answered By 10 points N/A #110707

Codes for retrieving data in an RPG program

qa-featured

Some of the things that you will need to observe when retrieving data for the next 7th date in the RPG program are as follows:

When you have created the data and put it in the data area, you will need to supply a name and a length.  You will need to make sure that the name you use follows the naming conventions, and an example for that on how to name your data area is as follows: "INVA100"

Another thing that will need to observe is the length that you supply for the data area, you can create an extra room so that the data area can be even 100 characters in length.

You will also need to specify the library that you will store the data area.

-Thompson Locker

 

Best Answer
Best Answer
Answered By 0 points N/A #110709

Codes for retrieving data in an RPG program

qa-featured

 

In order to retrieve data in an RPG program you have to use the IN operation.

Syntax: IN{(E)} {*LOCK} data-area-name, were Factor 1-*LOCK and Factor 2 – data-area-name

The IN operation retrieves a data area and optionally allows you to specify whether the data area is to be locked from update by another program. For a data area to be retrieved by the IN operation, it must be specified in the result field of an *DTAARA DEFINE statement or using the DTAARA KETWORD on the Definition specification.

The variable containing the name of the data area must be set before the IN operation.

·         *LOCK can be specified in Factor 1 to indicate that the data area cannot be updated or locked by another program until an UNLOCK operation is processed,  and OUT operation with no data-area-name operand specified.

·          data-area-name must be the name of a definition defined with the DTAARA keyword, 

On a fixed-form calculation, positions 71-72 and 75-76 must be blank.

Eg:

/free
       in *lock *dtaara;
      TotAmt = TotAmt + Amount;
      TotGrs = TotGrs + Gross;
      TotNet = TotNet + Net;
  /end-free
* To start total calcs, code a fixed format calc statement with a
* level entry specified.
CL0   total_calcs   tag
/free
       if *inlr
         out *dtaara
      endif
/end-free

 

Related Questions