Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

update standard table error....

former_member225134
Participant
0 Kudos

Hi,

    i want to update multiple records from my internal table to standard database table,while updating it is not clear and

updating the first time given value to all places...

code is...

       LOOP AT GT_OUTTAB  WHERE FREI_DAT IN SO_DATE .

if GT_OUTTAB-edit is not initial.

         UPDATE QINF SET FREI_DAT = GT_OUTTAB-EDIT

                            WHERE MATNR IN SO_MATNR AND

                                  LIEFERANT IN SO_VEND AND

                                  WERK IN SO_PLANT AND

                                  FREI_DAT IN SO_DATE.

endif.

endloop.

it is updating like.....1.1.2014

                              1.1.2014

                              1.1.2014

same value is repeating.......How to update this???????

14 REPLIES 14

Former Member
0 Kudos

Hi Anitha,

Couldn't able to understand the issue. Can you please elaborate issue ?

Thanks & Regards,

Arun

0 Kudos

Hi,

     While updating multiple records same value is again and again updated...it is not cleared..

if i give 1.1.2000 as first line

           1.2.2000 as second line maens

it updates 1.1.2000

               1.1.2000 only....

same time    UPDATE QINF SET FREI_DAT = GT_OUTTAB-EDIT

qinf and gt_outtab has different structure.

0 Kudos

Hi Anitha,

After update Include

Commit Work

WAIT UP TO 1 SECONDS


and check.



Regards,

Venkat.

0 Kudos

Thanx for your repli,

                    commit work also not workingg..... May i know why same values are updating again and again..

0 Kudos

Hi Anitha,

Cross check the GT_OUTTAB at run time in debugger.

What happening is in each loop iteration you are updating same records ( where close is common ).

Ideally last record value FREI_DAT of GT_OUTTAB should have updated to all the records, as you told here first record FREI_DAT of GT_OUTTB updating. I think it's updating first time successfully, failing for rest of iterations . You need to check any update errors.

0 Kudos

yeah correct this only happening here,

But i didn get any update errors...It simply updates the same value to the standard qinf table.

0 Kudos

Hi Anitha,

Is this FREI_DAT IN SO_DATE  condition failing for rest of loop iteration after first loop updation ?

Have you checked the sy-subrc ?

Thanks & Regards,

Arun

0 Kudos

FREI_DAT IN SO_DATE condition is not failing,because it fetches within that value only..



LOOP AT GT_OUTTAB  WHERE FREI_DAT IN SO_DATE .

if GT_OUTTAB-edit is not initial.

         UPDATE QINF SET FREI_DAT = GT_OUTTAB-EDIT.

                           WHERE MATNR IN SO_MATNR AND

                                 LIEFERANT IN SO_VEND AND

                                WERK IN SO_PLANT AND

                                 FREI_DAT IN SO_DATE.

else.

   UPDATE QINF SET FREI_DAT = GT_OUTTAB-FREI_DAT.

                           WHERE MATNR IN SO_MATNR AND

                               LIEFERANT IN SO_VEND AND

                                 WERK IN SO_PLANT AND

                                FREI_DAT IN SO_DATE.

   endif.

   endloop.

0 Kudos

GT_OUTTAB-EDIT will be with in SO_DATE ? Secondly please check last record of GT_OUTAB whats the value of EDIT and FREI_DATE



0 Kudos

no GT_OUTTAB-EDIT it is users option ,,in editable alv user entered some date and save it...so some times it is not in  FREI_DATE..

0 Kudos

Hi Anitha,

Try this,

Include ZAEHL field  in where condition and check (Key field)

FIELD-SYMBOLS: <wa> like line of gt_outtab.

LOOP AT GT_OUTTAB  WHERE FREI_DAT  IN SO_DATE
                                           AND MATNR     IN SO_MATNR AND
                                                 LIEFERANT IN SO_VEND  AND
                                                    WERK      IN SO_PLANT AND
                                                   FREI_DAT  IN SO_DATE.


   MOVE-CORRESPONDING gt_outtab to <wa>.

   if <wa>-edit is not initial.

     UPDATE QINF SET FREI_DAT = GT_OUTTAB-EDIT
                       WHERE MATNR          EQ <wa>-matnr          AND
                                    ZAEHL           EQ  <wa>-zaehil          AND
                                   LIEFERANT     EQ  <wa>-LIEFERANT AND
                                   WERK             EQ   <wa>-werk.
     COMMIT WORK.
     WAIT UP TO 1 SECONDS.

   else.

     UPDATE QINF SET FREI_DAT = <wa>-FREI_DAT
                             WHERE MATNR        EQ <wa>-matnr           AND
                                          ZAEHL          EQ <wa>-zaehil          AND
                                          LIEFERANT   EQ <wa>-LIEFERANT AND
                                          WERK          EQ <wa>-werk.

     COMMIT WORK.
     WAIT UP TO 1 SECONDS.

   endif.

endloop.

Regards,

Venkat.

0 Kudos

Have you checked , first record of EDIT date in range of SO_DATE ? If it is not the range of SO_DATE than first time EDIT date updated to FREI_DATE in all the records,  for rest of loop iterations FREI_DATE(since its updated with EDIT date) not in range of SO_DATE it will fail.

As per your code, once EDIT date falls into not in the range of SO_DATE than that will be final update, remaining will fail

Private_Member_7726
Active Contributor
0 Kudos

Hi,

I'm not sure if what you are asking is strictly against the forum rules, but I don't believe it's a good idea to update that table directly, and if you must, sorry - you'd better know what you are doing and how to program updates.

sorry

Janis

Former Member
0 Kudos

Hi Anitha,

Try clearing the GT_OUTTAB inside the loop.Use Clear GT_OUTTAB.

By the way GT_OUTTAB is an internal table without headerline.?

Regards,

Kannan