cancel
Showing results for 
Search instead for 
Did you mean: 

Use Z FunctionModule in WebDynproJava

StefanReitz
Explorer
0 Kudos

Hello Forum,

i want to run the following FM in Web Dynpro Java: It shall read the Importparameters VkOrg and KunNr and provide a Result Table containing the accordant Conditions to the VkOrg and KunNr – Selections:

<i>FUNCTION Z_FB_READCOND.

*"----


""Lokale Schnittstelle:

*" IMPORTING

*" VALUE(I_KAPPL) TYPE KSCHL DEFAULT 'V'

*" VALUE(I_VKORG) TYPE VKORG OPTIONAL

*" VALUE(I_VTWEG) TYPE VTWEG OPTIONAL

*" VALUE(I_MATNR) TYPE MATNR OPTIONAL

*" VALUE(I_KUNNR) TYPE KUNNR OPTIONAL

*" VALUE(I_DATUM) TYPE SYDATUM OPTIONAL

*" VALUE(I_KSCHL) TYPE KSCHL OPTIONAL

*" TABLES

*" A305 STRUCTURE A305

*" KONP STRUCTURE KONP

*" EXCEPTIONS

*" INV_SELECTION

*" NOT_FOUND

*"----


TYPES BEGIN OF s_kunnr.

TYPES sign TYPE ddsign.

TYPES opti TYPE ddoption.

TYPES low TYPE kunnr.

TYPES high TYPE lifnr.

TYPES END OF s_kunnr.

TYPES BEGIN OF s_matnr.

TYPES sign TYPE ddsign.

TYPES opti TYPE ddoption.

TYPES low TYPE matnr.

TYPES high TYPE matnr.

TYPES END OF s_matnr.

DATA ls_kunnr TYPE s_kunnr.

DATA ls_matnr TYPE s_matnr.

DATA r_kunnr TYPE STANDARD TABLE OF s_kunnr.

DATA r_matnr TYPE STANDARD TABLE OF s_matnr.

IF i_matnr IS INITIAL AND i_kunnr IS INITIAL.

RAISE inv_selection.

ENDIF.

DEFINE ran>.

refresh &3.

if &1 is supplied.

clear &2.

&2-sign = 'I'.

&2-opti = 'EQ'.

&2-low = &1.

append &2 to &3.

endif.

END-OF-DEFINITION.

ran>: i_kunnr ls_kunnr r_kunnr,

i_matnr ls_matnr r_matnr.

REFRESH: a305, konp.

SELECT * FROM a305 INTO TABLE a305

WHERE kappl EQ i_kappl

AND kschl EQ i_kschl

AND vkorg EQ i_vkorg

AND vtweg EQ i_vtweg

AND kunnr IN r_kunnr

AND matnr IN r_matnr.

IF NOT a305[] IS INITIAL.

SELECT * FROM konp INTO TABLE konp

FOR ALL ENTRIES IN a305

WHERE knumh EQ a305-knumh.

ELSE.

<b>RAISE not_found.</b>

ENDIF.

ENDFUNCTION.</i>

The FM is RFC-enabled and I imported it per AdaptiveRFC as a model. To test it I passed all the Input Parameters (Kappl, Kschl, VkOrg, VtWeg, MatNr, KunNr, Date).

Unfortunately it always exits with <b>not_found</b> – Exception while it works when I test it with SE37. Would you know what the Problem might be? I tested the same procedure with another BAPI and it works fine. This is what my Web Dynpro Code looks like:

<i> public void wdDoInit()

{

//@@begin wdDoInit()

//$$begin Service Controller(-1558825981)

// wdContext.nodeZ_Fb_Readcond_Input().bind(new Z_Fb_Readcond_Input());

Z_Fb_Readcond_Input input = new Z_Fb_Readcond_Input();

wdContext.nodeZ_Fb_Readcond_Input().bind(input);

// #Einlesen der Inputparameter

input.setI_Kappl("");

input.setI_Kschl("");

input.setI_Kunnr("");

input.setI_Matnr("");

input.setI_Vkorg("");

input.setI_Vtweg("");

input.setI_Datum(new Date(12042007));<i></i></i>

Accepted Solutions (0)

Answers (6)

Answers (6)

StefanReitz
Explorer
0 Kudos

Hi B. van Prooijen,

thanks for the hint. My code is completely in wdDoInit. I tried to do the binding after setting the parameters; still get the not_found – Exception. Strangely the Table returns sy-subrc = 0 in R/3 and sy-subrc = 4 per RFC .

Regards

abhijeet_mukkawar
Active Contributor
0 Kudos

hi,

in external debugging if you are recieveing the parameters then just have a look at thier data types in abap tables , it should not happen while coming from WD , coz of data type mismatch it is converting parameteres in some other format.

Problem is because it is not finding entry in a305 , if it works fine in r3 then just have a look at the parameters datatype.

regards

StefanReitz
Explorer
0 Kudos

Hi All,

i have tried my Application with the following values which are working in R3(SE37).

Z_Fb_Readcond_Input input = new Z_Fb_Readcond_Input();

wdContext.nodeZ_Fb_Readcond_Input().bind(input);

// #Read Inputparameters

input.setI_Kappl("V");

input.setI_Kschl("PR00");

input.setI_Kunnr("1235");

input.setI_Matnr("QS8X30");

input.setI_Vkorg("1000");

input.setI_Vtweg("10");

input.setI_Datum(Date.valueOf("2007-04-12"));

The I_Datum Parameter does not have to be filled in R/3. Anyhow, I imported the java.class : “import java.sql.Date; but it isn't really an absolute part of the Functionality

I tried the external debugging and set a BreakPoint at this Position: <b>IF NOT a305[] IS INITIAL</b>

The sy-subrc Field shows 4, that means the Table is empty. I think that is my Problem. But why does it work when I test with SE37 with the same Values?

Any suggestion why the Table is empty?

Greets

Stefan

Former Member
0 Kudos

Hi Stefan,

I think your problem is that you bind the input and after that you set the input parameters.

All this code you are doing now is in the wdInit()-method right?

Or you have to write the wdContext.nodeZ_Fb_Readcond_Input().bind(input) after the code input.set...

Or you have to write the code:

Z_Fb_readcond_Input input = wdContext.nodeZ_Fb_Readcond_Input().currentZ_Fb_Readcond_InputElement();

input.set....

So your code will look like this then:

Z_Fb_Readcond_Input input = new Z_Fb_Readcond_Input();

// #Read Inputparameters

input.setI_Kappl("V");

input.setI_Kschl("PR00");

input.setI_Kunnr("1235");

input.setI_Matnr("QS8X30");

input.setI_Vkorg("1000");

input.setI_Vtweg("10");

input.setI_Datum(Date.valueOf("2007-04-12"));

wdContext.nodeZ_Fb_Readcond_Input().bind(input);

Message was edited by:

B. van Prooijen

abhijeet_mukkawar
Active Contributor
0 Kudos

hi,

in external debuggiing check out if other parameters are coming,

try i guess bind the model obje after you set value to them

regards

StefanReitz
Explorer
0 Kudos

Hello B.van Prooijen,

I tried your hint, but it still does exit with Not-Found – Exception.

Subramanian, how exactly can I set upper/lowercase Options in my FM? Is it not possible to simply take lowercase values? Could you give me an example for a conversion-exit? With SE37 both Upper and Lowercase works and I even can ignore the date-parameter. It always returns the two Tables Konp and A305 with Entries.

Regards

Stefan

Former Member
0 Kudos

Please check also from wich type this Date is.

It has to be in the format java.sql.Date and not java.util.Date.

Former Member
0 Kudos

Example of Conversion exit :

CONVERSION_EXIT_ALPHA_INPUT

Check how are you required to pass date in your function module ? DD/MM/YYYY or YYYYMMDD etc... this depends on your user settings.

If you are passing values through Web Dynpro, it is case sensitive. So if you want data for your function module in upper case, you need to convert it in your Web Dynpro program.

SImilarly for lower case.

Regards,

Subramanian V.

abhijeet_mukkawar
Active Contributor
0 Kudos

hi,

if JCOs are wotking fine then check these for faulty FM.

1) Through external debugging check out if proper values are being sent to backend or not(for external debugging goto transaction code se37, open your bapi->goto Utilities->Setting->Debugging->Here check if "Act" check box is activated or not), then put a break point in code and run application from WD.

Here check out if the date you recieve is incompatible with what you would have given in r3, if it is so then write following few lines of code in WD for type "DATE" in abap,

<b>SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");

Date st_date = wdContext.currentContextElement().get<value attrib of date type>(); // DATE in WD is

sql.date

input.setI_Datum(formatter.format(st_date));

//this will change the incompatibility in date from WD to abap "DATE" type .</b>

2) If proper values are sent to backend then check in WD if output node is recieving values as output or not, using

wdContext.node<output node containing values>.size()

3) If proper values are coming in output node ie if it is showing size non zero for valid parameter in import then check if the node is properly bind to UI element .

If you are using table control then best way is use Apply template method in the context menu of RootUIElement of view.

4) or finaly check if any exception is thrown while executing model object.

hoep it helps

regards

former_member189631
Active Contributor
0 Kudos

Stefan,

Please chech the following,

1)Check your Binding and Mapping.

2)Initially try to set some default parameter thriugh coding and execute.

3)Try Map and Bind your Return(If u have in the FM) Node also.

Regards,

Ram.

Former Member
0 Kudos

Hi Stefan,

The exception you retrieve is because of the way you define your input parameter Date.

With new Date(12042007) you set a new Date by a long value so not the real Date 12th of april 2007

please try this and it should work:

Date.valueOf("yyyy-mm-dd");

So for you code:

input.setI_Datum(Date.valueOf("2007-04-12"));

Regards

Former Member
0 Kudos

Hi Stefan,

You need to worry about a few things :

a) Date as B.van Prooijen mentioned it should be of format that has been defined for you in SAP R/3

b) Uppercase/Lowercase options in Function Module

c) Conversion exits

You need to make sure all the above 3 are taken care of before you pass the value to R/3 through Web Dynpro

Regards,

Subramanian V.