sponsored links

Collapse

Announcement

Collapse
No announcement yet.

How to write subfile and search record without physical file key?

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

  • How to write subfile and search record without physical file key?

    Hi seniors,

    I have a physical file without key and have to display in subfile in one category only.
    I cannot use key to chain the physical file and look for record. How can I do that?
    Firstly, user key in input 'A' then only records of category 'A' will be displayed.
    The physical file is like

    category Id Name
    a 12 yyyyyy
    a 13 wwwwww
    b 12 dddddddd
    a 10 kkkkkk
    c 10 ppppp
    b 15 mmmmmmmmm

    Subfile should be like this if 'c' is keyed in
    opt id name
    10 ppppp

    Thanks in advance for advices.
    p/s: I'm new to RPGLE

  • #2
    Re: How to write subfile and search record without physical file key?

    The first thing I would look at is if there is a suitable logical file over the physical (DSPDBR command)? If so use this and if not, why not? Can you create a logical?
    If not then you can read the file sequentially in full while filling subfile on your condition (or possibly look to using embedded SQL?).
    the smoking gnu

    Comment


    • #3
      Re: How to write subfile and search record without physical file key?

      Originally posted by chrisr View Post
      The first thing I would look at is if there is a suitable logical file over the physical (DSPDBR command)? If so use this and if not, why not? Can you create a logical?
      If not then you can read the file sequentially in full while filling subfile on your condition (or possibly look to using embedded SQL?).
      Well, I wonder can the logical file be like:
      R LOGICF PFILE(PHYSICALF)
      CATEGORY
      CODE
      NAME
      K CATEGORY
      S CATEGORY CMP(EQ 'INPUT')

      INPUT here as user input for category
      If can, how could logical file get the value for INPUT?
      EVAL INPUT=InputFldName
      INPUT SETLL LOGICALFNAME
      INPUT READE LOGICALFNAME

      Am I right?

      Comment


      • #4
        Re: How to write subfile and search record without physical file key?

        Originally posted by chrisr View Post
        The first thing I would look at is if there is a suitable logical file over the physical (DSPDBR command)? If so use this and if not, why not? Can you create a logical?
        If not then you can read the file sequentially in full while filling subfile on your condition (or possibly look to using embedded SQL?).
        Well, so the logical file can be coded as below:
        R RLogical PFILE(PHYSICALF)
        CATEGORY
        CODE
        NAME
        K CATEGORY
        S CATEGORY CMP(EQ 'INPUT')

        'INPUT' refers to the choice user type into the input field

        Comment


        • #5
          Re: How to write subfile and search record without physical file key?

          At last, I can create physical file with keys.
          That solved my problem.
          Anyway, I learn a lot here.

          Happy New Year guys

          Comment


          • #6
            Re: How to write subfile and search record without physical file key?

            Originally posted by PeonyWonderWhy View Post
            K CATEGORY
            S CATEGORY CMP(EQ 'INPUT')

            'INPUT' refers to the choice user type into the input field
            For that part of the question, no, you can't create a logical like that.

            You could, however, use embedded SQL simply to select and fetch just the rows that match the user's input. The result would effectively be the same as your proposed LF.
            Tom

            There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

            Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

            Comment

            Working...
            X