Skip to Content
author's profile photo Former Member
Former Member

small issue in dialog program

Hello all,

i have a requirement in dialog programming.

I have to modify a record a record which exist in zatble.

For each record , i have a header info, item details.

for header iam ok , i can use modify.

for item details i have like

itemno material materialdesc quantity

1 m1 pqr 12

2 m2 def 9

3 m3 abc 2

4 m4 xyz 1

item no and material are my primary keys.

so iam retrieving this data from a z table and have to update.

may be i need to delete 3 record and modify 2 record,i would do that based on the selectionfrom table control

itemno material materialdesc quantity

1 m1 pqr 12

2 m2 def 19

3 m4 xyz 1

now i have deleted 3 record and modifed 2 with increase in quantity and the itemno are changed

I have ths data in my internal table.

iAM USING MODIFY STATEMNT WHEN I SAVE THE DATA INTO DATABASE TABLE.

i SEE THE FOLLOWING DAT AIN MY ZTABLE

1 m1 pqr 12

2 m2 def 19

3 m3 abc 2

4 m4 xyz 1

3 m4 xyz 1

THOGHT I NEED ONLY THESE DATA TO BE PRESENT IN MY ZTABLE

1 m1 pqr 12

2 m2 def 19

3 m4 xyz 1

Any help or suggestions regarding this

Thanks

Suchitra

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 02:50 PM

    Can you not delete all items and insert the ones that you have in your bespoke transaction.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 04:37 PM

    Hi suchitra,

    do one thing ,,

    -


    first task

    1.first of all select all the contents of ztable based on primary keys into a internal table itab.

    1 m1 pqr 12

    2 m2 def 9

    3 m3 abc 2

    4 m4 xyz 1

    2. in ur m-pool table control u r performing the operations like delete and modify to the table control GET THE CONTENTS INTO UR FINAL TABLE JTAB ..Lets say

    This is ur final jtab.

    1 m1 pqr 12

    2 m2 def 19

    4 m4 xyz 1

    NOW PERFORM COMPARISIONS,

    3. LOOP AT ITAB.

    READ TABLE JTAB WITH KEY ITEMNO = ITAB-ITEMNO

    AND MATNR = JTAB-MATNR

    And menge = jtab -menge

    IF SY-SUBRC <> 0.

    ITAB-ITEMNO = JTAB-ITEMNO.

    ITAB_MATNR = JTAB-MATNR.

    ITAB_MATDESC = JTAB_MATDESC

    ITAB_MENGE = JTAB_MENGE

    MODIFY ITAB. ”TRANSPORTING

    ENDIF.

    ENDLOOP.

        • THIS WILL COVER RECORD 2 IN UR ITAB CHANGES ARE OK ..

        -


        second task ..

        4. NOW SINCE U HAVE DELETED RECORD 3 ,, PLACE IN AN EXTRA FILED IN THE JTAB STRUCTURE

        LIKE CHAR TYPE C, SAME HAS TO BE IN ITAB ALSO

        AND MAKE IT X WHEN EVER U DELETE IT IN TABLE CONTROL

        LIKE THIS THE O/P IM EXPECTING HERE IS IN JTAB

        1 m1 pqr 12

        2 m2 def 19

        3 m3 abc 2 x

        4 m4 xyz 1

        LOOP AT ITAB.

        READ TABLE JTAB WITH KEY ITEMNO = ITAB-ITEMNO

        AND MATNR = JTAB-MATNR

        IF JTAB-CHAR = ‘X’.

        ITAB-ITEMNO = JTAB-ITEMNO.

        ITAB_MATNR = JTAB-MATNR.

        ITAB_MATDESC = JTAB_MATDESC

        ITAB_MENGE = JTAB_MENGE

        ITAB-CHAR = JTAB-CHAR

        MODIFY ITAB. ”TRANSPORTING

        ENDIF.

        ENDLOOP.

        NOW THE ITAB CONTENT IS

        1 m1 pqr 12

        2 m2 def 19

        3 m3 abc 2 x

        4 m4 xyz 1

        My suggestion to u is modify the ztable from itab .

        Without deleting entry 3

        This will solve ur prob .

        Cause when u do a select next time

        Select entries where char <> ‘X’

        Which will fetch u

        1 m1 pqr 12

        2 m2 def 19

        4 m4 xyz 1

        Try to bring the logic in a single loop this will do

        i have split this for ur understanding ....

        Add a comment
        10|10000 characters needed characters exceeded

      • author's profile photo Former Member
        Former Member
        Posted on Oct 17, 2006 at 09:43 AM

        Hi suchitra,

        like with ref to prev reply ,

        u r logic was bringing the deletion / modification of the ztable in a single shot ..

        now u r trying to do two things at a single time ,,

        delete the entry ,,

        modify the item so a compaq logic has to be drawn to get this thing done ..

        THOGHT I NEED ONLY THESE DATA TO BE PRESENT IN MY ZTABLE

        1 m1 pqr 12

        2 m2 def 19

        3 m4 xyz 1

        but actually the correct one is

        u need to get this ..

        1 m1 pqr 12

        2 m2 def 19

        4 m4 xyz 1

        right.

        so its always a good practice to mark the deleted records with a indicator which will be easy .

        just try to get the content of the table control and check go with the logic.

        one advice from some one was delete the whole z table and insert it .. even that will work but what if the table contents are say 1000+ and u are changing only 2 records for this i need to delete and again insert back the whole stuff ..

        regards,

        Vijay

        Add a comment
        10|10000 characters needed characters exceeded

      • author's profile photo Former Member
        Former Member
        Posted on Oct 17, 2006 at 10:22 AM

        Suchitra,

        The simplest way is to try and follow the below logic.

        As you said that you have header and item tables...and surely the two have a common field. So once you have the modified data in ur table control (one deleted and other modified as in your example).

        logic for update_item_table.

        1. delete the records from ztable(details) for the particular header key.

        2. insert the records from control to ztable(details).

        U would get the required result.

        Add a comment
        10|10000 characters needed characters exceeded

      • author's profile photo Former Member
        Former Member
        Posted on Oct 17, 2006 at 11:55 AM

        Hi,

        Both deletion and updation could not be done together.

        There should be minimal database hits.

        1.Keep the deleted records of the item table in a temporary table and delete those records from the main item table.

        2.Update the main item table with the changed values.

        3.Delete the datarecords from the DB table using the temporary internal table.

        4.modify the records in in DB table using the modified main itab.

        Hope this will solve your issue

        cheers

        Add a comment
        10|10000 characters needed characters exceeded

      Before answering

      You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
      You must be Logged in to submit an answer.

      Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.