Skip to Content
0
Former Member
Feb 09, 2009 at 02:21 PM

Bapi with empty parameters

31 Views

Hi,

I am trying to create a BAPI that should retrieve a customer list. This Bapi should accept empty parameters in order to select a range of customers. This Bapi should accept wildcards * in the search like a ABAP program. But right now i only can retrieve some significant values if all the parameters are filled.

Am i doing something wrong? I know this is a basic request but it is my first BAPI.

The code is:

FUNCTION ZBAPI_CLIENTE.

*"----

-


""Interface local:

*" IMPORTING

*" VALUE(KUNNR) LIKE KNA1-KUNNR OPTIONAL

*" VALUE(STCEG) LIKE KNA1-STCEG OPTIONAL

*" VALUE(NAME1) LIKE KNA1-NAME1 OPTIONAL

*" VALUE(NAME2) LIKE KNA1-NAME2 OPTIONAL

*" VALUE(VTWEG) LIKE KNVV-VTWEG

*" EXPORTING

*" VALUE(RETURN) LIKE BAPIRETURN STRUCTURE BAPIRETURN

*" TABLES

*" ZITEMDATA STRUCTURE ZBAPICLIENTES

*"----

-


tables: kna1, knvv.

data: cli like kna1-kunnr.

data: nct like kna1-stceg.

data: nm1 like kna1-name1.

data: nm2 like kna1-name2.

cli = kunnr.

nct = stceg.

nm1 = name1.

nm2 = name2.

select * from kna1 where kunnr = cli and stceg = nct and name1 =

nm1 and name2 = nm2.

*select * from kna1 where kunnr = cli.

select * from knvv where kunnr = kna1-kunnr and vkorg = 'MR01' and

vtweg = vtweg and spart = '00'.

move kna1-kunnr to ZITEMDATA-kunnr.

move kna1-stceg to ZITEMDATA-stceg.

move kna1-name1 to ZITEMDATA-name1.

move kna1-name2 to ZITEMDATA-name2.

move knvv-vtweg to ZITEMDATA-vtweg.

append zitemdata.

endselect.

endselect.

ENDFUNCTION.

Can someone help me?

Thanks in advance

Best Regards

João Fernandes