Skip to Content
avatar image
Former Member

Dynamic delete and apppend

Dear Experts,

Can any one help out with any links or documents working on DYNAMICALLY DELETING THE RECORDS OF THE TABLE & DYNAMICALLY APPENDING THE RECORDS IN THE TABLE

Thanks

Katrice

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jul 04, 2012 at 07:19 AM

    Hi,

    Please statement your requirement more clearly.  Are you talking about internal table or database table?  What do you mean by "DYNAMICALLY"?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Dear Katrice Hwkins,

        What kind of "DYNAMIC" do you need?   If you want the database table name to be dynamic, you can use a character type variable to hold the database name.  The INSERT and DELETE statements both support dynamic database names.

      For example.

      DATA: dbname TYPE c LENGTH 5 VALUE 'SPFLI'.

      DATA: wa_spfli TYPE spfli.

      DELETE (dbname) FROM wa_spfli.

      INSERT (dbname) FROM wa_spfli.

      If you need the work area to be dynamic, try RTTI/RTTC Service.  Please read RTTS, RTTI and RTTC

      Best Regards,

  • Jul 04, 2012 at 08:36 AM

    Table name can be a variable "SELECT FROM (variable)"

    (Check Dynamic Program Development in SAP Abap online documentation.)

    Regards,

    Raymond

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 04, 2012 at 08:42 AM

    Hi,

    Please go through the following document to create dynamic internal table.

    http://wiki.sdn.sap.com/wiki/display/ABAP/Dynamic+Internal+table

    Here in the mentioned example, data is being fetched from data base table to the dynamic internal table <dyn_table>.

    Here is how you can append data to the dynamic internal table:

    * Creating work area for the dynamic internal table
    CREATE DATA dy_line LIKE LINE OF <dyn_table>.
    ASSIGN dy_line->* TO <dyn_wa>.

    Now <dyn_wa> will serve as a work area for the internal table, now you have to fill this work area and then append it to the dynamic internal table.

    Since, the field symbol <dyn_wa> is untyped. It has to be filled as follows:

    ASSIGN COMPONENT 1 OF STRUCTURE <dyn_wa> TO <dyn_field>.


    IF sy-subrc EQ 0.

    <dyn_field> = 'First field'.

    ENDIF.

    ASSIGN COMPONENT 2 OF STRUCTURE <dyn_wa> TO <dyn_field>.


    IF sy-subrc EQ 0.

    <dyn_field> = 'Second field'.

    ENDIF.

    Like wise the work area can be filled. For more details on access using field symbols you may visit the follwing link:


    http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3605358411d1829f0000e829fbfe/frameset.htm

    once your work area is ready it can be appended as:

    APPEND <dyn_wa> TO <dyn_table>.

    Similarly, delete operation can be performed as:

    DELETE <dyn_table> WHERE 'FIELD1' EQ <condition>.

    Hope it helps. Thank you.

    Regards,
    Kartik

    Add comment
    10|10000 characters needed characters exceeded