Kore Tech Tip
How to Unroll End of Month Sales Totals
Tip
#1018

Unrolling Monthly Sales Totals in DataFlo

As some things often go, the Roll process might get accidentally run a day or two early and then what o you do?

In DataFlo, normally at the end of each month (or end of the period) you run the "Roll Monthly Sales Totals" (MSO-U-03) process to put the "Current" period numbers into their current year buckets and then clear the current year fields so that the new period numbers can be stored.

As some things often go, the Roll process might get accidentally run a day or two early and then what do you do? It used to be you had to have someone write/run a rebuild sales analysis utility program which took a while and could even cost you a few dollars. Well, here is a fast little utility program that will "unroll" the Sales Analysis files so you can run the process again later.

The following program may be entered and compiled into your DW-CONV file. To execute this program you will need to provide the password "HOWDY".

Warning: You should backup your data before running this program. Once this program is run you cannot reverse the data. Although this program has been tested by Kore, we do not guarantee that will perform as expected.

Notes: This program is compatible with DataFlo Version 5.4 and higher. This program can be run when users are processing Invoices.
	** PROGRAM : Z.UNROLL.SA.PERIOD
** PURPOSE : Reverse Rolling the most current Sales Analysis Period
** AUTHOR  : pault, Kore Technologies
** WARNINGS: No Reversal after this program is run.
** NOTE    : This program can be run with users processing Invoices.
****************************************************************
** 00,10-27-05,pault: New.
****************************************************************
   PRINT "Enter password to run Z.UNROLL.SA.PERIOD ":
   INPUT ANS
   IF ANS # "HOWDY" THEN STOP
*
   OPEN "SACUST" TO F.SACUST ELSE CRT"Can't open SACUST";STOP
   OPEN "SAPART" TO F.SAPART ELSE CRT"Can't open SAPART";STOP
   CFG.FLG=1
   OPEN "SAOPTIONS" TO F.OPTIONS ELSE CFG.FLG=0
   OPEN "SO-TABLE" TO F.TABLE ELSE CRT"Can't open SO-TABLE";STOP
   READU ANALYSIS FROM F.TABLE,'ANALYSIS' ELSE
     PRINT "Cannot read ANALYSIS table, program halted!"
     RELEASE F.TABLE,'ANALYSIS' ; STOP
   END
*
   I=1
   LOOP UNTIL ANALYSIS<2,I> # "Y" DO
     I=I+1
   REPEAT
   PERIOD = I-1
   IF PERIOD < 1 OR PERIOD > 12 THEN
     PRINT "Period calculated as ":PERIOD:", program halting, cant process!"
     STOP
   END
   PRINT "Period to Unroll is calculated to be ":PERIOD:"."
   PRINT "OK to Continue, Y/N ":
   INPUT ANS
   IF ANS # "Y" THEN PRINT "Program halted!"
*
   CRT "Processing SAPART"
*
   SELECT F.SAPART
10 READNEXT ID ELSE GO 19
   READU ITEM FROM F.SAPART,ID ELSE ITEM=""
   IF ITEM = "" THEN
     RELEASE F.SAPART,ID
   END ELSE
     GOSUB UpdateItem
     WRITE ITEM ON F.SAPART,ID
   END
   GO 10
*
19 CRT "Processing SACUST"
*
   SELECT F.SACUST
20 READNEXT ID ELSE GO 29
   READU ITEM FROM F.SACUST,ID ELSE ITEM=""
   IF ITEM = "" THEN
     RELEASE F.SACUST,ID
   END ELSE
     GOSUB UpdateItem
     WRITE ITEM ON F.SACUST,ID
   END
   GO 20
*
29 IF NOT(CFG.FLG) THEN GO 99
   CRT "Processing SAOPTIONS"
*
   SELECT F.OPTIONS
30 READNEXT ID ELSE GO 99
   READU ITEM FROM F.OPTIONS,ID ELSE ITEM=""
   IF ITEM = "" THEN
     RELEASE F.OPTIONS,ID
   END ELSE
     GOSUB UpdateItem
     WRITE ITEM ON F.OPTIONS,ID
   END
   GO 30
*
99 CRT "Updating the Sales Analysis Control Table"
*
   ANALYSIS<2,PERIOD>=""
   ANALYSIS<3>=DATE():"*":"Z.UNROLL.SA.PERIOD ":PERIOD
   ANALYSIS<4,PERIOD>=DATE()+10 ;* Give them 10 days to Roll Month again
   WRITE ANALYSIS ON F.TABLE,'ANALYSIS'
*
   STOP ;***************************************** Program End
*
UpdateItem:
*
   PERIOD.QTY   = FIELD(ITEM<11,PERIOD>,'*',2)
   PERIOD.SALES = FIELD(ITEM<11,PERIOD>,'*',3)
   PERIOD.COSTS = FIELD(ITEM<16,PERIOD>,'*',3)
   ITEM<4>  = ITEM<4>  + PERIOD.QTY
   ITEM<5>  = ITEM<5>  + PERIOD.SALES
   ITEM<13> = ITEM<13> + PERIOD.COSTS
   ITEM = DELETE(ITEM,11,PERIOD)
   ITEM = DELETE(ITEM,16,PERIOD)
*
   RETURN
******************************************************
   END
We hope you find this tech tip as useful. As always, if you have any question on how to do any of this, please call us.
 
 
 
Our technical tips are provided to help you find new or easier ways to solve some of your technical challenges or to show you a new technique. We hope you find them useful. Please contact us if you would like to share one of your Tech Tips or need help solving a technical challenge. We would be happy to help you.