Creo que aqui hay un ejemplo, aunque no veo que sea por una clausula en la
hoja H.
Saludos
Espero que sirva.

-----Original Message-----
From: ClubTechiSeries PrgmTips
[mailto:ClubTechiSeries_PrgmTips@;lists.pentontech.com]
Sent: Thursday, April 25, 2002 10:59 AM
To: [EMAIL PROTECTED]
Subject: Club Tech iSeries Programming Tips -- April 25, 2002


*************** Club Tech iSeries Programming Tips Newsletter **************
An iSeries Network Publication                 http://www.iseriesnetwork.com
Home of iSeries NEWS Magazine
Issue 73                                                      April 25, 2002

Thanks to this issue's sponsors -- Magic Software and Applied Logic Corp.

SPONSORED IN PART BY MAGIC SOFTWARE ENTERPRISES
NEW! Download your FREE "Rapid Return on Investment -- RROI"
white paper today. Modernize your RPG and COBOL apps! Add GUI
or Web to IBM iSeries or AS/400 apps fast. Rapidly create
browser-based applications. Easily add logic with Magic
eDeveloper, the fastest iSeries development tool available.
http://www.magicsoftware.com/entry/roipaper.htm?s=ict&c=47

****************************************************************************

THIS WEEK:
> Detect Record Lock Conditions -- No Indicators Necessary
> Passing Data Structures as Parameters to Procedures

1. DETECT RECORD LOCK CONDITIONS -- NO INDICATORS NECESSARY
Q: Is it possible for RPG IV to check for a record lock condition without
using indicators?

A: It is indeed possible to detect a record lock condition without using
indicators. To do so, you use the 'E' (error handling) operation extender on
the read operation along with a couple of built-in functions (BIFs).

The 'E' operation extender traps any error conditions so that your program
doesn't terminate abnormally. When the 'E' operation extender traps an
error, RPG sets the %Error BIF value to '1'. You've probably already guessed
that a record lock condition is an error condition. The 'E' operation
extender can therefore trap the record lock condition and set the %Error BIF
value to '1'.

However, a record lock condition is but one potential error that the 'E'
operation extender might trap. You can't presume that because a read
operation's operation extender sets the %Error BIF value that the error is a
record lock condition. Instead, you must examine the value of yet another
BIF -- %Status -- to determine the nature of the error. In the case of a
record lock condition, the RPG status code is 01218.

The following sample program shows how to check for a record lock condition.
The program tries to update file Customer. When an error occurs on the Read
op-code, the program examines the %Status BIF value to determine whether the
program encountered a record lock condition. If no error occurs, the program
updates file Customer.

      *    =================================================================
      *    = Sample program to check for record lock condition             =
      *    =================================================================

     FCustomer  UF   E             Disk

      *    =================================================================
      *    = Definitions                                                   =
      *    =================================================================

      *    -----------------------------------------------------------------
      *    - Work variables                                                -
      *    -----------------------------------------------------------------

     D RecordLocked   C                    Const( 01218 )

      /Free

       .
       .
       .

       //  =================================================================
       //  = Try to update Customer record                                 =
       //  =================================================================

           Read(E) Customer ;

       //  -----------------------------------------------------------------
       //  - Error trying to read Customer record                          -
       //  -----------------------------------------------------------------

           If %Error ;
              Select ;

       //  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       //  - Record locked by another job                                  -
       //  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

                 When %Status = RecordLocked ;
                 .
                 .
                 .

       //  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       //  - Error other than record lock                                  -
       //  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

                 Other ;
                 .
                 .
                 .

              EndSl ;

       //  -----------------------------------------------------------------
       //  - No error when reading Customer record, so update record       -
       //  -----------------------------------------------------------------

           Else ;
              .
              .
              .
              Update CustomerR ;
           EndIf ;

           .
           .
           .

           *InLR = *On ;

      /End-Free

After detecting a record lock condition, you can get additional information
by examining information in the program status data structure. When an error
occurs, bytes 91 - 170 of this data structure contain message data
associated with the error. In the case of a record lock condition, the
message data contains the record number of the locked record along with the
job holding the lock.

If you simply add a program status data structure to your program, you'll
have access to this information. For example, the following sample program
status data structure specifies that subfield MsgDta contains the message
data associated with any errors encountered.

      *    -----------------------------------------------------------------
      *    - Program status data structure                                 -
      *    -----------------------------------------------------------------

     D PgmStsInfo     SDS
     D                               90
     D  MsgDta                       80

By the way, this technique also works if you're still using fixed-format
RPG. Of course, I urge you to use free-format RPG if you're at OS/400 V5R1.

***************************************************************************

SPONSORED IN PART BY Applied Logic Corp.
*UNDELETE records in any file! *Make global database CHANGES!
*CONVERT spool files to HTML! *EXPORT specified file data!
*PRINT ad-hoc reports with calculations and totals! All this and
much MORE with FEU (File Edit Utility), the iSeries database tool
used by thousands in 75 countries. Call (800) 588-8695 or visit
http://www.alcsoftware.com to download a FREE TRIAL of our tools.

***************************************************************************

2. PASSING DATA STRUCTURES AS PARAMETERS TO PROCEDURES
If you've ever had occasion to pass data structures as parameters, you'll be
happy to know that enhancements to V5R1 RPG let you do this more easily. The
secret is the LikeDS keyword used on D-specs. This keyword lets you define a
new data structure with the attributes (subfields) of an existing data
structure.

I've put together a sample application that retrieves shipping and mailing
address information and puts it into a data structure. (The application
defines a standard address structure in which all addresses are returned.)
In the sample service program, I include two procedures, GetShipAddress and
GetMailAddress, each of which accepts a data structure as a parameter in
which it returns address information.

The sample service program follows:

      *    =================================================================
      *    = Sample service program to retrieve shipping and mailing       =
      *    = address information into a data structure used as a parameter =
      *    =================================================================

     H NoMain


      *    =================================================================
      *    = Procedure prototypes                                          =
      *    =================================================================

     D GetShipAddress  Pr              N
     D  pAddressDS                         LikeDS( AddressDSTemp )

     D GetMailAddress  Pr              N
     D  pAddressDS                         LikeDS( AddressDSTemp )

      *    =================================================================
      *    = Global definitions                                            =
      *    =================================================================

      *    -----------------------------------------------------------------
      *    - Address data structure template                               -
      *    -----------------------------------------------------------------

     D AddressDSTemp   DS                  Based( AddressDSTempPtr )
     D  Name                         30
     D  Address1                     30
     D  Address2                     30
     D  City                         15
     D  State                         2
     D  PostalCode                    9

      *    =================================================================
      *    = Procedure GetShipAddress - Get shipping address               =
      *    =================================================================

     P GetShipAddress  B                   Export


     D GetShipAddress  PI              N
     D  ShipAddress                        LikeDS( AddressDSTemp )

      /Free

       //  -----------------------------------------------------------------
       //  - Set shipping address information                              -
       //  -----------------------------------------------------------------

           ShipAddress.Name       = 'Gary Guthrie' ;
           ShipAddress.Address1   = '1234 Southfork Lane' ;
           ShipAddress.Address2   = 'Suite 204' ;
           ShipAddress.City       = 'Austin' ;
           ShipAddress.State      = 'TX' ;
           ShipAddress.PostalCode = '76723' ;

           Return *Off ;

      /End-Free

     P GetShipAddress  E

      *    =================================================================
      *    = Procedure GetMailAddress - Get mailing address                =
      *    =================================================================

     P GetMailAddress  B                   Export


     D GetMailAddress  PI              N
     D  MailAddress                        LikeDS( AddressDSTemp )

      /Free

       //  -----------------------------------------------------------------
       //  - Set mailing address information                               -
       //  -----------------------------------------------------------------

           MailAddress.Name       = 'Gary Guthrie' ;
           MailAddress.Address1   = 'P.O. Box 2981' ;
           MailAddress.Address2   = *Blank ;
           MailAddress.City       = 'Austin' ;
           MailAddress.State      = 'TX' ;
           MailAddress.PostalCode = '76723' ;

           Return *Off ;

      /End-Free

     P GetMailAddress  E

The service program begins with procedure prototypes for procedures
GetShipAddress and GetMailAddress. Notice that the parameter for each of
these procedures specifies the LikeDS keyword. This instructs the compiler
to define a data structure with the attributes of the template data
structure AddressDSTemp. The definition for this template data structure
appears after the procedure prototypes. Notice that I've specified that data
structure AddressDSTemp is based on pointer AddressDSTempPtr. Because the
data structure is simply a template used to define the data structure
parameters, I use a basing pointer to prevent any storage allocation for
data structure AddressDSTemp.

Procedures GetShipAddress and GetMailAddress follow. Because data structure
AddressDSTemp appears in the global definitions section of the code, I can
define parameters ShipAddress (in procedure GetShipAddress) and MailAddress
(in procedure GetMailAddress) like data structure AddressDSTemp.

Notice that to set the address information, you specify qualified subfield
names. The qualified names are constructed of the data structure name
(ShipAddress and MailAddress) and the subfield names from the template data
structure (AddressDSTemp). The sample simply hardcodes the address
information returned to the caller. The procedures also return a Boolean
value indicating success (*Off) or failure (*On).

Following is a sample application program that retrieves the shipping
address and then the mailing address into a single address information data
structure.

After defining the procedure prototypes, the program defines the standard
address information data structure (AddressDS) into which it will retrieve
address information. The program first retrieves shipping address
information into the data structure by invoking procedure GetShipAddress.
After processing the shipping information, the program invokes procedure
GetMailAddress to retrieve mailing address information into the same data
structure.

      *    =================================================================
      *    = Sample program that uses procedures GetShipAddress and        =
      *    = GetMailAddress to get address information in a data structure =
      *    = used as a parameter                                           =
      *    =================================================================

      *    =================================================================
      *    = Procedure prototypes                                          =
      *    =================================================================

     D GetShipAddress  Pr              N
     D  pAddressDS                         LikeDS( AddressDS )


     D GetMailAddress  Pr              N
     D  pAddressDS                         LikeDS( AddressDS )


      *    =================================================================
      *    = Definitions                                                   =
      *    =================================================================

      *    -----------------------------------------------------------------
      *    - Address data structure                                        -
      *    -----------------------------------------------------------------

     D AddressDS       DS
     D  Name                         30
     D  Address1                     30
     D  Address2                     30
     D  City                         15
     D  State                         2
     D  PostalCode                    9

     D RtnCode         S               N

      /Free

           .
           .
           .

      *    =================================================================
      *    = Process shipping address                                      =
      *    =================================================================

           RtnCode = GetShipAddress( AddressDS ) ;
           .
           .
           .


      *    =================================================================
      *    = Process mailing address                                       =
      *    =================================================================

           RtnCode = GetMailAddress( AddressDS ) ;
           .
           .
           .


           *InLR = *On ;


      /End-Free


As in the previous tip, you can use this technique in fixed-format RPG. (But
why would you want to?!)

****************************************************************************

SPECIAL ISERIES NETWORK OFFER
HURRY TO REGISTER -- RPG IV CLASSES START SOON
There's still time to register! Sign up today for Bryan Meyers' new online
learning classes -- "RPG IV Modules, Procedures, and Service Programs" and
"RPG IV for RPG Programmers." Orientation for both classes is April 30 -- so
hurry to sign up by calling Bronya at (800) 650-1801 or (970) 663-4700. Find
out more about these class, including scheduling and fees -- only $299 for
iSeries Network Professional Members -- at
http://lists.pentontech.com/cgi-bin3/flo?y=eLfo0CcG7W0Bgt0Lfj0A3 .

******************** ABOUT ISERIES NETWORK NEWSLETTERS *********************

Club Tech iSeries Programming Tips Newsletter is published weekly on
Thursday. Club Tech iSeries Systems Management Newsletter and Club Tech
Networking Tips Newsletter are published on alternate Wednesdays. NEWS Wire
Daily brings you daily iSeries industry news, tech tips, product news, and
IBM announcements. Tech Observatory Newsletter is published every other
Tuesday and pinpoints Internet resources for iSeries 400 professionals.
All are *FREE OF CHARGE*!

IF YOU HAVE a technical question, please submit it to
mailto:clubtechprogrammingtips@;iseriesnetwork.com or post it in the
appropriate iSeriesNetwork.com forum. If you have a response to a tip in
this newsletter, please e-mail
mailto:clubtechprogrammingtips@;iseriesnetwork.com . This newsletter is
edited by Gary Guthrie.

FOR NEW SUBSCRIPTIONS, you can subscribe by joining the iSeries Network with
a handy Web form at http://www.iseriesnetwork.com/join/ or by sending an e-
mail to mailto:ClubTechiSeries_PrgmTips_Sub@;lists.pentontech.com .

TO UNSUBSCRIBE or CHANGE E-MAIL ADDRESSES, go to
http://www.iseriesnetwork.com/info/profile/profilelogin.cfm or send an
e-mail to mailto:ClubTechiSeries_PrgmTips_Unsub@;lists.pentontech.com .
(Note: Unsubscribing via e-mail will work only if the e-mail
address in your "From" field matches the one you are subscribed as.)

You are subscribed as: [EMAIL PROTECTED]

IF YOU WANT TO SPONSOR a Club Tech iSeries Programming Tips Newsletter,
please contact your iSeries Network sales manager. Click here for details:
http://www.iseriesnetwork.com/info/mediakit/Sales/Index.htm .
___________________________
Copyright 2002, Penton Technology Media
http://www.iseriesnetwork.com


---
Este Mail NO contiene Virus.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.349 / Virus Database: 195 - Release Date: 15/04/02

---
Este Mail NO contiene Virus.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.416 / Virus Database: 232 - Release Date: 06/11/02


_____________________________________________________
Forum.HELP400 es un servicio m�s de NEWS/400.
� Publicaciones Help400, S.L. - Todos los derechos reservados
http://www.help400.es
_____________________________________________________

Para darte de baja, env�a el mensaje resultante de pulsar
mailto:forum.help400-request@;combios.es?body=LEAVE

Responder a