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: 

Querying a table based on a selection criteria

Former Member
0 Kudos
212

Hi Gurus,

Could you please help me in creating a function module that picks records from the table based on certain selection criteria.For eg, If contract number(a primary field) is an import parameter and I want the Function module to export all the records with contract number starting with 1 or may be ending with 303.How could I query this??

Thanks,

Ashwini

5 REPLIES 5

Former Member
0 Kudos
97

An FM so flexible will cost a lot of ur efforts.. however you could do like this..

Hope you have only one field to be queried say Contract..the:

have 2 fields

1. Contract

2. Where --- say u pass BG for begginning BT for between and EN for End

Then inur query based on the where field concat CONTRACT and % either at beginning or end or both

In ur query write as

SELECT.....

WHERE contract LIKE wa_contract

Hope i understood ur problem correctly

Former Member
0 Kudos
97

u can create function module with se37 ,

write ur select query like

select fields1... from table table1

where contractno like '1%'

Former Member
0 Kudos
97

hi,

you need to create a function group and then create a function module ..

put the select query in its source code

thanks

ThomasZloch
Active Contributor
0 Kudos
97

Try using the existing function module RFC_READ_TABLE for this purpose. It is well documented.

Thomas

former_member15255
Active Participant
0 Kudos
97

Hello,

Creation of Function Module

Goto TCode SE37

Click on the Menu Goto->Create Function Group

Create Z (ZPTP) function group and Activate Function Group even if the error occurs

Create Function module Namely Z (ZTEST) assign to the function group (ZPTP)

Go to the Import parameters (EBLEN TYPE EKKO-EBELN)

Go to the Tables ( itab type ekpo)

Goto the Source code

tables ekpo.

Select * from ekpo into table itab

where ebeln eq ebeln.

Activate the function module and run the function

regards

suresh nair