Konsolidasi Contoh (Bag.2)

Berikut contoh Program Visual Foxpro, yang menggabungkan direktori-direktori data aplikasi, yang tersebar pada s:/projects/cas3/mgm1 ..dst.. dicontoh lengkap tersebut… mengkonsolidasikan dengan merekap data yang ada, terdiri dari tabel shiphist, didukung oleh tabel customer, inv dst …. menjadi kesatuan masuk kedalam data centdata.dbf untuk kemudian lilakukan pilot table dari excell, untuk mensumary-kan semua jenis laporan yang ada, minimal logic program ini dapat di pahami, atau dapat di terapkan dalam berbagai jenis database.

Bersambung …..

*****************
* MARKETPLAN *
*****************
public oxmenu

if not((sysmetric(1)>=1024) and (sysmetric(2)>=768))
_screen.visible =.f. && disable for massage error
messagebox(“Resolusi Harus 1024×768 pixel!”,48,”Error!”)
_screen.visible =.t.
cancel
endif

set talk off
set dele on
set esca off
set safe off
set date to ital
set century on
set separ to ‘.’

ON ERROR DO errtrap WITH ;
ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO( )
******************
* Loading database
* Open All Indexs
******************
CLOSE DATA
*cas3 = ‘s:\projects\cas3\ppm1\’

* End of Loading Table
* ——————–

oxmenu = createobject(“xFormsSet”)
oxmenu.show
read event
clear all
_screen.visible = .T.

define class xformsSet as formset
autorelease = .T. && If the last form of the formset release then the formset will autorelease
windowtype = 0 && modeless
*** Custom Property ***
mainformclose = .F.
*** End Of Custom Property ***
add object xmform as mainform
enddefine

DEFINE CLASS mainform AS FORM
autocenter = .T. && display at center of the screen
borderstyle = 0 && no border (unsizeable)
caption = ‘SYSTEM PROSES DATACENTER’
icon = ‘arppm.ico’
closable = .F. && able to use dbl-click to exit at pop-up menu icon / close disable – in menu exit
desktop = .T.
height = sysmetric(2)-520 && 520
maxbutton = .F. && Disable Maximize Button on the upper right corner
MDIform = .T.
showwindow = 2 && As Top Level Form
showtips = .T. && Enable the ToolTipText on the Controls
width = sysmetric(1)-700 && 600
windowtype = 0 && modeless
windowstate = 2 &&maximaize

ADD OBJECT pic_awal AS IMAGE;
WITH;
borderstyle = 1,;
picture = ‘wallp.jpg’,;
stretch = 2,;
top = 0,;
left = 0,;
width = sysmetric(1)-700,;
height = sysmetric(2)-520

ADD OBJECT titlez AS LABEL;
WITH;
alignment = 0,;
top = 10,;
left = 05,;
width = 600,; &&165
height = 30,;
caption = ‘SYETEM PROSES’,;
fontname = ‘Arial’,;
fontsize = 9,;
fontbold = .T.,;
backstyle = 0,;
fontunderline = .T.

add object belowmark AS obelowmark;
with;
top = thisform.height-40,;
left = 10 &&thisform.width-400

ADD OBJECT periode1_say AS LABEL;
WITH;
alignment = 0,; && Left Alignment
top = 20+20,;
left = 30,;
width = 105,;
height = 20,;
caption = ‘Periode Begin:’,;
fontname = ‘Arial’,;
forecolor = RGB(255,0,0),;
borderstyle = 0,;
backstyle = 0,;
fontsize = 8,;
fontbold = .T.

ADD OBJECT per1_get AS TEXTBOX;
WITH;
alignment = 0,; && center
top = 20+20,;
left = 155,;
width = 65,;
height = 18,;
margin = 0,; && no margin
value = date(),;
maxlength = 30,; && two digit input – 30 character field
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.,;
tooltiptext = ‘Periode Begin….’

ADD OBJECT per1a_get AS TEXTBOX;
WITH;
alignment = 0,; && center
top = 20+20,;
left = 155+70,;
width = 65,;
height = 18,;
margin = 0,; && no margin
value = date(),;
maxlength = 30,; && two digit input – 30 character field
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.,;
tooltiptext = ‘Periode Begin….’

ADD OBJECT periode2_say AS LABEL;
WITH;
alignment = 0,; && Left Alignment
top = 40+20,;
left = 30,;
width = 105,;
height = 20,;
caption = ‘Periode Ending:’,;
fontname = ‘Arial’,;
forecolor = RGB(255,0,0),;
borderstyle = 0,;
backstyle = 0,;
fontsize = 8,;
fontbold = .T.

ADD OBJECT per2_get AS TEXTBOX;
WITH;
alignment = 0,; && center
top = 40+20,;
left = 155,;
width = 65,;
height = 18,;
margin = 0,; && no margin
value = date(),;
maxlength = 30,; && two digit input – 30 character field
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.,;
tooltiptext = ‘Periode Ending…. ‘

ADD OBJECT per2a_get AS TEXTBOX;
WITH;
alignment = 0,; && center
top = 40+20,;
left = 155+70,;
width = 65,;
height = 18,;
margin = 0,; && no margin
value = date(),;
maxlength = 30,; && two digit input – 30 character field
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.,;
tooltiptext = ‘Periode Ending…. ‘

ADD OBJECT xwith_get AS TEXTBOX;
WITH;
alignment = 0,; && center
top = 40+20+20,;
left = 155+70,;
width = 20,;
height = 18,;
margin = 0,; && no margin
value = “Y”,;
maxlength = 30,; && two digit input – 30 character field
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.,;
tooltiptext = ‘Dengan Nilai Minus CN (Y/N)….?’

ADD OBJECT UEGB AS COMMANDGROUP;
WITH;
top = thisform.height-80,;
left = 30,;
width = 100,; && 50,100
height = 25,;
borderstyle = 0,;
visible=.T.

ADD OBJECT car1_say AS LABEL;
WITH;
alignment = 0,; && Left Alignment
top = 20+5,;
left = 155,;
width = 105,;
height = 20,;
caption = ‘Aktual(P#1)’,;
fontname = ‘Arial’,;
forecolor = RGB(255,0,0),;
borderstyle = 0,;
backstyle = 0,;
fontsize = 8,;
fontbold = .T.

ADD OBJECT car2_say AS LABEL;
WITH;
alignment = 0,; && Left Alignment
top = 20+5,;
left = 155+70,;
width = 105,;
height = 20,;
caption = ‘SO(P#2)’,;
fontname = ‘Arial’,;
forecolor = RGB(255,0,0),;
borderstyle = 0,;
backstyle = 0,;
fontsize = 8,;
fontbold = .T.

PROC UEGB.init()
this.addobject(‘prosess1button’,’proses1Obj’)
this.addobject(‘prosess2button’,’proses2Obj’)
ENDPROC

PROCEDURE init
DEFINE MENU xmform BAR IN xmform
DEFINE PAD _1 OF xmform PROMPT ‘\<File’ KEY ALT+F

ON PAD _1 OF xmform ACTIVATE POPUP xfile
DEFINE POPUP xfile MARGIN
DEFINE BAR 1 OF xfile PROMPT ‘Master Group Outle\<t’ KEY CTRL+E, ‘Ctrl+E’
DEFINE BAR 2 OF xfile PROMPT ‘Master Group P\<roduct’ KEY CTRL+P, ‘Ctrl+P’
DEFINE BAR 3 OF xfile PROMPT ‘Master Product S\<I’ KEY CTRL+S, ‘Ctrl+S’
DEFINE BAR 4 OF xfile PROMPT ‘\-‘
DEFINE BAR 5 OF xfile PROMPT ‘Group O\<utlet’ KEY CTRL+O, ‘Ctrl+O’
DEFINE BAR 6 OF xfile PROMPT ‘G\<roup Product’ KEY CTRL+G, ‘Ctrl+G’
DEFINE BAR 7 OF xfile PROMPT ‘S\<ales Supervisi’ KEY CTRL+S, ‘Ctrl+S’
DEFINE BAR 8 OF xfile PROMPT ‘\-‘
DEFINE BAR 9 OF xfile PROMPT ‘E\<xit’ KEY CTRL+X, ‘Ctrl+X’
ON SELECTION BAR 1 OF xfile accxa1()
ON SELECTION BAR 2 OF xfile accxa2()
ON SELECTION BAR 3 OF xfile accxa3()
ON SELECTION BAR 5 OF xfile accxa5()
ON SELECTION BAR 6 OF xfile accxa6()
ON SELECTION BAR 7 OF xfile accxa7()
ON SELECTION BAR 9 OF xfile oxmenu.release

ACTIVATE MENU xmform
ENDPROC

PROCEDURE Load()
_SCREEN.visible = .F. && disable for form loading
ENDPROC

PROCEDURE destroy()
thisformset.mainformclose = .T.
CLOSE TABLES ALL
RELEASE MENUS xmform EXTENDED
CLEAR EVENTS
ENDPROC

ENDDEFINE

define class obelowmark as container
width = 300
height = 20
specialeffect = 0 && raise

add object DP as label;
with;
alignment = 1,; && center
top = 2,;
left = 1,;
width = 250,;
height = 16,;
caption = ‘ Programmed by Mulyono Rafianto – MGM ‘,;
fontname = ‘Times New Roman’ && other possible font : ‘Comic Sans MS’,;
fontsize = 8,;
fontbold = .t.
ENDDEFINE

PROC accxa1()

SELECT 0
USE mastgrp
INDEX ON grouping TO mastgrp1

set proc to
set proc to ms1
LoadM1 = CREATEOBJECT(‘GroupM1LoadObj’)
LoadM1.Show
set proc to

CLOSE DATABASES

ENDPROC

PROC accxa2()

SELECT 0
USE mastprd
INDEX ON grouping TO mastprd1

set proc to
set proc to ms2
LoadM2 = CREATEOBJECT(‘GroupM2LoadObj’)
LoadM2.Show
set proc to

CLOSE DATABASES

ENDPROC

PROC accxa3()

SELECT 0
USE mastsi
INDEX ON grouping TO mastsi1

set proc to
set proc to ms3
LoadM3 = CREATEOBJECT(‘GroupM3LoadObj’)
LoadM3.Show
set proc to

CLOSE DATABASES

ENDPROC

* =================================================
PROC accxa5()

SELECT 0
USE agroup
INDEX ON group TO agroup1
INDEX ON custid TO agroup2
SET INDEX TO agroup1,agroup2

SELECT 0
USE MASTGRP
INDEX ON GROUPING TO MASTGRP1

GDir = “s:\projects\cas3\mgmjkt”
SELECT 0
USE Gdir+’\customer’ share ALIAS custjkt INDEX Gdir+’\custid’,Gdir+’\custname’,Gdir+’\custarea’,Gdir+’\custter’

set proc to
set proc to ag1
LoadM1 = CREATEOBJECT(‘GroupAG1LoadObj’)
LoadM1.Show
set proc to

CLOSE DATABASES

ENDPROC

PROC accxa6()

SELECT 0
USE aprod
INDEX ON group TO aprod1
INDEX ON pn TO aprod2
SET INDEX TO aprod1,aprod2

SELECT 0
USE aprox
INDEX ON pn TO aprox1
SET INDEX TO aprox1

SELECT 0
USE mastprd
INDEX ON grouping TO mastprd1

SELECT 0
USE mastsi
INDEX ON grouping TO mastsi1

GDir = “s:\projects\cas3\mgmjkt” && Default Parameter Directory Search Product Master
SELECT 0
USE Gdir+’\inv’ share ALIAS invjkt INDEX Gdir+’\invpn’,Gdir+’\invcmdty’,Gdir+’\invacct’,Gdir+’\invcycle’

GDir = “s:\projects\cas3\mgmbgr”
SELECT 0
USE Gdir+’\inv’ share ALIAS invbgr INDEX Gdir+’\invpn’,Gdir+’\invcmdty’,Gdir+’\invacct’,Gdir+’\invcycle’

GDir = “s:\projects\cas3\mgm2”
SELECT 0
USE Gdir+’\inv’ share ALIAS invbgrnew INDEX Gdir+’\invpn’,Gdir+’\invcmdty’,Gdir+’\invacct’,Gdir+’\invcycle’

set proc to
set proc to ag2
LoadA2 = CREATEOBJECT(‘GroupAG2LoadObj’)
LoadA2.Show
set proc to

CLOSE DATABASES

ENDPROC

PROC accxa7()

SELECT 0
USE mastsls
INDEX ON salesman TO mastsls1
INDEX ON name TO mastsls2
SET INDEX TO mastsls1,mastsls2

GDir = “s:\projects\cas3\mgmjkt”
SELECT 0
USE Gdir+’\salesman’ share ALIAS sales1 INDEX Gdir+’\salesman’

set proc to
set proc to ag3
LoadM3 = CREATEOBJECT(‘GroupAG3LoadObj’)
LoadM3.Show
set proc to

CLOSE DATABASES

ENDPROC

DEFINE CLASS Proses1Obj AS COMMANDBUTTON
caption = ‘\<P#1’
top = 0
left = 0
width = 50
height = 25
fontname = ‘Arial’
fontsize = 8
fontbold = .T.
tooltiptext = ‘Proses #1 (Sales Omzet Actual)…’
mousepointer = 99
mouseicon = ‘H_point.cur’
visible = .T.

PROCEDURE click()
this.Parent.parent.titlez.caption = “”
d1 = this.parent.parent.per1_get.value
d2 = this.parent.parent.per2_get.value

time1 = second()
namax = ‘Z.OTHER’

thisform.Caption = “Data Proses Index!. wait..”
CLOSE DATABASES

SELECT 0
USE s:\temp\datacent\CENTDATA EXCLU ALIAS CENTDATA
INDEX ON CUSTID TO s:\temp\datacent\CENTDATA

SELECT 0
USE s:\temp\datacent\MASKODE EXCLU ALIAS KODEPOS
INDEX ON KODEPOS TO s:\temp\datacent\MASKODE

GDir = “s:\projects\cas3\mgmjkt”
*——- jakarta ————
SELECT 0
USE Gdir+’\shiphist’ share ALIAS shiphist1 INDEX Gdir+’\shipdate’,Gdir+’\shipcust’,Gdir+’\shipord’,Gdir+’\shiphist’
SELECT 0
USE Gdir+’\customer’ share ALIAS customer1 INDEX Gdir+’\custid’,Gdir+’\custname’,Gdir+’\custarea’,Gdir+’\custter’
SELECT 0
USE Gdir+’\terr’ share ALIAS terr1 INDEX Gdir+’\terr’
SELECT 0
USE Gdir+’\salesman’ share ALIAS sales1 INDEX Gdir+’\salesman’
SELECT 0
USE Gdir+’\arbal’ share ALIAS arbal1 INDEX Gdir+’\arbalref’,Gdir+’\arbal’
SELECT 0
USE Gdir+’\inv’ share ALIAS inv1 INDEX Gdir+’\invpn’,Gdir+’\invacct’,Gdir+’\invcmdty’,Gdir+’\invcycle’

*GDir = “s:\projects\cas3\mgmbgr”
*——- bogor ————–
*SELECT 0
*USE Gdir+’\shiphist’ share ALIAS shiphist2 INDEX Gdir+’\shipdate’,Gdir+’\shipcust’,Gdir+’\shipord’,Gdir+’\shiphist’
*SELECT 0
*USE Gdir+’\customer’ share ALIAS customer2 INDEX Gdir+’\custid’,Gdir+’\custname’,Gdir+’\custarea’,Gdir+’\custter’
*SELECT 0
*USE Gdir+’\terr’ share ALIAS terr2 INDEX Gdir+’\terr’
*SELECT 0
*USE Gdir+’\salesman’ share ALIAS sales2 INDEX Gdir+’\salesman’

*GDir = “s:\projects\cas3\mgmbks”
*——- bekasi ————-
*SELECT 0
*USE Gdir+’\shiphist’ share ALIAS shiphist3 INDEX Gdir+’\shipdate’,Gdir+’\shipcust’,Gdir+’\shipord’,Gdir+’\shiphist’
*SELECT 0
*USE Gdir+’\customer’ share ALIAS customer3 INDEX Gdir+’\custid’,Gdir+’\custname’,Gdir+’\custarea’,Gdir+’\custter’
*SELECT 0
*USE Gdir+’\terr’ share ALIAS terr3 INDEX Gdir+’\terr’
*SELECT 0
*USE Gdir+’\salesman’ share ALIAS sales3 INDEX Gdir+’\salesman’

*GDir = “s:\projects\cas3\mgmskb”
*——- sukabumi ———–
*SELECT 0
*USE Gdir+’\shiphist’ share ALIAS shiphist4 INDEX Gdir+’\shipdate’,Gdir+’\shipcust’,Gdir+’\shipord’,Gdir+’\shiphist’
*SELECT 0
*USE Gdir+’\customer’ share ALIAS customer4 INDEX Gdir+’\custid’,Gdir+’\custname’,Gdir+’\custarea’,Gdir+’\custter’
*SELECT 0
*USE Gdir+’\terr’ share ALIAS terr4 INDEX Gdir+’\terr’
*SELECT 0
*USE Gdir+’\salesman’ share ALIAS sales4 INDEX Gdir+’\salesman’

*GDir = “s:\projects\cas3\mgmbdg”
*——- Bandung ————-
*SELECT 0
*USE Gdir+’\shiphist’ share ALIAS shiphist5 INDEX Gdir+’\shipdate’,Gdir+’\shipcust’,Gdir+’\shipord’,Gdir+’\shiphist’
*SELECT 0
*USE Gdir+’\customer’ share ALIAS customer5 INDEX Gdir+’\custid’,Gdir+’\custname’,Gdir+’\custarea’,Gdir+’\custter’
*SELECT 0
*USE Gdir+’\terr’ share ALIAS terr5 INDEX Gdir+’\terr’
*SELECT 0
*USE Gdir+’\salesman’ share ALIAS sales5 INDEX Gdir+’\salesman’

*GDir = “s:\projects\cas3\mgmpwk”
*——- Purwakarta ———-
*SELECT 0
*USE Gdir+’\shiphist’ share ALIAS shiphist6 INDEX Gdir+’\shipdate’,Gdir+’\shipcust’,Gdir+’\shipord’,Gdir+’\shiphist’
*SELECT 0
*USE Gdir+’\customer’ share ALIAS customer6 INDEX Gdir+’\custid’,Gdir+’\custname’,Gdir+’\custarea’,Gdir+’\custter’
*SELECT 0
*USE Gdir+’\terr’ share ALIAS terr6 INDEX Gdir+’\terr’
*SELECT 0
*USE Gdir+’\salesman’ share ALIAS sales6 INDEX Gdir+’\salesman’

GDir = “s:\projects\cas3\mgm2”
*——- BOGOR BARU ———-
SELECT 0
USE Gdir+’\shiphist’ share ALIAS shiphist7 INDEX Gdir+’\shipdate’,Gdir+’\shipcust’,Gdir+’\shipord’,Gdir+’\shiphist’
SELECT 0
USE Gdir+’\customer’ share ALIAS customer7 INDEX Gdir+’\custid’,Gdir+’\custname’,Gdir+’\custarea’,Gdir+’\custter’
SELECT 0
USE Gdir+’\terr’ share ALIAS terr7 INDEX Gdir+’\terr’
SELECT 0
USE Gdir+’\salesman’ share ALIAS sales7 INDEX Gdir+’\salesman’
SELECT 0
USE Gdir+’\arbal’ share ALIAS arbal7 INDEX Gdir+’\arbalref’,Gdir+’\arbal’

*GDir = “s:\projects\cas3\ppm1”
*——- PPM ———-
*SELECT 0
*USE Gdir+’\shiphist’ share ALIAS shiphist8 INDEX Gdir+’\shipdate’,Gdir+’\shipcust’,Gdir+’\shipord’,Gdir+’\shiphist’
*SELECT 0
*USE Gdir+’\customer’ share ALIAS customer8 INDEX Gdir+’\custid’,Gdir+’\custname’,Gdir+’\custarea’,Gdir+’\custter’
*SELECT 0
*USE Gdir+’\terr’ share ALIAS terr8 INDEX Gdir+’\terr’
*SELECT 0
*USE Gdir+’\salesman’ share ALIAS sales8 INDEX Gdir+’\salesman’

GDir = “s:\projects\cas3\mgmdpk”
*——- DEPOK BARU ———-
SELECT 0
USE Gdir+’\shiphist’ share ALIAS shiphist9 INDEX Gdir+’\shipdate’,Gdir+’\shipcust’,Gdir+’\shipord’,Gdir+’\shiphist’
SELECT 0
USE Gdir+’\customer’ share ALIAS customer9 INDEX Gdir+’\custid’,Gdir+’\custname’,Gdir+’\custarea’,Gdir+’\custter’
SELECT 0
USE Gdir+’\terr’ share ALIAS terr9 INDEX Gdir+’\terr’
SELECT 0
USE Gdir+’\salesman’ share ALIAS sales9 INDEX Gdir+’\salesman’
SELECT 0
USE Gdir+’\arbal’ share ALIAS arbal9 INDEX Gdir+’\arbalref’,Gdir+’\arbal’

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

SELECT 0
*USE C:\SOFTWARE\XPROGRAM\ARPPM\JKTGROUP SHARED ALIAS GROUPS INDEX C:\SOFTWARE\XPROGRAM\ARPPM\JKTGROUP2
USE AGROUP SHARE ALIAS GROUPS INDEX AGROUP1,AGROUP2 && Group, Custid
SET ORDER TO 2

SELECT 0
*USE C:\SOFTWARE\XPROGRAM\ARPPM\JKTPROD SHARED ALIAS PRODS INDEX C:\SOFTWARE\XPROGRAM\ARPPM\JKTPROD2
USE APROD SHARE ALIAS PRODS INDEX APROD1,APROD2
SET ORDER TO 2

SELECT 0
USE GCOMDTY SHARED ALIAS GCOMD INDEX GCOMDTY

thisform.Caption = “Centdata Table Zapping! wait..”

SELECT CENTDATA
ZAP
PACK

thisform.Caption = ‘Searching Jakarta Data wait…’
DO CARIDATA WITH ‘shiphist1′,d1,d2,’customer1′,’terr1′,’1.JAKARTA’,’sales1′
*thisform.Caption = ‘Searching Bogor Data wait…’
*DO CARIDATA WITH ‘shiphist2′,d1,d2,’customer2′,’terr2′,’2.BOGOR’,’sales2′
*thisform.Caption = ‘Searching Bekasi Data wait…’
*DO CARIDATA WITH ‘shiphist3′,d1,d2,’customer3′,’terr3′,’3.BEKASI’,’sales3′
*thisform.Caption = ‘Searching Sukabumi Data wait…’
*DO CARIDATA WITH ‘shiphist4′,d1,d2,’customer4′,’terr4′,’4.SUKABUMI’,’sales4′
*thisform.Caption = ‘Searching Bandung Data wait…’
*DO CARIDATA WITH ‘shiphist5′,d1,d2,’customer5′,’terr5′,’5.BANDUNG’,’sales5′
*thisform.Caption = ‘Searching Purwakarta Data wait…’
*DO CARIDATA WITH ‘shiphist6′,d1,d2,’customer6′,’terr6′,’6.PURWAKARTA’,’sales6′
thisform.Caption = ‘Searching Bogor Data wait…’
DO CARIDATA WITH ‘shiphist7′,d1,d2,’customer7′,’terr7′,’2.Bogor’,’sales7′
*thisform.Caption = ‘Searching PPM Data wait…’
*DO CARIDATA WITH ‘shiphist8′,d1,d2,’customer8′,’terr8′,’8.PPM’,’sales8′
*thisform.Caption = ‘Searching PPM Data wait…’
*DO CARIDATA WITH ‘shiphist8′,d1,d2,’customer8′,’terr8′,’8.PPM’,’sales8′
thisform.Caption = ‘Searching Depok Data wait…’
DO CARIDATA WITH ‘shiphist9′,d1,d2,’customer9′,’terr9′,’3.Depok’,’sales9′
thisform.Caption = “End Of Proses !”

** Cari Inv No di Arballance
SELECT centdata
GO top

time2 = SECONDS()
this.Parent.parent.titlez.caption = “Proses Result in :”+STR(time2-time1)+” second.”

** USE
CLOSE DATABASES
ENDPROC
ENDDEFINE

PROCEDURE CARIDATA
PARAMETERS DNAMAFILE,D1,D2,CS,TR,DPX,SLSM
* shiphist,tg1,tgl2,customer,terr,deponame
SELECT (dnamafile)
SET NEAR ON
SEEK DTOS(d1)
SET NEAR OFF
DO WHILE shipdate >= d1 AND shipdate <= d2 AND !EOF()
*IF SUBSTR(pn,1,2)<>”GM” or usell <> 0 &&tambahan sementara
* skip
* loop
*ENDIF

IF SUBSTR(pn,1,2)=”GM”
skip
loop
ENDIF

store 0 to hit1,hit2,hit3
STORE SPACE(8) TO ids
STORE 0 TO xdscpct
hit1 = qtyshp
hit2 = qtyshp*usell
hit3 = ((QTYSHP*USELL) – ((DISCQTY * USELL) + ((discpct/100)*((QTYSHP-DISCQTY)*USELL)) + ((discash/100)*(((QTYSHP-DISCQTY)*USELL)-((discpct/100)*((QTYSHP-DISCQTY)*USELL))))))
pnx = pn
desx = desc
ids = custid
trs = terr
dt1 = shipdate
oex = oeno
usl = usell
uct = ucost
slm = salesman
acct = acctno
zpx = zip
clx = custclass
xdscpct = discpct
nwclas1 = ”

* CARI COMODITY DI INV MASTER
SELECT INV1
GO top
SEEK pnx
IF FOUND()
xcomdty = inv1->comdty
ELSE
xcomdty = ‘Free’
ENDIF

* CARI GROUP ID
NAMAX = ‘Z.OTHER’
namaxs = ‘Z.OTHER’
SELECT GROUPS
SET ORDER TO 2 && Custid
GO top
SEEK ids
IF !EOF()
IDGRP = GROUP
nwclas1 = nwclass
SELECT (CS)
GO TOP
SEEK ids
IF !EOF()
NAMAX = NAME
namaxs = ALLTRIM(sname)+” # “+ALLTRIM(saddress1)
ELSE
NAMAX = ‘Z.OTHER’
namaxs = ‘Z.OTHER’
ENDIF
ELSE
IDGRP = ‘Z.OTHER’
nwclas1 = ‘XL’
SELECT (CS)
GO TOP
SEEK ids
IF !EOF()
NAMAX = NAME
namaxs = ALLTRIM(sname)+” # “+ALLTRIM(saddress1)
ELSE
NAMAX = ‘Z.OTHER’
namaxs = ‘Z.OTHER’
ENDIF
ENDIF

* CARI GROUP PN
SELECT PRODS
GO top
SEEK pnx
IF !EOF()
IDPN = GROUP
IDCOM = COMODITY
SIPN = SI_PROD
ELSE
IDPN = ’99.OTHER’
IDCOM = ‘9.Other’
SIPN = ‘ZSI.Other’
ENDIF

* CARI AREA
SELECT (TR)
SEEK trs
IF !EOF()
XAREA = DESC
ELSE
XAREA = “ZCUSSER”
ENDIF

* CARI KECAMATAN
SELECT KODEPOS
SEEK zpx
IF !EOF()
xkec = kecamatan
ELSE
xkec = ‘Z.CLUSTER’
ENDIF

* CARI SALESMAN NAME
SELECT (slsm)
SEEK slm
IF !EOF()
namslm = name
ELSE
namslm = ‘Z.NONAME’
ENDIF

SELECT centdata
SET ORDER TO 1

APPEND BLANK
REPLACE WILAYAH WITH dpx
REPLACE AREA WITH xarea
REPLACE GROUPID WITH idgrp
REPLACE GROUPPN WITH idpn
REPLACE SIPART WITH sipn
** REPLACE COMDITY WITH idcom NEW
REPLACE comdity WITH caricomodity(xcomdty)
**
REPLACE TAHUN WITH YEAR(dt1)
REPLACE BULAN WITH MONTH(dt1)
REPLACE CBULAN WITH CBUL(BULAN)
REPLACE MINGGU WITH WEEK(dt1)
REPLACE PN WITH pnx
REPLACE DESC WITH desx
REPLACE OENO WITH oex
REPLACE CUSTID WITH ids
REPLACE NAMA WITH namax
REPLACE SNAMA WITH namaxs
REPLACE SHIPDATE WITH dt1
REPLACE QTYSHP WITH hit1
IF usl <> 0
IF xdscpct = 100
REPLACE qtysales WITH 0 &&Bonus Barang 100% tidak dihitung
else
REPLACE qtysales WITH hit1
endif
ENDIF
REPLACE USELL WITH usl
REPLACE GROSSALES WITH hit2
REPLACE NETSALES WITH hit3
REPLACE SALESMAN WITH slm
REPLACE NAMASLS WITH namslm
REPLACE UCOST WITH uct
REPLACE ACCTNO WITH acct
REPLACE ZIP WITH zpx
REPLACE CUSTCLASS WITH clx
REPLACE KECAMATAN WITH xkec
REPLACE nwclass WITH nwclas1
REPLACE com WITH xcomdty

*** FLUSH
SELECT (dnamafile)
skip
ENDDO
ENDPROC

FUNCTION CBUL
PARAMETERS nbul
DO case
CASE nbul = 1
cx = “01.Jan”
CASE nbul = 2
cx = “02.Feb”
CASE nbul = 3
cx = “03.Mar”
CASE nbul = 4
cx = “04.Apr”
CASE nbul = 5
cx = “05.Mei”
CASE nbul = 6
cx = “06.Jun”
CASE nbul = 7
cx = “07.Jul”
CASE nbul = 8
cx = “08.Agt”
CASE nbul = 9
cx = “09.Sep”
CASE nbul = 10
cx = “10.Okt”
CASE nbul = 11
cx = “11.Nov”
CASE nbul = 12
cx = “12.Des”
ENDCASE
RETURN (cx)

**** cari so *****
*** Pencarian Servive Level ****
DEFINE CLASS Proses2Obj AS COMMANDBUTTON
caption = ‘\<P#2’
top = 0
left = 51
width = 50
height = 25
fontname = ‘Arial’
fontsize = 8
fontbold = .T.
tooltiptext = ‘Proses #2 (Service Level)….’
mousepointer = 99
mouseicon = ‘H_point.cur’
visible = .T.

PROCEDURE click()
this.Parent.parent.titlez.caption = “”
d1 = this.parent.parent.per1a_get.value
d2 = this.parent.parent.per2a_get.value

time1 = second()
namax = ‘Z.OTHER’

thisform.Caption = “Data Proses Index!. wait..”
CLOSE DATABASES

SELECT 0
USE s:\temp\datacent\CENTLEVL EXCLU ALIAS CENTLEVL
INDEX ON CUSTID+OENO+item+PN TO s:\temp\datacent\CENTLEVL

SELECT 0
USE s:\temp\datacent\MASKODE EXCLU ALIAS KODEPOS
INDEX ON KODEPOS TO s:\temp\datacent\MASKODE

GDir = “s:\projects\cas3\mgmjkt”
*——- jakarta ————
SELECT 0
USE Gdir+’\shiphist’ share ALIAS shiphist1 INDEX Gdir+’\shipdate’,Gdir+’\shipcust’,Gdir+’\shipord’,Gdir+’\shiphist’
SELECT 0
USE Gdir+’\customer’ share ALIAS customer1 INDEX Gdir+’\custid’,Gdir+’\custname’,Gdir+’\custarea’,Gdir+’\custter’
SELECT 0
USE Gdir+’\terr’ share ALIAS terr1 INDEX Gdir+’\terr’
SELECT 0
USE Gdir+’\codet’ share ALIAS codet1 INDEX Gdir+’\codetky’,Gdir+’\codetpn’,Gdir+’\prodord1′
SELECT 0
USE Gdir+’\comast’ share ALIAS comast1 INDEX Gdir+’\comastky’,Gdir+’\comast’
SELECT 0
USE Gdir+’\inv’ share ALIAS inv1 INDEX Gdir+’\invpn’,Gdir+’\invacct’,Gdir+’\invcmdty’,Gdir+’\invcycle’
SELECT 0
USE Gdir+’\salesman’ share ALIAS sales1 INDEX Gdir+’\salesman’

SELECT 0
USE AGROUP SHARE ALIAS GROUPS INDEX AGROUP1,AGROUP2 && Group, Custid
SET ORDER TO 2

SELECT 0
USE APROD SHARE ALIAS PRODS INDEX APROD1,APROD2
SET ORDER TO 2

SELECT 0
USE MASTSLS SHARE ALIAS SLSX1 INDEX MASTSLS1,MASTSLS2
SET ORDER TO 1

SELECT centlevl
ZAP
PACK

SELECT codet1
GO top
DO WHILE !EOF()
IF codet1.duedate >= d1 AND codet1.duedate <= d2
IF SUBSTR(pn,1,2) = “GM”
skip
loop
ENDIF

store 0 to hit1,hit2,hit3
STORE SPACE(8) TO ids
hit1 = qtyshp
hit2 = qtyshp*usell
hit3 = ((QTYSHP*USELL) – ((DISCQTY * USELL) + ((discpct/100)*((QTYSHP-DISCQTY)*USELL)) + ((discash/100)*(((QTYSHP-DISCQTY)*USELL)-((discpct/100)*((QTYSHP-DISCQTY)*USELL))))))
xitem= item
pnx = pn
desx = desc
ids = custid
dt1 = duedate
oex = oeno
usl = usell
uct = ucost
acct = acctno
nwclas1 = ”
xpocst = ”
xsname = ”
xsales = ”
xzip = ”
xtrs = ”
xklas= ”
STORE CTOD(‘ – – ‘) TO xentrydate,xreqdate,xshipdate
xqtyord = qtyord
xqtyshp = qtyshp
xqtybor = qtybo
xqtyinv = qtyinv
xxqtyshp= 0
xxusell = 0
xacctno = acctno

* CARI COMODITY DI INV MASTER
SELECT INV1
SEEK pnx
IF FOUND()
xcomdty = inv1->comdty
ELSE
xcomdty = ‘Free’
ENDIF

SELECT comast1
SET ORDER TO 1
GO top
SEEK IDS+oex && Custid+Oeno
IF FOUND()
xpocst = ponum
xsnama = ALLTRIM(scompany)+’ / ‘+ALLTRIM(saddress1)+’ / ‘+ALLTRIM(saddress2)
xsales = salesman
xreqdate = reqdate
xentrydate = entrydate
xzip = szip
xtrs = terr
xklas= custclass
ENDIF

SELECT SHIPHIST1
SET ORDER TO 3
GO TOP
SEEK OEX+XITEM
IF FOUND()
xxqtyshp = qtyshp
** xxusell = usell dari codet
xshipdate = shipdate
ENDIF

SELECT sales1
SEEK xsales
IF FOUND()
xnamasl = name
ELSE
xnamasl = ”
ENDIF

SELECT slsx1
SET ORDER TO 1
SEEK xsales
IF FOUND()
xsuperv = supervisor
ELSE
xsuperv = ”
ENDIF

SELECT inv1
SEEK pnx
IF FOUND()
desxpn = desc
ELSE
desxpn = ‘Not Found’
endif

* CARI AREA
SELECT terr1
SEEK xtrs
IF !EOF()
XAREA = DESC
ELSE
XAREA = “ZCUSSER”
ENDIF

* CARI KECAMATAN
SELECT KODEPOS
SEEK xzip
IF !EOF()
xkec = kecamatan
ELSE
xkec = ‘Z.CLUSTER’
ENDIF

* CARI GROUP ID
NAMAX = ‘Z.OTHER’
namaxs = ‘Z.OTHER’
SELECT GROUPS
SET ORDER TO 2 && Custid
GO top
SEEK ids
IF !EOF()
IDGRP = GROUP
nwclas1 = nwclass
SELECT customer1
GO TOP
SEEK ids
IF !EOF()
NAMAX = NAME
namaxs = ALLTRIM(sname)+” # “+ALLTRIM(saddress1)
ELSE
NAMAX = ‘Z.OTHER’
namaxs = ‘Z.OTHER’
ENDIF
ELSE
IDGRP = ‘Z.OTHER’
nwclas1 = ‘XL’
SELECT CUSTOMER1
GO TOP
SEEK ids
IF !EOF()
NAMAX = NAME
namaxs = ALLTRIM(sname)+” # “+ALLTRIM(saddress1)
ELSE
NAMAX = ‘Z.OTHER’
namaxs = ‘Z.OTHER’
ENDIF
ENDIF

* CARI GROUP PN — tidak dipakai lagi
SELECT PRODS
GO top
SEEK pnx
IF !EOF()
IDPN = GROUP
IDCOM = COMODITY
SIPN = SI_PROD
ELSE
IDPN = ’99.OTHER’
IDCOM = ‘9.Other’
SIPN = ‘ZSI.Other’
ENDIF

SELECT centlevl
APPEND BLANK

REPLACE WILAYAH WITH “JKT”
REPLACE GROUPID WITH idgrp
REPLACE GROUPPN WITH idpn
REPLACE SIPART WITH sipn
** REPLACE COMDITY WITH idcom NEW
REPLACE comdity WITH caricomodity(xcomdty)
**
REPLACE TAHUN WITH YEAR(dt1)
REPLACE BULAN WITH MONTH(dt1)
REPLACE CBULAN WITH CBUL(BULAN)
REPLACE MINGGU WITH WEEK(dt1)
REPLACE ITEM WITH XITEM
REPLACE PN WITH pnx
REPLACE DESC WITH desxpn &&desx
REPLACE OENO WITH oex
REPLACE CUSTID WITH ids
REPLACE NAMA WITH namax
REPLACE stx WITH “A1”
REPLACE orddate WITH codet1.duedate
REPLACE ponum WITH oex
REPLACE custid WITH ids
REPLACE qtyord WITH xqtyord
REPLACE qtyshp WITH xqtyshp
REPLACE qtyinv WITH xqtyinv
REPLACE qtybor WITH xqtybor
REPLACE custpo WITH xpocst
REPLACE snama WITH namaXS
REPLACE salesman WITH xsales
REPLACE entrydate WITH xentrydate
REPLACE reqdate WITH xreqdate
REPLACE kecamatan WITH xkec
REPLACE qtysales WITH xxqtyshp
REPLACE usell WITH usl
REPLACE shipdate WITH xshipdate
REPLACE custclass WITH xklas
REPLACE namasls WITH xnamasl
REPLACE nilaiord WITH (xqtyord*usell)
REPLACE nilaishp WITH (xqtyshp*usell)
REPLACE nilaisale WITH (xxqtyshp*usell)
REPLACE acctno WITH xacctno
REPLACE supervisor WITH xsuperv

endif
SELECT codet1
skip
ENDDO
** prepare ceking data arus balik dari shiphist ke codet ****

thisform.Caption = “Cek Balik Shiphist ….!”
SELECT shiphist1
SET ORDER TO 1
GO top
DO WHILE !EOF()
IF (shiphist1.shipdate >= d1 AND shiphist1.shipdate <= d2)
cidx = shiphist1.custid
cone = shiphist1.oeno
citm = shiphist1.item
cpnx = shiphist1.pn
SELECT centlevl
GO top
SEEK cidx+cone+citm+cpnx
IF FOUND()
REPLACE cek WITH “OK”
ELSE
xsales = shiphist1.salesman
ids = custid

* CARI GROUP ID
NAMAX = ‘Z.OTHER’
namaxs = ‘Z.OTHER’
SELECT GROUPS
SET ORDER TO 2 && Custid
GO top
SEEK ids
IF !EOF()
IDGRP = GROUP
nwclas1 = nwclass
SELECT customer1
GO TOP
SEEK ids
IF !EOF()
NAMAX = NAME
namaxs = ALLTRIM(sname)+” # “+ALLTRIM(saddress1)
ELSE
NAMAX = ‘Z.OTHER’
namaxs = ‘Z.OTHER’
ENDIF
ELSE
IDGRP = ‘Z.OTHER’
nwclas1 = ‘XL’
SELECT CUSTOMER1
GO TOP
SEEK ids
IF !EOF()
NAMAX = NAME
namaxs = ALLTRIM(sname)+” # “+ALLTRIM(saddress1)
ELSE
NAMAX = ‘Z.OTHER’
namaxs = ‘Z.OTHER’
ENDIF
ENDIF

SELECT sales1
SEEK xsales
IF FOUND()
xnamasl = name
ELSE
xnamasl = ”
ENDIF

SELECT centlevl
APPEND BLANK
REPLACE custid WITH cidx
REPLACE oeno WITH cone
REPLACE item WITH citm
REPLACE pn WITH cpnx
REPLACE cek WITH “NEW”
REPLACE nilaishp WITH (shiphist1.qtyshp*shiphist1.usell)

REPLACE TAHUN WITH YEAR(shiphist1.shipdate)
REPLACE BULAN WITH MONTH(shiphist1.shipdate)
REPLACE CBULAN WITH CBUL(BULAN)
REPLACE MINGGU WITH WEEK(shiphist1.shipdate)

REPLACE DESC WITH shiphist1.desc
REPLACE stx WITH “A1”
REPLACE qtyshp WITH shiphist1.qtyshp
REPLACE qtyinv WITH shiphist1.qtyshp
REPLACE custpo WITH shiphist1.ponum
REPLACE namasls WITH xnamasl
REPLACE NAMA WITH namax
REPLACE snama WITH namaXS

ENDIF
ENDIF
SELECT shiphist1
skip
ENDDO

thisform.Caption = “End Of Proses !”
CLOSE DATABASES

time2 = SECONDS()
this.Parent.parent.titlez.caption = “Proses Result in :”+STR(time2-time1)+” second.”

ENDPROC
ENDDEFINE

FUNCTION caricomodity
* 1. Softex
* 2. Pantyliners
* 3. Softove
* 4. Sweety
* 5. Fit Pants
* 6. Toiletris
* 7. Softies
* 8. Export
* 9. Lain-Lain
PARAMETERS xcmdty
PUBLIC xcom
_mprd = ALLTRIM(xcmdty)
do case
case (_mprd=’FBRL’ .or. _mprd = ‘FBRL.0’) && Softlove
xcom = ‘3. Softlove’
case _mprd=’FBUK’ && Softlove
xcom = ‘3. Softlove’
case _mprd=’FSDL’ .or. _mprd = ‘FSDL.0’ .or. _mprd = ‘FSDL.1’
xcom = ‘1. Softex’
case _mprd=’FSFS’
xcom = ‘1. Softex’
case _mprd=’FSHD’
xcom = ‘1. Softex’
case _mprd=’FSDX’
xcom = ‘1. Softex’
case _mprd=’FSPB’
xcom = ‘1. Softex’
case _mprd=’FSPL’ && .or. _mprd = ‘FSMT’
xcom = ‘2. Pantyliners’
case _mprd=’FSSN’
xcom = ‘1. Softex’
case _mprd=’FSUD’ .or. _mprd = ‘FSMT’ &&Maternity
xcom = ‘1. Softex’
case _mprd=’FSUP’
xcom = ‘1. Softex’
case _mprd=’FSVC’ && Softex V Class
xcom = ‘1. Softex’
case _mprd=’FTFC’
xcom = ‘7. Softies’
case _mprd=’FTHK’
xcom = ‘7. Softies’
case _mprd=’FTNP’
xcom = ‘7. Softies’
case _mprd=’FTTR’
xcom = ‘7. Softies’
case _mprd==’FBWS’ && (_mpn=”FBSSL.100″ or _mpn=”FBSSL.200″ or _mpn=”FBSSM.100″ or _mpn=”FBSSM.200″ or _mpn=”FBSSX.080″ or _mpn=”FBSSX.160″)
xcom = ‘4. Sweety’
case _mprd==’FBWSFP’
xcom = ‘5. Sweety Fit Pants’
case _mprd==’FBWSTL’
xcom = ‘6. Sweety Toletris’
CASE _mprd==’FBWSWP’ .or. _mprd = ‘FBWB’
xcom = ’61. Sweety Wipes’
case _mprd=’FBXE’ .or. _mprd=’FSXE’
xcom = ‘8. Export’
case _mprd=’XAEX’ .or. _mprd=’XTXE’
xcom = ‘8. Export’
OTHERWISE
xcom = ‘9. Lain-Lain’
endcase
RETURN (xcom)

This entry was posted in Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s