ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Deleting single record from subfile,how???

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

  • Deleting single record from subfile,how???

    Hai,
    I wanna know how to delete a single record from a subfile,like in my program when i enter the customer id the customer details and the list of cars owned by the customer is displayed.Now if i use the delete function key the entire record is deleted.how to delete a single car detail without the other records gettin affected.this my rpg.

    Thanx,

    Andrew..

  • #2
    Re: Deleting single record from subfile,how???

    well..... the answer is you cant. You could chain to the record clear it and update the record to say "deleted" in a text field.....

    or what i do is just delete the record and re-load the subfile.

    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: Deleting single record from subfile,how???

      Ok i also tried but i cud only delete the last record , this is how to user screen looks

      16:07:31 CUSTOMER AND VEHICLE DETAILS 220308

      CUST ID: 656565 CHASSIS:

      CUSTOMER DETAILS

      CUSTNAME: ALOO D ADDR: 56A STREET TELNO: 678666

      CAR DETAILS FOR THE CUSTOMER
      CHASSIS MODEL YEAR
      8876548862 FERRARI X 2007
      8798797677 DODGE 1998
      8478547899 CHRYSLER 2009
      3657389785 PONTIAC 1998
      7647843687 MUSTANG 2005
      6148736487 JAGUAR 2003
      3784628734 TATA 2002
      3786823468 MAZDA 2004


      Bottom

      F3=EXIT F5=DLT ALL F6=ADD F7=UPDATE F10=PRINT F11=ADD CAR F4=DLT

      Im askin how to delete one of these car details , the f5 function key delets the whole record, if i search thru
      the chassis num by using one of these chassis num , i can delete dat paricular car detail which i have used.But wat the user wants is to delete here itself.

      Comment


      • #4
        Re: Deleting single record from subfile,how???

        Hai jamie,
        Ok i also tried but i cud only delete the last record , this is how to user screen looks

        16:07:31 CUSTOMER AND VEHICLE DETAILS 220308

        CUST ID: 656565 CHASSIS:

        CUSTOMER DETAILS

        CUSTNAME: ALOO D ADDR: 56A STREET TELNO: 678666

        CAR DETAILS FOR THE CUSTOMER
        CHASSIS MODEL YEAR
        8876548862 FERRARI X 2007
        8798797677 DODGE 1998
        8478547899 CHRYSLER 2009
        3657389785 PONTIAC 1998
        7647843687 MUSTANG 2005
        6148736487 JAGUAR 2003
        3784628734 TATA 2002
        3786823468 MAZDA 2004


        Bottom

        F3=EXIT F5=DLT ALL F6=ADD F7=UPDATE F10=PRINT F11=ADD CAR F4=DLT

        Im askin how to delete one of these car details , the f5 function key delets the whole record, if i search thru
        the chassis num by using one of these chassis num , i can delete dat paricular car detail which i have used.But wat the user wants is to delete here itself.

        Comment


        • #5
          Re: Deleting single record from subfile,how???


          you have to have the user identify the correct record. by either using this:

          dds
          Code:
          A                                      SFLCSRRRN(&WHERE)
          RPG
          Code:
               C*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-==-
               C* $Process - Process the subfile.
               C*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-==-
               C     $Process      Begsr
               C*
               C                   If        Where > *Zeros
               C*
               C     Where         Chain     SUB01
               C                   If        %Found
               C* this is where your delete would go
               C                   Movel(p)  S1WHS         OutWHS
               C                   Eval      @Scrn1 = *Blanks
               C*
               C                   Endif
               C*
               C                   Endif
               C*
               C                   Endsr
          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


          • #6
            Re: Deleting single record from subfile,how???

            Hai jamie,

            I used the SELECT operation and did here is the code.

            Code:
            C           DLTC      BEGSR                            
            C                     READCCVSUB                    74 
            C                     SELEC                            
            C           SCHAS     WHNE *ZEROS                      
            C           SMOD      ANDEQ*BLANKS                     
            C           SYEAR     ANDEQ*ZEROS                      
            C                     MOVE SCHAS     CHASIS            
            C           CHASIS    CHAINVDET                 74     
            C           *IN74     IFEQ *OFF                        
            C                     DELETVREC                        
            C                     ENDIF                            
            C                     MOVE *BLANKS   SCHAS             
            C                     MOVE *BLANKS   SMOD              
            C                     MOVE *BLANKS   SYEAR             
            C                     MOVELTMSG,4    MCG               
            C                     ENDSL                            
            C                     ENDSR
            This is working and iam able to delete a particular car detail , but the criteria is not to delete the chassis num of the particular car detail and the model and year can br deleted from the screen.Why m leavin the chassis is to chain with it and then delete it from the PF.I wanna know whether this method is ok.

            Comment


            • #7
              Re: Deleting single record from subfile,how???

              Hi Jami and Andrew,

              I too have a similar requirement wherein i need to show some records using Subfile(SFL) which are present in a PF.
              Upon a selection by user, i should remove a corresponding record from the PF as well as in the SFL.

              I tried to do a direct delte on SFL to avoid reloading SFL. But, during the compilation itself, it's giving me a error like "UPDATE or DELETE operation is not allowed to a SFL record format or Display file".

              Is there any other way for this?

              Comment


              • #8
                Re: Deleting single record from subfile,how???

                you cannot....

                you must reload the subfile.... you can save the RRN of the deleted record then reload the subfile to the previous RRN..

                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


                • #9
                  Re: Deleting single record from subfile,how???

                  In this scenario, my personal preference is to change the color of the record to RED and display the word "*** DELETED ***" instead of the record information. Next time the SFL is loaded, it skips due to the record being removed and you don't see it. But, current session shows it being removed.

                  Comment


                  • #10
                    Re: Deleting single record from subfile,how???

                    By the way, it is VERY easy (and fast) to remove a single subfile record from a subfile if you use qualified data structures.

                    1. Create a new subprocedure, passing it the subfile number to delete.

                    2. Inside the subprocedure, create a data structure array based upon the subfile format. You can set the number of array elements to 9999. Since the data structure array is located within the subprocedure, it does not utilize static storage. So the size of the aray is allocated only when we call this subprocedure, and released as soon as we return.

                    3. Read the subfile into a Data Structure Array that was built using the LikeRec keyword on the subfile format, skipping over the record you want to delete from the subfile.

                    3. Clear the subfile.

                    4. Write the records from the DS array back into the subfile format.
                    Michael Catalani
                    IS Director, eCommerce & Web Development
                    Acceptance Insurance Corporation
                    www.AcceptanceInsurance.com
                    www.ProvatoSys.com

                    Comment


                    • #11
                      Re: Deleting single record from subfile,how???

                      I know this is an old post..... please dont yell @ me.

                      Michael,
                      can you post some code on this....
                      I'm about to do something similar and would like a leg up


                      Thanks
                      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


                      • #12
                        Re: Deleting single record from subfile,how???

                        Originally posted by jamief View Post
                        I know this is an old post..... please dont yell @ me.

                        Michael,
                        can you post some code on this....
                        I'm about to do something similar and would like a leg up


                        Thanks
                        Jamie
                        HOW DARE YOU DRUDGE UP A THREAD THIS OLD!

                        HEH couldn't resist...
                        I'm not anti-social, I just don't like people -Tommy Holden

                        Comment


                        • #13
                          Re: Deleting single record from subfile,how???

                          I was waiting for you
                          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


                          • #14
                            Re: Deleting single record from subfile,how???

                            Originally posted by jamief View Post
                            I know this is an old post..... please dont yell @ me.

                            Michael,
                            can you post some code on this....
                            I'm about to do something similar and would like a leg up


                            Thanks
                            Jamie
                            Yea, I'll write something quick and generic. I would also recomend downloading and applying the following ptf's if you havent done so yet:


                            V6.1 PTF SI41201
                            V7.1 PTF SI41005 *current compiler
                            V7.1 PTF SI40622 *tgtrls compiler V6.1


                            These ptf's allow you to specify *ALL when creating a data structure format based upon a display file format. Without them, you have to create an input data structure, and an output data structure. These ptfs load and apply immediately without the need to IPL. Just apply, and it starts working.
                            Michael Catalani
                            IS Director, eCommerce & Web Development
                            Acceptance Insurance Corporation
                            www.AcceptanceInsurance.com
                            www.ProvatoSys.com

                            Comment


                            • #15
                              Re: Deleting single record from subfile,how???

                              I know i'm currently on v5r4 and have been using *INPUT only.
                              (we are going to V7r1 over easter weekend finally)

                              I have a semi start... Excited to see your version.

                              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

                              Working...
                              X