Focal Point
Web Focus File Definition with OCCURS

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/4797020326

August 09, 2012, 10:55 AM
AnnaR
Web Focus File Definition with OCCURS
Hi All, I am trying to define a synonym for the following csv file:

HDR,10000000,111225,00401,000,6600,H,20111218,20111224,,001,
DTL,1,EN,123456789,US,
SDQ,001,8,003,1,004,2,008,1,010,1,017,1,023,1,024,3,026,2,028,1,,,
SDQ,030,2,032,2,036,2,041,2,043,2,046,1,057,2,072,2,207,1,212,2,,,
SDQ,253,2,254,1,667,2,675,1,679,2,,,,,,,,,,,,,
HDR,10000000,111225,00401,000,6600,H,20111218,20111224,,002,
DTL,1,EN,123456700,UA,
SDQ,202,1,207,1,,,,,,,,,,,,,,,,,,,

I created synonym uisng the following structure:
FILENAME=test, SUFFIX=DFIX ,
DATASET=C:\CLIENTS\TEST\TEST1.CSV, $
SEGMENT=ONE, SEGTYPE=S0, $
FIELDNAME=RECTYPE, ALIAS=HDR, USAGE=A3, ACTUAL=A3, $
FIELDNAME=TPID, ALIAS=TPID, USAGE=A14, ACTUAL=A14, $
FIELDNAME=IDNUM, ALIAS=IDNUM, USAGE=P9, ACTUAL=A9, $
FIELDNAME=VICID, ALIAS=VICID, USAGE=A15, ACTUAL=A15, $
FIELDNAME=TRTYPE, ALIAS=TRTYPE, USAGE=A3, ACTUAL=A3, $
FIELDNAME=DK1, ALIAS=DK1, USAGE=A4, ACTUAL=A4, $
FIELDNAME=DK2, ALIAS=DK2, USAGE=A6, ACTUAL=A6, $
FIELDNAME=START_DATE, ALIAS=START_DATE, USAGE=I8YYMD, ACTUAL=A8, $
FIELDNAME=END_DATE, ALIAS=WEEK_ENDING_DATE, USAGE=I8YYMD, ACTUAL=A8, $
FIELDNAME=DK3, ALIAS=DK3, USAGE=A4, ACTUAL=A4, $
FIELDNAME=DK4, ALIAS=DK4, USAGE=A3, ACTUAL=A3, $
FIELDNAME=DK5, ALIAS=DK5, USAGE=A3, ACTUAL=A3, $
SEGMENT=TWO, SEGTYPE=S1, PARENT=ONE, $
FIELDNAME=RECTYPE, ALIAS=DTL, USAGE=A3, ACTUAL=A3, $
FIELDNAME=LINE_ID, ALIAS=LINE_ID, USAGE=I4, ACTUAL=A15, $
FIELDNAME=IDK1, ALIAS=IDK1, USAGE=A2, ACTUAL=A10, $
FIELDNAME=CCODE, ALIAS=CCODE, USAGE=P14, ACTUAL=A15, $
FIELDNAME=TRANS_ID, ALIAS=TRANS_ID, USAGE=A15, ACTUAL=A15, $
FIELDNAME=IDK2, ALIAS=IDK2, USAGE=A10, ACTUAL=A10, $
SEGMENT=THREE, SEGTYPE=S1, PARENT=TWO, $
FIELDNAME=RECTYPE, ALIAS=SDQ, USAGE=A3, ACTUAL=A3, $
FIELDNAME=STORE_DATA, ALIAS=STORE_DATA, USAGE=A100, $
SEGMENT=FOUR, SEGTYPE=S1, PARENT=THREE, OCCURS=11, POSITION=STORE_DATA, $
FIELDNAME=ST_NUMBER, ALIAS=ST_NUMBER, USAGE=I4, ACTUAL=A4, $
FIELDNAME=QUANTITY, ALIAS=QUANTITY, USAGE=I4, ACTUAL=A4, $

The structure reads data correctly until SDQ segment is reached, then reads correctly the first column (ST_number) but does not recognize the next column (Quantity) within the segment. Moreover, next locations (ST_number) within the same SDQ segment are not recognized by this structure. Any ideas are appreciated.

Thanks!


WebFOCUS 7.7, iWay Data Migrator, Windows
Excel, PDF, HTML, XML
August 09, 2012, 05:38 PM
Waz
I didn't think you could use OCCURS with CSV.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.06OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

August 13, 2012, 12:35 PM
Dan Satchell
Though you defined your STORE_DATA field with length 100, it "sees" only the first value in the string because it stops at the first field delimiter (i.e., comma). The following variation does work for reading all of the SDQ values. And it works if you PRINT SEG.TPID or PRINT SEG.LINE_ID or PRINT SEG.ST_NUMBER. But if you try to print fields from more than one segment at a time, the first HDR values and first DTL values are assigned to all records. So something is still not working correctly. Perhaps as Waz says, this type of synonym cannot be used with flat files. (FYI: you seem to have one too many commas at the end of your SDQ data lines.)

FILENAME=TESTDATA, SUFFIX=DFIX ,$
 DATASET=C:\CLIENTS\TEST\TEST1.CSV, $
 SEGMENT=HDRDATA, SEGTYPE=S0, $
  FIELDNAME=RECTYPE   , ALIAS=HDR             , USAGE=A3    , ACTUAL=A3 , $
  FIELDNAME=TPID      , ALIAS=TPID            , USAGE=A14   , ACTUAL=A14, $
  FIELDNAME=IDNUM     , ALIAS=IDNUM           , USAGE=P9    , ACTUAL=A9 , $
  FIELDNAME=VICID     , ALIAS=VICID           , USAGE=A15   , ACTUAL=A15, $
  FIELDNAME=TRTYPE    , ALIAS=TRTYPE          , USAGE=A3    , ACTUAL=A3 , $
  FIELDNAME=DK1       , ALIAS=DK1             , USAGE=A4    , ACTUAL=A4 , $
  FIELDNAME=DK2       , ALIAS=DK2             , USAGE=A6    , ACTUAL=A6 , $
  FIELDNAME=START_DATE, ALIAS=START_DATE      , USAGE=I8YYMD, ACTUAL=A8 , $
  FIELDNAME=END_DATE  , ALIAS=WEEK_ENDING_DATE, USAGE=I8YYMD, ACTUAL=A8 , $
  FIELDNAME=DK3       , ALIAS=DK3             , USAGE=A4    , ACTUAL=A4 , $
  FIELDNAME=DK4       , ALIAS=DK4             , USAGE=A3    , ACTUAL=A3 , $
  FIELDNAME=DK5       , ALIAS=DK5             , USAGE=A3    , ACTUAL=A3 , $
  FIELDNAME=DELIMITER, ALIAS=','              ,USAGE=A1     , ACTUAL=A1 , $
 SEGMENT=DTLDATA, SEGTYPE=S0, PARENT=HDRDATA, $
  FIELDNAME=RECTYPE  , ALIAS=DTL     , USAGE=A3 , ACTUAL=A3 , $
  FIELDNAME=LINE_ID  , ALIAS=LINE_ID , USAGE=I4 , ACTUAL=A15, $
  FIELDNAME=IDK1     , ALIAS=IDK1    , USAGE=A2 , ACTUAL=A10, $
  FIELDNAME=CCODE    , ALIAS=CCODE   , USAGE=P14, ACTUAL=A15, $
  FIELDNAME=TRANS_ID , ALIAS=TRANS_ID, USAGE=A15, ACTUAL=A15, $
  FIELDNAME=IDK2     , ALIAS=IDK2    , USAGE=A10, ACTUAL=A10, $
  FIELDNAME=DELIMITER, ALIAS=','     , USAGE=A1 , ACTUAL=A1 , $
 SEGMENT=SDQFIELDS, SEGTYPE=S0, PARENT=DTLDATA, $
  FIELDNAME=RECTYPE  , ALIAS=SDQ  , USAGE=A3, ACTUAL=A3, $
  FIELDNAME=SDQ01    , ALIAS=SDQ01, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ02    , ALIAS=SDQ02, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ03    , ALIAS=SDQ03, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ04    , ALIAS=SDQ04, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ05    , ALIAS=SDQ05, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ06    , ALIAS=SDQ06, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ07    , ALIAS=SDQ07, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ08    , ALIAS=SDQ08, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ09    , ALIAS=SDQ09, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ10    , ALIAS=SDQ10, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ11    , ALIAS=SDQ11, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ12    , ALIAS=SDQ12, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ13    , ALIAS=SDQ13, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ14    , ALIAS=SDQ14, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ15    , ALIAS=SDQ15, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ16    , ALIAS=SDQ16, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ17    , ALIAS=SDQ17, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ18    , ALIAS=SDQ18, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ19    , ALIAS=SDQ19, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ20    , ALIAS=SDQ20, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ21    , ALIAS=SDQ22, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=SDQ22    , ALIAS=SDQ22, USAGE=A4, ACTUAL=A4, $
  FIELDNAME=DELIMITER, ALIAS=','  , USAGE=A1, ACTUAL=A1 ,$
 SEGMENT=SDQDATA, SEGTYPE=S0, PARENT=SDQFIELDS, OCCURS=11, POSITION=SDQ01, $
  FIELDNAME=ST_NUMBER, ALIAS=ST_NUMBER, USAGE=I4, ACTUAL=A4, $
  FIELDNAME=QUANTITY , ALIAS=QUANTITY , USAGE=I4, ACTUAL=A4, $



WebFOCUS 7.7.05
August 14, 2012, 09:17 AM
George Patton
Occurs can certainly be used with flat files, but maybe not with .CSV files - I haven't tried it. But I use it all the time with fixed-column files:
FILENAME=inv2comp2, SUFFIX=FIX     , $
  SEGMENT=MAIN, SEGTYPE=S1, $
    FIELDNAME=ITEM_ID, ALIAS=E01, USAGE=A25, ACTUAL=A25,
      MISSING=ON, $
    FIELDNAME=CONVERSION, ALIAS=E02, USAGE=I9, ACTUAL=A09,
      MISSING=ON, $
    FIELDNAME=MAXNUM, ALIAS=E03, USAGE=I2, ACTUAL=A02, $
  SEGMENT=BINREC, SEGTYPE=S1, PARENT=MAIN, OCCURS=MAXNUM, $
    FIELDNAME=BINNUM, ALIAS=E04, USAGE=I2, ACTUAL=A02,
      MISSING=ON, $
    FIELDNAME=SPACE1, ALIAS=SPACE1, USAGE=A2, ACTUAL=A2, $
    FIELDNAME=BINLOC, ALIAS=BINLOC, USAGE=A6, ACTUAL=A6, $
    FIELDNAME=SPACE2, ALIAS=SPACE2, USAGE=A42, ACTUAL=A42, $
    FIELDNAME=PHYSQTY, ALIAS=PHYSQTY, USAGE=I10, ACTUAL=A10, $
    FIELDNAME=SPACE3, ALIAS=SPACE3, USAGE=A10, ACTUAL=A10, $
    FIELDNAME=PHYSPO, ALIAS=PHYSPO, USAGE=A8, ACTUAL=A8, $
    FIELDNAME=SPACE4, ALIAS=SPACE4, USAGE=A8, ACTUAL=A8, $


As you can see, I'm using MAXNUM in the parent to count the number of OCCURS instances.

I see that Dan has the child segment identified as an S0, while I (and Anna) have it as an S1. Dan - if there are multiple children how do you identify them with S0 ?

This message has been edited. Last edited by: George Patton,


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
August 14, 2012, 09:30 AM
AnnaR
Thank you all for suggestions and comments. Based on your responses, I gather that OCCURS cannot be used with csv in variable format. I used option to define each of the columns individually. It takes a bit more processing as I need to transpose the data later on, so Location is one column and not 11.


WebFOCUS 7.7, iWay Data Migrator, Windows
Excel, PDF, HTML, XML