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

Getting values in select query

sandeep_gvv2
Participant
0 Likes
1,821

Hi,

My question is simple,Like

i have two select queries, in the first select query  i am getting three fields -partner,taxtype,taxnum  from a standard table and stored in IT1.

This it1 values are called through a custom function module in that we write another select query like as above

code :

--------

if it1 is not initial.

DELETE ADJACENT DUPLICATES FROM lt_dfkk[].

       SELECT mc_name1 mc_name2 bu_sort1 bu_sort2 partner FROM but000
                             INTO CORRESPONDING FIELDS OF TABLE lt_result
                             UP TO callcontrol-maxrecords ROWS
                             FOR ALL ENTRIES IN lt_dfkk WHERE
                             partner  = lt_dfkk-partner.


here i want to get taxtype taxnum in lt_result table.


What is the possible way to make it happen ???

6 REPLIES 6
Read only

Former Member
0 Likes
1,333

You can make this:

SELECT mc_name1 mc_name2 bu_sort1 bu_sort2 partner FROM but000

                             INTO CORRESPONDING FIELDS OF TABLE lt_result

To

SELECT mc_name1 mc_name2 bu_sort1 bu_sort2 partner FROM but000

                             INTO TABLE lt_it2


Declare a result table with all fields required and move values from it1 and lt_it2 to lt_result.


Does this help?


Thanks,

Sowbhagya

Read only

0 Likes
1,333

If the OP has to merge the data, why he has to use another table?

He can do the select as he already does and then update LT_RESULT with data from IT1.

I do not see any benefit in using another internal table!

Read only

SimoneMilesi
Active Contributor
0 Likes
1,333

I do not understand your requirement or the issue you are facing and what you tried to solve.

If I understood well, you need to merge data from IT1 and LT_RESULT, correct?

Read only

VenuAnumayam
Participant
0 Likes
1,333

Not sure If I understand your requirement correctly, but as Simone mentioned, you could do something like this:

Assuming your IT_RESULT already has both the taxtype and taxnum fields, Loop at IT_RESULT and read IT1 with key Partner and modify with those two field values. Hope it helps!!

Read only

Former Member
0 Likes
1,333

This message was moderated.

Read only

Former Member
0 Likes
1,333

Hi,

Declare work areas for the two internal table.

then.

data : idx type i.

Loop at lt_result into wa_result.

idx = sy-tabix.

Read table lt_dfkk into wa_dfkk with key partner  = wa_result-partner

if sy-subrc = 0.

wa_result-taxtype = wa_dfkk-taxtype.

wa_result-taxnum = wa_dfkk-taxnum.

modify it_result from wa_result index idx transporting taxtype taxnum.

endif.

endloop.

Thanks.