com.sap.cloud.sdk.s4hana.datamodel.bapi.functions.DefaultFxOptionCreateFunction 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.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.datamodel.bapi.structures.CreateAnFxOption;
import com.sap.cloud.sdk.s4hana.datamodel.bapi.structures.FtrStructureForCreatingTransactions;
import com.sap.cloud.sdk.s4hana.datamodel.bapi.types.TransactionActivityCategory;
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;
/**
* {@inheritDoc}
*
*/
@ToString
@EqualsAndHashCode
@Accessors(fluent = true)
@RequiredArgsConstructor(access = AccessLevel.PUBLIC)
public class DefaultFxOptionCreateFunction
implements FxOptionCreateFunction
{
/**
* Creating an FX Option with BAPI
*
*/
private final CreateAnFxOption forex;
/**
* FTR: BAPI Structure for Creating Transactions
*
*/
private final FtrStructureForCreatingTransactions generalContractData;
/**
* (Optional) Switch to Simulation Mode for Write BAPIs
* 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) Transaction Activity Category
* Field name: ACTIVITYCAT
*
* Type element: TB_SFGZUTY
* Domain name: T_SFGZUTY
* Internal type: NUMC
* Description: Transaction Activity Category
* Max length: 2
*
*
*/
@Setter
private TransactionActivityCategory activityCategory = null;
/**
* {@inheritDoc}
*
*/
@Override
@Nonnull
public FxOptionCreateFunctionResult execute(final ErpConfigContext erpConfigContext)
throws QueryExecutionException
{
final BapiQuery query = toQuery();
final BapiQueryResult queryResult = query.execute(erpConfigContext);
return new DefaultFxOptionCreateFunctionResult(queryResult);
}
/**
* {@inheritDoc}
*
*/
@Override
@Nonnull
public FxOptionCreateFunctionResult execute()
throws QueryExecutionException
{
return execute(new ErpConfigContext());
}
/**
* {@inheritDoc}
*
*/
@Override
@Nonnull
public BapiQuery toQuery() {
forex.validate();
generalContractData.validate();
final BapiQuery query = new BapiQuery("BAPI_FTR_CREATE_FXOPTIONS");
if (testRun!= null) {
query.withExporting("TESTRUN", "TESTRUN", testRun);
}
if (activityCategory!= null) {
query.withExporting("ACTIVITY_CATEGORY", "TB_SFGZUTY", activityCategory);
}
{
final ParameterFields row = query.withExportingFields("FOREX", "BAPI_FTR_CREATE_FXOPTION");
if (forex.getBarrierRate1()!= null) {
row.field("BARRIER_RATE_1", "TX_KWKURB1", forex.getBarrierRate1());
}
if (forex.getBarrierRate2()!= null) {
row.field("BARRIER_RATE_2", "TX_KWKURB2", forex.getBarrierRate2());
}
if (forex.getCurrencyOptionPremium()!= null) {
row.field("CURRENCY_OPTION_PREMIUM", "TI_PRKUR", forex.getCurrencyOptionPremium());
}
if (forex.getExerciseType()!= null) {
row.field("EXERCISE_TYPE", "SOPTAUS", forex.getExerciseType());
}
if (forex.getExpirationDate()!= null) {
row.field("EXPIRATION_DATE", "TB_DMATUR", forex.getExpirationDate());
}
if (forex.getExpiryLocation()!= null) {
row.field("EXPIRY_LOCATION", "FTR_EXPIRY_LOCATION", forex.getExpiryLocation());
}
if (forex.getExpiryTime()!= null) {
row.field("EXPIRY_TIME", "FTR_EXPIRY_TIME", forex.getExpiryTime());
}
if (forex.getFlowType()!= null) {
row.field("FLOW_TYPE", "TB_SFHAZBA", forex.getFlowType());
}
if (forex.getFollowCurrency()!= null) {
row.field("FOLLOW_CURRENCY", "TB_WFWAERS", forex.getFollowCurrency());
}
if (forex.getFollowCurrencyIso()!= null) {
row.field("FOLLOW_CURRENCY_ISO", "ISOCD", forex.getFollowCurrencyIso());
}
if (forex.getLeadCurrency()!= null) {
row.field("LEAD_CURRENCY", "TB_WLWAERS", forex.getLeadCurrency());
}
if (forex.getLeadCurrencyIso()!= null) {
row.field("LEAD_CURRENCY_ISO", "ISOCD", forex.getLeadCurrencyIso());
}
if (forex.getOptionType()!= null) {
row.field("OPTION_TYPE", "TV_OPTTYP", forex.getOptionType());
}
if (forex.getPaymentAmount()!= null) {
row.field("PAYMENT_AMOUNT", "BAPITM_BZBETR", forex.getPaymentAmount());
}
if (forex.getPaymentCurrency()!= null) {
row.field("PAYMENT_CURRENCY", "TB_WZBETR", forex.getPaymentCurrency());
}
if (forex.getPaymentCurrencyIso()!= null) {
row.field("PAYMENT_CURRENCY_ISO", "ISOCD", forex.getPaymentCurrencyIso());
}
if (forex.getPaymentDateOption()!= null) {
row.field("PAYMENT_DATE_OPTION", "TB_DZTERM", forex.getPaymentDateOption());
}
if (forex.getPutCallIndicator()!= null) {
row.field("PUT_CALL_INDICATOR", "TI_SPUTCAL", forex.getPutCallIndicator());
}
if (forex.getRatePercentage()!= null) {
row.field("RATE_PERCENTAGE", "TB_PWKURS", forex.getRatePercentage());
}
if (forex.getSettlementIndicator()!= null) {
row.field("SETTLEMENT_INDICATOR", "TI_SETTLFL", forex.getSettlementIndicator());
}
if (forex.getSpotRate()!= null) {
row.field("SPOT_RATE", "TB_KKASSA", forex.getSpotRate());
}
if (forex.getStrikeRate()!= null) {
row.field("STRIKE_RATE", "TB_KKURS", forex.getStrikeRate());
}
if (forex.getSwapRate()!= null) {
row.field("SWAP_RATE", "TB_KSWAP", forex.getSwapRate());
}
if (forex.getUnderlyingAmount()!= null) {
row.field("UNDERLYING_AMOUNT", "BAPITM_BZBETR", forex.getUnderlyingAmount());
}
if (forex.getUnderlyingCurrency()!= null) {
row.field("UNDERLYING_CURRENCY", "TB_WZBETR", forex.getUnderlyingCurrency());
}
if (forex.getUnderlyingCurrencyIso()!= null) {
row.field("UNDERLYING_CURRENCY_ISO", "ISOCD", forex.getUnderlyingCurrencyIso());
}
if (forex.getUnderlyingValueDate()!= null) {
row.field("UNDERLYING_VALUE_DATE", "TB_DVALUTA", forex.getUnderlyingValueDate());
}
row.end();
}
{
final ParameterFields row = query.withExportingFields("GENERALCONTRACTDATA", "BAPI_FTR_CREATE");
if (generalContractData.getAcctAssignmentRef()!= null) {
row.field("ACCT_ASSIGNMENT_REF", "RREFKONT_OBSOLETE", generalContractData.getAcctAssignmentRef());
}
if (generalContractData.getAssignment()!= null) {
row.field("ASSIGNMENT", "TB_ZUOND", generalContractData.getAssignment());
}
if (generalContractData.getAuthGroup()!= null) {
row.field("AUTH_GROUP", "TBEGRU", generalContractData.getAuthGroup());
}
if (generalContractData.getBusinessArea()!= null) {
row.field("BUSINESS_AREA", "GSBER", generalContractData.getBusinessArea());
}
if (generalContractData.getCfiCode()!= null) {
row.field("CFI_CODE", "FTR_CFI_CODE", generalContractData.getCfiCode());
}
if (generalContractData.getCharacteristics()!= null) {
row.field("CHARACTERISTICS", "TB_MERKM", generalContractData.getCharacteristics());
}
if (generalContractData.getClearingDate()!= null) {
row.field("CLEARING_DATE", "TPM_TREA_CLEARING_DATE", generalContractData.getClearingDate());
}
if (generalContractData.getClearingOption()!= null) {
row.field("CLEARING_OPTION", "TPM_TREA_CLEARING_OPT", generalContractData.getClearingOption());
}
if (generalContractData.getClearingStatus()!= null) {
row.field("CLEARING_STATUS", "TPM_TREA_CLEARING_STATUS", generalContractData.getClearingStatus());
}
if (generalContractData.getClearDateAct()!= null) {
row.field("CLEAR_DATE_ACT", "TPM_TREA_CLEARING_DATE_ACT", generalContractData.getClearDateAct());
}
if (generalContractData.getCompanyCode()!= null) {
row.field("COMPANY_CODE", "BUKRS", generalContractData.getCompanyCode());
}
if (generalContractData.getContactPerson()!= null) {
row.field("CONTACT_PERSON", "TB_GSPPART", generalContractData.getContactPerson());
}
if (generalContractData.getContractDate()!= null) {
row.field("CONTRACT_DATE", "TB_DVTRAB", generalContractData.getContractDate());
}
if (generalContractData.getContractTime()!= null) {
row.field("CONTRACT_TIME", "TB_TVTRAB", generalContractData.getContractTime());
}
if (generalContractData.getContractTimestampUtc()!= null) {
row.field("CONTRACT_TIMESTAMP_UTC", "FTR_CONTRACT_TIMESTAMP_UTC", generalContractData.getContractTimestampUtc());
}
if (generalContractData.getCostCenter()!= null) {
row.field("COST_CENTER", "KOSTL", generalContractData.getCostCenter());
}
if (generalContractData.getCountry()!= null) {
row.field("COUNTRY", "LAND1", generalContractData.getCountry());
}
if (generalContractData.getCountryIso()!= null) {
row.field("COUNTRY_ISO", "INTCA", generalContractData.getCountryIso());
}
if (generalContractData.getCreateUser()!= null) {
row.field("CREATE_USER", "TB_CRUSER", generalContractData.getCreateUser());
}
if (generalContractData.getEntryDate()!= null) {
row.field("ENTRY_DATE", "TB_DCRDAT", generalContractData.getEntryDate());
}
if (generalContractData.getExpenseKey()!= null) {
row.field("EXPENSE_KEY", "TB_SPESEN", generalContractData.getExpenseKey());
}
if (generalContractData.getExternalReference()!= null) {
row.field("EXTERNAL_REFERENCE", "TB_NORDEXT", generalContractData.getExternalReference());
}
if (generalContractData.getExternalTradeId()!= null) {
row.field("EXTERNAL_TRADE_ID", "FTR_TARO_TRADE_ID", generalContractData.getExternalTradeId());
}
if (generalContractData.getExternalTransactionNumber()!= null) {
row.field("EXTERNAL_TRANSACTION_NUMBER", "TB_RFHA", generalContractData.getExternalTransactionNumber());
}
if (generalContractData.getExtAccount()!= null) {
row.field("EXT_ACCOUNT", "TPM_EXT_ACCOUNT", generalContractData.getExtAccount());
}
if (generalContractData.getFacility()!= null) {
row.field("FACILITY", "TB_FACILITYNR", generalContractData.getFacility());
}
if (generalContractData.getFacilityCompanyCode()!= null) {
row.field("FACILITY_COMPANY_CODE", "TB_FACILITYBUKRS", generalContractData.getFacilityCompanyCode());
}
if (generalContractData.getFinanceProject()!= null) {
row.field("FINANCE_PROJECT", "TB_TFPROJ", generalContractData.getFinanceProject());
}
if (generalContractData.getFund()!= null) {
row.field("FUND", "FM_FUND", generalContractData.getFund());
}
if (generalContractData.getGrantNbr()!= null) {
row.field("GRANT_NBR", "GM_GRANT_NBR", generalContractData.getGrantNbr());
}
if (generalContractData.getGuarantor()!= null) {
row.field("GUARANTOR", "TB_RGARANT_NEW", generalContractData.getGuarantor());
}
if (generalContractData.getHedgeClassification()!= null) {
row.field("HEDGE_CLASSIFICATION", "TOE_HEDGING_CLASSIFICATION_OLD", generalContractData.getHedgeClassification());
}
if (generalContractData.getHedgeRequestId()!= null) {
row.field("HEDGE_REQUEST_ID", "TOE_REQUEST_ID", generalContractData.getHedgeRequestId());
}
if (generalContractData.getHedgingClassification()!= null) {
row.field("HEDGING_CLASSIFICATION", "TOE_HEDGING_CLASSIFICATION", generalContractData.getHedgingClassification());
}
if (generalContractData.getInitClassifier()!= null) {
row.field("INIT_CLASSIFIER", "TRPA_INITIAL_STAGE", generalContractData.getInitClassifier());
}
if (generalContractData.getInternalReference()!= null) {
row.field("INTERNAL_REFERENCE", "TB_REFER", generalContractData.getInternalReference());
}
if (generalContractData.getIsin()!= null) {
row.field("ISIN", "RANL_ISIN", generalContractData.getIsin());
}
if (generalContractData.getLegalBasis()!= null) {
row.field("LEGAL_BASIS", "FTR_THRESHOLD_SCHEME", generalContractData.getLegalBasis());
}
if (generalContractData.getMasterAgreement()!= null) {
row.field("MASTER_AGREEMENT", "TB_RMAID", generalContractData.getMasterAgreement());
}
if (generalContractData.getMic()!= null) {
row.field("MIC", "TBA_MIC", generalContractData.getMic());
}
if (generalContractData.getOnBehalfOfCompany()!= null) {
row.field("ON_BEHALF_OF_COMPANY", "TRBA_BEHALF_OF_COMPANY", generalContractData.getOnBehalfOfCompany());
}
if (generalContractData.getPartner()!= null) {
row.field("PARTNER", "TB_KUNNR_NEW", generalContractData.getPartner());
}
if (generalContractData.getPortfolio()!= null) {
row.field("PORTFOLIO", "RPORTB", generalContractData.getPortfolio());
}
if (generalContractData.getProductType()!= null) {
row.field("PRODUCT_TYPE", "VVSART", generalContractData.getProductType());
}
if (generalContractData.getProfitCenter()!= null) {
row.field("PROFIT_CENTER", "PRCTR", generalContractData.getProfitCenter());
}
if (generalContractData.getReservReason()!= null) {
row.field("RESERV_REASON", "TB_SANST", generalContractData.getReservReason());
}
if (generalContractData.getRiskMitigation()!= null) {
row.field("RISK_MITIGATION", "FTR_THRESHOLD_RISK_MITIGATING", generalContractData.getRiskMitigation());
}
if (generalContractData.getSegment()!= null) {
row.field("SEGMENT", "FB_SEGMENT", generalContractData.getSegment());
}
if (generalContractData.getTrader()!= null) {
row.field("TRADER", "RDEALER", generalContractData.getTrader());
}
if (generalContractData.getTransactionType()!= null) {
row.field("TRANSACTION_TYPE", "TB_SFHAART", generalContractData.getTransactionType());
}
if (generalContractData.getValuationClass()!= null) {
row.field("VALUATION_CLASS", "TPM_COM_VAL_CLASS", generalContractData.getValuationClass());
}
if (generalContractData.getWbsElement()!= null) {
row.field("WBS_ELEMENT", "PS_PSP_PNR", generalContractData.getWbsElement());
}
row.end();
}
query.withImportingAsReturn("FINANCIALTRANSACTION", "BAPI2042");
query.withImportingAsReturn("COMPANYCODE", "BAPI2042");
query.withTableAsReturn("RETURN", "BAPIRET2");
return query;
}
}