I'm getting run time error 1004 method range of object global failed - runtime-error

I'm getting an error in this script and I'm not sure how to fix it. It's the if Range statement.
Sub ShowHideChart()
If Range("show_chart").Value = True Then To the left is the line I'm having trouble with
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveSheet.Shapes.Range(Array("Chart 2")).Visible = msoTrue

Related

Calling PATCH API method returns 400 error?

I'm trying to call a PATCH Method API within ABAP, but i am always getting code 400 back with error message that content type is not supported, its needed application/json which i am setting already in the code.
cl_http_client=>create_by_url(
EXPORTING
url = lv_url
IMPORTING
client = lo_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4 ).
* Set request parameter (Authorization)
lo_client->request->set_header_field(
name = mc_param_name_authorization
value = mc_auth_type_bearer && | { mv_access_token }|
).
* Set request parameter (apiKey)
lo_client->request->set_header_field(
name = mc_param_name_apikey
value = CONV string( ms_access_settings-api_key )
).
* Set request parameter (realm)
lo_client->request->set_header_field(
name = mc_param_name_realm
value = get_realm( mc_api_call_approve )
).
lo_client->request->set_method( 'PATCH' ).
lo_client->request->set_content_type( 'application/json' ).
lo_http_client->request->set_cdata( lv_body_json ).
lo_client->send( ).
lo_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4 ).

SAP - Error 800A026B - The control could not be found by id

I´m dealing with the problem regarding SAP GUI automation.
I have a script shown below which is working without any problem BUT it is working only in the first window of the SAP.
When I have something open in the first window of the SAP and for example the home page of the SAP in 2nd window - I will get this error :
800A026B - The control could not be found by id.
Is there any option how to tell: If window 1 is not available try window No. 2 (Or If window No.1 is not available open a new window and perform there the script?)
Script as below:
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").resizeWorkingPane 206,40,false
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00082"
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = "/CASWW/LBL_DATA"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/mbar/menu[3]/menu[2]").select
session.findById("wnd[1]/usr/chk[2,13]").selected = true
session.findById("wnd[1]/usr/chk[2,13]").setFocus
session.findById("wnd[1]/usr").verticalScrollbar.position = 21
session.findById("wnd[1]/usr/chk[2,13]").selected = true
session.findById("wnd[1]/usr/chk[2,13]").setFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/ctxtI1-LOW").text = "2000"
session.findById("wnd[0]/usr/ctxtI2-LOW").text = "A2C03664400"
session.findById("wnd[0]/usr/ctxtI3-LOW").text = "1.1.2021"
session.findById("wnd[0]/usr/ctxtI3-HIGH").setFocus
session.findById("wnd[0]/usr/ctxtI3-HIGH").caretPosition = 0
session.findById("wnd[0]").sendVKey 4
session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = "20220104"
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/ctxtLIST_BRE").text = "2500"
session.findById("wnd[0]/usr/txtMAX_SEL").text = "5000 "
session.findById("wnd[0]/usr/txtMAX_SEL").setFocus
session.findById("wnd[0]/usr/txtMAX_SEL").caretPosition = 10
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/mbar/menu[3]/menu[0]/menu[1]").select
session.findById("wnd[1]/tbar[0]/btn[14]").press
session.findById("wnd[1]/usr/chk[1,3]").selected = true
session.findById("wnd[1]/usr/chk[1,4]").selected = true
session.findById("wnd[1]/usr/chk[1,5]").selected = true
session.findById("wnd[1]/usr/chk[1,6]").selected = true
session.findById("wnd[1]/usr/chk[1,8]").selected = true
session.findById("wnd[1]/usr/chk[1,9]").selected = true
session.findById("wnd[1]/usr/chk[1,12]").selected = true
session.findById("wnd[1]/usr/chk[1,17]").selected = true
session.findById("wnd[1]/usr/chk[1,20]").selected = true
session.findById("wnd[1]/usr/chk[1,21]").selected = true
session.findById("wnd[1]/usr/chk[1,21]").setFocus
session.findById("wnd[1]/usr").verticalScrollbar.position = 19
session.findById("wnd[1]/usr/chk[1,14]").selected = true
session.findById("wnd[1]/usr/chk[1,14]").setFocus
session.findById("wnd[1]/tbar[0]/btn[6]").press
session.findById("wnd[0]/usr/lbl[173,3]").setFocus
session.findById("wnd[0]/usr/lbl[173,3]").caretPosition = 0
session.findById("wnd[0]").sendVKey 42
session.findById("wnd[0]/mbar/menu[1]/menu[5]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").setFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "D3.XLS"
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "\\cw01.contiwan.com\bdyp\dida4065\Zakaznicka_kvalita\300003300023-0002-0001"
session.findById("wnd[1]/usr/ctxtDY_FILE_ENCODING").text = "0000"
session.findById("wnd[1]/usr/ctxtDY_FILE_ENCODING").setFocus
session.findById("wnd[1]/usr/ctxtDY_FILE_ENCODING").caretPosition = 4
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]").resizeWorkingPane 206,40,false
session.findById("wnd[0]/tbar[0]/okcd").text = "mb52"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtMATNR-LOW").text = "A2C03664400"
session.findById("wnd[0]/usr/ctxtWERKS-LOW").text = "2000"
session.findById("wnd[0]/usr/ctxtWERKS-LOW").setFocus
session.findById("wnd[0]/usr/ctxtWERKS-LOW").caretPosition = 4
session.findById("wnd[0]/tbar[1]/btn[8]").press
Thank you for any advise.
Ok, I just solve the issue so the guidance for everyone who would deal with the same problem..
If you have something open in the Window No.1 you have 2 options:
Terminate the script in Window No.1 no matter what has been open there
For the termination add /n before the name of transaction..
Open a new session and perform the script there.
For new session add /o before name of the transaction
Use Followigs:
session.findById("wnd[0]").resizeWorkingPane 159,28,false
session.findById("wnd[0]/tbar[0]/okcd").text = "/nName_of_Transaction"
session.findById("wnd[0]").sendVKey 0
So in my code it would be:
session.findById("wnd[0]").resizeWorkingPane 159,28,false
session.findById("wnd[0]/tbar[0]/okcd").text = "/nZQQN_WLQN"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/chkDY_RST").selected = true
session.findById("wnd[0]/usr/chkDY_MAB").selected = true
session.findById("wnd[0]/usr/chkDY_DEL").selected = true
etc...
Thank also Sandra for her help.

Android program crashes before running.when compiled for Debug

I'm developing a program using Android Studio that runs as expected when the normal APK is run, but if I compile it for Debugging, it crashes before the 1st line of code executes, so setting a brake-point on the 1st line of my code to execute, never trips.
I have already
Completely deleted the program from the test target (nexus 7)
Power offed the tablet and then restarted tablet
Power off/rebooted the development machine
Cleaned the project
Rebuilt the project.
The program still runs as expected when compiled/run without debugging.
Crashes after loading, but before running when compiled/run in debug.
Any ideas on how to try and overcome this problem would be welcome.
Android Studio 2.1.2
compileSdkVersion 21
buildToolsVersion "21.1.2
Copy of exception variable after crash
shadow$klass = {Class#613} "class java.lang.Class"
superClass = {Class#1356} "class java.lang.Exception"
2 = {ArtMethod#3613}
17 = {ArtMethod#3628}
numReferenceStaticFields = 0
verifyErrorClass = null
iFields = {ArtField[2]#3636}
stackState = {Object[22]#3602}
3 = {ArtMethod#3614}
0 = {ArtMethod#3611}
errno = 2
classLoader = null
8 = {ArtMethod#3619}
dexCache = {DexCache#3633}
functionName = "stat"
virtualMethods = {ArtMethod[3]#3639}
shadow$monitor = -1294973706
primitiveType = 0
Exception = {ErrnoException#3590}
16 = {ArtMethod#3627}
value = {char[4]#3607}
ifTable = {Object[2]#3637}
vtable = null
4 = {ArtMethod#3615}
suppressedExceptions = {Collections$EmptyList#3604} size = 0
classSize = 468
functionName = "stat"
6 = {ArtMethod#3617}
errno = 2
hashCode = 3540564
referenceStaticOffsets = 0
1 = {ArtMethod#3612}
13 = {ArtMethod#3624}
detailMessage = null
18 = {ArtMethod#3629}
stackTrace = {StackTraceElement[0]#3603}
sFields = null
dexClassDefIndex = 4
componentType = null
15 = {ArtMethod#3626}
status = 10
10 = {ArtMethod#3621}
shadow$klass = {Class#3428} "class java.lang.String"
shadow$klass = {Class#183} "class android.system.ErrnoException"
19 = {ArtMethod#3630}
12 = {ArtMethod#3623}
5 = {ArtMethod#3616}
referenceInstanceOffsets = -1090519040
cause = {ErrnoException#3590} "android.system.ErrnoException: stat failed: ENOENT (No such file or directory)"
suppressedExceptions = {Collections$EmptyList#3604} size = 0
objectSize = 36
detailMessage = null
shadow$klass = {Class#183} "class android.system.ErrnoException"
dexCacheStrings = {String[23663]#3634}
dexTypeIndex = 6
shadow$monitor = -1665173294
offset = 0
14 = {ArtMethod#3625}
numReferenceInstanceFields = 1
Variables debug info not available
21 = {int[21]#3632}
name = "android.system.ErrnoException"
stackState = {Object[22]#3602}
clinitThreadId = 456
directMethods = {ArtMethod[2]#3635}
7 = {ArtMethod#3618}
20 = {ArtMethod#3631}
9 = {ArtMethod#3620}
11 = {ArtMethod#3622}
count = 4
shadow$monitor = -1353303322
cause = {ErrnoException#3590} "android.system.ErrnoException: stat failed:
ENOENT (No such file or directory)"
stackTrace = {StackTraceElement[0]#3603}
accessFlags = 524305
Well, I solved the problem myself. NOT in a way that I'd like to have solved it, or that in any way explained what caused the problem, but the problem was corrected. - I've been in IT long enough to know you need to do backups, and once I remembered I had them, I pulled the backup of a day before the problem surfaced, restored the entire directory tree when the project resided and PUFF, everything worked. Re-applied any code changes I made in the day after the backup (I keep pretty good paper notes on changes) and away I went.
- BUT -
This doesn't explain why the system was working one day and after a night of sleep, the system wouldn't work the next day. And I still have no idea how a person who received the error message I received would go about debugging/fixing the problem if he/she didn't have a good set of backups.
ALSO – it seems that someone downgraded my question. Maybe it did deserve to be downgraded, but I have no idea why it was downgraded. The question seemed reasonable to me. One day late in the evening the system worked, and the next day it didn't and the information the system offered was posted in the question.
I'd be very happy if anyone could explain to me how a person could extract information from the posted log, to find out what was wrong – or – at least explain why the question was improper enough to warrant a downgrade ?
any reasonable comments would be welcome.
Joe Cullity

How to display WebDynpro ABAP in ABAP report?

I've just started coding ABAP for a few days and I have a task to call the report from transaction SE38 and have
the report's result shown on the screen of the WebDynPro application SE80.
The report take the user input ( e.g: Material Number, Material Type, Plant, Sale Org. ) as a condition for querying, so the WebDynPro application must allow user to key in this parameters.
In some related article they were talking about using SUBMIT rep EXPORTING LIST TO MEMORY and CALL FUNCTION 'LIST_FROM_MEMORY' but so far I really have no idea to implement it.
Any answers will be appreciated. Thanks!
You can export it to PDF. Therefore, when a user clicks on a link, you run the conversion and display the file in the browser window.
To do so, you start by creating a JOB using the following code below:
constants c_name type tbtcjob-jobname value 'YOUR_JOB_NAME'.
data v_number type tbtcjob-jobcount.
data v_print_parameters type pri_params.
call function 'JOB_OPEN'
exporting
jobname = c_name
importing
jobcount = v_number
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.
if sy-subrc = 0.
commit work and wait.
else.
EXIT. "// todo: err handling here
endif.
Then, you need to get the printer parameters in order to submit the report:
call function 'GET_PRINT_PARAMETERS'
exporting
destination = 'LP01'
immediately = space
new_list_id = 'X'
no_dialog = 'X'
user = sy-uname
importing
out_parameters = v_print_parameters
exceptions
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
others = 4.
v_print_parameters-linct = 55.
v_print_parameters-linsz = 1.
v_print_parameters-paart = 'LETTER'.
Now you submit your report using the filters that apply. Do not forget to add the job parameters to it, as the code below shows:
submit your_report_name
to sap-spool
spool parameters v_print_parameters
without spool dynpro
with ...(insert all your filters here)
via job c_name number v_number
and return.
if sy-subrc = 0.
commit work and wait.
else.
EXIT. "// todo: err handling here
endif.
After that, you close the job:
call function 'JOB_CLOSE'
exporting
jobcount = v_number
jobname = c_name
strtimmed = 'X'
exceptions
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
others = 8.
if sy-subrc = 0.
commit work and wait.
else.
EXIT. "// todo: err handling here
endif.
Now the job will proceed and you'll need to wait for it to complete. Do it with a loop. Once the job is completed, you can get it's spool output and convert to PDF.
data v_rqident type tsp01-rqident.
data v_job_head type tbtcjob.
data t_job_steplist type tbtcstep occurs 0 with header line.
data t_pdf like tline occurs 0 with header line.
do 200 times.
wait up to 1 seconds.
call function 'BP_JOB_READ'
exporting
job_read_jobcount = v_number
job_read_jobname = c_name
job_read_opcode = '20'
importing
job_read_jobhead = v_job_head
tables
job_read_steplist = t_job_steplist
exceptions
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 3
others = 4.
read table t_job_steplist index 1.
if not t_job_steplist-listident is initial.
v_rqident = t_job_steplist-listident.
exit.
else.
clear v_job_head.
clear t_job_steplist.
clear t_job_steplist[].
endif.
enddo.
check not v_rqident is initial.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = v_rqident
dst_device = 'LP01'
tables
pdf = t_pdf
exceptions
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
others = 12.
If you're going to send it via HTTP, you may need to convert it to BASE64 as well.
field-symbols <xchar> type x.
data v_offset(10) type n.
data v_char type c.
data v_xchar(2) type x.
data v_xstringdata_aux type xstring.
data v_xstringdata type xstring.
data v_base64data type string.
data v_base64data_aux type string.
loop at t_pdf.
do 134 times.
v_offset = sy-index - 1.
v_char = t_pdf+v_offset(1).
assign v_char to <xchar> casting type x.
concatenate v_xstringdata_aux <xchar> into v_xstringdata_aux in byte mode.
enddo.
concatenate v_xstringdata v_xstringdata_aux into v_xstringdata in byte mode.
clear v_xstringdata_aux.
endloop.
call function 'SCMS_BASE64_ENCODE_STR'
exporting
input = v_xstringdata
importing
output = v_base64data.
v_base64data_aux = v_base64data.
while strlen( v_base64data_aux ) gt 255.
clear t_base64data.
t_base64data-data = v_base64data_aux.
v_base64data_aux = v_base64data_aux+255.
append t_base64data.
endwhile.
if not v_base64data_aux is initial.
t_base64data-data = v_base64data_aux.
append t_base64data.
endif.
And you're done!
Hope it helps.
As previous speakers said, you should do extensive training before implementing such stuff in productive environment.
However, calling WebdynPro ABAP within report can be done with the help of WDY_EXECUTE_IN_PLACE function module. You should pass there Webdyn Pro application and necessary parameters.
CALL FUNCTION 'WDY_EXECUTE_IN_PLACE'
EXPORTING
* PROTOCOL =
INTERNALMODE = ' '
* SMARTCLIENT =
APPLICATION = 'Z_MY_WEBDYNPRO'
* CONTAINER_NAME =
PARAMETERS = lt_parameters
SUPPRESS_OUTPUT =
TRY_TO_USE_SAPGUI_THEME = ' '
IMPORTING
OUT_URL = ex_url
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

R: field '$addToSet' in '$addToSet' is not valid for storage: rmongodb

I am trying to write a generic upsert for a tick Database in R.
The python code would be:
collection.update({'symbol':'somesymbol', 'sha':'SoM3__W3|Re|7__Sh#'},
{'$set':{segment:5},
'$addToSet': {'parent':parent_id}}},
upsert=True)
In R I am using rmongodb and trying to build the BSON Objects
#get the query
mtch_b<-mongo.bson.buffer.create()
mongo.bson.buffer.append(mtch_b, "symbol", "somesymbol")
mongo.bson.buffer.append(mtch_b, "sha", "SoM3__W3|Re|7__Sh#")
mtch<-mongo.bson.from.buffer(mtch_b)
#set the segment
qry_b<-mongo.bson.buffer.create()
mongo.bson.buffer.start.object(qry_b, "$set")
mongo.bson.buffer.append(qry_b, "segment", 5)
mongo.bson.buffer.start.object(qry_b, "$addToSet")
mongo.bson.buffer.append(qry_b, "parent", "Initial")
mongo.bson.buffer.finish.object(qry_b) #end of $addtoSet object
mongo.bson.buffer.finish.object(qry_b) #end of $set object
qry_bsn <-mongo.bson.from.buffer(qry_b)
mongo.update(mongo, "M__test.tmp", mtch, qry_bsn, flags=mongo.update.upsert)
When I run this I get an error:
"The dollar ($) prefixed field '$addToSet' in '$addToSet' is not valid for storage."
looking at the qry_bsn:
qry_bsn
$set : 3
segment : 4
0 : 1 1.000000
1 : 1 2.000000
2 : 1 3.000000
3 : 1 4.000000
$addToSet : 3
parent : 2 Initial
When I remove the $addToSet, append and finish objects of the $addToSet object the query runs fine.
Any help on how to do this would be much appreciated.
I can't find reason for not using mongo.bson.from.list. It make all mongo.bson.buffer.* calls for you. And it is much less chance to produce a bug with bson construction.
query <- mongo.bson.from.list(list("symbol" = "somesymbol", "sha" = "SoM3__W3|Re|7__Sh#"))
upd_obj <- mongo.bson.from.list(list('$set' = list('segment' = 1:4), '$addToSet' = list('parent' = 'PARENT_ID')))
mongo.update(mongo = mongo, ns = "M__test.tmp", criteria = query, objNew = upd_obj, flags=mongo.update.upsert)

Resources