Application Development and Automation 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: 
Read only

Flag from internal tables

Former Member
0 Likes
3,054

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

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

10 REPLIES 10
Read only

Former Member
0 Likes
2,191

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

Neal

Read only

0 Likes
2,191

Hi Neal,

Can you be more specfic please?

I didn't gey your point.

Amine

Read only

Former Member
0 Likes
2,191

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

Read only

former_member220538
Active Participant
0 Likes
2,191

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

Read only

0 Likes
2,191

Hi jeffin,

What you saying is to keep my logic and use modify instead of append, right?

Correct me if I'm wrong.

Amine

Read only

mayur_priyan
Active Participant
0 Likes
2,191

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.

Read only

Former Member
0 Likes
2,191

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

Read only

0 Likes
2,191

Hi Max,

I am going to copy the content of this global table into an SE11 table.

Amine

Read only

Former Member
0 Likes
2,191

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.

Read only

Former Member
0 Likes
2,191

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.