ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

edit subfile

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

  • edit subfile

    How can I edit or delete data from selected row of subfile.
    I created special field, displayed in the first column of subfile where can I type eg. A - for change data or D- for delete .

  • #2
    The delete or change of a subfile can be or not tricky. Depends on your aproach to the problem.

    The delete or update u may use the array aproach...
    When you have a subfile change (have input like A or D) u read the info on that line , change it and update the subfile.

    Code:
    ----
    (read next change)
    readc     subfile 
    ----
    update   subfile

    hope you catch the ideia

    hope it helped somehow..
    "It's like a koala pooped a rainbow on my head and I can taste the colors."

    Comment


    • #3
      Thanks
      But, I don't know how to check in RPG code in which line and what kind of action (to ammend or delete ) was selected by my on screen. I think, I have to check coursor positon or subfile record number. I'ld be greatefull is you could send me a sample rpg code and subfile dds for following case.

      screen design :

      action cust. no cust name
      _ 1 customer1
      _ 2 customer2


      Available actions : A- ammend D- delete
      I type eg. A and press Enter to ammend the record.

      Comment


      • #4
        How to check subfile entries

        First welcome Krism.....

        Please go here and download the text files.

        Look at both the dds and the rpg.



        the file defined in the RPG

        Code:
        FSRBCTLSS  IF   E           K DISK
        must be changed to your file.
        also load up your file/fields and replace mine. This is done is the
        subroutine $LOADSFL. and in the $CLRSFL replace file name.

        and KAPOW you have a working subfile.

        [code]

        C*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
        C* $LoadSFL - Load the Main Menu.
        C*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
        CSR $LoadSFL Begsr
        C*
        C If SavRrn > *Zeros
        C Z-add SavRrn RRN1
        C Z-add SavRrn SCRRN
        C Endif
        C*
        C Dou %Eof(SRBCTLSS)
        C*
        C Read SRBCTLSS 89
        C*
        C If Not*In89
        C*
        C Movel(p) CTSROM S1WHS
        C Movel(p) CTSDES S1WNAME
        C*
        C Add 1. RRN1
        C Add 1. SCRRN
        C*
        C*
        C Write SUB01
        C*
        C Endif
        C Enddo
        C*
        C Z-add SCRRN SavRrn
        C*
        C* If no records in subfile then do not disply the subfile.
        C*
        C If SavRrn = *Zeros And *In89
        C Eval *In50 = *Off
        C Else
        C Z-add 1. SCRRN
        C Z-add 1. RRN1
        C Endif
        C
        C*
        C Endsr


        [code]



        now if you want to make this work for your case you would either
        use readc in RPG plus the SFLNEXTCHG keywork in your dds as idscypher said earlier.

        how this works is once you hit enter all records in the subfile that the user put their cursor on. (changed) will be read in order by the readc command. So you would need a loop.

        like .........

        readc(subfile)
        dow %found
        select
        when selection = 'E'
        exsr $Edit
        when selection = 'D'
        exsr $delete
        endsl
        readc(subfile)
        enddo



        Finally here is the code I think you really want just download and modify





        I wish you luck there is alot to subfiles.
        take care
        jimmy

        Comment

        Working...
        X