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

Function module

Former Member
0 Likes
405

Hi All,

pls can you help me

i have created function module

import parameters are

p_stdate

p_eddate

p_vbeln

all are optionals

the select query is

DATA lr_vbeln TYPE RANGE OF vbak-vbeln.

DATA l_rvbeln LIKE LINE OF lr_vbeln.

IF P_vbeln IS NOT INITIAL.

l_rvbeln-sign = 'I'.

l_rvbeln-option = 'EQ'.

l_rvbeln-low = p_vbeln.

APPEND l_rvbeln TO lr_vbeln.

ENDIF.

select a~vbeln

a~erdat

a~auart

a~vkorg

a~vtweg

a~spart

a~kunnr

b~posnr

b~matnr

b~werks

b~lgort

b~kwmeng

INTO CORRESPONDING FIELDS OF TABLE it_inquiry

FROM vbak AS a inner join vbap as b on bvbeln = avbeln

where aerdat BETWEEN p_stdate AND p_eddate AND AAUART = 'AF' AND a~vbeln IN lr_vbeln .

1. when i was giving start date and enddate , it working fine.

2. with start date , end date and sales order number, its working fine.

3. but i was given only sales order number with out giving start date and end date ,its not working

pls can you tell me

thanks

mars

4 REPLIES 4
Read only

Former Member
0 Likes
375

Hi,

the reason you are not getting data when you dont mention date is because you have used :

where aerdat BETWEEN p_stdate AND p_eddate AND AAUART = 'AF' AND a~vbeln etc...

Here you should use queries seperately like:

If p_stdate is not initial and p_eddate is not initial.

then go for as now.

elseif p_stdate is not initial and p_eddate is initial

then : where a~erdat > p_stdate

elseif p_stdate is initial and p_eddate is not initial

then : where a~erdat < p_eddate

else.

then : do not include erdat in select query.

endif.

Please reward if useful,

Regards,

Ramesh

Edited by: Ramesh Jakkula on Mar 13, 2008 9:53 AM

Read only

Former Member
0 Likes
375

Check your table vbak (in se16/se11) by giving erdat

as initial (i.e. no values) ..

In select you have where condition as

where a~erdat BETWEEN p_stdate AND p_eddate

It is checking if any records exist with erdat = initial.

ERDAT(Date on which the record was created) will not be initial

Read only

Former Member
0 Likes
375

hi,

Because when you leave them blank it is only looking for values that are beteen blanks which fetches you no data.

change the query in case the values for the parameter are initial and it would work fine .

Regards,

Himanshu

Read only

Former Member
0 Likes
375

DATA lr_erdat TYPE RANGE OF vbak-erdat.

DATA lr_vbeln TYPE RANGE OF vbak-vbeln.

DATA l_rvbeln LIKE LINE OF lr_vbeln.

IF P_vbeln IS NOT INITIAL.

l_rvbeln-sign = 'I'.

l_rvbeln-option = 'EQ'.

l_rvbeln-low = p_vbeln.

APPEND l_rvbeln TO lr_vbeln.

ENDIF.

lr_erdat-options = 'EQ'.

lr_erdat-sign = 'I'.

if not p_stdate is initial.

lr_erdat-low = p_stdate.

endif.

if not p_eddate is initial.

lr_erdat-high = p_eddate.

endif.

append lr_erdat.

select a~vbeln

a~erdat

a~auart

a~vkorg

a~vtweg

a~spart

a~kunnr

b~posnr

b~matnr

b~werks

b~lgort

b~kwmeng

INTO CORRESPONDING FIELDS OF TABLE it_inquiry

FROM vbak AS a inner join vbap as b on bvbeln = avbeln

where a~erdat in lr_erdat

AND p_eddate AND AAUART = 'AF' AND avbeln IN lr_vbeln .