com.sap.cloud.sdk.s4hana.datamodel.bapi.functions.DefaultAcctngManCostAllocCheckFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bapi-api Show documentation
Show all versions of bapi-api Show documentation
Generated classes of the SAP S/4HANA Virtual Data Model (VDM) for BAPIs.
/*
* Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
*/
package com.sap.cloud.sdk.s4hana.datamodel.bapi.functions;
import javax.annotation.Nonnull;
import com.google.common.collect.Lists;
import com.sap.cloud.sdk.s4hana.connectivity.ErpConfigContext;
import com.sap.cloud.sdk.s4hana.connectivity.exception.QueryExecutionException;
import com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiQuery;
import com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiQueryResult;
import com.sap.cloud.sdk.s4hana.connectivity.rfc.ParameterFields;
import com.sap.cloud.sdk.s4hana.connectivity.rfc.Table;
import com.sap.cloud.sdk.s4hana.connectivity.rfc.TableRow;
import com.sap.cloud.sdk.s4hana.datamodel.bapi.structures.ContainerForCustomerExitParameter;
import com.sap.cloud.sdk.s4hana.datamodel.bapi.structures.DocumentHeaderPostCostsRevenuesActualPostings;
import com.sap.cloud.sdk.s4hana.datamodel.bapi.structures.LineItemsManualCostAllocationActualPosting;
import com.sap.cloud.sdk.s4hana.serialization.ErpBoolean;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import lombok.experimental.Tolerate;
/**
* {@inheritDoc}
*
*/
@ToString
@EqualsAndHashCode
@Accessors(fluent = true)
@RequiredArgsConstructor(access = AccessLevel.PUBLIC)
public class DefaultAcctngManCostAllocCheckFunction
implements AcctngManCostAllocCheckFunction
{
/**
* Document Header Data
*
*/
private final DocumentHeaderPostCostsRevenuesActualPostings docHeader;
/**
* (Optional) Indicator: Ignore Warnings
* Field name: IGNWARN
*
* Type element: BAPIIGNWAR
* Domain name: SYCHAR01
* Internal type: CHAR
* Description: Ignore Warnings
* Max length: 1
*
*
*/
@Setter
private ErpBoolean ignoreWarnings = null;
/**
* Line Item Data
*
*/
@Nonnull
private final Iterable docItems;
/**
* (Optional) Customer Fields
*
*/
@Setter
@Nonnull
private Iterable customerFields = Lists.newArrayList();
/**
* {@inheritDoc}
*
*/
@Override
@Nonnull
public AcctngManCostAllocCheckFunctionResult execute(final ErpConfigContext erpConfigContext)
throws QueryExecutionException
{
final BapiQuery query = toQuery();
final BapiQueryResult queryResult = query.execute(erpConfigContext);
return new DefaultAcctngManCostAllocCheckFunctionResult(queryResult);
}
/**
* {@inheritDoc}
*
*/
@Override
@Nonnull
public AcctngManCostAllocCheckFunctionResult execute()
throws QueryExecutionException
{
return execute(new ErpConfigContext());
}
/**
* {@inheritDoc}
*
*/
@Override
@Nonnull
public BapiQuery toQuery() {
docHeader.validate();
for (LineItemsManualCostAllocationActualPosting item: docItems) {
item.validate();
}
if (customerFields!= null) {
for (ContainerForCustomerExitParameter item: customerFields) {
item.validate();
}
}
final BapiQuery query = new BapiQuery("BAPI_ACC_MANUAL_ALLOC_CHECK");
if (ignoreWarnings!= null) {
query.withExporting("IGNORE_WARNINGS", "BAPIIGNWAR", ignoreWarnings);
}
{
final ParameterFields row = query.withExportingFields("DOC_HEADER", "BAPIDOCHDRU12P");
if (docHeader.getAccPrinciple()!= null) {
row.field("ACC_PRINCIPLE", "ACCOUNTING_PRINCIPLE", docHeader.getAccPrinciple());
}
if (docHeader.getCoArea()!= null) {
row.field("CO_AREA", "KOKRS", docHeader.getCoArea());
}
if (docHeader.getDocdate()!= null) {
row.field("DOCDATE", "CO_BLDAT", docHeader.getDocdate());
}
if (docHeader.getDocHdrTx()!= null) {
row.field("DOC_HDR_TX", "CO_BLTXT", docHeader.getDocHdrTx());
}
if (docHeader.getDocNo()!= null) {
row.field("DOC_NO", "CO_BELNR", docHeader.getDocNo());
}
if (docHeader.getDocType()!= null) {
row.field("DOC_TYPE", "BLART", docHeader.getDocType());
}
if (docHeader.getLedgerGroup()!= null) {
row.field("LEDGER_GROUP", "LEDGER_GROUP", docHeader.getLedgerGroup());
}
if (docHeader.getObjKey()!= null) {
row.field("OBJ_KEY", "AWKEY", docHeader.getObjKey());
}
if (docHeader.getObjSys()!= null) {
row.field("OBJ_SYS", "AWSYS", docHeader.getObjSys());
}
if (docHeader.getObjType()!= null) {
row.field("OBJ_TYPE", "AWTYP", docHeader.getObjType());
}
if (docHeader.getPeriod()!= null) {
row.field("PERIOD", "CO_PERIO", docHeader.getPeriod());
}
if (docHeader.getPostgdate()!= null) {
row.field("POSTGDATE", "CO_BUDAT", docHeader.getPostgdate());
}
if (docHeader.getTransCurr()!= null) {
row.field("TRANS_CURR", "TWAER", docHeader.getTransCurr());
}
if (docHeader.getTransCurrIso()!= null) {
row.field("TRANS_CURR_ISO", "ISOCD", docHeader.getTransCurrIso());
}
if (docHeader.getUsername()!= null) {
row.field("USERNAME", "USNAM", docHeader.getUsername());
}
if (docHeader.getValuedate()!= null) {
row.field("VALUEDATE", "CO_WSDAT", docHeader.getValuedate());
}
if (docHeader.getVariant()!= null) {
row.field("VARIANT", "CO_VARNR", docHeader.getVariant());
}
row.end();
}
if (docItems.iterator().hasNext()) {
final Table table = query.withTable("DOC_ITEMS", "BAPIMAITM");
for (LineItemsManualCostAllocationActualPosting item: docItems) {
final TableRow row = table.row();
if (item.getCostElem()!= null) {
row.field("COST_ELEM", "KSTAR", item.getCostElem());
}
if (item.getItemnoAcc()!= null) {
row.field("ITEMNO_ACC", "POSNR_ACC", item.getItemnoAcc());
}
if (item.getPersonNo()!= null) {
row.field("PERSON_NO", "PERNR_D", item.getPersonNo());
}
if (item.getPostquun()!= null) {
row.field("POSTQUUN", "MEINB", item.getPostquun());
}
if (item.getPostquunIso()!= null) {
row.field("POSTQUUN_ISO", "ISOCD_UNIT", item.getPostquunIso());
}
if (item.getQuantity()!= null) {
row.field("QUANTITY", "MBGXXX", item.getQuantity());
}
if (item.getRecbusproc()!= null) {
row.field("RECBUSPROC", "EPRZNR", item.getRecbusproc());
}
if (item.getReccostobj()!= null) {
row.field("RECCOSTOBJ", "EKSTR", item.getReccostobj());
}
if (item.getRecitem()!= null) {
row.field("RECITEM", "EKDPO", item.getRecitem());
}
if (item.getRecoperatn()!= null) {
row.field("RECOPERATN", "EVORG", item.getRecoperatn());
}
if (item.getRecsaleord()!= null) {
row.field("RECSALEORD", "EKDAU", item.getRecsaleord());
}
if (item.getRecBudgetPeriod()!= null) {
row.field("REC_BUDGET_PERIOD", "FM_EBUDGET_PERIOD", item.getRecBudgetPeriod());
}
if (item.getRecCctr()!= null) {
row.field("REC_CCTR", "EKOSTL", item.getRecCctr());
}
if (item.getRecFunction()!= null) {
row.field("REC_FUNCTION", "EFKTBER", item.getRecFunction());
}
if (item.getRecFund()!= null) {
row.field("REC_FUND", "FM_EFONDS", item.getRecFund());
}
if (item.getRecFundLong()!= null) {
row.field("REC_FUND_LONG", "FM_RGEBER_LONG", item.getRecFundLong());
}
if (item.getRecGrant()!= null) {
row.field("REC_GRANT", "GM_GRANT_RECEIVER", item.getRecGrant());
}
if (item.getRecNetwrk()!= null) {
row.field("REC_NETWRK", "ENPLN", item.getRecNetwrk());
}
if (item.getRecOrder()!= null) {
row.field("REC_ORDER", "EAUFNR", item.getRecOrder());
}
if (item.getRecRsrce()!= null) {
row.field("REC_RSRCE", "ERSRCE", item.getRecRsrce());
}
if (item.getRecWbsEl()!= null) {
row.field("REC_WBS_EL", "E_PS_POSID", item.getRecWbsEl());
}
if (item.getRecWorkItm()!= null) {
row.field("REC_WORK_ITM", "EWORKITM", item.getRecWorkItm());
}
if (item.getRreBuilding()!= null) {
row.field("RRE_BUILDING", "ESGENR", item.getRreBuilding());
}
if (item.getRreBusEnt()!= null) {
row.field("RRE_BUS_ENT", "ESWENR", item.getRreBusEnt());
}
if (item.getRreCompCode()!= null) {
row.field("RRE_COMP_CODE", "EBUKRS", item.getRreCompCode());
}
if (item.getRreConNo()!= null) {
row.field("RRE_CON_NO", "REECNNR", item.getRreConNo());
}
if (item.getRreIncExp()!= null) {
row.field("RRE_INC_EXP", "ESNKSL", item.getRreIncExp());
}
if (item.getRreLease()!= null) {
row.field("RRE_LEASE", "ESMIVE", item.getRreLease());
}
if (item.getRreMgmtCon()!= null) {
row.field("RRE_MGMT_CON", "VVESVWNR", item.getRreMgmtCon());
}
if (item.getRreProperty()!= null) {
row.field("RRE_PROPERTY", "ESGRNR", item.getRreProperty());
}
if (item.getRreRefDate()!= null) {
row.field("RRE_REF_DATE", "EDABRBEZ", item.getRreRefDate());
}
if (item.getRreRentUnit()!= null) {
row.field("RRE_RENT_UNIT", "ESMENR", item.getRreRentUnit());
}
if (item.getRreSettUnit()!= null) {
row.field("RRE_SETT_UNIT", "ESEMPSL", item.getRreSettUnit());
}
if (item.getSegText()!= null) {
row.field("SEG_TEXT", "CO_SGTXT", item.getSegText());
}
if (item.getSenbusproc()!= null) {
row.field("SENBUSPROC", "SPRZNR", item.getSenbusproc());
}
if (item.getSencostobj()!= null) {
row.field("SENCOSTOBJ", "SKSTRG", item.getSencostobj());
}
if (item.getSendBudgetPeriod()!= null) {
row.field("SEND_BUDGET_PERIOD", "FM_SBUDGET_PERIOD", item.getSendBudgetPeriod());
}
if (item.getSendCctr()!= null) {
row.field("SEND_CCTR", "SKOSTL", item.getSendCctr());
}
if (item.getSendFunction()!= null) {
row.field("SEND_FUNCTION", "SFKTBER", item.getSendFunction());
}
if (item.getSendFund()!= null) {
row.field("SEND_FUND", "FM_SFONDS", item.getSendFund());
}
if (item.getSendFundLong()!= null) {
row.field("SEND_FUND_LONG", "FM_SGEBER_LONG", item.getSendFundLong());
}
if (item.getSendGrant()!= null) {
row.field("SEND_GRANT", "GM_GRANT_SENDER", item.getSendGrant());
}
if (item.getSenitem()!= null) {
row.field("SENITEM", "SKDPO", item.getSenitem());
}
if (item.getSenoperatn()!= null) {
row.field("SENOPERATN", "SVORG", item.getSenoperatn());
}
if (item.getSensaleord()!= null) {
row.field("SENSALEORD", "SKDAU", item.getSensaleord());
}
if (item.getSenNetwrk()!= null) {
row.field("SEN_NETWRK", "SNPLN", item.getSenNetwrk());
}
if (item.getSenOrder()!= null) {
row.field("SEN_ORDER", "SAUFNR", item.getSenOrder());
}
if (item.getSenRsrce()!= null) {
row.field("SEN_RSRCE", "SRSRCE", item.getSenRsrce());
}
if (item.getSenWbsEl()!= null) {
row.field("SEN_WBS_EL", "S_PS_POSID", item.getSenWbsEl());
}
if (item.getSenWorkItm()!= null) {
row.field("SEN_WORK_ITM", "SWORKITM", item.getSenWorkItm());
}
if (item.getServDate()!= null) {
row.field("SERV_DATE", "BAPI_FBUDA", item.getServDate());
}
if (item.getSreBuilding()!= null) {
row.field("SRE_BUILDING", "SSGENR", item.getSreBuilding());
}
if (item.getSreBusEnt()!= null) {
row.field("SRE_BUS_ENT", "SSWENR", item.getSreBusEnt());
}
if (item.getSreCompCode()!= null) {
row.field("SRE_COMP_CODE", "VVSBUKRS", item.getSreCompCode());
}
if (item.getSreConNo()!= null) {
row.field("SRE_CON_NO", "RESCNNR", item.getSreConNo());
}
if (item.getSreIncExp()!= null) {
row.field("SRE_INC_EXP", "SSNKSL", item.getSreIncExp());
}
if (item.getSreLease()!= null) {
row.field("SRE_LEASE", "SSMIVE", item.getSreLease());
}
if (item.getSreMgmtCon()!= null) {
row.field("SRE_MGMT_CON", "VVSSVWNR", item.getSreMgmtCon());
}
if (item.getSreProperty()!= null) {
row.field("SRE_PROPERTY", "SSGRNR", item.getSreProperty());
}
if (item.getSreRefDate()!= null) {
row.field("SRE_REF_DATE", "SDABRBEZ", item.getSreRefDate());
}
if (item.getSreRentUnit()!= null) {
row.field("SRE_RENT_UNIT", "SSMENR", item.getSreRentUnit());
}
if (item.getSreSettUnit()!= null) {
row.field("SRE_SETT_UNIT", "SSEMPSL", item.getSreSettUnit());
}
if (item.getTransCurr()!= null) {
row.field("TRANS_CURR", "TWAER", item.getTransCurr());
}
if (item.getTransCurrIso()!= null) {
row.field("TRANS_CURR_ISO", "ISOCD", item.getTransCurrIso());
}
if (item.getValueTcur()!= null) {
row.field("VALUE_TCUR", "BGTXXX", item.getValueTcur());
}
if (item.getValueTcurLong()!= null) {
row.field("VALUE_TCUR_LONG", "BGTXXX_31_8", item.getValueTcurLong());
}
}
table.end();
}
if ((customerFields!= null)&&customerFields.iterator().hasNext()) {
final Table table = query.withTable("CUSTOMER_FIELDS", "BAPIEXTC");
for (ContainerForCustomerExitParameter item: customerFields) {
final TableRow row = table.row();
if (item.getField1()!= null) {
row.field("FIELD1", "STRNG250", item.getField1());
}
if (item.getField2()!= null) {
row.field("FIELD2", "STRNG250", item.getField2());
}
if (item.getField3()!= null) {
row.field("FIELD3", "STRNG250", item.getField3());
}
if (item.getField4()!= null) {
row.field("FIELD4", "STRNG250", item.getField4());
}
}
table.end();
}
query.withTableAsReturn("RETURN", "BAPIRET2");
return query;
}
/**
* {@inheritDoc}
*
*/
@Override
@Nonnull
@Tolerate
public AcctngManCostAllocCheckFunction customerFields(ContainerForCustomerExitParameter... items) {
customerFields = Lists.newArrayList(items);
return this;
}
}