2013 Sep 30 1:09 PM
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
2013 Sep 30 1:17 PM
2013 Sep 30 4:21 PM
Hi Neal,
Can you be more specfic please?
I didn't gey your point.
Amine
2013 Sep 30 1: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
2013 Sep 30 1: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
2013 Sep 30 4:27 PM
Hi jeffin,
What you saying is to keep my logic and use modify instead of append, right?
Correct me if I'm wrong.
Amine
2013 Sep 30 2: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.
2013 Sep 30 3: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
2013 Sep 30 4:25 PM
Hi Max,
I am going to copy the content of this global table into an SE11 table.
Amine
2013 Oct 01 12:31 AM
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.
2013 Oct 01 6: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.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |