[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference ilbbak::ibi_focus

Title:FOCUS, from INFORMATION BUILDERS
Moderator:ZAYIUS::BROUILLETTE
Created:Thu Feb 19 1987
Last Modified:Mon May 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:615
Total number of notes:1779

493.0. "can I subtotal occurs fields?" by GOLF::JANOWSKI (CitizensAgainstContinentalDrift) Tue Feb 04 1992 18:38

I am a FOCUS novice and need advice for the following.

I have a file that contains a dollar field and occurs 54 times ($ per week).
I have no problem finding the sum and average of the 54 weeks but I need to 
find the sum after 13, 26, 39, and 54 weeks. Is there an easy method to subtotal
these from an occurs field?

Thanks ahead.
Paul

  SEGNAME=MRP_NUM,SEGTYPE=S0,PARENT=ROOT, OCCURS=54,$
  FIELD=M_GROSS_REQ        ,ALIAS=M_GROSS_REQ  ,USAGE=I6        ,ACTUAL=I4   ,$
  FIELD=M_OPEN_ORDER       ,ALIAS=M_OPEN_ORDER ,USAGE=P6        ,ACTUAL=I4   ,$
  FIELD=M_ON_HAND          ,ALIAS=M_ON_HAND    ,USAGE=P6        ,ACTUAL=I4   ,$
  FIELD=M_REC_ORDER        ,ALIAS=M_REC_ORDER  ,USAGE=P6        ,ACTUAL=I4   ,$
  FIELD=M_REC_RESCH        ,ALIAS=M_REC_RESCH  ,USAGE=P6        ,ACTUAL=I4   ,$
  FIELD=M_AVAIL_RES        ,ALIAS=M_AVAIL_RES  ,USAGE=P6        ,ACTUAL=I4   ,$

T.RTitleUserPersonal
Name
DateLines
493.1RUNTUF::IMFRAWed Feb 05 1992 20:1752
    
    Not directly, but if these are stored sequentially with respect to
    week (i.e. first rec = week 1 rec), then you can do it via a DEFINE. 
    
    B-T-W, you do mean 52 weeks not 54, n'est-ce pas??? 
    
    
    DEFINE FILE yourfile 
    
       REC_CNT/I2 = IF LAST REC_CNT EQ 52 THEN 1 
                    ELSE LAST REC_CNT + 1; 
    
       M_GROSS_REQ_Q1/I6 = IF (REC_CNT GE 1) AND (REC_CNT LE 13) 
                           THEN M_GROSS_REQ 
                           ELSE 0;
    
       M_GROSS_REQ_Q2/I6 = IF (REC_CNT GE 14) AND (REC_CNT LE 26) 
                           THEN M_GROSS_REQ 
                           ELSE 0;
     
    
      etc., etc.
    
    
    
    END 
    
    TABLE FILE yourfile  
      SUM M_GROSS_REQ_Q1 ... 
    
    ON TABLE HOLD 
    END
    
    
    TABLE FILE HOLD
    
     SUM ...
    
     BY ...
     BY ...
    
    etc., etc. 
    
    
    
    
    
    
    
    
    
    hope this is useful
493.2OCCURS Segment and ORDER fieldEVTDD1::CARRIEREJean-Claude CarriereThu Feb 06 1992 07:4031
Paul,

Along the same idea, you can use one of the OCCURS segment feature :

	There can be a special field (called ORDER field) that must be
	placed at the end of the segment, and that will be incremented
	for each record in the occurs segment. The field must have an
	ALIAS or "ORDER" and an ACTUAL format of I4

which gives :


  SEGNAME=MRP_NUM,SEGTYPE=S0,PARENT=ROOT, OCCURS=54,$
  FIELD=M_GROSS_REQ        ,ALIAS=M_GROSS_REQ  ,USAGE=I6        ,ACTUAL=I4   ,$
  FIELD=M_OPEN_ORDER       ,ALIAS=M_OPEN_ORDER ,USAGE=P6        ,ACTUAL=I4   ,$
  FIELD=M_ON_HAND          ,ALIAS=M_ON_HAND    ,USAGE=P6        ,ACTUAL=I4   ,$
  FIELD=M_REC_ORDER        ,ALIAS=M_REC_ORDER  ,USAGE=P6        ,ACTUAL=I4   ,$
  FIELD=M_REC_RESCH        ,ALIAS=M_REC_RESCH  ,USAGE=P6        ,ACTUAL=I4   ,$
  FIELD=M_AVAIL_RES        ,ALIAS=M_AVAIL_RES  ,USAGE=P6        ,ACTUAL=I4   ,$

  FIELD=M_WEEK_CNT         ,ALIAS=ORDER        ,USAGE=I2        ,ACTUAL=I4   ,$

Then you can either do :

	SUM M_ON_HAND
	IF M_WEEK_CNT IS_FROM 1 TO 16

or use define field computed depending on M_WEEK_CNT, if you want all your
sums to be computed on the same pass.

Jean-Claude