Technical Articles
How to get ByDesign Code Lists via Web Service QueryCodeListIn
SAP Business ByDesign provides the web service QueryCodeListIn to query and read ByD code lists.
You’ll find a documentation of the web service on SAP Business ByDesign – SAP Help Portal Page > Web Service APIs.
Below, I explain how to use web service QueryCodeListIn in context of other ByD web services.
Example Scenario
Assume we have a master data integration scenario in which we query, read, create and update accounts in ByD. ByD web services for accounts always request and return language-independent codes, for example industrial sector code 23 (meaning “Construction”).
However, for some integration scenarios the code description is required as well, to be able to display account data in a human readable form.
How to use web service QueryCodeListIn?
The request signature of web service QueryCodeListIn mainly contain 3 elements:
- Code data type name
- Code data type namespace
- Language code
The code data type specifies the data type for which the code list shall be requested.
The language code specifies in which language the code list descriptions shall be returned.
The key question is: How do I get the code data type name and namespace?
Step 1:
Get the WSDL of the web service which used the code; in our example scenario QueryCustomerIn or ManageCustomerIn.
You can download the web service WSDL via ByD UI, work center view Application and User Management > Communication Arrangements.
The code data type name and namespace URI are provided by the WSDL of the account/contact web service (the data type of the corresponding element):
Step 2:
Get the code data type name from the WSDL:
Step 3:
Get the code data type namespace URI from the WSDL:
Now you have all information available to query the code list for industrial sector codes:
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:glob=”http://sap.com/xi/SAPGlobal20/Global“>
<soapenv:Header/>
<soapenv:Body>
<glob:CodeListByIDQuery_sync>
<CodeListSelectionByID>
<SelectionByCodeDataType>
<Name>IndustrialSectorCode</Name>
<NamespaceURI>http://sap.com/xi/AP/Common/GDT</NamespaceURI>
</SelectionByCodeDataType>
<SelectionByLanguageCode>EN</SelectionByLanguageCode>
</CodeListSelectionByID>
</glob:CodeListByIDQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
… some more Query Code List Request Examples
Country Codes:
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:glob=”http://sap.com/xi/SAPGlobal20/Global“>
<soapenv:Header/>
<soapenv:Body>
<glob:CodeListByIDQuery_sync>
<CodeListSelectionByID>
<SelectionByCodeDataType>
<Name>CountryCode</Name>
<NamespaceURI>http://sap.com/xi/AP/Common/GDT</NamespaceURI>
</SelectionByCodeDataType>
<SelectionByLanguageCode>EN</SelectionByLanguageCode>
</CodeListSelectionByID>
</glob:CodeListByIDQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Region Codes:
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:glob=”http://sap.com/xi/SAPGlobal20/Global“>
<soapenv:Header/>
<soapenv:Body>
<glob:CodeListByIDQuery_sync>
<CodeListSelectionByID>
<SelectionByCodeDataType>
<Name>RegionCode</Name>
<NamespaceURI>http://sap.com/xi/AP/Common/GDT</NamespaceURI>
</SelectionByCodeDataType>
<SelectionByLanguageCode>EN</SelectionByLanguageCode>
<SelectionByContext>
<Parameter>
<Name>CountryCode</Name>
<Value>DE</Value>
<ListAgencyID></ListAgencyID>
</Parameter>
</SelectionByContext>
</CodeListSelectionByID>
</glob:CodeListByIDQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Customer ABC Classification Codes:
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:glob=”http://sap.com/xi/SAPGlobal20/Global“>
<soapenv:Header/>
<soapenv:Body>
<glob:CodeListByIDQuery_sync>
<CodeListSelectionByID>
<SelectionByCodeDataType>
<Name>CustomerABCClassificationCode</Name>
<NamespaceURI>http://sap.com/xi/AP/Common/GDT</NamespaceURI>
</SelectionByCodeDataType>
<SelectionByLanguageCode>EN</SelectionByLanguageCode>
</CodeListSelectionByID>
</glob:CodeListByIDQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Company Legal Form Codes:
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:glob=”http://sap.com/xi/SAPGlobal20/Global“>
<soapenv:Header/>
<soapenv:Body>
<glob:CodeListByIDQuery_sync>
<CodeListSelectionByID>
<SelectionByCodeDataType>
<Name>CompanyLegalFormCode</Name>
<NamespaceURI>http://sap.com/xi/AP/Common/GDT</NamespaceURI>
</SelectionByCodeDataType>
<SelectionByLanguageCode>EN</SelectionByLanguageCode>
</CodeListSelectionByID>
</glob:CodeListByIDQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Tax Rate Type Codes:
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:glob=”http://sap.com/xi/SAPGlobal20/Global“>
<soapenv:Header/>
<soapenv:Body>
<glob:CodeListByIDQuery_sync>
<CodeListSelectionByID>
<SelectionByCodeDataType>
<Name>TaxRateTypeCode</Name>
<NamespaceURI>http://sap.com/xi/AP/Common/GDT</NamespaceURI>
</SelectionByCodeDataType>
<SelectionByLanguageCode>EN</SelectionByLanguageCode>
<SelectionByContext>
<Parameter>
<Name>CountryCode</Name>
<Value>DE</Value>
<ListAgencyID></ListAgencyID>
</Parameter>
<Parameter>
<Name>TaxTypeCode</Name>
<Value>2</Value>
<ListAgencyID></ListAgencyID>
</Parameter>
</SelectionByContext>
</SelectionByContext>
</CodeListSelectionByID>
</glob:CodeListByIDQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Chart of Account Codes:
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:glob=”http://sap.com/xi/SAPGlobal20/Global“>
<soapenv:Header/>
<soapenv:Body>
<glob:CodeListByIDQuery_sync>
<CodeListSelectionByID>
<SelectionByCodeDataType>
<Name>ChartOfAccountsCode</Name>
<NamespaceURI>http://sap.com/xi/AP/FinancialAccounting/Global</NamespaceURI>
</SelectionByCodeDataType>
<SelectionByLanguageCode>EN</SelectionByLanguageCode>
</CodeListSelectionByID>
</glob:CodeListByIDQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Chart of Account Item Codes:
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:glob=”http://sap.com/xi/SAPGlobal20/Global“>
<soapenv:Header/>
<soapenv:Body>
<glob:CodeListByIDQuery_sync>
<CodeListSelectionByID>
<SelectionByCodeDataType>
<Name>ChartOfAccountsItemCode</Name>
<NamespaceURI>http://sap.com/xi/AP/FinancialAccounting/Global</NamespaceURI>
</SelectionByCodeDataType>
<SelectionByLanguageCode>EN</SelectionByLanguageCode>
<SelectionByContext>
<Parameter>
<Name>ChartOfAccountsCode</Name>
<Value>CAAT</Value>
<ListAgencyID></ListAgencyID>
</Parameter>
</SelectionByContext>
</CodeListSelectionByID>
</glob:CodeListByIDQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Accounting Document Type Code (aka Journal Entry Type Code):
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:glob=”http://sap.com/xi/SAPGlobal20/Global“>
<soapenv:Header/>
<soapenv:Body>
<glob:CodeListByIDQuery_sync>
<CodeListSelectionByID>
<SelectionByCodeDataType>
<Name>AccountingDocumentTypeCode</Name>
<NamespaceURI>http://sap.com/xi/AP/FinancialAccounting/Global</NamespaceURI>
</SelectionByCodeDataType>
<SelectionByLanguageCode>EN</SelectionByLanguageCode>
</CodeListSelectionByID>
</glob:CodeListByIDQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Object Type Codes (for example Journal Entry Source Document Type Codes):
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:glob=”http://sap.com/xi/SAPGlobal20/Global“>
<soapenv:Header/>
<soapenv:Body>
<glob:CodeListByIDQuery_sync>
<CodeListSelectionByID>
<SelectionByCodeDataType>
<Name>ObjectTypeCode</Name>
<NamespaceURI>http://sap.com/xi/Common/DataTypes</NamespaceURI>
</SelectionByCodeDataType>
<SelectionByLanguageCode>EN</SelectionByLanguageCode>
</CodeListSelectionByID>
</glob:CodeListByIDQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Industry Classification System Code and Industrial Sector Code:
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:glob=”http://sap.com/xi/SAPGlobal20/Global“>
<soapenv:Header/>
<soapenv:Body>
<glob:CodeListByIDQuery_sync>
<CodeListSelectionByID>
<SelectionByCodeDataType>
<Name>IndustrialSectorCode</Name>
<NamespaceURI>http://sap.com/xi/AP/Common/GDT</NamespaceURI>
</SelectionByCodeDataType>
<SelectionByLanguageCode>EN</SelectionByLanguageCode>
<SelectionByContext>
<Parameter>
<Name>IndustryClassificationSystemCode</Name>
<Value>0005</Value>
<ListAgencyID></ListAgencyID>
</Parameter>
</SelectionByContext>
</CodeListSelectionByID>
</glob:CodeListByIDQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Payment Method / Payment Form Code
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:glob=”http://sap.com/xi/SAPGlobal20/Global“>
<soapenv:Header/>
<soapenv:Body>
<glob:CodeListByIDQuery_sync>
<CodeListSelectionByID>
<SelectionByCodeDataType>
<Name>PaymentFormCode</Name>
<NamespaceURI>http://sap.com/xi/AP/Common/GDT</NamespaceURI>
</SelectionByCodeDataType>
<SelectionByLanguageCode>EN</SelectionByLanguageCode>
</CodeListSelectionByID>
</glob:CodeListByIDQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Hi Knut,
Thank you for this great explanation.
Do you use it also for customer specific fields? We actually work with SAP Cloud for Customer (same Codebase and WebServices like ByD). But we face the problem that the QueryCodeListIn only works for standard fields.
BR
Roberto
Knut, Thanks for this it is really useful. I am trying to extract a few more challenging options which I can't seem to find.
Would you open to an email if I gave a you a short list of what we are looking for?
BR
Simon
Hi Knut,
Thanks for your wonderful blog.
Can we get Custom Codelists using the service QueryCodeListIn.
I have a requirement to fetch all the custom codelists which will be used by ECC team.
Regards
Navin
Dear Knut
Thanks for you great blog.
I would like to query the cash discount terms from supplier.
I got the Name and the Namespace, but I guess the Parameter are missing.
How I now which parameter i have to use?
Thanks for your support.
best regards
Jasmin Schaad
Hi Jasmin,
are you looking for the code list used for supplier - purchasing data - cash discount terms?
Here it is:
Best regards,
Knut
Knut Heusermann Good Informative Blog But How to get the List of code data type name and code data type namespace URI from the WSDL. Kindly Explain with one Standard Web service and What Parameters need to be inputted to get the code data type name and code data type namespace URI for the WSDL.
Hi Kamalesh,
you get all code lists using the same web service: QueryCodeListIn. The WSDL of this web service and all other web services can be retrieved via the WSIL-URL: https://myXXXXXX.sapbydesign.com/sap/ap/srt/wsil.
Best regards,
Knut
Hi Kamalesh
How do customers make adjustment on the code list?
Kindly Regards
Edwin Bliss
Thank you Knut Heusermann for this useful blog. I would like to extract codes and their related description for extension fields we have created in the Product master data. Is it possible?
I've tried with the querymaterialin wsdl but I have this error description: "The detailed error description may not be available in logon language: Message "CodeListByIDQuery_sync{http://sap.com/xi/SAPGlobal20/Global}" not supported (interface: "QUERYMATERIALIN" binding key:"
Thank you
Thibaut
Hi Thibaut,
the error message looks like you send the xml-request for the code list to the endpoint of service QueryMaterialIn. Please check and make sure to use the endpoint of service QueryCodeListIn.
Best regards, Knut
Hello Knut,
Thank you for this blog post.
I am trying to fetch codes for key user extension fields in the product master data.
I have tried every namespace found in the querymaterialin WSDL, but I always get error Data type does not exist; check combination of Name and NamespaceURI
And it's the same for other codes on the product master data.
Could you advise on this ? Do you have a code example to get codes of the product data fields ?
Regards,
Benjamin
Hi Benjamin,
please find a short guideline below.
Best regards,
Knut
How to get code lists of extension fields using web service QueryCodeListIn?
Starting point: You created a key user extension field of type "List" with a multi-lingual code list with code values and descriptions (in my example the extension field name is "KHCode" and I added the extension field to the materials screen). Then you add the extension field to one or more SOAP services (e.g. web service "Manage Materials").
Download the web service WSDL (e.g. of service ManageMaterialIn) and look for the key user extension field in the WSDL. Get the data type and the name space of the key user extension field from the schema definition:
Create the code list request for web service QueryCodeListIn using the technical key user extension field name and the namespace:
Please note: you can get code lists via Custom OData services as well (see https://github.com/SAP/sapbydesign-api-samples).
Hi,
Great it worked, thanks Knut.
Hi Knut,
Thank you for this very helpful blog post.
I am working on a solution to create Suppliers using the SOAP webservice ManageSupplierIn, and I am struggeling with the WithholdingTaxClassification section.
If I try to fill the TaxTypeCode parameter with the values that I got for this Country from the QueryCodeListIn repsonse I keep getting errors.
The TaxTypeCode codes I received for the country BD:
"BD","1","Value Added Tax"
"BD","304","Withholding Tax_BD"
SOAP part of the Code:
<WithholdingTaxClassification actionCode="01">
<CountryCode>BD</CountryCode>
<TaxTypeCode listID="">304</TaxTypeCode>
</WithholdingTaxClassification>
Error I get is:
TypeID CategoryCode SeverityCode Note
------ ------------ ------------ ----
012(//APBP/SWTC/) INC.BOI 3 You cannot assign tax type 304 to country BD for withholding tax classifications.
Do you have any guidance how I map the codes to the SOAP request?
Hi Knut Heusermann
Thanks for the informative blog. We are planning to use QueryCodeListIn webservice to retrieve all the fields of type code list from C4C to our data lake environment using CPI as a middleware.
When we tested this service in SOAP UI we were not able to prepare a request payload which can fetch multiple code list values in a single call.
Since our requirement is to fetch all code list values from C4C ,it would not be a good idea to make individual call for each field of type code list.
Could you please let me know how we can achieve this requirement.
Thanks in advance for your support.
Regards
Navin
Hi Navin,
Using the web service QueryCodeListIn you can retrieve one code list per call only.
You may use Customer OData Service with code lists and OData-batch requests to retrieve multiple code lists in a single service roundtrip; but here I'm only familar with the details in ByD and not 100% sure if this works the same in C4C. Might be a good question for the C4C community.
Best regards,
Knut