Skip to Content

Flag from internal tables

Hi experts,

I am filling in an abap program 3 internal tables with some document numbers.

Example:

Table 1:

Document number

Field1

Field2

1

XXX

ZZZ

2

YYY

VVV

Table 2:

Document number

Field1

Field2

Field3

1

AAA

300

A

3

BBB

400

C

Table 3:

Document number

Field1

2

200

3

150

I would like to create a global table listing the existence of a document in one of the internal tables or not with a flag as following:

Global Table:

Document number

Itable1

Itable2

Itable3

1

X

X

2

X

X

3

X

X

I thought about appending all the content of the 3 tables into one global table, then delete adjacent duplicates rcomparing document number.

Read table 1 with key Document number.
If sy-subrc eq 0.
GlobalTable-Itable1 = ‘X’.
Endif.

Do the same for the other tables.


What do you think? May be there is other simple and efficient ways to perform it. Waiting for your advices.

Thanks.

Amine

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 30, 2013 at 12:28 PM

    Hi,

    As u mentioned,

    Append all the entries into a global table.

    Sort the global table by document number.

    Delete the adjacent duplicates.

    It will be good.

    Thanks

    Pavan.N

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 30, 2013 at 01:51 PM

    Hi,

    If you just need to just check the existence of the doc number in all the 3 tables you can go ahead with the logic which u have stated. Else if you are about to use the values from all the tables it is better to create a final table which will contain the fields from all three table and append the corresponding fields .

    TYPES: Begin of ty_final,

    docu TYPE docu,

    field1_tb1 TYPE field1, ----- table 1 fields

    field2_tb1 TYPE field2,

    field1_tb2 TYPE field1,. ----- table 2 fields

    .

    field2_tb2 TYPE field2,

    .

    .

    End of ty_final.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 30, 2013 at 11:31 PM

    I am not sure if its applicable to your application logic but creating a sorted table with docnum as an unique key and inserting data is one way I am thinking off. One can later use this table to read from it or do any further processing.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 01, 2013 at 05:44 AM

    Hi amine lamkaissi,

    First of all append to global internal table. Then sort the internal table and delete duplicate entries.

    While reading internal table use Binary Search.

    Read <internal_table> into <wa> with key <key_name> binary search.

    if sy-subrc eq 0.

    global_internal table = abap_true.

    endif.

    Regards,

    Riju Thomas.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 30, 2013 at 12:17 PM

    Instead of a flag, how about an integer. Then collect.

    Neal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 30, 2013 at 12:57 PM

    Hi,

    Use MODIFY statement to set the flag so that it is possible to update the other flags also if the values exist in other tables , so that there wont be any duplicate entries .If you are appending you need to delete the duplicate entries.

    wa-doc = 1.

    wa-fld1 = 'X'.

    MODIFY <db> FROM <wa>.

    Regards,

    Jeffin

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 30, 2013 at 02:09 PM

    Hi

    Before answerin it should be better if you explain to us what you need to do with that big table

    All I can sa you is only about the maintenance....if tomorrow you need to add a new internal table?

    Max

    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.