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

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

/*
 * Copyright (c) 2018 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.CostCenterCreateInput;
import com.sap.cloud.sdk.s4hana.datamodel.bapi.structures.ProfitCenterLanguage;
import com.sap.cloud.sdk.s4hana.datamodel.bapi.structures.RefStructureForParameterExtensioninExtensionout;
import com.sap.cloud.sdk.s4hana.datamodel.bapi.types.ControllingArea;
import com.sap.cloud.sdk.s4hana.datamodel.bapi.types.MasterRecordInactive;
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 DefaultCostCenterCreateMultipleFunction
    implements CostCenterCreateMultipleFunction
{

    /**
     * Controlling Area
     * Field name: CO_AREA
     * 
     *  Type element: KOKRS
     *  Domain name: CACCD
     *  Internal type: CHAR
     *  Description: Controlling Area
     *  Max length: 4
     * 
* */ private final ControllingArea controllingArea; /** * (Optional) Switch to simulation mode (no changes in database!) * Field name: TESTRUN *
     *  Type element: TESTRUN
     *  Domain name: BAPIFLAG
     *  Internal type: CHAR
     *  Description: Switch to Simulation Session for Write BAPIs
     *  Max length: 1
     * 
* */ @Setter private ErpBoolean testRun = null; /** * (Optional) Post Inactive Master Record * Field name: MASTER_DATA_INACTIVE *
     *  Type element: CMDT_INACT
     *  Domain name: XFLAG
     *  Internal type: CHAR
     *  Description: Master Record Inactive
     *  Max length: 1
     * 
* */ @Setter private MasterRecordInactive masterDataInactive = null; /** * (Optional) Language Key * */ @Setter private ProfitCenterLanguage languageKey = null; /** * Cost Centers * */ @Nonnull private final Iterable costCenterList; /** * (Optional) Additional Entries * */ @Setter @Nonnull private Iterable extensionIn = Lists.newArrayList(); /** * {@inheritDoc} * */ @Override @Nonnull public CostCenterCreateMultipleFunctionResult execute(final ErpConfigContext erpConfigContext) throws QueryExecutionException { final BapiQuery query = toQuery(); final BapiQueryResult queryResult = query.execute(erpConfigContext); return new DefaultCostCenterCreateMultipleFunctionResult(queryResult); } /** * {@inheritDoc} * */ @Override @Nonnull public CostCenterCreateMultipleFunctionResult execute() throws QueryExecutionException { return execute(new ErpConfigContext()); } /** * {@inheritDoc} * */ @Override @Nonnull public BapiQuery toQuery() { if (languageKey!= null) { languageKey.validate(); } for (CostCenterCreateInput item: costCenterList) { item.validate(); } if (extensionIn!= null) { for (RefStructureForParameterExtensioninExtensionout item: extensionIn) { item.validate(); } } final BapiQuery query = new BapiQuery("BAPI_COSTCENTER_CREATEMULTIPLE"); query.withExporting("CONTROLLINGAREA", "KOKRS", controllingArea); if (testRun!= null) { query.withExporting("TESTRUN", "TESTRUN", testRun); } if (masterDataInactive!= null) { query.withExporting("MASTER_DATA_INACTIVE", "CMDT_INACT", masterDataInactive); } if (languageKey!= null) { final ParameterFields row = query.withExportingFields("LANGUAGE", "BAPI0015_10"); if (languageKey.getLangu()!= null) { row.field("LANGU", "SPRAS", languageKey.getLangu()); } if (languageKey.getLanguIso()!= null) { row.field("LANGU_ISO", "LAISO", languageKey.getLanguIso()); } row.end(); } if (costCenterList.iterator().hasNext()) { final Table table = query.withTable("COSTCENTERLIST", "BAPI0012_CCINPUTLIST"); for (CostCenterCreateInput item: costCenterList) { final TableRow row = table.row(); if (item.getActyDepTemplate()!= null) { row.field("ACTY_DEP_TEMPLATE", "CCA_TEMPL_CPD", item.getActyDepTemplate()); } if (item.getActyDepTemplateAllocCc()!= null) { row.field("ACTY_DEP_TEMPLATE_ALLOC_CC", "CCA_TEMPL_SCD", item.getActyDepTemplateAllocCc()); } if (item.getActyDepTemplateSk()!= null) { row.field("ACTY_DEP_TEMPLATE_SK", "CCA_TEMPL_SKD", item.getActyDepTemplateSk()); } if (item.getActyIndepTemplate()!= null) { row.field("ACTY_INDEP_TEMPLATE", "CCA_TEMPL_CPI", item.getActyIndepTemplate()); } if (item.getActyIndepTemplateAllocCc()!= null) { row.field("ACTY_INDEP_TEMPLATE_ALLOC_CC", "CCA_TEMPL_SCI", item.getActyIndepTemplateAllocCc()); } if (item.getActyIndepTemplateSk()!= null) { row.field("ACTY_INDEP_TEMPLATE_SK", "CCA_TEMPL_SKI", item.getActyIndepTemplateSk()); } if (item.getAddrCity()!= null) { row.field("ADDR_CITY", "ORT01_GP", item.getAddrCity()); } if (item.getAddrCountry()!= null) { row.field("ADDR_COUNTRY", "LAND1", item.getAddrCountry()); } if (item.getAddrCountryIso()!= null) { row.field("ADDR_COUNTRY_ISO", "LAND1_ISO", item.getAddrCountryIso()); } if (item.getAddrDistrict()!= null) { row.field("ADDR_DISTRICT", "ORT02_GP", item.getAddrDistrict()); } if (item.getAddrName1()!= null) { row.field("ADDR_NAME1", "NAME1_GP", item.getAddrName1()); } if (item.getAddrName2()!= null) { row.field("ADDR_NAME2", "NAME2_GP", item.getAddrName2()); } if (item.getAddrName3()!= null) { row.field("ADDR_NAME3", "NAME3_GP", item.getAddrName3()); } if (item.getAddrName4()!= null) { row.field("ADDR_NAME4", "NAME4_GP", item.getAddrName4()); } if (item.getAddrPobxPcd()!= null) { row.field("ADDR_POBX_PCD", "PSTL2", item.getAddrPobxPcd()); } if (item.getAddrPostlCode()!= null) { row.field("ADDR_POSTL_CODE", "PSTLZ", item.getAddrPostlCode()); } if (item.getAddrPoBox()!= null) { row.field("ADDR_PO_BOX", "PFACH", item.getAddrPoBox()); } if (item.getAddrRegion()!= null) { row.field("ADDR_REGION", "REGIO", item.getAddrRegion()); } if (item.getAddrStreet()!= null) { row.field("ADDR_STREET", "STRAS_GP", item.getAddrStreet()); } if (item.getAddrTaxjurcode()!= null) { row.field("ADDR_TAXJURCODE", "TXJCD", item.getAddrTaxjurcode()); } if (item.getAddrTitle()!= null) { row.field("ADDR_TITLE", "ANRED", item.getAddrTitle()); } if (item.getApplication()!= null) { row.field("APPLICATION", "KAPPL", item.getApplication()); } if (item.getBusArea()!= null) { row.field("BUS_AREA", "GSBER", item.getBusArea()); } if (item.getCompCode()!= null) { row.field("COMP_CODE", "BUKRS", item.getCompCode()); } if (item.getConditionTableUsage()!= null) { row.field("CONDITION_TABLE_USAGE", "KVEWE", item.getConditionTableUsage()); } if (item.getCostcenter()!= null) { row.field("COSTCENTER", "KOSTL", item.getCostcenter()); } if (item.getCostcenterType()!= null) { row.field("COSTCENTER_TYPE", "KOSAR", item.getCostcenterType()); } if (item.getCostctrHierGrp()!= null) { row.field("COSTCTR_HIER_GRP", "KHINR", item.getCostctrHierGrp()); } if (item.getCstgSheet()!= null) { row.field("CSTG_SHEET", "AUFKALSM", item.getCstgSheet()); } if (item.getCurrency()!= null) { row.field("CURRENCY", "WAERS", item.getCurrency()); } if (item.getCurrencyIso()!= null) { row.field("CURRENCY_ISO", "WAERS_ISO", item.getCurrencyIso()); } if (item.getDepartment()!= null) { row.field("DEPARTMENT", "ABTEI", item.getDepartment()); } if (item.getDescript()!= null) { row.field("DESCRIPT", "KLTXT", item.getDescript()); } if (item.getFuncArea()!= null) { row.field("FUNC_AREA", "FKBER_SHORT", item.getFuncArea()); } if (item.getFuncAreaLong()!= null) { row.field("FUNC_AREA_LONG", "FKBER", item.getFuncAreaLong()); } if (item.getJvEquityTyp()!= null) { row.field("JV_EQUITY_TYP", "JV_ETYPE", item.getJvEquityTyp()); } if (item.getJvJibcl()!= null) { row.field("JV_JIBCL", "JV_JIBCL", item.getJvJibcl()); } if (item.getJvJibsa()!= null) { row.field("JV_JIBSA", "JV_JIBSA", item.getJvJibsa()); } if (item.getJvOtype()!= null) { row.field("JV_OTYPE", "JV_OTYPE", item.getJvOtype()); } if (item.getJvRecInd()!= null) { row.field("JV_REC_IND", "JV_RECIND", item.getJvRecInd()); } if (item.getJvVenture()!= null) { row.field("JV_VENTURE", "JV_NAME", item.getJvVenture()); } if (item.getLockIndActualPrimaryCosts()!= null) { row.field("LOCK_IND_ACTUAL_PRIMARY_COSTS", "BKZKP", item.getLockIndActualPrimaryCosts()); } if (item.getLockIndActualRevenues()!= null) { row.field("LOCK_IND_ACTUAL_REVENUES", "BKZER", item.getLockIndActualRevenues()); } if (item.getLockIndActSecondaryCosts()!= null) { row.field("LOCK_IND_ACT_SECONDARY_COSTS", "BKZKS", item.getLockIndActSecondaryCosts()); } if (item.getLockIndCommitmentUpdate()!= null) { row.field("LOCK_IND_COMMITMENT_UPDATE", "BKZOB", item.getLockIndCommitmentUpdate()); } if (item.getLockIndPlanPrimaryCosts()!= null) { row.field("LOCK_IND_PLAN_PRIMARY_COSTS", "PKZKP", item.getLockIndPlanPrimaryCosts()); } if (item.getLockIndPlanRevenues()!= null) { row.field("LOCK_IND_PLAN_REVENUES", "PKZER", item.getLockIndPlanRevenues()); } if (item.getLockIndPlanSecondaryCosts()!= null) { row.field("LOCK_IND_PLAN_SECONDARY_COSTS", "PKZKS", item.getLockIndPlanSecondaryCosts()); } if (item.getLogsystem()!= null) { row.field("LOGSYSTEM", "LOGSYSTEM", item.getLogsystem()); } if (item.getName()!= null) { row.field("NAME", "KTEXT", item.getName()); } if (item.getPersonInCharge()!= null) { row.field("PERSON_IN_CHARGE", "VERAK", item.getPersonInCharge()); } if (item.getPersonInChargeUser()!= null) { row.field("PERSON_IN_CHARGE_USER", "VERAK_USER", item.getPersonInChargeUser()); } if (item.getProfitCtr()!= null) { row.field("PROFIT_CTR", "PRCTR", item.getProfitCtr()); } if (item.getRecordQuantity()!= null) { row.field("RECORD_QUANTITY", "MGEFL", item.getRecordQuantity()); } if (item.getTelcoDataLine()!= null) { row.field("TELCO_DATA_LINE", "DATLT", item.getTelcoDataLine()); } if (item.getTelcoFaxNumber()!= null) { row.field("TELCO_FAX_NUMBER", "TELFX", item.getTelcoFaxNumber()); } if (item.getTelcoLangu()!= null) { row.field("TELCO_LANGU", "SPRAS", item.getTelcoLangu()); } if (item.getTelcoLanguIso()!= null) { row.field("TELCO_LANGU_ISO", "LAISO", item.getTelcoLanguIso()); } if (item.getTelcoPrinter()!= null) { row.field("TELCO_PRINTER", "KDNAM", item.getTelcoPrinter()); } if (item.getTelcoTelebox()!= null) { row.field("TELCO_TELEBOX", "TELBX", item.getTelcoTelebox()); } if (item.getTelcoTelephone()!= null) { row.field("TELCO_TELEPHONE", "TELF1", item.getTelcoTelephone()); } if (item.getTelcoTelephone2()!= null) { row.field("TELCO_TELEPHONE2", "TELF2", item.getTelcoTelephone2()); } if (item.getTelcoTeletex()!= null) { row.field("TELCO_TELETEX", "TELTX", item.getTelcoTeletex()); } if (item.getTelcoTelex()!= null) { row.field("TELCO_TELEX", "TELX1", item.getTelcoTelex()); } if (item.getValidFrom()!= null) { row.field("VALID_FROM", "DATAB", item.getValidFrom()); } if (item.getValidTo()!= null) { row.field("VALID_TO", "DATBI", item.getValidTo()); } } table.end(); } if ((extensionIn!= null)&&extensionIn.iterator().hasNext()) { final Table table = query.withTable("EXTENSIONIN", "BAPIPAREX"); for (RefStructureForParameterExtensioninExtensionout item: extensionIn) { final TableRow row = table.row(); if (item.getStructure()!= null) { row.field("STRUCTURE", "TE_STRUC", item.getStructure()); } if (item.getValuepart1()!= null) { row.field("VALUEPART1", "VALUEPART", item.getValuepart1()); } if (item.getValuepart2()!= null) { row.field("VALUEPART2", "VALUEPART", item.getValuepart2()); } if (item.getValuepart3()!= null) { row.field("VALUEPART3", "VALUEPART", item.getValuepart3()); } if (item.getValuepart4()!= null) { row.field("VALUEPART4", "VALUEPART", item.getValuepart4()); } } table.end(); } query.withTableAsReturn("EXTENSIONOUT", "BAPIPAREX"); query.withTableAsReturn("RETURN", "BAPIRET2"); return query; } /** * {@inheritDoc} * */ @Override @Tolerate public CostCenterCreateMultipleFunction extensionIn(RefStructureForParameterExtensioninExtensionout... items) { extensionIn = Lists.newArrayList(items); return this; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy