COMMUNICATION_FAILURE during a Webdynpro BAPI call? - abap

I have created a simple WebDynpro application that calls a BAPI. However, i am getting an error as RFC is not setup.
How do i setup the RFC call?
Error:
The URL call http://crmehp.sat.com:8024/sap/bc/webdynpro/sap/zwd_bapi_call was terminated because of an error.
The following error text was processed in system EH5 : RFC Exception COMMUNICATION_FAILURE with Message RFC destination BAPI Call does not exist. Occurred
◾ The error occurred on the application server CRMEHP2_EH5_24 and in the work process 0 .
◾ The termination type was: RABAX_STATE
◾ The ABAP call stack was:
Method: EXECUTE_BAPI_FLIGHT_GETLIST of program /1BCWDY/0AA4D2ZOSMWRNSH8KCQZ==CP
Method: IF_COMPONENTCONTROLLER~EXECUTE_BAPI_FLIGHT_GETLIST of program /1BCWDY/0AA4D2ZOSMWRNSH8KCQZ==CP
Method: WDDOINIT of program /1BCWDY/0AA4D2ZOSMWRNSH8KCQZ==CP
Method: IF_WDR_VIEW_DELEGATE~WD_DO_INIT of program /1BCWDY/0AA4D2ZOSMWRNSH8KCQZ==CP
Method: DO_INIT of program CL_WDR_DELEGATING_VIEW========CP
Method: INIT_CONTROLLER of program CL_WDR_CONTROLLER=============CP
Method: INIT_CONTROLLER of program CL_WDR_VIEW===================CP
Method: INIT of program CL_WDR_CONTROLLER=============CP
Method: GET_VIEW of program CL_WDR_VIEW_MANAGER===========CP
Method: BIND_ROOT of program CL_WDR_VIEW_MANAGER===========CP
Calling procedure bapi_flight_getlist in WDDOINIT method of webdynpro:
method WDDOINIT .
DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).
lo_componentcontroller->execute_bapi_flight_getlist(
airline = 'AA' " bapisflkey-airlineid
* destination_from = " bapisfldst
* destination_to = " bapisfldst
* max_rows = " bapisflaux-bapimaxrow
).
endmethod.
execute_bapi_flight_getlist defination:
CALL FUNCTION 'BAPI_FLIGHT_GETLIST'
DESTINATION 'BAPI Call'
EXPORTING
airline = airline
destination_from = destination_from
destination_to = destination_to
max_rows = max_rows
TABLES
date_range = lt_c_date_range
extension_in = lt_c_extension_in
flight_list = lt_c_flight_list
extension_out = lt_c_extension_out
return = lt_c_return
EXCEPTIONS
system_failure = 1 MESSAGE lv_rfc_error
communication_failure = 2 MESSAGE lv_rfc_error.
I checked sm59 and a BAPI Call RFC dosen't exist. However, there are other RFC connections that work.

Assuming you don't want to call a remote system:
Change
DESTINATION 'BAPI Call'
To
DESTINATION 'NONE'
If it is a remote system, create a destination in SM59 (but without the space) and reference that instead.

Related

Akka - Unable to send Discriminated Unions as messages in F#

Akka - Discriminated Unions as messages in F#
I am unable to use discriminated unions as messages to akka actors. If anyone can point me at an example that does this, it would be much appreciated.
My own attempt at this is at git#github.com:Tweega/AkkaMessageIssue.git. (snippets below). It is a cutdown version of a sample found at https://github.com/rikace/AkkaActorModel.git (Chat project)
Problem
The DU message never finds its target on the server actor, but is sent to the deadletter box. If I send Objects, instead, they do arrive.
If I send a DU, but set my server actor to listen for generic Objects, the message does arrive, but its type is
seq [seq [seq []]
and I can't get at underlying DU.
The DU I am trying to send as message
type PrinterJob =
| PrintThis of string
| Teardown
The client code
let system = System.create "MyClient" config
let chatClientActor =
spawn system "ChatClient" <| fun mailbox ->
let server = mailbox.Context.ActorSelection("akka.tcp://MyServer#localhost:8081/user/ChatServer")
let rec loop nick = actor {
let! (msg:PrinterJob) = mailbox.Receive()
server.Tell(msg)
return! loop nick
}
loop ""
while true do
let input = Console.ReadLine()
chatClientActor.Tell(PrintThis(input))
Messages are forwarded to the client from console input
while true do
let input = Console.ReadLine()
chatClientActor.Tell(PrintThis(input))
The server code
let system = System.create "MyServer" config
let chatServerActor =
spawn system "ChatServer" <| fun (mailbox:Actor<_>) ->
let rec loop (clients:Akka.Actor.IActorRef list) = actor {
let! (msg:PrinterJob) = mailbox.Receive()
printfn "Received %A" msg //Received seq [seq [seq []]; seq [seq [seq []]]] ???
match msg with
| PrintThis str ->
Console.WriteLine("Printing: {0} Do we get this?", str)
return! loop clients
| Teardown ->
Console.WriteLine("Tearing down now")
return! loop clients
}
loop []
Dependencies
(I am not using paket here) - PM commands below:
Install-Package Akka -Version 1.4.23
Install-Package Akka.Remote -Version 1.4.23
Install-Package Akka.FSharp -Version 1.4.23
I am hosting the application in net5.0
Constructor argument names - oddity?
When passing in class instances as objects, akka seems to be sensitive to the name of constructor parameters. The message gets handled, but the data is not copied across from client to server. If you have a property called Username, the constructor parameter cannot be, for example, uName, otherwise its value is null when it reaches the server. Code for this is in branch params.
type DoesWork(montelimar: string) =
member x.Montelimar = montelimar
type DoesNotWork(montelimaro: string) =
member x.Montelimar = montelimaro
I opened an issue in the Akka.NET repository: https://github.com/akkadotnet/akka.net/issues/5194
And added a detailed reproduction for this: https://github.com/akkadotnet/akka.net/pull/5196
But it looks like Newtonsoft.Json really can't perform this deserialization without being given a type hint, which Akka.NET's network serialization does not do by default for JSON:
type TestUnion =
| A of string
| B of int * string
type TestUnion2 =
| C of string * TestUnion
| D of int
[<Fact(Skip="JSON.NET really does not support even basic DU serialization")>]
member _.``JSON.NET must serialize DUs`` () =
let du = C("a-11", B(11, "a-12"))
let settings = new JsonSerializerSettings()
settings.Converters.Add(new DiscriminatedUnionConverter())
let serialized = JsonConvert.SerializeObject(du, settings)
let deserialized = JsonConvert.DeserializeObject(serialized, settings)
Assert.Equal(du :> obj, deserialized)
That test will not pass and it doesn't use any of Akka.NET's infrastructure at all - so the default JSON serializer simply won't work for real-world F# use cases.
We can try changing the defaults of our serialization system to include a type hint, but that will take a lot of validation testing (for old Akka.Persistence data serialized without one).
A better solution, which my pull request validates, is to use Hyperion for polymorphic serialization instead - it will be similarly transparent to you but it has much more robust handling for complex types than Newtonsoft.Json and is actually faster: https://getakka.net/articles/networking/serialization.html#how-to-setup-hyperion-as-default-serializer

Changes don't commit after RFC of ME_INFORECORD_MAINTAIN_MULTI

I'm calling ME_INFORECORD_MAINTAIN_MULTI with an RFC. The purchase info records get a new number, but the changes aren't commited to the db.
The commit is supposed to be implicit after a RFC, but it isn't. I've tried adding an explicit COMMIT WORK after the function call, but this didn't help.
The changes are commited properly if I use a regular function call (not remote), however performance is very slow.
Please help.
FORM CALL_BAPI_PIR.
lv_taskname = |PIR-{ lv_sentjobs WIDTH = 3 ALIGN = RIGHT PAD = '0' }|.
CALL FUNCTION 'ME_INFORECORD_MAINTAIN_MULTI'
STARTING NEW TASK lv_taskname
DESTINATION IN GROUP DEFAULT
PERFORMING RETURN_BAPI_PIR ON END OF TASK
EXPORTING
testrun = p_test
TABLES
t_eina = GT_ME_EINA
t_einax = GT_ME_EINAX
t_eine = GT_ME_EINE
t_einex = GT_ME_EINEX
return = GT_ME_INFORECORD_RETURN
EXCEPTIONS
system_failure = 1 MESSAGE lv_exceptionmsg
communication_failure = 2 MESSAGE lv_exceptionmsg
resource_failure = 3
.
CASE sy-subrc.
WHEN 0.
lv_sentjobs = lv_sentjobs + 1.
COMMIT WORK.
WHEN 1 OR 2.
MESSAGE lv_exceptionmsg TYPE 'I'.
WRITE: / lv_taskname, ':', lv_exceptionmsg.
ENDCASE.
ENDFORM.
FORM RETURN_BAPI_PIR USING TASKNAME.
DATA INFO LIKE RFCSI.
RECEIVE RESULTS FROM FUNCTION 'ME_INFORECORD_MAINTAIN_MULTI'
IMPORTING
RFCSI_EXPORT = INFO
RETURN = GT_ME_INFORECORD_RETURN.
lv_recvjobs = lv_recvjobs + 1.
ENDFORM.
I've solved this by making a wrapper function that ends with a commit, and calling the wrapper function instead of the standard function.
FUNCTION z_inforecord_maintain_mult2
IMPORTING
VALUE(testrun) TYPE bapiflag-bapiflag OPTIONAL
EXPORTING
VALUE(et_eina) TYPE mewieina_mig_t
VALUE(et_eine) TYPE mewieine_t
TABLES
t_eina TYPE mewieina_mig_t OPTIONAL
t_einax TYPE mewieinax_t OPTIONAL
t_eine TYPE mewieine_t OPTIONAL
t_einex TYPE mewieinex_t OPTIONAL
txt_lines TYPE mewipirtext_tt OPTIONAL
cond_validity TYPE mewivalidity_tt OPTIONAL
condition TYPE mewicondition_tt OPTIONAL
cond_scale_value TYPE mewiscaleval_tt OPTIONAL
cond_scale_quan TYPE mewiscalequan_tt OPTIONAL
return TYPE fs4mig_t_bapiret2 OPTIONAL.
CALL FUNCTION 'ME_INFORECORD_MAINTAIN_MULTI'
EXPORTING
testrun = testrun
IMPORTING
et_eina = et_eina
et_eine = et_eine
TABLES
t_eina = t_eina
t_einax = t_einax
t_eine = t_eine
t_einex = t_einex
txt_lines = txt_lines
cond_validity = cond_validity
condition = condition
cond_scale_value = cond_scale_value
cond_scale_quan = cond_scale_quan
return = return
.
IF SY-subrc = 0.
COMMIT WORK.
ENDIF.
ENDFUNCTION.
With RFC, there's an implicit database commit at some point of time in the calling program, but not in the RFC session, like there's no implicit database commit after SUBMIT.
You may chain several function module calls in the same RFC session, and to chain a SAP LUW commit in the RFC session you may call the function module BAPI_TRANSACTION_COMMIT to do a COMMIT WORK. The solution then depends on the type of RFC you use.
In your case, you use asynchronous RFC with a callback i.e. with wait, so the solution will be to
indicate KEEPING TASK at RECEIVE RESULTS so that to keep the RFC session open after calling ME_INFORECORD_MAINTAIN_MULTI
use WAIT FOR ASYNCHRONOUS TASKS so that BAPI_TRANSACTION_COMMIT is called sequentially after ME_INFORECORD_MAINTAIN_MULTI has ended.
CALL FUNCTION 'ME_INFORECORD_MAINTAIN_MULTI'
STARTING NEW TASK lv_taskname
DESTINATION IN GROUP DEFAULT
PERFORMING RETURN_BAPI_PIR ON END OF TASK
...
EXCEPTIONS
system_failure = 1 MESSAGE lv_exceptionmsg
communication_failure = 2 MESSAGE lv_exceptionmsg
resource_failure = 3.
IF sy-subrc = 0.
WAIT FOR ASYNCHRONOUS TASKS UNTIL lv_recvjobs = lv_sentjobs.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
STARTING NEW TASK lv_taskname " <====== reuse existing RFC session/closed implicitly right after
DESTINATION IN GROUP DEFAULT
EXCEPTIONS
system_failure = 1 MESSAGE lv_exceptionmsg
communication_failure = 2 MESSAGE lv_exceptionmsg
resource_failure = 3.
...
FORM RETURN_BAPI_PIR USING TASKNAME.
DATA INFO LIKE RFCSI.
RECEIVE RESULTS FROM FUNCTION 'ME_INFORECORD_MAINTAIN_MULTI'
KEEPING TASK " <============== add this to not close the RFC session
IMPORTING
RFCSI_EXPORT = INFO
RETURN = GT_ME_INFORECORD_RETURN.
lv_recvjobs = lv_recvjobs + 1.
ENDFORM.
NB:
I did not handle the exceptions to simplify the demonstration.
If you run the RFC under several task names, several RFC sessions are started, so you must call BAPI_TRANSACTION_COMMIT in each of these RFC sesssions.

Open Document returns error (SOFFICEINTEGRATION)

I'm trying to open a Excel file with SOFFICEINTEGRATION to modify the file inplace.
But I always get the CALL_NOT_FLUSHED error, I tried several code snippets (with no_flush = X and no_flush = ' ')
The error "CALL_NOT_FLUSHED" is appearing after calling proxy->open_document
My current code:
DATA proxy TYPE REF TO i_oi_document_proxy.
PARAMETERS dummy.
AT SELECTION-SCREEN OUTPUT.
IF proxy IS NOT BOUND.
CALL METHOD c_oi_container_control_creator=>get_container_control
IMPORTING
control = DATA(lo_container_control)
retcode = DATA(l_rc).
CALL METHOD lo_container_control->init_control
EXPORTING
r3_application_name = 'EXCEL' "#EC NOTEXT
inplace_enabled = 'X'
inplace_scroll_documents = 'X'
parent = cl_gui_container=>screen0
IMPORTING
retcode = l_rc.
CALL METHOD lo_container_control->get_document_proxy
EXPORTING
document_type = 'EXCEL.SHEET'
IMPORTING
document_proxy = proxy.
CALL METHOD proxy->open_document
EXPORTING
document_url = 'file://C:\Users\yourusername\Documents\test.xlsx'
open_inplace = 'X'
IMPORTING
error = DATA(openerr).
ENDIF.

Datadog monitor API/terraform process monitor check

I'm trying to integrate a Datadog monitor check on sshd process in my terraform codebase, but I'm getting datadog_monitor.host_is_up2: error updating monitor: API error 400 Bad Request: {"errors":["The value provided for parameter 'query' is invalid"]}
What I did was to copy the monitor's query I created on the Datadog panel and pasted it into the tf file:
resource "datadog_monitor" "host_is_up2" {
name = "host is up"
type = "metric alert"
message = "Monitor triggered"
escalation_message = "Escalation message"
query = "process.up.over('process:ssh').last(4).count_by_status()"
thresholds {
ok = 0
warning = 1
critical = 2
}
notify_no_data = false
renotify_interval = 60
notify_audit = false
timeout_h = 60
include_tags = true
silenced {
"*" = 0
}
}
ofc the query example "avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} > 2" works
What's the right way to check via Datadog API or terraform if a specific service, like sshd, is up or not?
There are two error in your code:
The type used is wrong. It should be service check instead of metric alert.
You need to enclose process.up in a pair of ''.
Once done, your code will run flawlessly.

ABAP Webdynpro error in supply function for a singleton

The following error text was processed in system EH5 : Invalid operand type for the MOVE-CORRESPONDING statement.
◾ The error occurred on the application server CRMEHP2_EH5_24 and in the work process 8 .
◾ The termination type was: RABAX_STATE
◾ The ABAP call stack was:
Method: IF_WD_CONTEXT_ELEMENT~GET_STATIC_ATTRIBUTES of program CL_WDR_CONTEXT_ELEMENT========CP
Method: BOOKINGS_READ of program /1BCWDY/0AA4D2ZOSMXD1LD8M8M2==CP
Method: BOOKINGS_READ of program /1BCWDY/0AA4D2ZOSMXD1LD8M8M2==CP
Method: SUPPLY_ELEMENTS of program CL_WDR_CONTEXT_NODE_VAL=======CP
Method: IF_WD_CONTEXT_NODE~GET_LEAD_SELECTION of program CL_WDR_CONTEXT_NODE_VAL=======CP
Method: IF_WD_CONTEXT_NODE~GET_LEAD_SELECTION of program CL_WDR_CONTEXT_NODE_MAP=======CP
Method: GET_LEAD_SELECTION of program CL_WDR_TABLE_DATA_PROVIDER====CP
Method: UPDATE_RANGE_SELECT_START of program CL_WDR_TABLE_DATA_PROVIDER====CP
Method: GET_TABLE_DATA of program CL_WDR_TABLE_DATA_PROVIDER====CP
Method: GET_VISIBLE_TABLE_DATA of program CL_WDR_TABLE_DATA_PROVIDER====CP
I have created two controllers
Componentcontroller is bound to flightinfo table. This table is populated. However, if_componentcontroller=>element_flightinfo dosen't fetch any data. Why?
Customcontroller2 is bound to bookingtab table.
Method:
**METHOD bookings_read.**
DATA:
stru_flight TYPE if_componentcontroller=>element_flightinfo,
itab_booking TYPE if_customcontroller2=>elements_bookingtab.
* Get Parent Element.
* Error is here: All attributes of stru_flight are either blank or zero.
* The error disappears once CALL METHOD is commented.
CALL METHOD parent_element->get_static_attributes
IMPORTING
static_attributes = stru_flight.
* read bookings
*Rest of the satatements work fine.
SELECT * FROM sbook
INTO CORRESPONDING FIELDS OF TABLE itab_booking
WHERE carrid = stru_flight-carrid
AND connid = stru_flight-connid
AND fldate = stru_flight-fldate.
* bind all the elements
node->bind_table(
new_items = itab_booking
set_initial_elements = abap_true ).
**ENDMETHOD.**
Definition of parent_element, and stru_flights structure
NODE Importing IF_WD_CONTEXT_NODE
PARENT_ELEMENT Importing IF_WD_CONTEXT_ELEMENT
stru_flight TYPE if_componentcontroller=>element_flightinfo,
**CALL METHOD parent_element->get_static_attributes
IMPORTING
static_attributes = stru_flight.**
implicit constant definition for context node bookingtab types:
Element_bookingtab type SBOOK,
Elements_bookingtab type standard table of Element_bookingtab with default key.