How to retrieve xstring value from ABAP using RfcQuery? - s4sdk

I am wondering how a xstring should be retrieved from ABAP backend using RfcQuery.
final RfcQuery query = new RfcQuery(<myRFC>)...
Byte[] pdf = query.execute(erpEndpoint).get("EX_BLOB").getAs ??
Any ideas?

As of now retrieving XSTRING values from an remote-enabled function module is not supported.
I'll edit this question if there is an update.

Related

CMS Open Payments Data Limitation

I've finally got around to getting the code needed to import web API into my SQL environment. However, when I ran the SSIS Script Component package (Script Language: Visual Studio C# 2017) I was only able to retrieve 1000 records out of of millions. A consultant mentioned that I may have to incorporate the App Token into my code in order to access additional records.
Would someone be able to confirm that this true? And if so, how should it be coded?
Here is the code prior to my "ForEach" loop code:
public override void CreateNewOutputRows()
{
//Set Webservice URL
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
string wUrl = "https://openpaymentsdata.cms.gov/resource/bqf5-h6wd.json";
string appt = "MyAppToken";
try
{
//Call getWebServiceResult to return our Article attributes
List<Payment> outPutResponse = GetWebServiceResult(wUrl);
If there's an alternative method to using the app token (like in the HTTP Connection for example) please let me know.
Figured it out...
https://openpaymentsdata.cms.gov/resource/bqf5-h6wd.json?$limit=10000&$$app_token="MyAppToken"

XrmServiceContext object is not getting the latest data from CRM

i have a wcf which connects to crm (on prem) to retrieve an account record. i can see when the entity is retrieved it does not hold the current record i.e. some field will still hold the old column value. i tried with various merge option with no avail. please see the code below
using (XrmServiceContext cContext = new XrmServiceContext(con))
{
Entity ent = cContext.Retrieve(ConstantKVP.AccountSchema.ENTITY_LOGICAL_NAME, AccountId, new ColumnSet(true));
}
any suggestions?
Is it possible the data is being cached?
cContext.TryAccessCache(cache => cache.Mode = OrganizationServiceCacheMode.Disabled);
I took this approach for a CrmOrganizationServiceContext, so perhaps the same theory applies.
After save use clear changes cContext.ClearChanges();
For retrieves use MergeOption.OverwriteChanges
Or
Create a new XrmServiceContext object by passing a newed up organizationservice:
var uncachedOrganizationService = new OrganizationService("Xrm");
var uncachedXrmServiceContext = new XrmServiceContext(uncachedOrganizationService);
var ent = uncachedXrmServiceContext.Retrieve(ConstantKVP.AccountSchema.ENTITY_LOGICAL_NAME,AccountId,new ColumnSet(true));

Very new to express and mongodb with gridfs-stream

and thanks in advance for any help you guys can give me. I am trying to use mongodb, mongoose, gridfs-strea, and express to store img files on mongodb.
I do not want to store the file in a folder. I want gfs.createWriteStream to take the file directly from app.post from express. App.post is currently saving some strings through a schema model into mongodb.
The form that routes to app.post contains strings and a input for img file.
I tried to do this(dnimgfront being the name of the input):
dnimgfront:req.pipe(gfs.createWriteStream('req.body.dnimgfront'))
I am getting back.
TypeError: Object function Grid(db, mongo) {
if (!(this instanceof Grid)) {
return new Grid(db, mongo);
}
mongo || (mongo = Grid.mongo ? Grid.mongo : undefined);
My problem is I have to be able to store the img and the strings from the same app.post save function. Any ideas?
What I'm using to connect to mongodb is:
mongoose.connect('mongodb://localhost/veeltaxi');
var con=mongoose.connection;
con.once('open', function(){
console.log('connected to mongodb succesfully!')
});
Thanks in advance for your help.
First, you need an instead of gridfs-stream:
var GridStream = require('gridfs-stream');
var mongodb = require('mongodb');
var gfs = new GridStream(mongoose.connection,mongodb);
At which point you can create the write stream and pipe:
var writeStream = gfs.createWriteStream({
filename: filename, // the name of the file
content_type: mimetype, // somehow get mimetype from request,
mode: 'w' // ovewrite
});
req.pipe(writeStream);
However, at this time the Node.js MongoDB Driver is at version 2.0 which uses Streams 2, so there is no reason to use gridfs-stream if you're using that version of the mongodb lib. See the source code for v2.0.13. FYI, the stream that is implemented in the updated driver is Duplex. (Aside: gridfs-stream has its share of problems, and while actively maintained, is not very frequent.)

Returning Raw Json in ElasticSearch NEST query

I'm doing a small research about a client for elastic search in .net and I found that NEST is one of the most supported solutions for this matter.
I was looking at Nest's docummentation and I couldn´t find a way to output a raw json from a query and avoid the serialization into an object, because I'm using angularJs in the front end I don´t want to overload the process of sending the information to the client with some unnecessary steps.
......and also I'd like to know how can I overrdide the serialization process?
I found that NEST uses Json.NET which I would like to change for the servicestack json serielizer.
thanks!
Hi Pedro you can do this with NEST
var searchDescriptor = new SearchDescriptor<ElasticSearchProject>()
.Query(q=>q.MatchAll());
var request = this._client.Serializer.Serialize(searchDescriptor);
ConnectionStatus result = this._client.Raw.SearchPost(request);
Assert.NotNull(result);
Assert.True(result.Success);
Assert.IsNotEmpty(result.Result);
This allows you to strongly type your queries, but return the string .Result which is the raw response from elasticsearch as string to your
request can be an object or the string so if you are OK with the internal json serialize just pass searchDescriptor directly
Use RequestResponseSerializer instead of Serializer.
var searchDescriptor = ...;
...
byte[] b = new byte[60000];
using (MemoryStream ms = new MemoryStream(b))
{
this._client.RequestResponseSerializer.Serialize(searchDescriptor , ms);
}
var rawJson = System.Text.Encoding.Default.GetString(b);

Issue Retrieving a Screenshot from a database

I've got a bunch of screenshots and some screenshot meta data I'm trying to display in an ASP.NET MVC 3 web application, I'm trying to retrieve the data from my databse but I get this error:
LINQ to Entities does not recognize the method 'System.Drawing.Image
ByteArrayToImage(Byte[])' method, and this method cannot be translated
into a store expression.
Here's my code:
var screenshotData = (from screenshots in db.screenshots
where screenshots.projects_ID == projectID
select new ImageInformation
{
ID = screenshots.id,
Language = screenshots.language,
Screenshot = Utility.ByteArrayToImage(screenshots.screen_shot),
ProjectID = screenshots.projects_ID
});
foreach (ImageInformation info in screenshotData)
{
this.Add(info);
}
ImageInformation is just a simple class that contains the defintion the information stored (ID, Language, Screenshot, ProjectID).
Here's my ByteArrayToImage function:
public static Image ByteArrayToImage(byte[] byteArrayIn)
{
using (MemoryStream ms = new MemoryStream(byteArrayIn))
{
Image returnImage = Image.FromStream(ms);
return returnImage;
}
}
Can anybody tell me why I receive this error when this code runs?
Thanks.
I think it's because, with LINQ-to-Entities, the code is turned into server-side query and it can't do that in this case. I don't think you can mix client-side code like this directly with L2E.
I would suspect you will have to do the conversion from byte->image after you've retrieved the data from the database as a distinct step.
You can't do the function in a LINQ to Entities query... one option:
1) have a byte[] property on the object you are instantiating (ImageInformation) and copy the data in there along with another propery to read the image from this ImageInformation object.

Resources