cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

#CoE#MKI How to set up additional custom items in Java using the SOAP API of Journal Entry Post

k-fuji2458
Explorer
0 Kudos
700

We are developing a function to register accounting vouchers in Java, but when we try to register CustomFields, we get the error "cannot null" even though we have set the value.

I am thinking that the error "null" may be caused by not being able to set the namespace yy1 in SOAP Envelop.

Please tell me how to add namespace to SOAP Envelop in the ServiceStab Java generated from WSDL.

We believe that namespace can be added by modifying the following source code in ServiceStab.java automatically generated by Axis2 from the WSDL.

      // create SOAP envelope with that payload
      org.apache.axiom.soap.SOAPEnvelope env = null;

      env =
          toEnvelope(
              getFactory(_operationClient.getOptions().getSoapVersionURI()),
              journalEntryBulkCreateRequest0,
              optimizeContent(
                  new javax.xml.namespace.QName(
                      "http://sap.com/xi/SAPSCORE/SFIN",
                      "journalEntryCreateRequestConfirmation_In")),
              new javax.xml.namespace.QName(
                  "http://sap.com/xi/SAPSCORE/SFIN", "JournalEntryBulkCreateRequest"));

Accepted Solutions (1)

Accepted Solutions (1)

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert

Hi kento_fujita,

Are you converting the wsdl file directly downloaded from the s/4 instance or are you downloading it from the documentation?

My understanding is that if you have custom fields, you also have a custom wsdl containing such fields and their corresponding namespaces. This should be the one used in axis2 to generate the java proxy classes. This in turn will make the namespaces available in the proxy classes - so there is no need to "adapt" the generated clases to your needs. If so, your wsdl could be obtained directly through the instance - check the following blog:

https://blogs.sap.com/2019/02/15/user-guide-for-journal-entry-post-api-on-s4-hana-cloud

---> Item 4.2.3

Best regards,
Ivan

Answers (2)

Answers (2)

junaidalam
Product and Topic Expert
Product and Topic Expert
0 Kudos

hi k-fuji2458 - Can you please suggest that your issue has been resolved. Is there any thing related to this post we can help you with.

Junaid

k-fuji2458
Explorer

Hi junaid.alam1976 ,

I'm sorry I haven't been in touch with you.

I was able to resolve this issue by modifying the logic in the class generated from the WSDL.

Thank you for your support.

Best Regards, Kento

k-fuji2458
Explorer
0 Kudos

Hi ivan.mirisola,

We are using classes generated by Axis2 from the WSDL downloaded from the S/4HANA Cloud instance.

This is how we set the values.

        YY1_BP_Outside_type1 type1 = new YY1_BP_Outside_type1();
        type1.setYY1_BP_Outside_type0(list.get(1).get(12));
        YY1_U4K2EPYMXDLMYBRKUZDI33CJP4_YY1_BP_Outside customerItem1 = new YY1_U4K2EPYMXDLMYBRKUZDI33CJP4_YY1_BP_Outside();
        customerItem1.setYY1_BP_Outside(type1);
        accountAssignmentItem1.setYY1_U4K2EPYMXDLMYBRKUZDI33CJP4_YY1_BP_Outside(customerItem1);

However, I am getting a cannot null error in this section.

JournalEntryCreateRequestJournalEntryItemAccountAssignment.java

    if (localYY1_U4K2EPYMXDLMYBRKUZDI33CJP4_YY1_BP_Outside == null) {
      throw new org.apache.axis2.databinding.ADBException(
          "YY1_U4K2EPYMXDLMYBRKUZDI33CJP4_YY1_BP_Outside cannot be null!!");
    }
    localYY1_U4K2EPYMXDLMYBRKUZDI33CJP4_YY1_BP_Outside.serialize(null, xmlWriter);

Is there something wrong with the way I am setting the values for the items?

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi kento_fujita,

Would you mind sharing your wsdl file here (you can replace your real hostname with localhost).

Also, could you please share the complete code for your servlet (or the part where you consume the generated classes).

Best regards,
Ivan