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
437

Hi All there,

I am writing a function module the coding for that is like this

FUNCTION ZBAPI_CUST_MAT_NUM.

*"----


""Local interface:

*" IMPORTING

*" VALUE(SALES_ORG) TYPE KNMT_REF-VKORG OPTIONAL

*" VALUE(DISTR_CHANNEL) TYPE KNMT_REF-VTWEG OPTIONAL

*" VALUE(CUSTOMER_NUMBER) TYPE KNMT_REF-KUNNR OPTIONAL

*" VALUE(MATERIAL_NUMBER) TYPE KNMT_REF-MATNR OPTIONAL

*" VALUE(CUSTOMER_DESCR) TYPE KNMT_REF-KDPTX OPTIONAL

*" TABLES

*" OUTTAB STRUCTURE ZVBAP OPTIONAL

*"----


*SELECT KDMAT FROM KNMT_REF INTO TABLE OUTTAB WHERE

*VKORG EQ VKORG AND VTWEG EQ VTWEG AND KUNNR EQ KUNNR AND MATNR EQ MATNR AND KDPTX EQ KDPTX.

*ENDSELECT.

data i_selopt like ddshselopt occurs 0 with header line.

data v_whereclause type string.

if SALES_ORG = ' '.

else.

i_selopt-shlpname = 'KNMT_REF'.

i_selopt-shlpfield = 'VKORG'.

i_selopt-sign = 'I'.

i_selopt-option = 'EQ'.

i_selopt-low = SALES_ORG.

append i_selopt.

endif.

if DISTR_CHANNEL = ' '.

else.

i_selopt-shlpname = 'KNMT_REF'.

i_selopt-shlpfield = 'VTWEG'.

i_selopt-sign = 'I'.

i_selopt-option = 'EQ'.

i_selopt-low = DISTR_CHANNEL.

append i_selopt.

endif.

if CUSTOMER_NUMBER = ' '.

else.

i_selopt-shlpname = 'KNMT_REF'.

i_selopt-shlpfield = 'KUNNR'.

i_selopt-sign = 'I'.

i_selopt-option = 'EQ'.

i_selopt-low = CUSTOMER_NUMBER.

append i_selopt.

endif.

if MATERIAL_NUMBER = ' '.

else.

i_selopt-shlpname = 'KNMT_REF'.

i_selopt-shlpfield = 'MATNR'.

i_selopt-sign = 'I'.

i_selopt-option = 'EQ'.

i_selopt-low = MATERIAL_NUMBER.

append i_selopt.

ENDIF.

if CUSTOMER_DESCR = ' '.

else.

i_selopt-shlpname = 'KNMT_REF'.

i_selopt-shlpfield = 'KDPTX'.

i_selopt-sign = 'I'.

i_selopt-option = 'EQ'.

i_selopt-low = CUSTOMER_DESCR.

append i_selopt.

endif.

call function 'F4_CONV_SELOPT_TO_WHERECLAUSE'

importing

where_clause = v_whereclause

tables

selopt_tab = i_selopt.

SELECT KDMAT FROM KNMT_REF INTO TABLE OUTTAB WHERE (V_WHERECLAUSE).

ENDFUNCTION.

here in the last condition ie in the costumer_descr it is not taking value more than length 20

pl suggest me

helpful answer will definatly rewarded

Regards

shashi

3 REPLIES 3
Read only

Former Member
0 Likes
380

Hi Sashi,

In outtab u may given length 20 for Material Number

Description.Actual length for this is 35.I am expecting this

may be the problem in ur case.

(KDMAT CHAR 35 Material Number Used by Customer)

Regards,

kishore.

Read only

Former Member
0 Likes
380

Hi,

1.The problem in the customer_desc for taking the 20 char length for the material description is , the selopt-low length is 24 char only.

2.so it is opting to 24 chars with including spaces.

Regards,

Reward if helpful(Don't forget).

Read only

0 Likes
380

Hi,

DDSHSELOPT in this structure length for low is 45 but u r

saying this length is 24.i didnt get u what exact the problem

it is.If u dont mine could u plz explain in clear way.

regards,

kishore.