Example using a Warehouse Master

Customer Service reps know the Distribution center in Kansas City as "Kansas City" and may not remember that it is owned by "Weber Shipping". We want to put together a subfile where they can look up the Kansas City warehouse by either City or Vendor Name. Using a multi-format logical over the warehouse master, we can easily do this in the data presentation to the program, and the program is a simple Subfile display program. Without using this trick, the programming for this functionality is immense.

 

The effect of building this kind of logical is that each record in the physical file will appear in the logical twice, once as it was entered, and once redefined with mapped fields. In fact, the DBU file utility shows us the relative record number of these records.

/--------------------------------------------------------------------\

File Format Mode Window Search Extra Help

DATA BASE UTILITY (DBU)

File . . . : MFPWH Member . . : MFPWH Record Length . : 377

Library . : JVORIS Format . . : MFRWH File Access . . : Arrival

Mode . . . : Display Record Number . : 1

Control . . .

1 2

Record# Address 1 City

1 WEBER SHIPPING KANSAS CITY

2 RHONE POULENC TURNSVILLE

3 SANFORD & SON MINNEAPOLIS

4 SANFORD & SON REFRIGERATED STORAGE MINNEAPOLIS

5 ACME WAREHOUSING BOCA RATON

\--------------------------------------------------------------------/

Using the Database to sort by the alpha field in Address Line 1 and City Name.

Note that each physical record can appear in the logical twice

/--------------------------------------------------------------------\

File Format Mode Window Search Extra Help

DATA BASE UTILITY (DBU)

File . . . : MFLWH Member . . : MFLWH Record Length . : 81

Library . : JVORIS Format . . : BYCITY File Access . . : Keyed

Mode . . . : Display Record Number . : 5

Control . . .

Record# ....5...10...15...20...25...30...35...40...45...50...55...60...65

5 ACME WAREHOUSING BOCA RATON

5 BOCA RATON ACME WAREHOUSING

1 KANSAS CITY WEBER SHIPPING

3 MINNEAPOLIS SANFORD & SON

4 MINNEAPOLIS SANFORD & SON REFRIGERATED STO

2 RHONE POULENC TURNSVILLE

3 SANFORD & SON MINNEAPOLIS

4 SANFORD & SON REFRIGERATED STORAGE MINNEAPOLIS

2 TURNSVILLE RHONE POULENC

1 WEBER SHIPPING KANSAS CITY

Bottom

F1=Help F2=Nondisplay keys F3=Exit F4=List fields

F5=Refresh F6=Set key F10=Action F24=More keys

\-------------------------------------------------------------------/

 

 

The source for the Physical File

A* Warehouse Master

A*

A* An example of multi-format file built over a single physical

A*

A R MFRWH

A WHID 10 COLHDG('Warehouse' 'ID')

A WHADR1 50 COLHDG('Address 1')

A WHADR2 50 COLHDG('Address 2')

A WHADR3 50 COLHDG('Address 3')

A WHADR4 50 COLHDG('Address 4')

A WHCITY 30 COLHDG('City')

A WHST 2 COLHDG('State')

A WHZIP 10 COLHDG('Zip' 'Canadian’)

A WHCNTR 4 COLHDG('Country')

A WHDUM 1 COLHDG('Dummy' 'Location')

A WHLOAD 120 COLHDG('Loading' ‘Direct’)

A

A WHID

The source for the Logical File

 

A* Warehouse Master -- By Name and City

A*

A* An example of multi-format file built over a single physical

A* used in a search screen

A*

A R BYLINE1 PFILE(MFPWH)

A WHADR1 R 35

A* Shorten Address Line 1 from 50A to 35A

A*

A WHCITY R

A WHST R

A WHCNTR R

A WHID R

A K WHADR1

A*************************************

A R BYCITY PFILE(MFPWH)

A WHADR1 R 35 RENAME(WHCITY)

A COLHDG('Adr1')

A* Change field length of City 30A to Adr1, now shortened to 35A

A*

A WHCITY R 30 RENAME(WHADR1)

A COLHDG('City')

A* Change field length of Adr1 50A to City 30A

A*

A WHST R

A WHCNTR R

A WHID R

A K WHADR1

 

 

RPG Source for a Display of Warehouse

 

* MFGWH *RPG

* An Example of using a multiformat logical

* over a single physical

H

FMFDWH CF E WORKSTN

F SFILE(SFL:SRRN)

FMFLWH IF E K DISK

F*

C *ENTRY PLIST

C PARM WHID

C*

C *IN41 DOUEQ *ON

C*

C* Don't READ by RECORD FORMAT, just read the file

C* Don't worry about which format is next in the keyed file

C*

C READ MFLWH 41

C *IN41 IFNE *ON

C ADD 1 SRRN 3 0

C WRITE SFL

C ELSE

C* Time to display SFL

C WRITE SFLCTL

C WRITE BOTTOM

C ENDIF

C ENDDO

C*

C* Read the user's selection

C READ SFLCTL 44

C 1 CHAIN SFL 44

C READC SFL 45

C *IN03 IFEQ *ON

C *IN41 OREQ *ON

C EXSR ENDPGM

C ENDIF

C*

C etc. etc. etc. etc. etc. etc. etc. etc. etc. etc. etc. etc.

If you should want to know the format name, insert an information D.S. to determine which format is being read. This may be useful for the Unit-of-Measure example previously discussed.

 

FMFLWH IF E WORKSTN INFDS(INF)

D INF DS

D STDFIL *FILE

D STDFMT *RECORD

 

 

 

Example using a Warehouse Master

Note that records appear in the logical twice