cancel
Showing results for 
Search instead for 
Did you mean: 

Help regarding Rfc_Read_table

Former Member
0 Kudos

Hi All,

Can anybody have the code related to call rfc_read_table bapi from webdynpro. I wrote the code like

try {

Rfc_Read_Table_Input input = new Rfc_Read_Table_Input ();

wdContext.nodeRfc_Read_Table_Input().bind(input);

Rfc_Db_Opt optionValue = new Rfc_Db_Opt ();

input.setQuery_Table("/BIC/AZEMPLOYE00");

optionValue.setText("USERNAME LIKE 'suresh');

wdContext.nodeRfc_Read_Table_Input().bind(input);

input.addOptions(optionValue);

wdContext.currentRfc_Read_Table_InputElement().modelObject().execute();

} catch (WDDynamicRFCExecuteException e) {

// TODO Auto-generated catch block

mgr.reportException("EXception "+e, true);

}

It is giving 0 results.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Problem solved

ashish_shah
Contributor
0 Kudos

Hi ,

Can you share your solution with us?

Regards,

Ashish shah

ashish_shah
Contributor
0 Kudos

Hi,

The following code may be used for fetching data from RFC_READ_TABLE.


IPublic<app>.IRfc_Read_Table_InputNode rfcNode =
			wdContext.nodeRfc_Read_Table_Input();

		try {

			Rfc_Read_Table_Input input =
				new Rfc_Read_Table_Input();
			input.setQuery_Table("<tablename>");
			input.setDelimiter("|");

			Rfc_Db_Fld fieldValue = new Rfc_Db_Fld();
			fieldValue.setFieldname("<field1>");
			input.addFields(fieldValue);

			fieldValue = new Rfc_Db_Fld();
			fieldValue.setFieldname("<field2>");
			input.addFields(fieldValue);

			Rfc_Db_Opt optionValue = new Rfc_Db_Opt ();
			optionValue.setText(" USERNAME LIKE 'abc' ");
			input.addOptions(optionValue);

			rfcNode.bind(input);

			wdContext
				.currentRfc_Read_Table_InputElement()
				.modelObject()
				.execute();
			wdContext.nodeOutput().invalidate();
		} 
		
		catch (WDDynamicRFCExecuteException e) {
			//	   TODO Auto-generated catch block
			mgr.reportException("EXception " + e, true);
		}

Ashish shah

Former Member
0 Kudos

hi

only one solution......

go in bapi and change little programing .......instade of space change to comma(,)

then it is possible.....

and even sequense is also important because it is going to use in programing...

with regards

jayesh talreja

Former Member
0 Kudos

wdContext.nodeRfc_Read_Table_Input().bind(input);

input.addOptions(optionValue);

in above to line......

first add option value.......i.e.input.addOptions(optionValue);

then bind....

ok

Former Member
0 Kudos

Hi,

Thanks fro your response. I Got the result what I want with my code only, the issue I was faced with setting the input parameter, any way thanks for your code.

One more issue I am facing here is my output table has 20 fields and those fields are comming as one whole string. I want to display those in view with different UI elements.Do you have any idea regarding my issue?

Former Member
0 Kudos

HI,

Do you mean that you have got a single output parameter in your RFC which returns you a single string message that you need to break and display in different UI elements in WD.

Also, reply is this output in form of some comma seperated string or something like that.

Regards,

Murtuza

Former Member
0 Kudos

When we execute Rfc_Read_Table function module it will give two tables as output one is for fields and another one is for records based on our query, but the table for the records is comming as one string and the string is comming as spaces for every record in the whole string.

The Tabales for the output are : Fields and Data

Actual output is comming in Data table, the table has only one field.

Former Member
0 Kudos

r u returning single string or single attribute from RFC ........

one option is take all fields from RFC in different attributes

or using coding u have to seperate all attribute and then u have to disply

with regards

jayesh talreja

Former Member
0 Kudos

Hi,

You can get the values from the nodes as follow:

wdContext.node<nodename>().get<nodename>ElementAt(<index>).get<attributename>();

For breaking your single space seperated string you can use this:

StringTokenizer st = new StringTokenizer(<outputstring>," ");

while(st.hasMoreElements())

{

wdComponentAPI.getMessageManager().reportSuccess(st.nextToken());

//your logic

}

Regards,

Murtuza

Former Member
0 Kudos

Actauallu when we execute that bapi the table itself is giving as one string and the output is comming as single string with the collection attributes. I can seperate those records onlt with the spaces but for some attributes are having spaces(For ex: the country name "United States"). Is there any other solution to resolve my issue?

Former Member
0 Kudos

hi......

Z_Admin_Schadd_Input obj_add = new Z_Admin_Schadd_Input();

Zschedule_Table obj_add_table = new Zschedule_Table();

obj_add_table.setAgency(wdContext.currentContextElement().getCtx_agency());

obj_add_table.setBatchsize(wdContext.currentContextElement().getCtx_batch_size());

obj_add_table.setDuration(wdContext.currentContextElement().getCtx_duration());

Date temp1 =Date.valueOf(wdContext.currentContextElement().getCtx_e_date().toString());

obj_add_table.setE_Date(temp1);

obj_add_table.setE_Time(wdContext.currentContextElement().getCtx_e_time());

obj_add_table.setFactype(wdContext.currentContextElement().getCtx_fac_type());

obj_add_table.setFaculty(wdContext.currentContextElement().getCtx_faculty());

obj_add_table.setLoc(wdContext.currentContextElement().getCtx_location());

Date temp =Date.valueOf(wdContext.currentContextElement().getCtx_s_date().toString());

obj_add_table.setS_Date(temp);

obj_add_table.setS_Time(wdContext.currentContextElement().getCtx_s_time());

obj_add_table.setSeat_Avail(wdContext.currentContextElement().getCtx_seats_aval());

obj_add_table.setSeat_Res(wdContext.currentContextElement().getCtx_seats_res());

obj_add_table.setVenue(wdContext.currentContextElement().getCtx_venue());

short select = 1;

obj_add.setI_Select(select);

obj_add.addIt_Adm(obj_add_table);

wdContext.nodeZ_Admin_Schadd_Input().bind(obj_add);

try

{

wdContext.currentZ_Admin_Schadd_InputElement().modelObject().execute();

}

catch (Exception e)

{

wdComponentAPI.getMessageManager().reportSuccess(e.getMessage());

}

wdContext.nodeOutput().invalidate();

i hope this code will be help full for u