SAP API Journal Entry "Post Journal Entries from External Systems" (SAP_COM_0002) - api

Has anyone successfully created a Journal Entry in S/4HANA Cloud system via POSTMAN or Cloud Platform App?
I keep getting 401 unauthorized in POSTMAN. I tried PO GET API URL, and it is working fine.
https://:/sap/bc/srt/scs/sap/journalentrycreaterequestconfi
{
"JournalEntryBulkCreateRequest": {
"MessageHeader": { "CreationDateTime": "2018-05-27T12:50:30.45+01:00" },
"JournalEntryCreateRequest": {
"MessageHeader": { "CreationDateTime": "2018-05-27T12:50:30.45+01:00" },
"JournalEntry": {
"OriginalReferenceDocumentLogicalSystem": "",
"OriginalReferenceDocumentType": "BKPFF",
"OriginalReferenceDocument": "",
"BusinessTransactionType": "RFBU",
"AccountingDocumentType": "",
"DocumentHeaderText": "Header Value",
"CompanyCode": "US01",
"CreatedByUser": "CB9980000010",
"DocumentDate": "2018-05-27",
"PostingDate": "2018-05-27",
"item": [
{
"GLAccount": "0021517000",
"AmountInTransactionCurrency": {
"Amount": "1200.00",
"currencyCode": "USD"
},
"DocumentItemText": "Text1"
},
{
"GLAccount": "0010010000",
"AmountInTransactionCurrency": {
"Amount": "-1200.00",
"currencyCode": "USD"
},
"DocumentItemText": "Text2"
}
]
}
}
}

This is a Soap Request so you need to call by sending XML Envelop data.
var request =
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope\"" +
" xmlns:sfin=\"http://sap.com/xi/SAPSCORE/SFIN\"><soapenv:Header/><soapenv:Body><sfin:JournalEntryBulkCreateRequest>" +
"<MessageHeader><CreationDateTime>" + currentDate.toISOString() + "</CreationDateTime></MessageHeader>" +
"<JournalEntryCreateRequest><MessageHeader><CreationDateTime>" + currentDate.toISOString() + "</CreationDateTime></MessageHeader>" +
"<JournalEntry>" +
"<OriginalReferenceDocumentType>BKPFF</OriginalReferenceDocumentType>" +
"<OriginalReferenceDocument>" + Item[1] + "</OriginalReferenceDocument>" + // Report number
"<OriginalReferenceDocumentLogicalSystem>INBOUND</OriginalReferenceDocumentLogicalSystem>" +
"<BusinessTransactionType>RFBU</BusinessTransactionType>" +
"<AccountingDocumentType>SA</AccountingDocumentType>" +
"<DocumentHeaderText>Certify NonReimbursement</DocumentHeaderText>" +
"<CreatedByUser>CC0000000001</CreatedByUser>" +
"<CompanyCode>" + Item[8] + "</CompanyCode>" +
"<DocumentDate>" + this.parseJsonDate(documentDate) + "</DocumentDate>" +
"<PostingDate>" + this.parseJsonDate(postingdate) + "</PostingDate>" +
"<Item>" +
"<CompanyCode>" + Item[8] + "</CompanyCode>" +
"<GLAccount>" + this.suffixZeros(nonExpAcc + "") + "</GLAccount>" +
"<AmountInTransactionCurrency currencyCode=\"" + Item[5] + "\">-" + Item[4] + "</AmountInTransactionCurrency>" +
"<DebitCreditCode>S</DebitCreditCode>" +
"</Item>" +
"<Item>" +
"<CompanyCode>" + Item[8] + "</CompanyCode>" +
"<GLAccount>" + this.suffixZeros(Item[3] + "") + "</GLAccount>" +
"<AmountInTransactionCurrency currencyCode=\"" + Item[5] + "\">" + Item[4] + "</AmountInTransactionCurrency>" +
"<DebitCreditCode>H</DebitCreditCode>" +
"<AccountAssignment>" +
"<CostCenter>" + this.suffixZeros(Item[7] + "") + "</CostCenter>" +
"</AccountAssignment>" +
"</Item>" +
"</JournalEntry></JournalEntryCreateRequest></sfin:JournalEntryBulkCreateRequest></soapenv:Body></soapenv:Envelope>";

Related

setting password on pdf in appscript while expert pdf with URL?

pdf which was created in google-apps-script need to set a password then this pdf will be attached with email service
Is there any parameter to set a password within an export "url" before it is exported to Google drive?
function createPDF(ssId, sheet, pdfName) {
const fr = 0, fc = 0, lc = 9, lr = 27;
const url = "https://docs.google.com/spreadsheets/d/" + ssId + "/export" +
"?format=pdf&" +
"size=8&" +
"fzr=true&" +
"portrait=false&" +
"fitw=true&" +
"gridlines=false&" +
"printtitle=false&" +
"top_margin=0.25&" +
"bottom_margin=0.25&" +
"left_margin=0.25&" +
"right_margin=0.25&" +
"sheetnames=false&" +
"pagenum=UNDEFINED&" +
"attachment=true&" +
"gid=" + sheet.getSheetId() + '&' +
"r1=" + fr + "&c1=" + fc + "&r2=" + lr + "&c2=" + lc;
const params = { method: "GET", headers: { "authorization": "Bearer " + ScriptApp.getOAuthToken() } };
const blob = UrlFetchApp.fetch(url, params).getBlob().setName(pdfName + '.pdf');
// Gets the folder in Drive where the PDFs are stored.
const folder = getFolderByName_(OUTPUT_FOLDER_NAME);
const pdfFile = folder.createFile(blob);
return pdfFile;
}
No.
Unfortunately, there is no way of setting a password of an exported Drive File, that is, by using the Files.export method. That is for pdf files as well as other MIME types.
So, the password protection would have to be added (either manually or programatically) after the export from Drive.

Getting variable from webview to react native

I have a function in a webview which has response:
var respMsg = function(e)
{
var respData = eval("(" + e.data + ")");
document.getElementById("response").innerHTML = e.origin + " SENT " + " - " +
respData.responseCode + "-" + respData.dataKey + "-" + respData.errorMessage;
document.getElementById("response").style.display = 'none';
}
My question is: how to get for example respData.dataKey in a react native value so I can use it further (for example to get it and log its value)

web3 - event.watch spits out events in random order

I am watching an event:
var events = EthProj.Message({}, { fromBlock: 0, toBlock: 'latest'});
events.watch((error, results) => {
Inside the event I do this tempString = ((messages.split(":")[1].split(",")[0] + " (From: " + messages.split(":")[2].split("}")[0]) + ")").replace(/"/g, ''); Which, long story short, makes a string from the event giving the event from the block (i.e. It gives the event made at block 173).
I then set a <h2> element's text from each event. When this happens it sets them in a seemingly random order. What can be going on, it sets them from block 0 to the latest block, so how can this happen.
Here is the full code: https://pastebin.com/wGt5kL1Y
var events = EthProj.Message({}, { fromBlock: 0, toBlock: 'latest'});
events.watch((error, results) => {
i++;
messages = "";
messages = JSON.stringify(results.args);
if(i === messageToGet) {
if(messages.split(":")[1].split(",")[0] != '""') {
console.log(messages.split(":")[1].split(",")[0] + " (From: " + messages.split(":")[2].split(",")[0].split("}")[0].split("}")[0] + ")");
tempString = ((messages.split(":")[1].split(",")[0] + " (From: " + messages.split(":")[2].split("}")[0]) + ")").replace(/"/g, '');
} else {
console.log("(No included text)" + "(From: " + messages.split(":")[2].split(",")[0].split("}")[0] + ")");
tempString = (("(no included text) " + " (From: " + messages.split(":")[2].split("}")[0]) + ")").replace(/"/g, '');
}
if((messages.split(":")[1].split(",")[0] === undefined) || (messages.split(":")[2].split(")")[0] === undefined)) {
return;
}
if(document.getElementById("Message" + placeToSet) != null) {
document.getElementById("Message" + placeToSet).remove();
if(document.getElementById("hr" + placeToSet) != null) {
document.getElementById("hr" + placeToSet).remove();
}
}
if(document.getElementById("Message" + placeToSet) === null) {
var newh2 = document.createElement('h2');
newh2.setAttribute("id", ("Message" + placeToSet));
var text = document.createTextNode(tempString);
newh2.appendChild(text);
document.body.appendChild(newh2);
var newHR = document.createElement('hr');
newHR.setAttribute("id", ("hr" + placeToSet));
}
}
});

Cannot read property 'opacity' of undefined

I am loading the fine uploader in this manner:
var uploader = new qq.FineUploaderBasic({
button: $("#docAddHref"),
request: {
endpoint: 'server/handleUploads'
},
validation: {
allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
sizeLimit: 204800 // 200 kB = 200 * 1024 bytes
},
callbacks: {
onSubmit: function (id, fileName) {
$messages.append('<div id="file-' + id + '" class="alert" style="margin: 20px 0 0"></div>');
},
onUpload: function (id, fileName) {
$('#file-' + id).addClass('alert-info')
.html('<img src="client/loading.gif" alt="Initializing. Please hold."> ' +
'Initializing ' +
'“' + fileName + '”');
},
onProgress: function (id, fileName, loaded, total) {
if (loaded < total) {
progress = Math.round(loaded / total * 100) + '% of ' + Math.round(total / 1024) + ' kB';
$('#file-' + id).removeClass('alert-info')
.html('<img src="client/loading.gif" alt="In progress. Please hold."> ' +
'Uploading ' +
'“' + fileName + '” ' +
progress);
} else {
$('#file-' + id).addClass('alert-info')
.html('<img src="client/loading.gif" alt="Saving. Please hold."> ' +
'Saving ' +
'“' + fileName + '”');
}
},
onComplete: function (id, fileName, responseJSON) {
if (responseJSON.success) {
$('#file-' + id).removeClass('alert-info')
.addClass('alert-success')
.html('<i class="icon-ok"></i> ' +
'Successfully saved ' +
'“' + fileName + '”' +
'<br><img src="img/success.jpg" alt="' + fileName + '">');
} else {
$('#file-' + id).removeClass('alert-info')
.addClass('alert-error')
.html('<i class="icon-exclamation-sign"></i> ' +
'Error with ' +
'“' + fileName + '”: ' +
responseJSON.error);
}
},
onError: function (id, name, reason, xhr) {
$('#fubErrorAlert .message').text(reason);
$('#fubErrorAlert button').click(function () {
$('#fubErrorAlert').hide();
});
$('#fubErrorAlert').show();
}
}
});
console.log('uploader called');
uploader();
When the page loads I am getting this javascript error:
Cannot read property 'opacity' of undefined
I installed the FineUploader via Nuget Pacakage for ASP.NET
https://github.com/Widen/fine-uploader-server/tree/master/ASP.NET%20MVC%20C%23
Please advice!
Your button option is likely the problem. You should change it to:
button: $("#docAddHref")[0]
If you want to do things like pass in a jQuery object, you will need to download and use Fine Uploader's jQuery plugin. More info about the plugin at http://docs.fineuploader.com/integrating/jquery.html

Debugging PhantomJS webpage.open failures

In PhantomJS, webpage.open takes a callback with a status parameter that's set to 'success' or 'fail'. According to the docs, it wll be "'success' if no network errors occurred, otherwise 'fail'." Is there a way to see the underlying network error that caused the failure?
The url I'm trying to load works fine when I put it in my browser, and when I take a screenshot after getting the 'fail' message I see the page that I was on before I called webpage.open (so I can't just ignore the fail). I'm using Phantom for testing, so ideally I'd like a robust way of easily getting a helpful error messsage when webpage.open fails (or better yet have it never fail!)
Found this post which explains how to set up callbacks to get at the underlying reason for the failure: http://newspaint.wordpress.com/2013/04/25/getting-to-the-bottom-of-why-a-phantomjs-page-load-fails/
Based on the that page, you could print out errors as follows:
page.onResourceError = function(resourceError) {
console.error(resourceError.url + ': ' + resourceError.errorString);
};
The page goes on to show an example of detailed logging for phantoms
var system = require('system');
page.onResourceRequested = function (request) {
system.stderr.writeLine('= onResourceRequested()');
system.stderr.writeLine(' request: ' + JSON.stringify(request, undefined, 4));
};
page.onResourceReceived = function(response) {
system.stderr.writeLine('= onResourceReceived()' );
system.stderr.writeLine(' id: ' + response.id + ', stage: "' + response.stage + '", response: ' + JSON.stringify(response));
};
page.onLoadStarted = function() {
system.stderr.writeLine('= onLoadStarted()');
var currentUrl = page.evaluate(function() {
return window.location.href;
});
system.stderr.writeLine(' leaving url: ' + currentUrl);
};
page.onLoadFinished = function(status) {
system.stderr.writeLine('= onLoadFinished()');
system.stderr.writeLine(' status: ' + status);
};
page.onNavigationRequested = function(url, type, willNavigate, main) {
system.stderr.writeLine('= onNavigationRequested');
system.stderr.writeLine(' destination_url: ' + url);
system.stderr.writeLine(' type (cause): ' + type);
system.stderr.writeLine(' will navigate: ' + willNavigate);
system.stderr.writeLine(' from page\'s main frame: ' + main);
};
page.onResourceError = function(resourceError) {
system.stderr.writeLine('= onResourceError()');
system.stderr.writeLine(' - unable to load url: "' + resourceError.url + '"');
system.stderr.writeLine(' - error code: ' + resourceError.errorCode + ', description: ' + resourceError.errorString );
};
page.onError = function(msg, trace) {
system.stderr.writeLine('= onError()');
var msgStack = [' ERROR: ' + msg];
if (trace) {
msgStack.push(' TRACE:');
trace.forEach(function(t) {
msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function + '")' : ''));
});
}
system.stderr.writeLine(msgStack.join('\n'));
};