Skip to content

Instantly share code, notes, and snippets.

View dhananjayhegde's full-sized avatar

Dhananjay Hegde dhananjayhegde

  • TATA Consultancy Services
  • Bangalore
View GitHub Profile
@dhananjayhegde
dhananjayhegde / list_binding_in_fe_v4.md
Last active August 2, 2024 07:29
Working with List Binding in Fiori Elements v4 apps

Working with List Binding in Fiori Elements v4 apps

Recently, I had to work on a requirement to download data from FE v4 list report to a Google Sheet. We had an API that would take the result of a OData GET call and an array of column names and then would save the results into a Google Sheet file. Problem came when we realized that there is no "read" method exposed in OData V4 model object unlike OData v2 model object in UI5.
So, how do we read the data that then?

Problem Statement

Suppose that we have a List Report application to show Purchase Order details with some filter fields. This is a Fiori Elements v4 application. We have applied some filter criteria, say, CompanyCode = 1000 and DocumentType = ZDEMO. This will result in 5000 POs. However, the app does not fetch all the 5000 records. It would fetch only 20 records initially and then as you

@dhananjayhegde
dhananjayhegde / VideoCard.jsx
Last active July 29, 2023 13:48
Local Storage with React Component - store the state
import React, { useEffect, useState } from "react";
import "./VideoCard.css";
import { useNavigate } from "react-router-dom";
import { MdOutlineWatchLater } from "react-icons/md";
import { useData } from "../../context/DataContext";
export const VideoCard = ({ videoInfo }) => {
const { title, creator, thumbnail, views, category, _id } = videoInfo;
const navigate = useNavigate();
const { dispatch } = useData();
@dhananjayhegde
dhananjayhegde / ListReportExt.controller.js
Created June 24, 2022 06:49
Wrap OData v2 model read into a Promise
sap.ui.define(
[], function(){
"use strict";
return sap.ui.controller("todo.app.todoapp1.ext.controller.ListReportExt", {
promiseToRead: function(sPath){
var oModel = this.oModel;
return new Promise(function(resolveCallback, rejectCallback){
@dhananjayhegde
dhananjayhegde / contracts...dnote.sol
Created January 11, 2022 14:16
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// This line imports the ERC-20 token standard from OpenZeppelin (OZ). OZ is an Ethereum security company.
// Among other things, OZ develops reference contracts for popular smart contract standards which are thoroughly
// tested and secure. Whenever implementing a smart contract which needs to comply with a standard, try to
// find an OZ reference implementation rather than rewriting the entire standard from scratch.
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";
@dhananjayhegde
dhananjayhegde / contracts...FundMe.sol
Created December 7, 2021 03:06
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.9.0;
// to get latest price data
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract FundMe {
mapping(address => uint256) public addressToAmountFunded;
@dhananjayhegde
dhananjayhegde / contracts...FundMe.sol
Created December 5, 2021 16:50
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=undefined&runs=undefined&gist=
//SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.9.0;
contract FundMe {
mapping(address => uint256) public addressToAmountFunded;
// "payable" function -> accespts payment
// Every transaction has some inbuilt variables
// "msg"
@dhananjayhegde
dhananjayhegde / contracts...StorageFactory.sol
Created December 5, 2021 14:55
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=undefined&runs=undefined&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
import "./SimpleStorage.sol";
// This is a contract that will let you create and deploy SimpleStorage contracts
// A Contract that creates other contracts - Contract Factory
// In the end, we also inherited SimpleStorage here so that
// SimpleStorageFactory gets all functionalities of SimpleStorage
@dhananjayhegde
dhananjayhegde / contracts...SimpleStorage.sol
Created December 5, 2021 14:23
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=undefined&runs=undefined&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
contract SimpleStorage{
struct People {
uint256 favoriteNumber;
string name;
}