Application Development 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: 

Select query for the table using user input and internal table

mahabaleshwar_patil
Participant
0 Kudos

I have internal table it_characteristics which is type table of  structure characteristics which contains some values name_char which are various characteristics of materials and I have fetch the data from the  ausp table based on objek (material number which is entered in selection screen  ) and all character values from the internal table it_characteristics .

What would be my select query ?

SELECT objek
atinn
atzhl
mafid
klart
adzhl
atwrt
FROM ausp
INTO TABLE it_ausp
WHERE objek EQ s_object(this is material number)

And now I want feach attn. comparing the   name_chares values from the internal table    it_characteristics

Means atinn must match with the name_char vales





5 REPLIES 5

Former Member
0 Kudos

Hi ,

use this .

sort it_characteristics by name_char.

Loop at it_ausp into wa_ausp.

read table it_characteristics into wa_characteristics with key

                                                  name_char = wa_ausp-atinn

                                                  binary search.

if sy-subrc eq 0.

"put your logic here .

endif.

endloop.

Regards,

Saddam

0 Kudos

First of all no use of looping it_ausp because there no data in that internal table.

i want put put values in internal table based on charterstics values.

mayur_priyan
Active Participant
0 Kudos

Use

IF NOT it_characteristics[] IS INITIAL.

SELECT objek
atinn
atzhl
mafid
klart
adzhl
atwrt
FROM ausp
INTO TABLE it_ausp

FOR ALL ENTRIES IN it_characteristics                   <<<
WHERE objek IN s_object(this is material number)

   AND atinn EQ it_characteristics-name_char.            <<<

ENDIF.      

0 Kudos

getting error

there is conversion routine present for the filed attin field

CONVERSION_EXIT_ATINN_INPUT. but in table it_charaterstics there wont apply the conversion rotine so cant use /....

0 Kudos

Hi,

Befor writing select query convert your it_charaterstics-name_char into the type which you want by using CONVERSION_EXIT_ATINN_INPUT and then write the select query as described by

Mayur Priyan.

LOOP AT it_charaterstics ASSIGNING <FS_CHAR>.

CALL FUNCTION CONVERSION_EXIT_ATINN_INPUT

EXPORTING

INPUT = <FS_CHAR>-MANE_CHAR

IMPORTING

OUTPUT =  <FS_CHAR>-MANE_CHAR

ENDLOOP.

IF NOT it_characteristics[] IS INITIAL.

SELECT objek
atinn
atzhl
mafid
klart
adzhl
atwrt
FROM ausp
INTO TABLE it_ausp

FOR ALL ENTRIES IN it_characteristics                 
WHERE objek IN s_object(this is material number)

   AND atinn EQ it_characteristics-name_char.         

ENDIF.      

Reagrds

Mani