我使用 CAP NG 创建了一个项目,我使用 VDM 从位于https://sapes5.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/的 ES5 后端提取 BusinessPartners 。我成功导入了 EDMX,并且类也是用 VDM 生成的。但是,如果我尝试从 BusinessPartner 类中获取方法,许多“设置”方法都没有公开,正如您从这张图片中看到的那样:
如果我尝试像在这段代码中那样手动创建 BusinessPartner 实体:
@On(event = CdsService.EVENT_READ, entity = "CatalogService.BusinessPartner")
public void getBusinessPartners(CdsReadEventContext context) {
log.info("Entering " + getClass().getSimpleName() + ":getBusinessPartners");
System.out.println("Entering " + getClass().getSimpleName() + ":getBusinessPartners");
// Get name of destination for ECC
final String DESTINATION_HEADER_KEY = "es5";
final Map<Object, Map<String, Object>> result = new HashMap<>();
try {
HttpDestination dest = DestinationAccessor.getDestination(DESTINATION_HEADER_KEY).asHttp();
final List<BusinessPartner> businessPartners = new DefaultGWSAMPLEBASICService().getAllBusinessPartner()
.top(5).executeRequest(dest);
final List<cds.gen.catalogservice.BusinessPartner> capBusinessPartners = new ArrayList<>();
int i = 0;
for (final BusinessPartner bp : businessPartners) {
final cds.gen.catalogservice.BusinessPartner capBusinessPartner = com.sap.cds.Struct
.create(cds.gen.catalogservice.BusinessPartner.class);
i = i + 1;
capBusinessPartner.setBusinessPartnerID("010000000" + i);
capBusinessPartner.setCompanyName("SAP");
capBusinessPartner.setEmailAddress("info@acme.com");
capBusinessPartner.setPhoneNumber("474848848");
// capBusinessPartner.setBusinessPartnerID(bp.);
// capBusinessPartner.setFirstName(s4BusinessPartner.getFirstName());
// capBusinessPartner.setSurname(s4BusinessPartner.getLastName());
// capBusinessPartner.setId(s4BusinessPartner.getBusinessPartner());
// capBusinessPartner.setSourceDestination(destinationName);
capBusinessPartners.add(capBusinessPartner);
}
capBusinessPartners.forEach(capBusinessPartner -> {
result.put(capBusinessPartner.getBusinessPartnerID(), capBusinessPartner);
});
} catch (Exception e) {
log.info(e.getMessage());
System.out.println(e.getMessage());
}
context.setResult(result.values());
}
他们根本没有检索。我只是得到一个空白页: 我的项目在这里https://github.com/simfer/myspringbootapp我正在试用版环境中使用 SAP Business Application Studio。
西马科