× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



The highest Level indicator should be set on the primary sort/key field. In this case:

STATE L2
CITY L1

The Level indicator on POPULATION is unnecessary.

Next, since you only want to print a record when the CITY changes your output should be conditioned on T(otal) output, not D(etail). For example:

QPRINT T L1

The way that the output is currently coded, every record in PF1 will be printed.

Just to confuse those to whom the Cycle is unfamiliar ground, in this particular case (not all cases, mind you), the output could, also, have been coded as:

QPRINT D L1

The reason being that your requirement is to print only one line per STATE + CITY.
Typically, the Cycle (for those of us who still care) would be used to, for example, accumulate sales totals by Division, Region, District, Salesman. Where L4 = Division, L3=Region, L2=District, and L1=Salesman. Short code sample:

C L2 MOVE *Zeros DistTtl
C L1 MOVE *Zeros SmTtl
C* accumulate totals

QPRINT T L1
SmTtl J 72
T L2
DistTtl J 72


In brief, using Level indicators in Detail will give you the beginning of the group *after* the record has been read into the input buffer. Using Level indicators in Total Calcs says that "The next record will start a new group" but the record which *will* cause the change has *not* been read into the input buffer.

Chapter 3 of the ILE RPG Language Reference manual (SC09-2508-06) covers the Cycle in more detail.


* Jerry C. Adams
*IBM System i Programmer/Analyst
B&W Wholesale Distributors, Inc.* *
voice
615.995.7024
fax
615.995.1201
email
jerry@xxxxxxxxxxxxxxx <mailto:jerry@xxxxxxxxxxxxxxx>



Srinivas Boggula wrote:
Hi every one,


My requirement is to generate a report using control level indicators
(L1-L9)

I have a physical file with following fields 1) STATE 2) CITY 3)
POPULATION

Now where ever city changes I need to print a new record on spool file

Below is the code I have written to do this, I'm getting the output but
I don't know

Whether this output is correct or not, I'm really confused with the
indicators


Can any one please guide me what is the exact use of control level
indicators.


Thanks in advance


Code for your reference



FPF1 IP E K DISK
FQPRINT O F 132 PRINTER
F*
IPFREC1 01
I STATE L1

I CITY L3

I POPULATION L2

I*
OQPRINT D 01
O STATE
O CITY
O POPULATION
O T LR

Physical file data


STATE CITY
POPULATION
000001 ANDHRA PRADESH New Delhi 3,00,000


000002 ANDHRA PRADESH SECUNDERABAD 300,000
000003 ANDHRA PRADESH SECUNDERABAD 300,000
000004 ANDHRA PRADESH SECUNDERABAD 400,000
000005 ANDHRA PRADESH VIJAYAWADA 300,000
000006 ANDHRA PRADESH VIJAYAWADA 300,000
000007 ANDHRA PRADESH VIJAYAWADA 300,000
000008 ANDHRA PRADESH VIJAYAWADA 300,000
000009 ANDHRA PRADESH KURNOOL 300,000
000010 ANDHRA PRADESH KURNOOL 300,000
000011 ANDHRA PRADESH KURNOOL 300,000
000012 ANDHRA PRADESH KURNOOL 300,000
000013 ANDHRA PRADESH KURNOOL 300,000
000014 ANDHARA PRADESH New Delhi 100,000
000015 ANDHARA PRADESH New Delhi 200,000


Best Regards,

Srinivas






----------------------------------------------------------------DISCLAIMER---------------------------------------------------------
Information transmitted by this EMAIL is proprietary to iGATE Group of Companies and is intended for use only by the individual or entity to whom it is addressed and may contain information that is privileged, confidential, or exempt from disclosure under applicable law. If you are not the intended recipient of this EMAIL immediately notify the sender at iGATE or mailadmin@xxxxxxxxx and delete this EMAIL including any attachments


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.