cancel
Showing results for 
Search instead for 
Did you mean: 

Please can any one tell me whether my code is correct or not......?

Former Member
0 Kudos

Hi

I have create on webservice for edit the customer details. I have imported this into my model.I got the stucture of the model like following

ChangeAddressModel

...|-----Request_Z_Bapi_Customer_Change_WS_CustomerChange

..........|-----parameters(ComplexType_CustomerChangeFromData)

..................|-----ComplexType_CustomerChangeFromData

.........................|------piAddress(ComplexType_Bapikna101)

.........................|........|-----ComplexType_Bapikna101

.........................|................|-- city

.........................|................|-- country

.........................|................|-- faxNumber

.........................|................|-- .......etc

.........................|----- customerNo

.........................|----- piDistrChan

.........................|----- piDivision

.........................|----- piSaleOrg

I have written the following code in CustomCutroller


Request_Z_BAPI_CUSTOMER_CHANGE_WS_customerChangeFromData customer = new Request_Z_BAPI_CUSTOMER_CHANGE_WS_customerChangeFromData();
	ComplexType_CustomerChangeFromData dataStructure = new ComplexType_CustomerChangeFromData();
	
	ComplexType_Bapikna101 bapi = new ComplexType_Bapikna101();
	customer._setUser("abap");
	customer._setPassword("quinnox");
	
	customer.setParameters(dataStructure);
	
	wdContext.nodeRequest_Z_Bapi_Customer_Change().bind(customer);

The following code is for executing the Bapi

public void executeChangeAddress( )
  {
    //@@begin executeChangeAddress()
    try{
		
    	wdContext.currentRequest_Z_Bapi_Customer_ChangeElement().modelObject().execute();
    	wdContext.nodeResponse().invalidate();
    }catch(Exception e){
    	wdComponentAPI.getMessageManager().reportException("Error :"+e,true);
    }
    //@@end
  }

But i am getting the following error........

<b> com.sap.engine.services.webservices.jaxrpc.exceptions.XmlMarshalException: XML Serialization Error. Property [PiAddress] of class [com.sap.changeaddress.model.proxies.types.p1.CustomerChangeFromData] must exist and can not be null. This is required by schema description.</b>

I have done one more for fetching the customer details which is working fine

Please help me

Best Regards

Ravi Shankar B

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

HI RaviShankar,

THe reason is ,there are seperate classes generated for context(component...) and model.if you see the generated clall you will come to know.

the situataions like if you create an object for model and for got create element for context your context will not allow you set the value.

if you do in the reverse way context will allow but rfc will not get any value so it will not will desired results

with Regards

Naidu

Former Member
0 Kudos

HI Balaram

I think my problem is same context is allowing but rfc is not getting any value thats why its not giving any desired results...that may be the reason i am still getting the following error

<b>Error in Controller java.rmi.RemoteException: Service call exception; nested exception is: com.sap.engine.services.webservices.jaxrpc.exceptions.XmlMarshalException: XML Serialization Error. Property [PiAddress] of class [com.sap.customer.address.model.proxies.types.p1.CustomerChangeFromData] must exist and can not be null. This is required by schema description.</b>

Now how to set these values to rfc. How to resolve this problem.... Can u give the any suggessions.

I am able to set values to <b>CUSTOMERNO,SALESORG,PIDIVISION and PIDISTR.</b>. I am unable to set piAddress values to rfc

I am executing the function like this

<b>wdContext.currentRequest_Z_Bapi_Customer_ChangeElement().modelObject().execute();

wdContext.nodeResult().invalidate();

wdContext.nodeResponse().invalidate();</b>

It will be very helpful to me...

Best Regards

Ravi Shankar B

Message was edited by:

RaviShankar B

Message was edited by:

RaviShankar B

Message was edited by:

RaviShankar B

Former Member
0 Kudos

Hi RaviShankar,

sorry ,you can use IPublicChangeAddressCustomController

when type wdcntext.createcreateComplexType_CustomerChangeFromDataElement you will get this return type

With Regards

Naidu

Former Member
0 Kudos

HI

Thanks for u help. Now i am able to insert the values into the appropriate fileds but still i am getting the following error.....

<b>Error in Controller java.rmi.RemoteException: Service call exception; nested exception is: com.sap.engine.services.webservices.jaxrpc.exceptions.XmlMarshalException: XML Serialization Error. Property [PiAddress] of class [com.sap.customer.address.model.proxies.types.p1.CustomerChangeFromData] must exist and can not be null. This is required by schema description.</b>

I have tested the WSDL file its working fine. The same inputs i have given inputs in my program but still i am getting the above error..... Can u please resolve my problem.

I am very thankful to u for u solution. I am trying to insert values into fields from past three days.Your solution is very helpful to me. Can u tell me one more thing why do we need to create a element. Why cant we insert directly.

Best Regards

Ravi Shankar B.

Former Member
0 Kudos

Hi Ravishankar,

try followiing code

Request_Z_BAPI_CUSTOMER_CHANGE_WS_customerChangeFromData customer = new Request_Z_BAPI_CUSTOMER_CHANGE_WS_customerChangeFromData();

ComplexType_CustomerChangeFromData dataStructure = new ComplexType_CustomerChangeFromData();

ComplexType_Bapikna101 bapi = new ComplexType_Bapikna101();

bapi.setCity("");

bapi.setCountry("");

bapi.setFaxNumber("");

dataStructure .setPiAddress(bapi);

customer._setUser("abap");

customer._setPassword("quinnox");

customer.setParameters(dataStructure);

wdContext.nodeRequest_Z_Bapi_Customer_Change().bind(customer);

iPrivate<controllername>.IComplexType_CustomerChangeFromDataElement element = wdContext.createComplexType_CustomerChangeFromDataElement(dataStructure);

wdcontext.nodeComplexType_CustomerChangeFromData().addEleemnt(element);

iPrivate<controllername>.IComplexType_Bapikna101 element1 = wdContext.createIComplexType_Bapikna101 (bapi);

wdContext.nodeIComplexType_Bapikna101().addElement(element1);

Hope this helps

With Regards

Balaram Naidu

Former Member
0 Kudos

Hi

I am not getting any inteface like

iPrivateChangeAddressCustomController.IComplexType_CustomerChangeFromDataElement

Best Regrads

Ravi Shankar B

Former Member
0 Kudos

Ravi,

The code should looks like this:


Request_Z_BAPI_CUSTOMER_CHANGE_WS_customerChangeFromData customer =
  new Request_Z_BAPI_CUSTOMER_CHANGE_WS_customerChangeFromData();

ComplexType_CustomerChangeFromData dataStructure 
  = new ComplexType_CustomerChangeFromData();
	
ComplexType_Bapikna101 bapi = new ComplexType_Bapikna101();

/* THIS LINE IS MISSING IN YOUR CODE */
dataStructure.setPiAddress(bapi);

customer._setUser("abap");
customer._setPassword("quinnox");
	
customer.setParameters(dataStructure);
	
wdContext.nodeRequest_Z_Bapi_Customer_Change().bind(customer);

VS

Former Member
0 Kudos

Hi

I have done the same thing but still i am getting the same error

Best Regards

Ravi Shankar B

Former Member
0 Kudos

ChangeAddressModel

...|-----Request_Z_Bapi_Customer_Change_WS_CustomerChange

..........|-----parameters(ComplexType_CustomerChangeFromData)

..................|-----ComplexType_CustomerChangeFromData

.........................|------piAddress(ComplexType_Bapikna101)

.........................|........|-----ComplexType_Bapikna101

.........................|................|-- city

.........................|................|-- country

.........................|................|-- faxNumber

.........................|................|-- .......etc

.........................|----- customerNo

.........................|----- piDistrChan

.........................|----- piDivision

.........................|----- piSaleOrg

I have written the following code in CustomCutroller

Request_Z_BAPI_CUSTOMER_CHANGE_WS_customerChangeFromData customer = new Request_Z_BAPI_CUSTOMER_CHANGE_WS_customerChangeFromData();

ComplexType_CustomerChangeFromData dataStructure = new ComplexType_CustomerChangeFromData();

ComplexType_Bapikna101 bapi = new ComplexType_Bapikna101();

bapi.setCity("");

bapi.setCountry("");

bapi.setFaxNumber("");

dataStructure .setPiAddress(bapi);

customer._setUser("abap");

customer._setPassword("quinnox");

customer.setParameters(dataStructure);

wdContext.nodeRequest_Z_Bapi_Customer_Change().bind(customer);

The following code is for executing the Bapi

public void executeChangeAddress( )

{

//@@begin executeChangeAddress()

try{

wdContext.currentRequest_Z_Bapi_Customer_ChangeElement().modelObject().execute();

wdContext.nodeResponse().invalidate();

}catch(Exception e){

wdComponentAPI.getMessageManager().reportException("Error :"+e,true);

}

//@@end

}

try this it might helps you.

Thanks,

Lohi.

Message was edited by:

Lohitha M

Former Member
0 Kudos

Hi

I have done the same and i am also trying to print the CITY in executeMethod like this

[b

]wdComponentAPI.getMessageManager().reportSuccess("City "+wdContext.currentPiAddressElement().getCity());</b>

in custom Controller but i am getting null value..

I have printed the following values in executeMethod of CustomController and i am getting the values which are under the <b>piAddress</b>

CustomerNo

piDistrChan

piDivision

piSaleOrg

I am also trying to print the "CITY,COUNTRY...etc" values in executeMethod of CustomController but i am getting null which are under <b>CompexType_Bapikna101</b>

Help me.

Best Regards

Ravi Shankar B

Former Member
0 Kudos

Hi

Please Can any one help me

Best Regards

Ravi Shankar B

Former Member
0 Kudos

I think you missed out the following statement

dataStructure .set XXX (bapi);

Regards,Anilkumar

Former Member
0 Kudos

Hi

I have done the same but still i am getting the same error...

Best Regards

Ravi Shankar B