Thursday, February 11, 2010

RPGLE - Runtime Array

In RPGLE the array concept same as collection of same data type. But it is classified according to time of intialization.

Runtime array got populated while program running

While declaring runtime array we have to specify the size of the array ( Dimension ):

See below sample program:



OUTPUT:
=======

Wednesday, February 10, 2010

Convert date format RPGLE

A variable can be declared as date data type using 'D' in internal data type.






C ....*USA....... MOVE.......Datetemp.....Dat
C .... Dat ...... DSPLY....

Dat declared as 8 D ( date data type with 8 length ) to compact with *USA format

OUTPUT:
======






Character (A)
Graphic (G)
Numeric - Integer format (I)
Numeric – Packed decimal format (P)
Numeric - Zoned format (S)
Numeric - Unsigned format (U)
Float (F)
Date (D)
Time (T)
Timestamp (Z)

Shifting to tn5250

I got another terminal for logging into iSeries from ubuntu through just 'tn5250'. The GREEN screens makes more feeling that I am working in AS400 :-)

This has given by the http://www.rzkh.de/ as400 service administrators

See wiki.

http://en.wikipedia.org/wiki/IBM_5250

Tuesday, February 9, 2010

RPGLE - Concatenate two strings,addition


Simple programs are always helpful to get good step to learn a new language. See below how easy this is to write RPGLE ( am learning from basic ) rather than jumping to big things


INZ keyword is used to initialize the 'surname' and 'forename'. But before concatenating the variables using 'CAT' the valued changed using EVAL opcode.

Addition can be done using 'ADD'.

Arithmetic operations:

http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/evferlsh354.htm

Wednesday, February 3, 2010

RPG opcode screen

Op-Code -- Purpose
ACQ -- Acquire device
BEGSR -- Begin Subroutine
CALLP -- Call Prototyped Procedure or Program
CHAIN -- Retrieve Record by key
CLEAR -- Clear
CLOSE -- Close File
COMMIT -- Commit Database changes
DEALLOC -- Release Dynamically Allocated Storage
DELETE -- Delete Record
DOU -- Do Until
DOW -- Do While
DSPLY -- Display message
DUMP -- Dump Program
ELSE -- Else
ELSEIF -- Else If
ENDyy -- End a Structured Group (where yy = DO, FOR, IF, MON, SL, or SR)
EVAL -- Evaluate expression
EVALR -- Evaluate expression and right adjust result
EXCEPT -- Perform Exception Output
EXFMT -- Write/Then Read Format from display
EXSR -- Execute Subroutine
FEOD -- Force End of Data
FOR -- For
FORCE -- Force specified file to be read on next Cycle
IF -- If
IN -- Retrieve a Data Area
ITER -- Iterate
LEAVE -- Leave a Do/For Group
LEAVESR -- Leave a Subroutine
MONITOR -- Begin a Monitor Group
NEXT -- Next
ON-ERROR -- Specify errors to handle within MONITOR group
OPEN -- Open File for Processing
OTHER -- Start of default processing for SELECT group
OUT -- Write Data Area
POST -- Post
READ -- Read a record
READC -- Read next changed record
READE -- Read next record with equal Key
READP -- Read prior record
READPE -- Read prior record with equal Key
REL -- Release
RESET -- Reset
RETURN -- Return to Caller
ROLBK -- Roll Back uncommitted database changes
SELECT -- Begin a Select Group
SETGT -- Position database to record with key greater than specified key
SETLL -- Position database to record with key not greater than specified key
SORTA -- Sort an Array
TEST -- Test Date/Time/Timestamp
UNLOCK -- Unlock a Data Area or Release a Record
UPDATE -- Modify Existing Record
WHEN -- Condition test within SELECT group
WRITE -- Write New Record




RPGLE Built in function reference

RPGLE Dreamers built -in functions:
===================================
%ABS - Absolute Value of Expression

%ADDR - Get Address of Variable

%ALLOC - Allocate Storage

%CHAR - Convert to Character Data

%CHECK - Check Characters

%CHECKR - Check Reverse

%DATE - Convert to Date

%DAYS - Number of Days

%DEC - Convert to Packed Decimal Format

%DECH - Convert to Packed Decimal Format with Half Adjust

%DECPOS - Get Number of Decimal Positions

%DIFF - Difference Between Two Date, Time, or Timestamp Values

%DIV - Return Integer Portion of Quotient

%EDITC - Edit Value Using an Editcode

%EDITFLT - Convert to Float External Representation

%EDITW - Edit Value Using an Editword

%ELEM - Get Number of Elements

%EOF - Return End or Beginning of File Condition

%EQUAL - Return Exact Match Condition

%ERROR - Return Error Condition

%FLOAT - Convert to Floating Format

%FOUND - Return Found Condition

%GRAPH - Convert to Graphic Value

%HOURS - Number of Hours

%INT - Convert to Integer Format

%INTH - Convert to Integer Format with Half Adjust

%LEN - Get or Set Length

%LOOKUPxx - Look Up an Array Element

%MINUTES - Number of Minutes

%MONTHS - Number of Months

%MSECONDS - Number of Microseconds

%NULLIND - Query or Set Null Indicator

%OCCUR - Set/Get Occurrence of a Data Structure

%OPEN - Return File Open Condition

%PADDR - Get Procedure Address

%PARMS - Return Number of Parameters

%REALLOC - Reallocate Storage

%REM - Return Integer Remainder

%REPLACE - Replace Character String

%SCAN - Scan for Characters

%SECONDS - Number of Seconds

%SHTDN - Shut Down

%SIZE - Get Size in Bytes

%SQRT - Square Root of Expression

%STATUS - Return File or Program Status

%STR - Get or Store Null-Terminated String

%SUBDT - Extract a Portion of a Date, Time, or Timestamp

%SUBST - Get Substring

%THIS - Return Class Instance for Native Method

%TIME - Convert to Time

%TIMESTAMP - Convert to Timestamp

%TLOOKUPxx - Look Up a Table Element

%TRIM - Trim Blanks at Edges

%TRIML - Trim Leading Blanks

%TRIMR - Trim Trailing Blanks

%UCS2 - Convert to UCS-2 Value

%UNS - Convert to Unsigned Format

%UNSH - Convert to Unsigned Format with Half Adjust

%XFOOT - Sum Array Expression Elements

%XLATE - Translate

%YEARS - Number of Years