cancel
Showing results for 
Search instead for 
Did you mean: 

JCO to access BAPI

Former Member
0 Kudos

Hi,

I am trying to access an BAPI which has an Import parameter as an Table "ORDERDATA". So i need to form the Table with the values entered in the textboxes in Portal to send the Import input Table while calling a BAPI.

Can someone help me out to Create an Table "Ord_Table" with 5 fields or more so that i can pass it as an import to the function module?

JCO.Function function = repository.getFunctionTemplate("Z_ORDER_CREATE").getFunction();

JCO.ParameterList input = function.getImportParameterList();

input.setValue(<b>Ord_Table</b> , "ORDERDATA");

client = JCO.getClient(SID);

client.execute(function);

JCO.Structure ret=function.getExportParameterList().getStructure("RETURN");

System.out.println("RETURN MESSAGE: " + ret.getString("MESSAGE"));

JCO.Table code=function.getTableParameterList().getTable("STATUS");

Thank you

arun

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hey Arun,

Tables are not quite treated the in the same manner that inputFields are. Check it out:

JCO.ParameterList importList = function.getImportParameterList();

// set import field and table

importList.setValue(myVariable, "SOME_SAP_ INPUT_FIELD");

// retrieve JCO.Table structure from backend

JCO.Table newDataTable = function.getTableParameterList().getTable("ORDERDATA");

// append data to Table

newDataTable.appendRow();

// these are the column names of the 'import' table

newDataTable.setValue(myVar1, "ORDERDATA_COLUMN_1");

newDataTable.setValue(myVar2, "ORDERDATA_COLUMN_2");

...

newDataTable.setValue(myVar5, "ORDERDATE_COLUMN_5");

// call the function module

client.execute(function);

Hopefully that helps,

Mike

P.S. if you are dev'ing for EP6.0 you should be using the JCA instead of the JCo.

Former Member
0 Kudos

How to pass table through JCA to a BAPI ??

Former Member
0 Kudos

Bhabesh,

I would suggest that you read the document 'JCA on EP6 Building Portal Applications' which can be found right here on the SDN. It shows you all you need to know about using the JCA

Cheers,

Mike

david_fryda2
Participant
0 Kudos

Hi,

I am calling a BAPI via JCo. Everything works except when the BAPI has an input field of type sy_datum.

In my Java code, I write : "newDataTable.setValue("01.01.2003", fieldName)" or "newDataTable.setValue(("01012003", fieldName)" and so on.

I get an exception that says that the Object passed is not accepted. So what I did is passing an Date Object like this : newDataTable.setValue(new Date("01.01.2003"), fieldName)" .

Can You help me this stuff ?

Thank you.

Former Member
0 Kudos

Hi can anybody tell me how to do this for the JCA framework?

I've tried to search for the document 'JCA on EP6 Building Portal Applications' as suggested but couldn't find it anywhere.

Please provide me with some sample coding if possible.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi david fryda,

I faced the same problem, The format of the Date should be different. it should be 8 characters total in the format yyyymmdd continously.

Hope that this helps.

Thank you

arun

david_fryda2
Participant
0 Kudos

Hi,

You did help me with the format.

Now I am facing another problem : retrieving the next line of a table returned by a BAPI.

I am only getting the first line of the table. How can I parse all the lines of the table ?

NB : I am using JCO.

Thanx

gregorw
Active Contributor
0 Kudos

Hello DAvid,

have a look at the Example2.java coming with JCo.

Regards

Gregor