Midrange News for the IBM i Community


Posted by: Sandeep Khandelwal
RPGLE
has no ratings.
Published: 02 Jan 2012
Revised: 23 Jan 2013 - 4105 days ago
Last viewed on: 19 Apr 2024 (8116 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.

RPGLE Published by: Sandeep Khandelwal on 02 Jan 2012 view comments(6)

Can we declare file information data structure and program status data structure as externally described data structure instead of program described data structure. IF yes then how to proceed.

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

COMMENTS

(Sign in to Post a Comment)
Posted by: FCSBRIAN
Premium member *
Southwestern Ontario, Canada
Comment on: RPGLE
Posted: 12 years 3 months 19 days 2 hours 3 minutes ago

In your RPG try

D PRGDS         ESDS                  EXTNAME(PRGDS)    

and create a PF called PRGDS with the fields needed:

1 - 10 Program name

11 - 15 Program Status

16 - 20 Previous Status

etc.

 

Brian 

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: RPGLE
Posted: 12 years 3 months 19 days 1 hours 23 minutes ago

With files you usually need 3 maps: Database Files, Printer Files & Display Files.  But it works the same way as the Program information DS

Posted by: Sandeeprpg
Premium member *
Comment on: RPGLE
Posted: 12 years 3 months 18 days 8 hours 51 minutes ago

@FCSBRIAN:

Declaring DS is not a problem I can declare it but how to write PF like you told..but how the positions of the fields in the PF gets into the program.

Variable like:

 

PrgStatus        *STATUS

  ErrType               40     42

  ErrCode               43     46

  JobName              244    253

  JobNumber            264    269

  UserName             354    363

how to declare them in PF.

Posted by: DaleB
Premium member *
Reading, PA
Comment on: RPGLE
Posted: 12 years 3 months 18 days 2 hours 10 minutes ago

It's possible, but why would you want to? Much simpler to put the SDS in a /COPY.

But, if you really want to, your PF would need enough filler to to get you to necessary positions:

     A          R PGMSTS
     A            PGMSTS1       39A         TEXT('Filler')
     A            ERRTYPE        3A         TEXT('Exception type')
     A            ERRCODE        4A         TEXT('Exceptoin number')
     A            PGMSTS47     197A         TEXT('Filler')
     A            JOBNAME       10A         TEXT('Job name')

Nothing you can do about the specials. You'd have to add them immediately after the E DS

     D               ESDS                  EXTNAME(PGMSTSFILE)
     D PrgStatus         *STATUS

A little messy, to say the least.

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: RPGLE
Posted: 12 years 3 months 18 days 1 hours 20 minutes ago

When you define a PF for use as information feedback (program & files) you must define every field position.  As Dale says, it's much easier to define as a /copy, since you can leave gaps in the DS for positions you don't need - and from a personal view, it's easier to see the length and position from the /copy.

Posted by: DaleB
Premium member *
Reading, PA
Comment on: RPGLE
Posted: 12 years 3 months 18 days 40 minutes ago

Copy source member would probably have a lot more, but along the lines of:

      * Program Status
     DPgmSts          SDS
     D PrgStatus         *STATUS
     D ErrType                        3A   OVERLAY(PgmSts:40)
     D ErrCode                        4A   OVERLAY(PgmSts:43)
     D JobName                       10A   OVERLAY(PgmSts:244)
     D User                          10A   OVERLAY(PgmSts:254)
     D JobNumber                      6A   OVERLAY(PgmSts:264)

Two comments:

1) Job's user is position 254, not 354. Note that Job name, User, and Job number are contiguous 26 bytes, in the order needed by many API's as qualified job name.

2) The specials do have offset equivalents; e.g., *STATUS is 5S0 starting at position 11. (Though I always use *STATUS, and can't say I've ever seen code that does it by position.)