ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

SCAN opcode -- scan for blank

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SCAN opcode -- scan for blank

    hi all,

    i have a flat file. i have to store the data of this file in a structured PF.
    the problem is that the delimiter for the fields in the flat file is one space-- ' '
    now when i do a Scan to store the position of all the blanks, it doesnt work. the first blank position it gives me is wrong and the rest are all consecutive.

    my flat file looks like this:
    Report width . . . . . : 1000

    ....+.... 1....+.... 2....+.... 3....+.... 4....+.... 5....+.... 6....+.... 7..

    8000102346.00 282820437807.00 500 0 0 0 778.28 0 0 99 IL
    8000102353.00 282820416381.00 500 0 0 0 1240 0 0 0 IL
    8000102361.00 343460155491.00 500 0 369.95 0 2617.33 6.85 0 0 NE

    my rpg code is:
    dDelimiter s 1 Inz(' ')
    c Delimiter Scan DATA Position

    the array populated is:
    POSITION(1) = 063.
    POSITION(2) = 064.
    POSITION(3) = 065.
    POSITION(4) = 066.
    POSITION(5) = 067.
    POSITION(6) = 068.
    POSITION(7) = 069.
    POSITION(8) = 070.
    POSITION(9) = 071.
    POSITION(10) = 072.
    POSITION(11) = 073.
    POSITION(12) = 074.
    POSITION(13) = 075.

    please help!
    TIA
    ruma
    Regards,
    Ruma

  • #2
    Re: SCAN opcode -- scan for blank

    Im guessing that the "spaces" are not spaced but nondisplayed HEX codes.

    DBU the file then hit F9 i think for hex and see whats really in that field.

    you could also try the %xlate opcode and xlate the ' ' to ',' just to prove they are not blanks.

    jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: SCAN opcode -- scan for blank

      The following code should work;

      Delimeter Inz(' ')

      Read Flat file

      Dow (till end of flat file)

      Eval totrec = %Trim(totrec) ;
      Eval Len = %Len(%Trim(totrec)) ;
      Eval Blanpos = 0;

      Ev index=1
      For i=1; i<=Len;
      Eval Blankpos = %Scan(Delimiter:totrec:Blankpos+1);
      Eval formatedfieldname(index) = %Subst(totrec:i: (Blankpos-i));
      index = index + 1;
      i = BlankPos ;
      EndFor;

      Read Flat file

      EndDo;
      Thanks,
      Giri

      Comment


      • #4
        Re: SCAN opcode -- scan for blank

        Thanks Giri, thanks Jamie.

        as you said jamie, i figured out that the spaces are actually hex. i down load a text file to 400 and then do the processing. lemme check again by downloading it some other way and i shall get back with queries
        Regards,
        Ruma

        Comment

        Working...
        X