How to create file xslx multpi sheet sap - xlsx

I need to create a file xlsx from itab of string.
I used the class cl_gui_frontend_services, the method clipboard_export.
I write the following code but it does not create a file in the path, as expected.
IF v_excel-header = space OR v_excel-handle = -1.
CREATE OBJECT v_excel 'EXCEL.APPLICATION'.
ENDIF.
CALL METHOD OF v_excel 'Workbooks' = v_workbooklist.
SET PROPERTY OF v_excel 'Visible' = 0.
CALL METHOD OF v_workbooklist 'Add' = v_workbook.
v_sheet_name = 'A'.
SET PROPERTY OF v_worksheet 'Name' = v_sheet_name.
GET PROPERTY OF v_excel 'ACTIVESHEET' = v_worksheet.
CALL METHOD OF v_excel 'range' = v_range
EXPORTING
#1 = 'A1' "From column
#2 = 'D1'. "To column
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = pt_data_s1
CHANGING
rc = v_return_code
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
CALL METHOD OF v_excel 'Cells' = v_fromcell
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF v_excel 'Cells' = v_tocell
EXPORTING
#1 = 3
#2 = 4.
CALL METHOD OF v_excel 'Range' = v_datarange
EXPORTING
#1 = v_fromcell
#2 = v_tocell.
CALL METHOD OF v_excel 'Columns' = v_column.
CALL METHOD OF v_column 'Autofit'.
FREE OBJECT v_column.
CALL METHOD OF v_datarange 'Select'.
CALL METHOD OF v_worksheet 'Paste'.
GET PROPERTY OF v_excel 'ActiveWorkbook' = v_worksheet.
CALL METHOD OF v_worksheet 'SAVEAS'
EXPORTING
#1 = lv_path
#2 = 1.
CALL METHOD OF v_worksheet 'close'.
Someone could give me some suggestions?
Thank you

At begging you need to make call to Method of Worksheet, example:
DATA: go_sheet TYPE ole2_object.
CALL METHOD OF v_excel
'Worksheets' = go_sheet
EXPORTING
#1 = gs_config-id_sheet.
CALL METHOD OF go_sheet 'Activate'.
SET PROPERTY OF go_sheet 'Name' = gs_config-name_sheet. "'Sheet1'.

Related

Inject user index into body file in Gatling scenario

I want to use ELFileBody and put a variable in a txt file.
This file contains a soap request.
The request (scenario) is executed only one time but as many times as users.
I want to put into file variable, the user index (position in execution).
Something like this :
.set("myVar", userIndex) //myVar is the variable declared in the body file ( ${myVar} )
Here is my code for now :
val users = 1500
val baseUrl = "http://127.0.0.1:7001"
val httpProtocol = http
.baseURL(baseUrl)
.inferHtmlResources()
.acceptEncodingHeader("gzip,deflate")
.contentTypeHeader("text/xml;charset=UTF-8")
.userAgentHeader("Apache-HttpClient/4.1.1 (java 1.5)")
val headers_0 = Map("SOAPAction" -> """""""")
val uri1 = "http://127.0.0.1:7001/myProject-ws/myProjectWebService"
val scn = scenario("Scenario1Name")
.exec(http("scn.Scenario1Name")
.post("/myProject-ws/myProjectWebService")
.headers(headers_0)
.body(RawFileBody("File_0000_request.txt")))
setUp(scn.inject(atOnceUsers(users))).protocols(httpProtocol)
How can I inject the user index into myVar variable in the request body ?
finally, i used a function that return a dynamic reference (id) and I call it from my scenario.
def getDynamicId(): String = {
val formatter = new SimpleDateFormat("yyyyMMddHHmmss.SSS")
val result = "PM".concat(formatter.format(Calendar.getInstance().getTime()))
result
}
//[...]
scenario("ScenarioName")
.exec(session => session.set("myVar", getDynamicId))
// [...]
.body(ElFileBody("BodyFile_0000_request.txt")))
And in the body file, I have the variable ${myVar}
You need read file like e.g.
val customSeparatorFeeder = separatedValues(pathToFile, separator).queue circular
after scenario("Scenario1Name") you need to add .feed(customSeparatorFeeder)
you can read more about it here https://gatling.io/docs/2.3/session/feeder/

Gideros event showing as null after being triggered

I have got Dispatched events in my gideros game. What im not certain of, is that when i try access the event (object triggered) it returns a table that has a length of 0.
I have a letter class as below:
GridLetter = gideros.class(Sprite)
function GridLetter:init(letter)
self.image = Bitmap.new(Texture.new("GridLetters/"..letter.."Grid.png"))
self.image:setAnchorPoint(0.5, 0.5)
self.focus = false
self:updateVisualState(true)
self:addEventListener(Event.MOUSE_DOWN, self.onMouseDown, self)
end
function GridLetter:onMouseDown(event)
if self:hitTestPoint(event.x, event.y) then
self.focus = true
self:dispatchEvent(Event.new("GridLetterDown"))
event:stopPropagation()
end
end
function GridLetter:updateVisualState(state)
if state then
self:addChild(self.image)
end
end
The code that implements this class is below:
grid = Core.class(Sprite)
local letterArr = {"a","b","c","d","e","f","g","h","u","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}
local gridboard = {{},{},{},{}}
local letterBoxArr = {{},{},{},{}}
local letterBox
function grid:init(params)
local widthOfSingle = (application:getContentWidth() / 4)
for rowCount = 1,4 do
for colCount = 1,4 do
rand = math.random(1, 26)
gridboard[rowCount][colCount] = letterArr[rand]
end
end
for rowCount = 1,4 do
for colCount = 1,4 do
letterBox = GridLetter.new(gridboard[rowCount][colCount])
letterBoxArr[rowCount][colCount] = {letterBoxItem=letterBox}
letterBoxArr[rowCount][colCount].letterBoxItem:setPosition(((widthOfSingle * colCount) - (widthOfSingle / 2)), 100 * rowCount)
letterBoxArr[rowCount][colCount].letterBoxItem.letter = gridboard[rowCount][colCount];
letterBoxArr[rowCount][colCount].letterBoxItem:addEventListener("GridLetterDown", LetterDown, self)
self:addChild(letterBoxArr[rowCount][colCount].letterBoxItem)
end
end
end
function LetterDown(event)
print(event.target.letter)
end
When i click on one of these image, the event is fired and code does run under the LetterDown event, but when trying to access the event parameter, it returns:
grid.lua:32: attempt to index field 'target' (a nil value)
stack traceback:
grid.lua:32: in function <grid.lua:31>
GridLetter.lua:15: in function <GridLetter.lua:12>
any idea or workarounds?
When replacing:
print(event.target.letter)
to
print(event.x)
It prints nil.
I appreciate your help in advance.
Regards,
Warren
This isn't an answer (I'd comment, but that strangely requires rep).
The error you're getting is because in event, there's nothing in the target field.
You could find out what's in the table by looping over it (or by using a pretty table print function, if glideros defines one/you define one yourself):
for k, v in pairs(target) do print(k, v) end
If you're not sure if target will exist all the time, you can also do something like this:
print(not event.target and "event.target does not exist" or event.target.letter)
You can read about the A and B or C construct here: http://lua-users.org/wiki/TernaryOperator
Edit: Assuming that the event you receive fires with a GridLetter object, you are not setting self.letter to anything. Perhaps setting the field will help:
function GridLetter:init(letter)
self.letter = letter -- Forgot this?
self.image = Bitmap.new(Texture.new("GridLetters/"..letter.."Grid.png"))
self.image:setAnchorPoint(0.5, 0.5)
self.focus = false
self:updateVisualState(true)
self:addEventListener(Event.MOUSE_DOWN, self.onMouseDown, self)
end
I have got it.. Someone on gideros forums helped me out, thanks to Advert as well.
So in my onMouseDown event i was assigning the .letter on the general event. So creating a local var and assigning it the event before dispatching it, the variable then keeps my assigned letter.
Hope this helps others in future!
function GridLetter:onMouseDown(event)
if self:hitTestPoint(event.x, event.y) then
self.focus = true
local e = Event.new("GridLetterDown")
e.letter = self.letter
self:dispatchEvent(e)
event:stopPropagation()
end
end
Thanks for all responses.

How to call a function in Matlab GUI?

Im new in matlab, Im trying to call a function inside a matlab GUI but I keep getting an error. Can you please help.
function PushMe_Callback(hObject, eventdata, handles)
set(handles.output_line,'String','I Got here');
Get_Length(Note_Vector,output,Counter,Total_num)
%------------------------------------------------------------
function Get_Length(Note_Vector,output,Counter,Total_num)
output = [ ];
while (1)
T = Total_num - Counter;
for j=1:T
[xml_input]=Get_Note(Note_Vector(j));
output = [output xml_input];
end
end
You have to get your data from the gui data. You can retrieve these data from the function "guidata".
In fact what happens, is that you define a variable in the "main function" but you cannot access this one.
What you should do is to add this variable in the handles in the "GUI_OpeningFcn" function:
Note_Vector = [ ];
output = [ ];
Counter = 0
for i=1:Total_num
Note_Vector = [Note_Vector Note+Shift];
end
handles.Note_Vector = Note_Vector;
handles.GLoutput = output; %handles.output is already the handle of your GUI, don't change it.
handles.counter=counter;
handles.Total_num=Total_num;
(...)
guidata(hObject, handles);
then you can either retrieve these data in PushMe_Callback by simply writing handles.Note_Vector OR you can retrieve them by doing the following in Get_Length function
handles = guidata(handle). In that case you'll have to put in input the handle of your GUI
Get_Length(Note_Vector,output,Counter,Total_num,handles.output)
I let you check the matlab help file concerning guidata() if you want more information.

Prestashop 1.4.3 I need to get a database value and use it in MailAlerts module

I have asked this question on the Prestashop forum, but haven't had a reply as of yet.
I need to be able to add a sagepay code to the new order email used in mailalert module.
What I have is;
// Filling-in vars for email
$template = 'new_order';
$subject = $this->l('New order');
$spvtxc = Db::getInstance()->ExecuteS("SELECT vendortxcode FROM `"._DB_PREFIX_."sagepay_transactions` WHERE id_cart = '$order->id_cart'");
...
$templateVars = array(
'{firstname}' => $customer->firstname,
'{lastname}' => $customer->lastname,
...
'{sagepay_no}' => $spvtxc,
...
);
Every time i test a transaction the $spvtxc returns 'ARRAY'.
I have tried;
$spvtxc = '5';
As Expected this returns 5 as the sagepay number, so I'm confident the variables are being called and added to the email.
And I tried;
$spvtxc = Db::getInstance()->ExecuteS("SELECT vendortxcode FROM `"._DB_PREFIX_."sagepay_transactions` WHERE id_cart = '2'");
So this should set $spvtxc to the value that is definatly there (i manually added it in the database), but this still returned 'ARRAY'.
If anyone can point out what I have missed, it is greatly appriceated.
As I was only needing to return a single value, I should have used getValue function instead of ExecuteS.
$spvtxc = Db::getInstance()->getValue("SELECT vendortxcode FROM `"._DB_PREFIX_."sagepay_transactions` WHERE id_cart = '$order->id_cart'");
This returned the value.

Re-assigning an array in ASP classic

I have the following function, designed to walk through XML and create a linear structure of all nodes:
function get_children(n)
if n.hasChildNodes() then
for each child in n.childNodes
set local_array = array_merge(get_children(child), local_array)
next
else
set local_array = Array(n)
end if
get_children = local_array
end function
I've tried a ton of variations, but I keep getting errors on the line
set local_array = Array(n)
It it's current form, I see:
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required
/_inc/nav/left-nav.inc, line 37
Am I mis-using the Array() construct? Aren't I able to create an array with a single value?
Change
set local_array = Array(n)
to
local_array = Array(0)
set local_array(0) = n

Resources