All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cloud.sdk.s4hana.datamodel.bapi.functions.DefaultAcctngActivityAllocCheckFunction Maven / Gradle / Ivy

There is a newer version: 2.28.0
Show newest version
/*
 * 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.DocumentHeaderPostActAllocActualPostings;
import com.sap.cloud.sdk.s4hana.datamodel.bapi.structures.LineItemsActivityAllocationActualPosting;
import com.sap.cloud.sdk.s4hana.datamodel.bapi.structures.PostingInAccountingCoPaAcctAssignmentCharacteristic;
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 DefaultAcctngActivityAllocCheckFunction
    implements AcctngActivityAllocCheckFunction
{

    /**
     * Document Header Data
     * 
     */
    private final DocumentHeaderPostActAllocActualPostings 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) Object Attributes for Profitability Segments * */ @Setter @Nonnull private Iterable criteria = Lists.newArrayList(); /** * (Optional) Customer Fields * */ @Setter @Nonnull private Iterable customerFields = Lists.newArrayList(); /** * {@inheritDoc} * */ @Override @Nonnull public AcctngActivityAllocCheckFunctionResult execute(final ErpConfigContext erpConfigContext) throws QueryExecutionException { final BapiQuery query = toQuery(); final BapiQueryResult queryResult = query.execute(erpConfigContext); return new DefaultAcctngActivityAllocCheckFunctionResult(queryResult); } /** * {@inheritDoc} * */ @Override @Nonnull public AcctngActivityAllocCheckFunctionResult execute() throws QueryExecutionException { return execute(new ErpConfigContext()); } /** * {@inheritDoc} * */ @Override @Nonnull public BapiQuery toQuery() { docHeader.validate(); for (LineItemsActivityAllocationActualPosting item: docItems) { item.validate(); } if (criteria!= null) { for (PostingInAccountingCoPaAcctAssignmentCharacteristic item: criteria) { item.validate(); } } if (customerFields!= null) { for (ContainerForCustomerExitParameter item: customerFields) { item.validate(); } } final BapiQuery query = new BapiQuery("BAPI_ACC_ACTIVITY_ALLOC_CHECK"); if (ignoreWarnings!= null) { query.withExporting("IGNORE_WARNINGS", "BAPIIGNWAR", ignoreWarnings); } { final ParameterFields row = query.withExportingFields("DOC_HEADER", "BAPIDOCHDRP"); 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.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.getPostgdate()!= null) { row.field("POSTGDATE", "CO_BUDAT", docHeader.getPostgdate()); } if (docHeader.getUsername()!= null) { row.field("USERNAME", "USNAM", docHeader.getUsername()); } if (docHeader.getValuedate()!= null) { row.field("VALUEDATE", "CO_WSDAT", docHeader.getValuedate()); } if (docHeader.getValFisyear()!= null) { row.field("VAL_FISYEAR", "GJAHR", docHeader.getValFisyear()); } if (docHeader.getValPeriod()!= null) { row.field("VAL_PERIOD", "CO_PERIO", docHeader.getValPeriod()); } if (docHeader.getVariant()!= null) { row.field("VARIANT", "CO_VARNR", docHeader.getVariant()); } if (docHeader.getVersion()!= null) { row.field("VERSION", "VERSN", docHeader.getVersion()); } row.end(); } if (docItems.iterator().hasNext()) { final Table table = query.withTable("DOC_ITEMS", "BAPIAAITM"); for (LineItemsActivityAllocationActualPosting item: docItems) { final TableRow row = table.row(); if (item.getActivityun()!= null) { row.field("ACTIVITYUN", "CO_MEINH_L", item.getActivityun()); } if (item.getActivityunIso()!= null) { row.field("ACTIVITYUN_ISO", "ISOCD_UNIT", item.getActivityunIso()); } if (item.getActtype()!= null) { row.field("ACTTYPE", "LSTAR", item.getActtype()); } if (item.getActvtyQty()!= null) { row.field("ACTVTY_QTY", "LSTXX", item.getActvtyQty()); } if (item.getCurrency()!= null) { row.field("CURRENCY", "WAERS", item.getCurrency()); } if (item.getCurrencyIso()!= null) { row.field("CURRENCY_ISO", "ISOCD", item.getCurrencyIso()); } if (item.getItemnoAcc()!= null) { row.field("ITEMNO_ACC", "POSNR_ACC", item.getItemnoAcc()); } if (item.getMaterial()!= null) { row.field("MATERIAL", "CO_EMATNR18", item.getMaterial()); } if (item.getMaterialExternal()!= null) { row.field("MATERIAL_EXTERNAL", "MGV_MATERIAL_EXTERNAL", item.getMaterialExternal()); } if (item.getMaterialGuid()!= null) { row.field("MATERIAL_GUID", "MGV_MATERIAL_GUID", item.getMaterialGuid()); } if (item.getMaterialLong()!= null) { row.field("MATERIAL_LONG", "CO_EMATNR40", item.getMaterialLong()); } if (item.getMaterialVersion()!= null) { row.field("MATERIAL_VERSION", "MGV_MATERIAL_VERSION", item.getMaterialVersion()); } if (item.getPersonNo()!= null) { row.field("PERSON_NO", "PERNR_D", item.getPersonNo()); } if (item.getPlant()!= null) { row.field("PLANT", "CO_EWERKS", item.getPlant()); } if (item.getPostoutun()!= null) { row.field("POSTOUTUN", "CO_MEINB_A", item.getPostoutun()); } if (item.getPostoutunIso()!= null) { row.field("POSTOUTUN_ISO", "ISOCD_UNIT", item.getPostoutunIso()); } if (item.getPosOutqty()!= null) { row.field("POS_OUTQTY", "AUBXX", item.getPosOutqty()); } if (item.getPrice()!= null) { row.field("PRICE", "BAPITAG", item.getPrice()); } if (item.getPriceFix()!= null) { row.field("PRICE_FIX", "BAPITAF", item.getPriceFix()); } if (item.getPriceFixLong()!= null) { row.field("PRICE_FIX_LONG", "BAPITAF_31", item.getPriceFixLong()); } if (item.getPriceLong()!= null) { row.field("PRICE_LONG", "BAPITAG_31", item.getPriceLong()); } if (item.getPriceUnit()!= null) { row.field("PRICE_UNIT", "BAPITEH", item.getPriceUnit()); } if (item.getPriceVar()!= null) { row.field("PRICE_VAR", "BAPITAV", item.getPriceVar()); } if (item.getPriceVarLong()!= null) { row.field("PRICE_VAR_LONG", "BAPITAV_31", item.getPriceVarLong()); } if (item.getProdVersn()!= null) { row.field("PROD_VERSN", "CO_EVERID", item.getProdVersn()); } if (item.getRecacttype()!= null) { row.field("RECACTTYPE", "E_LSTAR", item.getRecacttype()); } 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.getRecprcmtproc()!= null) { row.field("RECPRCMTPROC", "EPROCNR", item.getRecprcmtproc()); } if (item.getRecrunschd()!= null) { row.field("RECRUNSCHD", "ESAUFNR", item.getRecrunschd()); } 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.getRecCalcMotive()!= null) { row.field("REC_CALC_MOTIVE", "EBEMOT", item.getRecCalcMotive()); } 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.getSendBudgetPeriod()!= null) { row.field("SEND_BUDGET_PERIOD", "FM_SBUDGET_PERIOD", item.getSendBudgetPeriod()); } if (item.getSendCctr()!= null) { row.field("SEND_CCTR", "SKOST", 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.getSenRsrce()!= null) { row.field("SEN_RSRCE", "SRSRCE", item.getSenRsrce()); } 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.getValueFix()!= null) { row.field("VALUE_FIX", "BAPIWTF", item.getValueFix()); } if (item.getValueFixLong()!= null) { row.field("VALUE_FIX_LONG", "BAPIWTF_31", item.getValueFixLong()); } if (item.getValueTotal()!= null) { row.field("VALUE_TOTAL", "BAPIWTG", item.getValueTotal()); } if (item.getValueTotalLong()!= null) { row.field("VALUE_TOTAL_LONG", "BAPIWTG_31", item.getValueTotalLong()); } if (item.getValueVar()!= null) { row.field("VALUE_VAR", "BAPIWTV", item.getValueVar()); } if (item.getValueVarLong()!= null) { row.field("VALUE_VAR_LONG", "BAPIWTV_31", item.getValueVarLong()); } } table.end(); } if ((criteria!= null)&&criteria.iterator().hasNext()) { final Table table = query.withTable("CRITERIA", "BAPIACKECR"); for (PostingInAccountingCoPaAcctAssignmentCharacteristic item: criteria) { final TableRow row = table.row(); if (item.getCharacter()!= null) { row.field("CHARACTER", "RKE_CRIGEN", item.getCharacter()); } if (item.getFieldname()!= null) { row.field("FIELDNAME", "FIELDNAME", item.getFieldname()); } if (item.getItemnoAcc()!= null) { row.field("ITEMNO_ACC", "POSNR_ACC", item.getItemnoAcc()); } } 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 AcctngActivityAllocCheckFunction criteria(PostingInAccountingCoPaAcctAssignmentCharacteristic... items) { criteria = Lists.newArrayList(items); return this; } /** * {@inheritDoc} * */ @Override @Nonnull @Tolerate public AcctngActivityAllocCheckFunction customerFields(ContainerForCustomerExitParameter... items) { customerFields = Lists.newArrayList(items); return this; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy